babylon.module.d.ts 6.7 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275114276114277114278114279114280114281114282114283114284114285114286114287114288114289114290114291114292114293114294114295114296114297114298114299114300114301114302114303114304114305114306114307114308114309114310114311114312114313114314114315114316114317114318114319114320114321114322114323114324114325114326114327114328114329114330114331114332114333114334114335114336114337114338114339114340114341114342114343114344114345114346114347114348114349114350114351114352114353114354114355114356114357114358114359114360114361114362114363114364114365114366114367114368114369114370114371114372114373114374114375114376114377114378114379114380114381114382114383114384114385114386114387114388114389114390114391114392114393114394114395114396114397114398114399114400114401114402114403114404114405114406114407114408114409114410114411114412114413114414114415114416114417114418114419114420114421114422114423114424114425114426114427114428114429114430114431114432114433114434114435114436114437114438114439114440114441114442114443114444114445114446114447114448114449114450114451114452114453114454114455114456114457114458114459114460114461114462114463114464114465114466114467114468114469114470114471114472114473114474114475114476114477114478114479114480114481114482114483114484114485114486114487114488114489114490114491114492114493114494114495114496114497114498114499114500114501114502114503114504114505114506114507114508114509114510114511114512114513114514114515114516114517114518114519114520114521114522114523114524114525114526114527114528114529114530114531114532114533114534114535114536114537114538114539114540114541114542114543114544114545114546114547114548114549114550114551114552114553114554114555114556114557114558114559114560114561114562114563114564114565114566114567114568114569114570114571114572114573114574114575114576114577114578114579114580114581114582114583114584114585114586114587114588114589114590114591114592114593114594114595114596114597114598114599114600114601114602114603114604114605114606114607114608114609114610114611114612114613114614114615114616114617114618114619114620114621114622114623114624114625114626114627114628114629114630114631114632114633114634114635114636114637114638114639114640114641114642114643114644114645114646114647114648114649114650114651114652114653114654114655114656114657114658114659114660114661114662114663114664114665114666114667114668114669114670114671114672114673114674114675114676114677114678114679114680114681114682114683114684114685114686114687114688114689114690114691114692114693114694114695114696114697114698114699114700114701114702114703114704114705114706114707114708114709114710114711114712114713114714114715114716114717114718114719114720114721114722114723114724114725114726114727114728114729114730114731114732114733114734114735114736114737114738114739114740114741114742114743114744114745114746114747114748114749114750114751114752114753114754114755114756114757114758114759114760114761114762114763114764114765114766114767114768114769114770114771114772114773114774114775114776114777114778114779114780114781114782114783114784114785114786114787114788114789114790114791114792114793114794114795114796114797114798114799114800114801114802114803114804114805114806114807114808114809114810114811114812114813114814114815114816114817114818114819114820114821114822114823114824114825114826114827114828114829114830114831114832114833114834114835114836114837114838114839114840114841114842114843114844114845114846114847114848114849114850114851114852114853114854114855114856114857114858114859114860114861114862114863114864114865114866114867114868114869114870114871114872114873114874114875114876114877114878114879114880114881114882114883114884114885114886114887114888114889114890114891114892114893114894114895114896114897114898114899114900114901114902114903114904114905114906114907114908114909114910114911114912114913114914114915114916114917114918114919114920114921114922114923114924114925114926114927114928114929114930114931114932114933114934114935114936114937114938114939114940114941114942114943114944114945114946114947114948114949114950114951114952114953114954114955114956114957114958114959114960114961114962114963114964114965114966114967114968114969114970114971114972114973114974114975114976114977114978114979114980114981114982114983114984114985114986114987114988114989114990114991114992114993114994114995114996114997114998114999115000115001115002115003115004115005115006115007115008115009115010115011115012115013115014115015115016115017115018115019115020115021115022115023115024115025115026115027115028115029115030115031115032115033115034115035115036115037115038115039115040115041115042115043115044115045115046115047115048115049115050115051115052115053115054115055115056115057115058115059115060115061115062115063115064115065115066115067115068115069115070115071115072115073115074115075115076115077115078115079115080115081115082115083115084115085115086115087115088115089115090115091115092115093115094115095115096115097115098115099115100115101115102115103115104115105115106115107115108115109115110115111115112115113115114115115115116115117115118115119115120115121115122115123115124115125115126115127115128115129115130115131115132115133115134115135115136115137115138115139115140115141115142115143115144115145115146115147115148115149115150115151115152115153115154115155115156115157115158115159115160115161115162115163115164115165115166115167115168115169115170115171115172115173115174115175115176115177115178115179115180115181115182115183115184115185115186115187115188115189115190115191115192115193115194115195115196115197115198115199115200115201115202115203115204115205115206115207115208115209115210115211115212115213115214115215115216115217115218115219115220115221115222115223115224115225115226115227115228115229115230115231115232115233115234115235115236115237115238115239115240115241115242115243115244115245115246115247115248115249115250115251115252115253115254115255115256115257115258115259115260115261115262115263115264115265115266115267115268115269115270115271115272115273115274115275115276115277115278115279115280115281115282115283115284115285115286115287115288115289115290115291115292115293115294115295115296115297115298115299115300115301115302115303115304115305115306115307115308115309115310115311115312115313115314115315115316115317115318115319115320115321115322115323115324115325115326115327115328115329115330115331115332115333115334115335115336115337115338115339115340115341115342115343115344115345115346115347115348115349115350115351115352115353115354115355115356115357115358115359115360115361115362115363115364115365115366115367115368115369115370115371115372115373115374115375115376115377115378115379115380115381115382115383115384115385115386115387115388115389115390115391115392115393115394115395115396115397115398115399115400115401115402115403115404115405115406115407115408115409115410115411115412115413115414115415115416115417115418115419115420115421115422115423115424115425115426115427115428115429115430115431115432115433115434115435115436115437115438115439115440115441115442115443115444115445115446115447115448115449115450115451115452115453115454115455115456115457115458115459115460115461115462115463115464115465115466115467115468115469115470115471115472115473115474115475115476115477115478115479115480115481115482115483115484115485115486115487115488115489115490115491115492115493115494115495115496115497115498115499115500115501115502115503115504115505115506115507115508115509115510115511115512115513115514115515115516115517115518115519115520115521115522115523115524115525115526115527115528115529115530115531115532115533115534115535115536115537115538115539115540115541115542115543115544115545115546115547115548115549115550115551115552115553115554115555115556115557115558115559115560115561115562115563115564115565115566115567115568115569115570115571115572115573115574115575115576115577115578115579115580115581115582115583115584115585115586115587115588115589115590115591115592115593115594115595115596115597115598115599115600115601115602115603115604115605115606115607115608115609115610115611115612115613115614115615115616115617115618115619115620115621115622115623115624115625115626115627115628115629115630115631115632115633115634115635115636115637115638115639115640115641115642115643115644115645115646115647115648115649115650115651115652115653115654115655115656115657115658115659115660115661115662115663115664115665115666115667115668115669115670115671115672115673115674115675115676115677115678115679115680115681115682115683115684115685115686115687115688115689115690115691115692115693115694115695115696115697115698115699115700115701115702115703115704115705115706115707115708115709115710115711115712115713115714115715115716115717115718115719115720115721115722115723115724115725115726115727115728115729115730115731115732115733115734115735115736115737115738115739115740115741115742115743115744115745115746115747115748115749115750115751115752115753115754115755115756115757115758115759115760115761115762115763115764115765115766115767115768115769115770115771115772115773115774115775115776115777115778115779115780115781115782115783115784115785115786115787115788115789115790115791115792115793115794115795115796115797115798115799115800115801115802115803115804115805115806115807115808115809115810115811115812115813115814115815115816115817115818115819115820115821115822115823115824115825115826115827115828115829115830115831115832115833115834115835115836115837115838115839115840115841115842115843115844115845115846115847115848115849115850115851115852115853115854115855115856115857115858115859115860115861115862115863115864115865115866115867115868115869115870115871115872115873115874115875115876115877115878115879115880115881115882115883115884115885115886115887115888115889115890115891115892115893115894115895115896115897115898115899115900115901115902115903115904115905115906115907115908115909115910115911115912115913115914115915115916115917115918115919115920115921115922115923115924115925115926115927115928115929115930115931115932115933115934115935115936115937115938115939115940115941115942115943115944115945115946115947115948115949115950115951115952115953115954115955115956115957115958115959115960115961115962115963115964115965115966115967115968115969115970115971115972115973115974115975115976115977115978115979115980115981115982115983115984115985115986115987115988115989115990115991115992115993115994115995115996115997115998115999116000116001116002116003116004116005116006116007116008116009116010116011116012116013116014116015116016116017116018116019116020116021116022116023116024116025116026116027116028116029116030116031116032116033116034116035116036116037116038116039116040116041116042116043116044116045116046116047116048116049116050116051116052116053116054116055116056116057116058116059116060116061116062116063116064116065116066116067116068116069116070116071116072116073116074116075116076116077116078116079116080116081116082116083116084116085116086116087116088116089116090116091116092116093116094116095116096116097116098116099116100116101116102116103116104116105116106116107116108116109116110116111116112116113116114116115116116116117116118116119116120116121116122116123116124116125116126116127116128116129116130116131116132116133116134116135116136116137116138116139116140116141116142116143116144116145116146116147116148116149116150116151116152116153116154116155116156116157116158116159116160116161116162116163116164116165116166116167116168116169116170116171116172116173116174116175116176116177116178116179116180116181116182116183116184116185116186116187116188116189116190116191116192116193116194116195116196116197116198116199116200116201116202116203116204116205116206116207116208116209116210116211116212116213116214116215116216116217116218116219116220116221116222116223116224116225116226116227116228116229116230116231116232116233116234116235116236116237116238116239116240116241116242116243116244116245116246116247116248116249116250116251116252116253116254116255116256116257116258116259116260116261116262116263116264116265116266116267116268116269116270116271116272116273116274116275116276116277116278116279116280116281116282116283116284116285116286116287116288116289116290116291116292116293116294116295116296116297116298116299116300116301116302116303116304116305116306116307116308116309116310116311116312116313116314116315116316116317116318116319116320116321116322116323116324116325116326116327116328116329116330116331116332116333116334116335116336116337116338116339116340116341116342116343116344116345116346116347116348116349116350116351116352116353116354116355116356116357116358116359116360116361116362116363116364116365116366116367116368116369116370116371116372116373116374116375116376116377116378116379116380116381116382116383116384116385116386116387116388116389116390116391116392116393116394116395116396116397116398116399116400116401116402116403116404116405116406116407116408116409116410116411116412116413116414116415116416116417116418116419116420116421116422116423116424116425116426116427116428116429116430116431116432116433116434116435116436116437116438116439116440116441116442116443116444116445116446116447116448116449116450116451116452116453116454116455116456116457116458116459116460116461116462116463116464116465116466116467116468116469116470116471116472116473116474116475116476116477116478116479116480116481116482116483116484116485116486116487116488116489116490116491116492116493116494116495116496116497116498116499116500116501116502116503116504116505116506116507116508116509116510116511116512116513116514116515116516116517116518116519116520116521116522116523116524116525116526116527116528116529116530116531116532116533116534116535116536116537116538116539116540116541116542116543116544116545116546116547116548116549116550116551116552116553116554116555116556116557116558116559116560116561116562116563116564116565116566116567116568116569116570116571116572116573116574116575116576116577116578116579116580116581116582116583116584116585116586116587116588116589116590116591116592116593116594116595116596116597116598116599116600116601116602116603116604116605116606116607116608116609116610116611116612116613116614116615116616116617116618116619116620116621116622116623116624116625116626116627116628116629116630116631116632116633116634116635116636116637116638116639116640116641116642116643116644116645116646116647116648116649116650116651116652116653116654116655116656116657116658116659116660116661116662116663116664116665116666116667116668116669116670116671116672116673116674116675116676116677116678116679116680116681116682116683116684116685116686116687116688116689116690116691116692116693116694116695116696116697116698116699116700116701116702116703116704116705116706116707116708116709116710116711116712116713116714116715116716116717116718116719116720116721116722116723116724116725116726116727116728116729116730116731116732116733116734116735116736116737116738116739116740116741116742116743116744116745116746116747116748116749116750116751116752116753116754116755116756116757116758116759116760116761116762116763116764116765116766116767116768116769116770116771116772116773116774116775116776116777116778116779116780116781116782116783116784116785116786116787116788116789116790116791116792116793116794116795116796116797116798116799116800116801116802116803116804116805116806116807116808116809116810116811116812116813116814116815116816116817116818116819116820116821116822116823116824116825116826116827116828116829116830116831116832116833116834116835116836116837116838116839116840116841116842116843116844116845116846116847116848116849116850116851116852116853116854116855116856116857116858116859116860116861116862116863116864116865116866116867116868116869116870116871116872116873116874116875116876116877116878116879116880116881116882116883116884116885116886116887116888116889116890116891116892116893116894116895116896116897116898116899116900116901116902116903116904116905116906116907116908116909116910116911116912116913116914116915116916116917116918116919116920116921116922116923116924116925116926116927116928116929116930116931116932116933116934116935116936116937116938116939116940116941116942116943116944116945116946116947116948116949116950116951116952116953116954116955116956116957116958116959116960116961116962116963116964116965116966116967116968116969116970116971116972116973116974116975116976116977116978116979116980116981116982116983116984116985116986116987116988116989116990116991116992116993116994116995116996116997116998116999117000117001117002117003117004117005117006117007117008117009117010117011117012117013117014117015117016117017117018117019117020117021117022117023117024117025117026117027117028117029117030117031117032117033117034117035117036117037117038117039117040117041117042117043117044117045117046117047117048117049117050117051117052117053117054117055117056117057117058117059117060117061117062117063117064117065117066117067117068117069117070117071117072117073117074117075117076117077117078117079117080117081117082117083117084117085117086117087117088117089117090117091117092117093117094117095117096117097117098117099117100117101117102117103117104117105117106117107117108117109117110117111117112117113117114117115117116117117117118117119117120117121117122117123117124117125117126117127117128117129117130117131117132117133117134117135117136117137117138117139117140117141117142117143117144117145117146117147117148117149117150117151117152117153117154117155117156117157117158117159117160117161117162117163117164117165117166117167117168117169117170117171117172117173117174117175117176117177117178117179117180117181117182117183117184117185117186117187117188117189117190117191117192117193117194117195117196117197117198117199117200117201117202117203117204117205117206117207117208117209117210117211117212117213117214117215117216117217117218117219117220117221117222117223117224117225117226117227117228117229117230117231117232117233117234117235117236117237117238117239117240117241117242117243117244117245117246117247117248117249117250117251117252117253117254117255117256117257117258117259117260117261117262117263117264117265117266117267117268117269117270117271117272117273117274117275117276117277117278117279117280117281117282117283117284117285117286117287117288117289117290117291117292117293117294117295117296117297117298117299117300117301117302117303117304117305117306117307117308117309117310117311117312117313117314117315117316117317117318117319117320117321117322117323117324117325117326117327117328117329117330117331117332117333117334117335117336117337117338117339117340117341117342117343117344117345117346117347117348117349117350117351117352117353117354117355117356117357117358117359117360117361117362117363117364117365117366117367117368117369117370117371117372117373117374117375117376117377117378117379117380117381117382117383117384117385117386117387117388117389117390117391117392117393117394117395117396117397117398117399117400117401117402117403117404117405117406117407117408117409117410117411117412117413117414117415117416117417117418117419117420117421117422117423117424117425117426117427117428117429117430117431117432117433117434117435117436117437117438117439117440117441117442117443117444117445117446117447117448117449117450117451117452117453117454117455117456117457117458117459117460117461117462117463117464117465117466117467117468117469117470117471117472117473117474117475117476117477117478117479117480117481117482117483117484117485117486117487117488117489117490117491117492117493117494117495117496117497117498117499117500117501117502117503117504117505117506117507117508117509117510117511117512117513117514117515117516117517117518117519117520117521117522117523117524117525117526117527117528117529117530117531117532117533117534117535117536117537117538117539117540117541117542117543117544117545117546117547117548117549117550117551117552117553117554117555117556117557117558117559117560117561117562117563117564117565117566117567117568117569117570117571117572117573117574117575117576117577117578117579117580117581117582117583117584117585117586117587117588117589117590117591117592117593117594117595117596117597117598117599117600117601117602117603117604117605117606117607117608117609117610117611117612117613117614117615117616117617117618117619117620117621117622117623117624117625117626117627117628117629117630117631117632117633117634117635117636117637117638117639117640117641117642117643117644117645117646117647117648117649117650117651117652117653117654117655117656117657117658117659117660117661117662117663117664117665117666117667117668117669117670117671117672117673117674117675117676117677117678117679117680117681117682117683117684117685117686117687117688117689117690117691117692117693117694117695117696117697117698117699117700117701117702117703117704117705117706117707117708117709117710117711117712117713117714117715117716117717117718117719117720117721117722117723117724117725117726117727117728117729117730117731117732117733117734117735117736117737117738117739117740117741117742117743117744117745117746117747117748117749117750117751117752117753117754117755117756117757117758117759117760117761117762117763117764117765117766117767117768117769117770117771117772117773117774117775117776117777117778117779117780117781117782117783117784117785117786117787117788117789117790117791117792117793117794117795117796117797117798117799117800117801117802117803117804117805117806117807117808117809117810117811117812117813117814117815117816117817117818117819117820117821117822117823117824117825117826117827117828117829117830117831117832117833117834117835117836117837117838117839117840117841117842117843117844117845117846117847117848117849117850117851117852117853117854117855117856117857117858117859117860117861117862117863117864117865117866117867117868117869117870117871117872117873117874117875117876117877117878117879117880117881117882117883117884117885117886117887117888117889117890117891117892117893117894117895117896117897117898117899117900117901117902117903117904117905117906117907117908117909117910117911117912117913117914117915117916117917117918117919117920117921117922117923117924117925117926117927117928117929117930117931117932117933117934117935117936117937117938117939117940117941117942117943117944117945117946117947117948117949117950117951117952117953117954117955117956117957117958117959117960117961117962117963117964117965117966117967117968117969117970117971117972117973117974117975117976117977117978117979117980117981117982117983117984117985117986117987117988117989117990117991117992117993117994117995117996117997117998117999118000118001118002118003118004118005118006118007118008118009118010118011118012118013118014118015118016118017118018118019118020118021118022118023118024118025118026118027118028118029118030118031118032118033118034118035118036118037118038118039118040118041118042118043118044118045118046118047118048118049118050118051118052118053118054118055118056118057118058118059118060118061118062118063118064118065118066118067118068118069118070118071118072118073118074118075118076118077118078118079118080118081118082118083118084118085118086118087118088118089118090118091118092118093118094118095118096118097118098118099118100118101118102118103118104118105118106118107118108118109118110118111118112118113118114118115118116118117118118118119118120118121118122118123118124118125118126118127118128118129118130118131118132118133118134118135118136118137118138118139118140118141118142118143118144118145118146118147118148118149118150118151118152118153118154118155118156118157118158118159118160118161118162118163118164118165118166118167118168118169118170118171118172118173118174118175118176118177118178118179118180118181118182118183118184118185118186118187118188118189118190118191118192118193118194118195118196118197118198118199118200118201118202118203118204118205118206118207118208118209118210118211118212118213118214118215118216118217118218118219118220118221118222118223118224118225118226118227118228118229118230118231118232118233118234118235118236118237118238118239118240118241118242118243118244118245118246118247118248118249118250118251118252118253118254118255118256118257118258118259118260118261118262118263118264118265118266118267118268118269118270118271118272118273118274118275118276118277118278118279118280118281118282118283118284118285118286118287118288118289118290118291118292118293118294118295118296118297118298118299118300118301118302118303118304118305118306118307118308118309118310118311118312118313118314118315118316118317118318118319118320118321118322118323118324118325118326118327118328118329118330118331118332118333118334118335118336118337118338118339118340118341118342118343118344118345118346118347118348118349118350118351118352118353118354118355118356118357118358118359118360118361118362118363118364118365118366118367118368118369118370118371118372118373118374118375118376118377118378118379118380118381118382118383118384118385118386118387118388118389118390118391118392118393118394118395118396118397118398118399118400118401118402118403118404118405118406118407118408118409118410118411118412118413118414118415118416118417118418118419118420118421118422118423118424118425118426118427118428118429118430118431118432118433118434118435118436118437118438118439118440118441118442118443118444118445118446118447118448118449118450118451118452118453118454118455118456118457118458118459118460118461118462118463118464118465118466118467118468118469118470118471118472118473118474118475118476118477118478118479118480118481118482118483118484118485118486118487118488118489118490118491118492118493118494118495118496118497118498118499118500118501118502118503118504118505118506118507118508118509118510118511118512118513118514118515118516118517118518118519118520118521118522118523118524118525118526118527118528118529118530118531118532118533118534118535118536118537118538118539118540118541118542118543118544118545118546118547118548118549118550118551118552118553118554118555118556118557118558118559118560118561118562118563118564118565118566118567118568118569118570118571118572118573118574118575118576118577118578118579118580118581118582118583118584118585118586118587118588118589118590118591118592118593118594118595118596118597118598118599118600118601118602118603118604118605118606118607118608118609118610118611118612118613118614118615118616118617118618118619118620118621118622118623118624118625118626118627118628118629118630118631118632118633118634118635118636118637118638118639118640118641118642118643118644118645118646118647118648118649118650118651118652118653118654118655118656118657118658118659118660118661118662118663118664118665118666118667118668118669118670118671118672118673118674118675118676118677118678118679118680118681118682118683118684118685118686118687118688118689118690118691118692118693118694118695118696118697118698118699118700118701118702118703118704118705118706118707118708118709118710118711118712118713118714118715118716118717118718118719118720118721118722118723118724118725118726118727118728118729118730118731118732118733118734118735118736118737118738118739118740118741118742118743118744118745118746118747118748118749118750118751118752118753118754118755118756118757118758118759118760118761118762118763118764118765118766118767118768118769118770118771118772118773118774118775118776118777118778118779118780118781118782118783118784118785118786118787118788118789118790118791118792118793118794118795118796118797118798118799118800118801118802118803118804118805118806118807118808118809118810118811118812118813118814118815118816118817118818118819118820118821118822118823118824118825118826118827118828118829118830118831118832118833118834118835118836118837118838118839118840118841118842118843118844118845118846118847118848118849118850118851118852118853118854118855118856118857118858118859118860118861118862118863118864118865118866118867118868118869118870118871118872118873118874118875118876118877118878118879118880118881118882118883118884118885118886118887118888118889118890118891118892118893118894118895118896118897118898118899118900118901118902118903118904118905118906118907118908118909118910118911118912118913118914118915118916118917118918118919118920118921118922118923118924118925118926118927118928118929118930118931118932118933118934118935118936118937118938118939118940118941118942118943118944118945118946118947118948118949118950118951118952118953118954118955118956118957118958118959118960118961118962118963118964118965118966118967118968118969118970118971118972118973118974118975118976118977118978118979118980118981118982118983118984118985118986118987118988118989118990118991118992118993118994118995118996118997118998118999119000119001119002119003119004119005119006119007119008119009119010119011119012119013119014119015119016119017119018119019119020119021119022119023119024119025119026119027119028119029119030119031119032119033119034119035119036119037119038119039119040119041119042119043119044119045119046119047119048119049119050119051119052119053119054119055119056119057119058119059119060119061119062119063119064119065119066119067119068119069119070119071119072119073119074119075119076119077119078119079119080119081119082119083119084119085119086119087119088119089119090119091119092119093119094119095119096119097119098119099119100119101119102119103119104119105119106119107119108119109119110119111119112119113119114119115119116119117119118119119119120119121119122119123119124119125119126119127119128119129119130119131119132119133119134119135119136119137119138119139119140119141119142119143119144119145119146119147119148119149119150119151119152119153119154119155119156119157119158119159119160119161119162119163119164119165119166119167119168119169119170119171119172119173119174119175119176119177119178119179119180119181119182119183119184119185119186119187119188119189119190119191119192119193119194119195119196119197119198119199119200119201119202119203119204119205119206119207119208119209119210119211119212119213119214119215119216119217119218119219119220119221119222119223119224119225119226119227119228119229119230119231119232119233119234119235119236119237119238119239119240119241119242119243119244119245119246119247119248119249119250119251119252119253119254119255119256119257119258119259119260119261119262119263119264119265119266119267119268119269119270119271119272119273119274119275119276119277119278119279119280119281119282119283119284119285119286119287119288119289119290119291119292119293119294119295119296119297119298119299119300119301119302119303119304119305119306119307119308119309119310119311119312119313119314119315119316119317119318119319119320119321119322119323119324119325119326119327119328119329119330119331119332119333119334119335119336119337119338119339119340119341119342119343119344119345119346119347119348119349119350119351119352119353119354119355119356119357119358119359119360119361119362119363119364119365119366119367119368119369119370119371119372119373119374119375119376119377119378119379119380119381119382119383119384119385119386119387119388119389119390119391119392119393119394119395119396119397119398119399119400119401119402119403119404119405119406119407119408119409119410119411119412119413119414119415119416119417119418119419119420119421119422119423119424119425119426119427119428119429119430119431119432119433119434119435119436119437119438119439119440119441119442119443119444119445119446119447119448119449119450119451119452119453119454119455119456119457119458119459119460119461119462119463119464119465119466119467119468119469119470119471119472119473119474119475119476119477119478119479119480119481119482119483119484119485119486119487119488119489119490119491119492119493119494119495119496119497119498119499119500119501119502119503119504119505119506119507119508119509119510119511119512119513119514119515119516119517119518119519119520119521119522119523119524119525119526119527119528119529119530119531119532119533119534119535119536119537119538119539119540119541119542119543119544119545119546119547119548119549119550119551119552119553119554119555119556119557119558119559119560119561119562119563119564119565119566119567119568119569119570119571119572119573119574119575119576119577119578119579119580119581119582119583119584119585119586119587119588119589119590119591119592119593119594119595119596119597119598119599119600119601119602119603119604119605119606119607119608119609119610119611119612119613119614119615119616119617119618119619119620119621119622119623119624119625119626119627119628119629119630119631119632119633119634119635119636119637119638119639119640119641119642119643119644119645119646119647119648119649119650119651119652119653119654119655119656119657119658119659119660119661119662119663119664119665119666119667119668119669119670119671119672119673119674119675119676119677119678119679119680119681119682119683119684119685119686119687119688119689119690119691119692119693119694119695119696119697119698119699119700119701119702119703119704119705119706119707119708119709119710119711119712119713119714119715119716119717119718119719119720119721119722119723119724119725119726119727119728119729119730119731119732119733119734119735119736119737119738119739119740119741119742119743119744119745119746119747119748119749119750119751119752119753119754119755119756119757119758119759119760119761119762119763119764119765119766119767119768119769119770119771119772119773119774119775119776119777119778119779119780119781119782119783119784119785119786119787119788119789119790119791119792119793119794119795119796119797119798119799119800119801119802119803119804119805119806119807119808119809119810119811119812119813119814119815119816119817119818119819119820119821119822119823119824119825119826119827119828119829119830119831119832119833119834119835119836119837119838119839119840119841119842119843119844119845119846119847119848119849119850119851119852119853119854119855119856119857119858119859119860119861119862119863119864119865119866119867119868119869119870119871119872119873119874119875119876119877119878119879119880119881119882119883119884119885119886119887119888119889119890119891119892119893119894119895119896119897119898119899119900119901119902119903119904119905119906119907119908119909119910119911119912119913119914119915119916119917119918119919119920119921119922119923119924119925119926119927119928119929119930119931119932119933119934119935119936119937119938119939119940119941119942119943119944119945119946119947119948119949119950119951119952119953119954119955119956119957119958119959119960119961119962119963119964119965119966119967119968119969119970119971119972119973119974119975119976119977119978119979119980119981119982119983119984119985119986119987119988119989119990119991119992119993119994119995119996119997119998119999120000120001120002120003120004120005120006120007120008120009120010120011120012120013120014120015120016120017120018120019120020120021120022120023120024120025120026120027120028120029120030120031120032120033120034120035120036120037120038120039120040120041120042120043120044120045120046120047120048120049120050120051120052120053120054120055120056120057120058120059120060120061120062120063120064120065120066120067120068120069120070120071120072120073120074120075120076120077120078120079120080120081120082120083120084120085120086120087120088120089120090120091120092120093120094120095120096120097120098120099120100120101120102120103120104120105120106120107120108120109120110120111120112120113120114120115120116120117120118120119120120120121120122120123120124120125120126120127120128120129120130120131120132120133120134120135120136120137120138120139120140120141120142120143120144120145120146120147120148120149120150120151120152120153120154120155120156120157120158120159120160120161120162120163120164120165120166120167120168120169120170120171120172120173120174120175120176120177120178120179120180120181120182120183120184120185120186120187120188120189120190120191120192120193120194120195120196120197120198120199120200120201120202120203120204120205120206120207120208120209120210120211120212120213120214120215120216120217120218120219120220120221120222120223120224120225120226120227120228120229120230120231120232120233120234120235120236120237120238120239120240120241120242120243120244120245120246120247120248120249120250120251120252120253120254120255120256120257120258120259120260120261120262120263120264120265120266120267120268120269120270120271120272120273120274120275120276120277120278120279120280120281120282120283120284120285120286120287120288120289120290120291120292120293120294120295120296120297120298120299120300120301120302120303120304120305120306120307120308120309120310120311120312120313120314120315120316120317120318120319120320120321120322120323120324120325120326120327120328120329120330120331120332120333120334120335120336120337120338120339120340120341120342120343120344120345120346120347120348120349120350120351120352120353120354120355120356120357120358120359120360120361120362120363120364120365120366120367120368120369120370120371120372120373120374120375120376120377120378120379120380120381120382120383120384120385120386120387120388120389120390120391120392120393120394120395120396120397120398120399120400120401120402120403120404120405120406120407120408120409120410120411120412120413120414120415120416120417120418120419120420120421120422120423120424120425120426120427120428120429120430120431120432120433120434120435120436120437120438120439120440120441120442120443120444120445120446120447120448120449120450120451120452120453120454120455120456120457120458120459120460120461120462120463120464120465120466120467120468120469120470120471120472120473120474120475120476120477120478120479120480120481120482120483120484120485120486120487120488120489120490120491120492120493120494120495120496120497120498120499120500120501120502120503120504120505120506120507120508120509120510120511120512120513120514120515120516120517120518120519120520120521120522120523120524120525120526120527120528120529120530120531120532120533120534120535120536120537120538120539120540120541120542120543120544120545120546120547120548120549120550120551120552120553120554120555120556120557120558120559120560120561120562120563120564120565120566120567120568120569120570120571120572120573120574120575120576120577120578120579120580120581120582120583120584120585120586120587120588120589120590120591120592120593120594120595120596120597120598120599120600120601120602120603120604120605120606120607120608120609120610120611120612120613120614120615120616120617120618120619120620120621120622120623120624120625120626120627120628120629120630120631120632120633120634120635120636120637120638120639120640120641120642120643120644120645120646120647120648120649120650120651120652120653120654120655120656120657120658120659120660120661120662120663120664120665120666120667120668120669120670120671120672120673120674120675120676120677120678120679120680120681120682120683120684120685120686120687120688120689120690120691120692120693120694120695120696120697120698120699120700120701120702120703120704120705120706120707120708120709120710120711120712120713120714120715120716120717120718120719120720120721120722120723120724120725120726120727120728120729120730120731120732120733120734120735120736120737120738120739120740120741120742120743120744120745120746120747120748120749120750120751120752120753120754120755120756120757120758120759120760120761120762120763120764120765120766120767120768120769120770120771120772120773120774120775120776120777120778120779120780120781120782120783120784120785120786120787120788120789120790120791120792120793120794120795120796120797120798120799120800120801120802120803120804120805120806120807120808120809120810120811120812120813120814120815120816120817120818120819120820120821120822120823120824120825120826120827120828120829120830120831120832120833120834120835120836120837120838120839120840120841120842120843120844120845120846120847120848120849120850120851120852120853120854120855120856120857120858120859120860120861120862120863120864120865120866120867120868120869120870120871120872120873120874120875120876120877120878120879120880120881120882120883120884120885120886120887120888120889120890120891120892120893120894120895120896120897120898120899120900120901120902120903120904120905120906120907120908120909120910120911120912120913120914120915120916120917120918120919120920120921120922120923120924120925120926120927120928120929120930120931120932120933120934120935120936120937120938120939120940120941120942120943120944120945120946120947120948120949120950120951120952120953120954120955120956120957120958120959120960120961120962120963120964120965120966120967120968120969120970120971120972120973120974120975120976120977120978120979120980120981120982120983120984120985120986120987120988120989120990120991120992120993120994120995120996120997120998120999121000121001121002121003121004121005121006121007121008121009121010121011121012121013121014121015121016121017121018121019121020121021121022121023121024121025121026121027121028121029121030121031121032121033121034121035121036121037121038121039121040121041121042121043121044121045121046121047121048121049121050121051121052121053121054121055121056121057121058121059121060121061121062121063121064121065121066121067121068121069121070121071121072121073121074121075121076121077121078121079121080121081121082121083121084121085121086121087121088121089121090121091121092121093121094121095121096121097121098121099121100121101121102121103121104121105121106121107121108121109121110121111121112121113121114121115121116121117121118121119121120121121121122121123121124121125121126121127121128121129121130121131121132121133121134121135121136121137121138121139121140121141121142121143121144121145121146121147121148121149121150121151121152121153121154121155121156121157121158121159121160121161121162121163121164121165121166121167121168121169121170121171121172121173121174121175121176121177121178121179121180121181121182121183121184121185121186121187121188121189121190121191121192121193121194121195121196121197121198121199121200121201121202121203121204121205121206121207121208121209121210121211121212121213121214121215121216121217121218121219121220121221121222121223121224121225121226121227121228121229121230121231121232121233121234121235121236121237121238121239121240121241121242121243121244121245121246121247121248121249121250121251121252121253121254121255121256121257121258121259121260121261121262121263121264121265121266121267121268121269121270121271121272121273121274121275121276121277121278121279121280121281121282121283121284121285121286121287121288121289121290121291121292121293121294121295121296121297121298121299121300121301121302121303121304121305121306121307121308121309121310121311121312121313121314121315121316121317121318121319121320121321121322121323121324121325121326121327121328121329121330121331121332121333121334121335121336121337121338121339121340121341121342121343121344121345121346121347121348121349121350121351121352121353121354121355121356121357121358121359121360121361121362121363121364121365121366121367121368121369121370121371121372121373121374121375121376121377121378121379121380121381121382121383121384121385121386121387121388121389121390121391121392121393121394121395121396121397121398121399121400121401121402121403121404121405121406121407121408121409121410121411121412121413121414121415121416121417121418121419121420121421121422121423121424121425121426121427121428121429121430121431121432121433121434121435121436121437121438121439121440121441121442121443121444121445121446121447121448121449121450121451121452121453121454121455121456121457121458121459121460121461121462121463121464121465121466121467121468121469121470121471121472121473121474121475121476121477121478121479121480121481121482121483121484121485121486121487121488121489121490121491121492121493121494121495121496121497121498121499121500121501121502121503121504121505121506121507121508121509121510121511121512121513121514121515121516121517121518121519121520121521121522121523121524121525121526121527121528121529121530121531121532121533121534121535121536121537121538121539121540121541121542121543121544121545121546121547121548121549121550121551121552121553121554121555121556121557121558121559121560121561121562121563121564121565121566121567121568121569121570121571121572121573121574121575121576121577121578121579121580121581121582121583121584121585121586121587121588121589121590121591121592121593121594121595121596121597121598121599121600121601121602121603121604121605121606121607121608121609121610121611121612121613121614121615121616121617121618121619121620121621121622121623121624121625121626121627121628121629121630121631121632121633121634121635121636121637121638121639121640121641121642121643121644121645121646121647121648121649121650121651121652121653121654121655121656121657121658121659121660121661121662121663121664121665121666121667121668121669121670121671121672121673121674121675121676121677121678121679121680121681121682121683121684121685121686121687121688121689121690121691121692121693121694121695121696121697121698121699121700121701121702121703121704121705121706121707121708121709121710121711121712121713121714121715121716121717121718121719121720121721121722121723121724121725121726121727121728121729121730121731121732121733121734121735121736121737121738121739121740121741121742121743121744121745121746121747121748121749121750121751121752121753121754121755121756121757121758121759121760121761121762121763121764121765121766121767121768121769121770121771121772121773121774121775121776121777121778121779121780121781121782121783121784121785121786121787121788121789121790121791121792121793121794121795121796121797121798121799121800121801121802121803121804121805121806121807121808121809121810121811121812121813121814121815121816121817121818121819121820121821121822121823121824121825121826121827121828121829121830121831121832121833121834121835121836121837121838121839121840121841121842121843121844121845121846121847121848121849121850121851121852121853121854121855121856121857121858121859121860121861121862121863121864121865121866121867121868121869121870121871121872121873121874121875121876121877121878121879121880121881121882121883121884121885121886121887121888121889121890121891121892121893121894121895121896121897121898121899121900121901121902121903121904121905121906121907121908121909121910121911121912121913121914121915121916121917121918121919121920121921121922121923121924121925121926121927121928121929121930121931121932121933121934121935121936121937121938121939121940121941121942121943121944121945121946121947121948121949121950121951121952121953121954121955121956121957121958121959121960121961121962121963121964121965121966121967121968121969121970121971121972121973121974121975121976121977121978121979121980121981121982121983121984121985121986121987121988121989121990121991121992121993121994121995121996121997121998121999122000122001122002122003122004122005122006122007122008122009122010122011122012122013122014122015122016122017122018122019122020122021122022122023122024122025122026122027122028122029122030122031122032122033122034122035122036122037122038122039122040122041122042122043122044122045122046122047122048122049122050122051122052122053122054122055122056122057122058122059122060122061122062122063122064122065122066122067122068122069122070122071122072122073122074122075122076122077122078122079122080122081122082122083122084122085122086122087122088122089122090122091122092122093122094122095122096122097122098122099122100122101122102122103122104122105122106122107122108122109122110122111122112122113122114122115122116122117122118122119122120122121122122122123122124122125122126122127122128122129122130122131122132122133122134122135122136122137122138122139122140122141122142122143122144122145122146122147122148122149122150122151122152122153122154122155122156122157122158122159122160122161122162122163122164122165122166122167122168122169122170122171122172122173122174122175122176122177122178122179122180122181122182122183122184122185122186122187122188122189122190122191122192122193122194122195122196122197122198122199122200122201122202122203122204122205122206122207122208122209122210122211122212122213122214122215122216122217122218122219122220122221122222122223122224122225122226122227122228122229122230122231122232122233122234122235122236122237122238122239122240122241122242122243122244122245122246122247122248122249122250122251122252122253122254122255122256122257122258122259122260122261122262122263122264122265122266122267122268122269122270122271122272122273122274122275122276122277122278122279122280122281122282122283122284122285122286122287122288122289122290122291122292122293122294122295122296122297122298122299122300122301122302122303122304122305122306122307122308122309122310122311122312122313122314122315122316122317122318122319122320122321122322122323122324122325122326122327122328122329122330122331122332122333122334122335122336122337122338122339122340122341122342122343122344122345122346122347122348122349122350122351122352122353122354122355122356122357122358122359122360122361122362122363122364122365122366122367122368122369122370122371122372122373122374122375122376122377122378122379122380122381122382122383122384122385122386122387122388122389122390122391122392122393122394122395122396122397122398122399122400122401122402122403122404122405122406122407122408122409122410122411122412122413122414122415122416122417122418122419122420122421122422122423122424122425122426122427122428122429122430122431122432122433122434122435122436122437122438122439122440122441122442122443122444122445122446122447122448122449122450122451122452122453122454122455122456122457122458122459122460122461122462122463122464122465122466122467122468122469122470122471122472122473122474122475122476122477122478122479122480122481122482122483122484122485122486122487122488122489122490122491122492122493122494122495122496122497122498122499122500122501122502122503122504122505122506122507122508122509122510122511122512122513122514122515122516122517122518122519122520122521122522122523122524122525122526122527122528122529122530122531122532122533122534122535122536122537122538122539122540122541122542122543122544122545122546122547122548122549122550122551122552122553122554122555122556122557122558122559122560122561122562122563122564122565122566122567122568122569122570122571122572122573122574122575122576122577122578122579122580122581122582122583122584122585122586122587122588122589122590122591122592122593122594122595122596122597122598122599122600122601122602122603122604122605122606122607122608122609122610122611122612122613122614122615122616122617122618122619122620122621122622122623122624122625122626122627122628122629122630122631122632122633122634122635122636122637122638122639122640122641122642122643122644122645122646122647122648122649122650122651122652122653122654122655122656122657122658122659122660122661122662122663122664122665122666122667122668122669122670122671122672122673122674122675122676122677122678122679122680122681122682122683122684122685122686122687122688122689122690122691122692122693122694122695122696122697122698122699122700122701122702122703122704122705122706122707122708122709122710122711122712122713122714122715122716122717122718122719122720122721122722122723122724122725122726122727122728122729122730122731122732122733122734122735122736122737122738122739122740122741122742122743122744122745122746122747122748122749122750122751122752122753122754122755122756122757122758122759122760122761122762122763122764122765122766122767122768122769122770122771122772122773122774122775122776122777122778122779122780122781122782122783122784122785122786122787122788122789122790122791122792122793122794122795122796122797122798122799122800122801122802122803122804122805122806122807122808122809122810122811122812122813122814122815122816122817122818122819122820122821122822122823122824122825122826122827122828122829122830122831122832122833122834122835122836122837122838122839122840122841122842122843122844122845122846122847122848122849122850122851122852122853122854122855122856122857122858122859122860122861122862122863122864122865122866122867122868122869122870122871122872122873122874122875122876122877122878122879122880122881122882122883122884122885122886122887122888122889122890122891122892122893122894122895122896122897122898122899122900122901122902122903122904122905122906122907122908122909122910122911122912122913122914122915122916122917122918122919122920122921122922122923122924122925122926122927122928122929122930122931122932122933122934122935122936122937122938122939122940122941122942122943122944122945122946122947122948122949122950122951122952122953122954122955122956122957122958122959122960122961122962122963122964122965122966122967122968122969122970122971122972122973122974122975122976122977122978122979122980122981122982122983122984122985122986122987122988122989122990122991122992122993122994122995122996122997122998122999123000123001123002123003123004123005123006123007123008123009123010123011123012123013123014123015123016123017123018123019123020123021123022123023123024123025123026123027123028123029123030123031123032123033123034123035123036123037123038123039123040123041123042123043123044123045123046123047123048123049123050123051123052123053123054123055123056123057123058123059123060123061123062123063123064123065123066123067123068123069123070123071123072123073123074123075123076123077123078123079123080123081123082123083123084123085123086123087123088123089123090123091123092123093123094123095123096123097123098123099123100123101123102123103123104123105123106123107123108123109123110123111123112123113123114123115123116123117123118123119123120123121123122123123123124123125123126123127123128123129123130123131123132123133123134123135123136123137123138123139123140123141123142123143123144123145123146123147123148123149123150123151123152123153123154123155123156123157123158123159123160123161123162123163123164123165123166123167123168123169123170123171123172123173123174123175123176123177123178123179123180123181123182123183123184123185123186123187123188123189123190123191123192123193123194123195123196123197123198123199123200123201123202123203123204123205123206123207123208123209123210123211123212123213123214123215123216123217123218123219123220123221123222123223123224123225123226123227123228123229123230123231123232123233123234123235123236123237123238123239123240123241123242123243123244123245123246123247123248123249123250123251123252123253123254123255123256123257123258123259123260123261123262123263123264123265123266123267123268123269123270123271123272123273123274123275123276123277123278123279123280123281123282123283123284123285123286123287123288123289123290123291123292123293123294123295123296123297123298123299123300123301123302123303123304123305123306123307123308123309123310123311123312123313123314123315123316123317123318123319123320123321123322123323123324123325123326123327123328123329123330123331123332123333123334123335123336123337123338123339123340123341123342123343123344123345123346123347123348123349123350123351123352123353123354123355123356123357123358123359123360123361123362123363123364123365123366123367123368123369123370123371123372123373123374123375123376123377123378123379123380123381123382123383123384123385123386123387123388123389123390123391123392123393123394123395123396123397123398123399123400123401123402123403123404123405123406123407123408123409123410123411123412123413123414123415123416123417123418123419123420123421123422123423123424123425123426123427123428123429123430123431123432123433123434123435123436123437123438123439123440123441123442123443123444123445123446123447123448123449123450123451123452123453123454123455123456123457123458123459123460123461123462123463123464123465123466123467123468123469123470123471123472123473123474123475123476123477123478123479123480123481123482123483123484123485123486123487123488123489123490123491123492123493123494123495123496123497123498123499123500123501123502123503123504123505123506123507123508123509123510123511123512123513123514123515123516123517123518123519123520123521123522123523123524123525123526123527123528123529123530123531123532123533123534123535123536123537123538123539123540123541123542123543123544123545123546123547123548123549123550123551123552123553123554123555123556123557123558123559123560123561123562123563123564123565123566123567123568123569123570123571123572123573123574123575123576123577123578123579123580123581123582123583123584123585123586123587123588123589123590123591123592123593123594123595123596123597123598123599123600123601123602123603123604123605123606123607123608123609123610123611123612123613123614123615123616123617123618123619123620123621123622123623123624123625123626123627123628123629123630123631123632123633123634123635123636123637123638123639123640123641123642123643123644123645123646123647123648123649123650123651123652123653123654123655123656123657123658123659123660123661123662123663123664123665123666123667123668123669123670123671123672123673123674123675123676123677123678123679123680123681123682123683123684123685123686123687123688123689123690123691123692123693123694123695123696123697123698123699123700123701123702123703123704123705123706123707123708123709123710123711123712123713123714123715123716123717123718123719123720123721123722123723123724123725123726123727123728123729123730123731123732123733123734123735123736123737123738123739123740123741123742123743123744123745123746123747123748123749123750123751123752123753123754123755123756123757123758123759123760123761123762123763123764123765123766123767123768123769123770123771123772123773123774123775123776123777123778123779123780123781123782123783123784123785123786123787123788123789123790123791123792123793123794123795123796123797123798123799123800123801123802123803123804123805123806123807123808123809123810123811123812123813123814123815123816123817123818123819123820123821123822123823123824123825123826123827123828123829123830123831123832123833123834123835123836123837123838123839123840123841123842123843123844123845123846123847123848123849123850123851123852123853123854123855123856123857123858123859123860123861123862123863123864123865123866123867123868123869123870123871123872123873123874123875123876123877123878123879123880123881123882123883123884123885123886123887123888123889123890123891123892123893123894123895123896123897123898123899123900123901123902123903123904123905123906123907123908123909123910123911123912123913123914123915123916123917123918123919123920123921123922123923123924123925123926123927123928123929123930123931123932123933123934123935123936123937123938123939123940123941123942123943123944123945123946123947123948123949123950123951123952123953123954123955123956123957123958123959123960123961123962123963123964123965123966123967123968123969123970123971123972123973123974123975123976123977123978123979123980123981123982123983123984123985123986123987123988123989123990123991123992123993123994123995123996123997123998123999124000124001124002124003124004124005124006124007124008124009124010124011124012124013124014124015124016124017124018124019124020124021124022124023124024124025124026124027124028124029124030124031124032124033124034124035124036124037124038124039124040124041124042124043124044124045124046124047124048124049124050124051124052124053124054124055124056124057124058124059124060124061124062124063124064124065124066124067124068124069124070124071124072124073124074124075124076124077124078124079124080124081124082124083124084124085124086124087124088124089124090124091124092124093124094124095124096124097124098124099124100124101124102124103124104124105124106124107124108124109124110124111124112124113124114124115124116124117124118124119124120124121124122124123124124124125124126124127124128124129124130124131124132124133124134124135124136124137124138124139124140124141124142124143124144124145124146124147124148124149124150124151124152124153124154124155124156124157124158124159124160124161124162124163124164124165124166124167124168124169124170124171124172124173124174124175124176124177124178124179124180124181124182124183124184124185124186124187124188124189124190124191124192124193124194124195124196124197124198124199124200124201124202124203124204124205124206124207124208124209124210124211124212124213124214124215124216124217124218124219124220124221124222124223124224124225124226124227124228124229124230124231124232124233124234124235124236124237124238124239124240124241124242124243124244124245124246124247124248124249124250124251124252124253124254124255124256124257124258124259124260124261124262124263124264124265124266124267124268124269124270124271124272124273124274124275124276124277124278124279124280124281124282124283124284124285124286124287124288124289124290124291124292124293124294124295124296124297124298124299124300124301124302124303124304124305124306124307124308124309124310124311124312124313124314124315124316124317124318124319124320124321124322124323124324124325124326124327124328124329124330124331124332124333124334124335124336124337124338124339124340124341124342124343124344124345124346124347124348124349124350124351124352124353124354124355124356124357124358124359124360124361124362124363124364124365124366124367124368124369124370124371124372124373124374124375124376124377124378124379124380124381124382124383124384124385124386124387124388124389124390124391124392124393124394124395124396124397124398124399124400124401124402124403124404124405124406124407124408124409124410124411124412124413124414124415124416124417124418124419124420124421124422124423124424124425124426124427124428124429124430124431124432124433124434124435124436124437124438124439124440124441124442124443124444124445124446124447124448124449124450124451124452124453124454124455124456124457124458124459124460124461124462124463124464124465124466124467124468124469124470124471124472124473124474124475124476124477124478124479124480124481124482124483124484124485124486124487124488124489124490124491124492124493124494124495124496124497124498124499124500124501124502124503124504124505124506124507124508124509124510124511124512124513124514124515124516124517124518124519124520124521124522124523124524124525124526124527124528124529124530124531124532124533124534124535124536124537124538124539124540124541124542124543124544124545124546124547124548124549124550124551124552124553124554124555124556124557124558124559124560124561124562124563124564124565124566124567124568124569124570124571124572124573124574124575124576124577124578124579124580124581124582124583124584124585124586124587124588124589124590124591124592124593124594124595124596124597124598124599124600124601124602124603124604124605124606124607124608124609124610124611124612124613124614124615124616124617124618124619124620124621124622124623124624124625124626124627124628124629124630124631124632124633124634124635124636124637124638124639124640124641124642124643124644124645124646124647124648124649124650124651124652124653124654124655124656124657124658124659124660124661124662124663124664124665124666124667124668124669124670124671124672124673124674124675124676124677124678124679124680124681124682124683124684124685124686124687124688124689124690124691124692124693124694124695124696124697124698124699124700124701124702124703124704124705124706124707124708124709124710124711124712124713124714124715124716124717124718124719124720124721124722124723124724124725124726124727124728124729124730124731124732124733124734124735124736124737124738124739124740124741124742124743124744124745124746124747124748124749124750124751124752124753124754124755124756124757124758124759124760124761124762124763124764124765124766124767124768124769124770124771124772124773124774124775124776124777124778124779124780124781124782124783124784124785124786124787124788124789124790124791124792124793124794124795124796124797124798124799124800124801124802124803124804124805124806124807124808124809124810124811124812124813124814124815124816124817124818124819124820124821124822124823124824124825124826124827124828124829124830124831124832124833124834124835124836124837124838124839124840124841124842124843124844124845124846124847124848124849124850124851124852124853124854124855124856124857124858124859124860124861124862124863124864124865124866124867124868124869124870124871124872124873124874124875124876124877124878124879124880124881124882124883124884124885124886124887124888124889124890124891124892124893124894124895124896124897124898124899124900124901124902124903124904124905124906124907124908124909124910124911124912124913124914124915124916124917124918124919124920124921124922124923124924124925124926124927124928124929124930124931124932124933124934124935124936124937124938124939124940124941124942124943124944124945124946124947124948124949124950124951124952124953124954124955124956124957124958124959124960124961124962124963124964124965124966124967124968124969124970124971124972124973124974124975124976124977124978124979124980124981124982124983124984124985124986124987124988124989124990124991124992124993124994124995124996124997124998124999125000125001125002125003125004125005125006125007125008125009125010125011125012125013125014125015125016125017125018125019125020125021125022125023125024125025125026125027125028125029125030125031125032125033125034125035125036125037125038125039125040125041125042125043125044125045125046125047125048125049125050125051125052125053125054125055125056125057125058125059125060125061125062125063125064125065125066125067125068125069125070125071125072125073125074125075125076125077125078125079125080125081125082125083125084125085125086125087125088125089125090125091125092125093125094125095125096125097125098125099125100125101125102125103125104125105125106125107125108125109125110125111125112125113125114125115125116125117125118125119125120125121125122125123125124125125125126125127125128125129125130125131125132125133125134125135125136125137125138125139125140125141125142125143125144125145125146125147125148125149125150125151125152125153125154125155125156125157125158125159125160125161125162125163125164125165125166125167125168125169125170125171125172125173125174125175125176125177125178125179125180125181125182125183125184125185125186125187125188125189125190125191125192125193125194125195125196125197125198125199125200125201125202125203125204125205125206125207125208125209125210125211125212125213125214125215125216125217125218125219125220125221125222125223125224125225125226125227125228125229125230125231125232125233125234125235125236125237125238125239125240125241125242125243125244125245125246125247125248125249125250125251125252125253125254125255125256125257125258125259125260125261125262125263125264125265125266125267125268125269125270125271125272125273125274125275125276125277125278125279125280125281125282125283125284125285125286125287125288125289125290125291125292125293125294125295125296125297125298125299125300125301125302125303125304125305125306125307125308125309125310125311125312125313125314125315125316125317125318125319125320125321125322125323125324125325125326125327125328125329125330125331125332125333125334125335125336125337125338125339125340125341125342125343125344125345125346125347125348125349125350125351125352125353125354125355125356125357125358125359125360125361125362125363125364125365125366125367125368125369125370125371125372125373125374125375125376125377125378125379125380125381125382125383125384125385125386125387125388125389125390125391125392125393125394125395125396125397125398125399125400125401125402125403125404125405125406125407125408125409125410125411125412125413125414125415125416125417125418125419125420125421125422125423125424125425125426125427125428125429125430125431125432125433125434125435125436125437125438125439125440125441125442125443125444125445125446125447125448125449125450125451125452125453125454125455125456125457125458125459125460125461125462125463125464125465125466125467125468125469125470125471125472125473125474125475125476125477125478125479125480125481125482125483125484125485125486125487125488125489125490125491125492125493125494125495125496125497125498125499125500125501125502125503125504125505125506125507125508125509125510125511125512125513125514125515125516125517125518125519125520125521125522125523125524125525125526125527125528125529125530125531125532125533125534125535125536125537125538125539125540125541125542125543125544125545125546125547125548125549125550125551125552125553125554125555125556125557125558125559125560125561125562125563125564125565125566125567125568125569125570125571125572125573125574125575125576125577125578125579125580125581125582125583125584125585125586125587125588125589125590125591125592125593125594125595125596125597125598125599125600125601125602125603125604125605125606125607125608125609125610125611125612125613125614125615125616125617125618125619125620125621125622125623125624125625125626125627125628125629125630125631125632125633125634125635125636125637125638125639125640125641125642125643125644125645125646125647125648125649125650125651125652125653125654125655125656125657125658125659125660125661125662125663125664125665125666125667125668125669125670125671125672125673125674125675125676125677125678125679125680125681125682125683125684125685125686125687125688125689125690125691125692125693125694125695125696125697125698125699125700125701125702125703125704125705125706125707125708125709125710125711125712125713125714125715125716125717125718125719125720125721125722125723125724125725125726125727125728125729125730125731125732125733125734125735125736125737125738125739125740125741125742125743125744125745125746125747125748125749125750125751125752125753125754125755125756125757125758125759125760125761125762125763125764125765125766125767125768125769125770125771125772125773125774125775125776125777125778125779125780125781125782125783125784125785125786125787125788125789125790125791125792125793125794125795125796125797125798125799125800125801125802125803125804125805125806125807125808125809125810125811125812125813125814125815125816125817125818125819125820125821125822125823125824125825125826125827125828125829125830125831125832125833125834125835125836125837125838125839125840125841125842125843125844125845125846125847125848125849125850125851125852125853125854125855125856125857125858125859125860125861125862125863125864125865125866125867125868125869125870125871125872125873125874125875125876125877125878125879125880125881125882125883125884125885125886125887125888125889125890125891125892125893125894125895125896125897125898125899125900125901125902125903125904125905125906125907125908125909125910125911125912125913125914125915125916125917125918125919125920125921125922125923125924125925125926125927125928125929125930125931125932125933125934125935125936125937125938125939125940125941125942125943125944125945125946125947125948125949125950125951125952125953125954125955125956125957125958125959125960125961125962125963125964125965125966125967125968125969125970125971125972125973125974125975125976125977125978125979125980125981125982125983125984125985125986125987125988125989125990125991125992125993125994125995125996125997125998125999126000126001126002126003126004126005126006126007126008126009126010126011126012126013126014126015126016126017126018126019126020126021126022126023126024126025126026126027126028126029126030126031126032126033126034126035126036126037126038126039126040126041126042126043126044126045126046126047126048126049126050126051126052126053126054126055126056126057126058126059126060126061126062126063126064126065126066126067126068126069126070126071126072126073126074126075126076126077126078126079126080126081126082126083126084126085126086126087126088126089126090126091126092126093126094126095126096126097126098126099126100126101126102126103126104126105126106126107126108126109126110126111126112126113126114126115126116126117126118126119126120126121126122126123126124126125126126126127126128126129126130126131126132126133126134126135126136126137126138126139126140126141126142126143126144126145126146126147126148126149126150126151126152126153126154126155126156126157126158126159126160126161126162126163126164126165126166126167126168126169126170126171126172126173126174126175126176126177126178126179126180126181126182126183126184126185126186126187126188126189126190126191126192126193126194126195126196126197126198126199126200126201126202126203126204126205126206126207126208126209126210126211126212126213126214126215126216126217126218126219126220126221126222126223126224126225126226126227126228126229126230126231126232126233126234126235126236126237126238126239126240126241126242126243126244126245126246126247126248126249126250126251126252126253126254126255126256126257126258126259126260126261126262126263126264126265126266126267126268126269126270126271126272126273126274126275126276126277126278126279126280126281126282126283126284126285126286126287126288126289126290126291126292126293126294126295126296126297126298126299126300126301126302126303126304126305126306126307126308126309126310126311126312126313126314126315126316126317126318126319126320126321126322126323126324126325126326126327126328126329126330126331126332126333126334126335126336126337126338126339126340126341126342126343126344126345126346126347126348126349126350126351126352126353126354126355126356126357126358126359126360126361126362126363126364126365126366126367126368126369126370126371126372126373126374126375126376126377126378126379126380126381126382126383126384126385126386126387126388126389126390126391126392126393126394126395126396126397126398126399126400126401126402126403126404126405126406126407126408126409126410126411126412126413126414126415126416126417126418126419126420126421126422126423126424126425126426126427126428126429126430126431126432126433126434126435126436126437126438126439126440126441126442126443126444126445126446126447126448126449126450126451126452126453126454126455126456126457126458126459126460126461126462126463126464126465126466126467126468126469126470126471126472126473126474126475126476126477126478126479126480126481126482126483126484126485126486126487126488126489126490126491126492126493126494126495126496126497126498126499126500126501126502126503126504126505126506126507126508126509126510126511126512126513126514126515126516126517126518126519126520126521126522126523126524126525126526126527126528126529126530126531126532126533126534126535126536126537126538126539126540126541126542126543126544126545126546126547126548126549126550126551126552126553126554126555126556126557126558126559126560126561126562126563126564126565126566126567126568126569126570126571126572126573126574126575126576126577126578126579126580126581126582126583126584126585126586126587126588126589126590126591126592126593126594126595126596126597126598126599126600126601126602126603126604126605126606126607126608126609126610126611126612126613126614126615126616126617126618126619126620126621126622126623126624126625126626126627126628126629126630126631126632126633126634126635126636126637126638126639126640126641126642126643126644126645126646126647126648126649126650126651126652126653126654126655126656126657126658126659126660126661126662126663126664126665126666126667126668126669126670126671126672126673126674126675126676126677126678126679126680126681126682126683126684126685126686126687126688126689126690126691126692126693126694126695126696126697126698126699126700126701126702126703126704126705126706126707126708126709126710126711126712126713126714126715126716126717126718126719126720126721126722126723126724126725126726126727126728126729126730126731126732126733126734126735126736126737126738126739126740126741126742126743126744126745126746126747126748126749126750126751126752126753126754126755126756126757126758126759126760126761126762126763126764126765126766126767126768126769126770126771126772126773126774126775126776126777126778126779126780126781126782126783126784126785126786126787126788126789126790126791126792126793126794126795126796126797126798126799126800126801126802126803126804126805126806126807126808126809126810126811126812126813126814126815126816126817126818126819126820126821126822126823126824126825126826126827126828126829126830126831126832126833126834126835126836126837126838126839126840126841126842126843126844126845126846126847126848126849126850126851126852126853126854126855126856126857126858126859126860126861126862126863126864126865126866126867126868126869126870126871126872126873126874126875126876126877126878126879126880126881126882126883126884126885126886126887126888126889126890126891126892126893126894126895126896126897126898126899126900126901126902126903126904126905126906126907126908126909126910126911126912126913126914126915126916126917126918126919126920126921126922126923126924126925126926126927126928126929126930126931126932126933126934126935126936126937126938126939126940126941126942126943126944126945126946126947126948126949126950126951126952126953126954126955126956126957126958126959126960126961126962126963126964126965126966126967126968126969126970126971126972126973126974126975126976126977126978126979126980126981126982126983126984126985126986126987126988126989126990126991126992126993126994126995126996126997126998126999127000127001127002127003127004127005127006127007127008127009127010127011127012127013127014127015127016127017127018127019127020127021127022127023127024127025127026127027127028127029127030127031127032127033127034127035127036127037127038127039127040127041127042127043127044127045127046127047127048127049127050127051127052127053127054127055127056127057127058127059127060127061127062127063127064127065127066127067127068127069127070127071127072127073127074127075127076127077127078127079127080127081127082127083127084127085127086127087127088127089127090127091127092127093127094127095127096127097127098127099127100127101127102127103127104127105127106127107127108127109127110127111127112127113127114127115127116127117127118127119127120127121127122127123127124127125127126127127127128127129127130127131127132127133127134127135127136127137127138127139127140127141127142127143127144127145127146127147127148127149127150127151127152127153127154127155127156127157127158127159127160127161127162127163127164127165127166127167127168127169127170127171127172127173127174127175127176127177127178127179127180127181127182127183127184127185127186127187127188127189127190127191127192127193127194127195127196127197127198127199127200127201127202127203127204127205127206127207127208127209127210127211127212127213127214127215127216127217127218127219127220127221127222127223127224127225127226127227127228127229127230127231127232127233127234127235127236127237127238127239127240127241127242127243127244127245127246127247127248127249127250127251127252127253127254127255127256127257127258127259127260127261127262127263127264127265127266127267127268127269127270127271127272127273127274127275127276127277127278127279127280127281127282127283127284127285127286127287127288127289127290127291127292127293127294127295127296127297127298127299127300127301127302127303127304127305127306127307127308127309127310127311127312127313127314127315127316127317127318127319127320127321127322127323127324127325127326127327127328127329127330127331127332127333127334127335127336127337127338127339127340127341127342127343127344127345127346127347127348127349127350127351127352127353127354127355127356127357127358127359127360127361127362127363127364127365127366127367127368127369127370127371127372127373127374127375127376127377127378127379127380127381127382127383127384127385127386127387127388127389127390127391127392127393127394127395127396127397127398127399127400127401127402127403127404127405127406127407127408127409127410127411127412127413127414127415127416127417127418127419127420127421127422127423127424127425127426127427127428127429127430127431127432127433127434127435127436127437127438127439127440127441127442127443127444127445127446127447127448127449127450127451127452127453127454127455127456127457127458127459127460127461127462127463127464127465127466127467127468127469127470127471127472127473127474127475127476127477127478127479127480127481127482127483127484127485127486127487127488127489127490127491127492127493127494127495127496127497127498127499127500127501127502127503127504127505127506127507127508127509127510127511127512127513127514127515127516127517127518127519127520127521127522127523127524127525127526127527127528127529127530127531127532127533127534127535127536127537127538127539127540127541127542127543127544127545127546127547127548127549127550127551127552127553127554127555127556127557127558127559127560127561127562127563127564127565127566127567127568127569127570127571127572127573127574127575127576127577127578127579127580127581127582127583127584127585127586127587127588127589127590127591127592127593127594127595127596127597127598127599127600127601127602127603127604127605127606127607127608127609127610127611127612127613127614127615127616127617127618127619127620127621127622127623127624127625127626127627127628127629127630127631127632127633127634127635127636127637127638127639127640127641127642127643127644127645127646127647127648127649127650127651127652127653127654127655127656127657127658127659127660127661127662127663127664127665127666127667127668127669127670127671127672127673127674127675127676127677127678127679127680127681127682127683127684127685127686127687127688127689127690127691127692127693127694127695127696127697127698127699127700127701127702127703127704127705127706127707127708127709127710127711127712127713127714127715127716127717127718127719127720127721127722127723127724127725127726127727127728127729127730127731127732127733127734127735127736127737127738127739127740127741127742127743127744127745127746127747127748127749127750127751127752127753127754127755127756127757127758127759127760127761127762127763127764127765127766127767127768127769127770127771127772127773127774127775127776127777127778127779127780127781127782127783127784127785127786127787127788127789127790127791127792127793127794127795127796127797127798127799127800127801127802127803127804127805127806127807127808127809127810127811127812127813127814127815127816127817127818127819127820127821127822127823127824127825127826127827127828127829127830127831127832127833127834127835127836127837127838127839127840127841127842127843127844127845127846127847127848127849127850127851127852127853127854127855127856127857127858127859127860127861127862127863127864127865127866127867127868127869127870127871127872127873127874127875127876127877127878127879127880127881127882127883127884127885127886127887127888127889127890127891127892127893127894127895127896127897127898127899127900127901127902127903127904127905127906127907127908127909127910127911127912127913127914127915127916127917127918127919127920127921127922127923127924127925127926127927127928127929127930127931127932127933127934127935127936127937127938127939127940127941127942127943127944127945127946127947127948127949127950127951127952127953127954127955127956127957127958127959127960127961127962127963127964127965127966127967127968127969127970127971127972127973127974127975127976127977127978127979127980127981127982127983127984127985127986127987127988127989127990127991127992127993127994127995127996127997127998127999128000128001128002128003128004128005128006128007128008128009128010128011128012128013128014128015128016128017128018128019128020128021128022128023128024128025128026128027128028128029128030128031128032128033128034128035128036128037128038128039128040128041128042128043128044128045128046128047128048128049128050128051128052128053128054128055128056128057128058128059128060128061128062128063128064128065128066128067128068128069128070128071128072128073128074128075128076128077128078128079128080128081128082128083128084128085128086128087128088128089128090128091128092128093128094128095128096128097128098128099128100128101128102128103128104128105128106128107128108128109128110128111128112128113128114128115128116128117128118128119128120128121128122128123128124128125128126128127128128128129128130128131128132128133128134128135128136128137128138128139128140128141128142128143128144128145128146128147128148128149128150128151128152128153128154128155128156128157128158128159128160128161128162128163128164128165128166128167128168128169128170128171128172128173128174128175128176128177128178128179128180128181128182128183128184128185128186128187128188128189128190128191128192128193128194128195128196128197128198128199128200128201128202128203128204128205128206128207128208128209128210128211128212128213128214128215128216128217128218128219128220128221128222128223128224128225128226128227128228128229128230128231128232128233128234128235128236128237128238128239128240128241128242128243128244128245128246128247128248128249128250128251128252128253128254128255128256128257128258128259128260128261128262128263128264128265128266128267128268128269128270128271128272128273128274128275128276128277128278128279128280128281128282128283128284128285128286128287128288128289128290128291128292128293128294128295128296128297128298128299128300128301128302128303128304128305128306128307128308128309128310128311128312128313128314128315128316128317128318128319128320128321128322128323128324128325128326128327128328128329128330128331128332128333128334128335128336128337128338128339128340128341128342128343128344128345128346128347128348128349128350128351128352128353128354128355128356128357128358128359128360128361128362128363128364128365128366128367128368128369128370128371128372128373128374128375128376128377128378128379128380128381128382128383128384128385128386128387128388128389128390128391128392128393128394128395128396128397128398128399128400128401128402128403128404128405128406128407128408128409128410128411128412128413128414128415128416128417128418128419128420128421128422128423128424128425128426128427128428128429128430128431128432128433128434128435128436128437128438128439128440128441128442128443128444128445128446128447128448128449128450128451128452128453128454128455128456128457128458128459128460128461128462128463128464128465128466128467128468128469128470128471128472128473128474128475128476128477128478128479128480128481128482128483128484128485128486128487128488128489128490128491128492128493128494128495128496128497128498128499128500128501128502128503128504128505128506128507128508128509128510128511128512128513128514128515128516128517128518128519128520128521128522128523128524128525128526128527128528128529128530128531128532128533128534128535128536128537128538128539128540128541128542128543128544128545128546128547128548128549128550128551128552128553128554128555128556128557128558128559128560128561128562128563128564128565128566128567128568128569128570128571128572128573128574128575128576128577128578128579128580128581128582128583128584128585128586128587128588128589128590128591128592128593128594128595128596128597128598128599128600128601128602128603128604128605128606128607128608128609128610128611128612128613128614128615128616128617128618128619128620128621128622128623128624128625128626128627128628128629128630128631128632128633128634128635128636128637128638128639128640128641128642128643128644128645128646128647128648128649128650128651128652128653128654128655128656128657128658128659128660128661128662128663128664128665128666128667128668128669128670128671128672128673128674128675128676128677128678128679128680128681128682128683128684128685128686128687128688128689128690128691128692128693128694128695128696128697128698128699128700128701128702128703128704128705128706128707128708128709128710128711128712128713128714128715128716128717128718128719128720128721128722128723128724128725128726128727128728128729128730128731128732128733128734128735128736128737128738128739128740128741128742128743128744128745128746128747128748128749128750128751128752128753128754128755128756128757128758128759128760128761128762128763128764128765128766128767128768128769128770128771128772128773128774128775128776128777128778128779128780128781128782128783128784128785128786128787128788128789128790128791128792128793128794128795128796128797128798128799128800128801128802128803128804128805128806128807128808128809128810128811128812128813128814128815128816128817128818128819128820128821128822128823128824128825128826128827128828128829128830128831128832128833128834128835128836128837128838128839128840128841128842128843128844128845128846128847128848128849128850128851128852128853128854128855128856128857128858128859128860128861128862128863128864128865128866128867128868128869128870128871128872128873128874128875128876128877128878128879128880128881128882128883128884128885128886128887128888128889128890128891128892128893128894128895128896128897128898128899128900128901128902128903128904128905128906128907128908128909128910128911128912128913128914128915128916128917128918128919128920128921128922128923128924128925128926128927128928128929128930128931128932128933128934128935128936128937128938128939128940128941128942128943128944128945128946128947128948128949128950128951128952128953128954128955128956128957128958128959128960128961128962128963128964128965128966128967128968128969128970128971128972128973128974128975128976128977128978128979128980128981128982128983128984128985128986128987128988128989128990128991128992128993128994128995128996128997128998128999129000129001129002129003129004129005129006129007129008129009129010129011129012129013129014129015129016129017129018129019129020129021129022129023129024129025129026129027129028129029129030129031129032129033129034129035129036129037129038129039129040129041129042129043129044129045129046129047129048129049129050129051129052129053129054129055129056129057129058129059129060129061129062129063129064129065129066129067129068129069129070129071129072129073129074129075129076129077129078129079129080129081129082129083129084129085129086129087129088129089129090129091129092129093129094129095129096129097129098129099129100129101129102129103129104129105129106129107129108129109129110129111129112129113129114129115129116129117129118129119129120129121129122129123129124129125129126129127129128129129129130129131129132129133129134129135129136129137129138129139129140129141129142129143129144129145129146129147129148129149129150129151129152129153129154129155129156129157129158129159129160129161129162129163129164129165129166129167129168129169129170129171129172129173129174129175129176129177129178129179129180129181129182129183129184129185129186129187129188129189129190129191129192129193129194129195129196129197129198129199129200129201129202129203129204129205129206129207129208129209129210129211129212129213129214129215129216129217129218129219129220129221129222129223129224129225129226129227129228129229129230129231129232129233129234129235129236129237129238129239129240129241129242129243129244129245129246129247129248129249129250129251129252129253129254129255129256129257129258129259129260129261129262129263129264129265129266129267129268129269129270129271129272129273129274129275129276129277129278129279129280129281129282129283129284129285129286129287129288129289129290129291129292129293129294129295129296129297129298129299129300129301129302129303129304129305129306129307129308129309129310129311129312129313129314129315129316129317129318129319129320129321129322129323129324129325129326129327129328129329129330129331129332129333129334129335129336129337129338129339129340129341129342129343129344129345129346129347129348129349129350129351129352129353129354129355129356129357129358129359129360129361129362129363129364129365129366129367129368129369129370129371129372129373129374129375129376129377129378129379129380129381129382129383129384129385129386129387129388129389129390129391129392129393129394129395129396129397129398129399129400129401129402129403129404129405129406129407129408129409129410129411129412129413129414129415129416129417129418129419129420129421129422129423129424129425129426129427129428129429129430129431129432129433129434129435129436129437129438129439129440129441129442129443129444129445129446129447129448129449129450129451129452129453129454129455129456129457129458129459129460129461129462129463129464129465129466129467129468129469129470129471129472129473129474129475129476129477129478129479129480129481129482129483129484129485129486129487129488129489129490129491129492129493129494129495129496129497129498129499129500129501129502129503129504129505129506129507129508129509129510129511129512129513129514129515129516129517129518129519129520129521129522129523129524129525129526129527129528129529129530129531129532129533129534129535129536129537129538129539129540129541129542129543129544129545129546129547129548129549129550129551129552129553129554129555129556129557129558129559129560129561129562129563129564129565129566129567129568129569129570129571129572129573129574129575129576129577129578129579129580129581129582129583129584129585129586129587129588129589129590129591129592129593129594129595129596129597129598129599129600129601129602129603129604129605129606129607129608129609129610129611129612129613129614129615129616129617129618129619129620129621129622129623129624129625129626129627129628129629129630129631129632129633129634129635129636129637129638129639129640129641129642129643129644129645129646129647129648129649129650129651129652129653129654129655129656129657129658129659129660129661129662129663129664129665129666129667129668129669129670129671129672129673129674129675129676129677129678129679129680129681129682129683129684129685129686129687129688129689129690129691129692129693129694129695129696129697129698129699129700129701129702129703129704129705129706129707129708129709129710129711129712129713129714129715129716129717129718129719129720129721129722129723129724129725129726129727129728129729129730129731129732129733129734129735129736129737129738129739129740129741129742129743129744129745129746129747129748129749129750129751129752129753129754129755129756129757129758129759129760129761129762129763129764129765129766129767129768129769129770129771129772129773129774129775129776129777129778129779129780129781129782129783129784129785129786129787129788129789129790129791129792129793129794129795129796129797129798129799129800129801129802129803129804129805129806129807129808129809129810129811129812129813129814129815129816129817129818129819129820129821129822129823129824129825129826129827129828129829129830129831129832129833129834129835129836129837129838129839129840129841129842129843129844129845129846129847129848129849129850129851129852129853129854129855129856129857129858129859129860129861129862129863129864129865129866129867129868129869129870129871129872129873129874129875129876129877129878129879129880129881129882129883129884129885129886129887129888129889129890129891129892129893129894129895129896129897129898129899129900129901129902129903129904129905129906129907129908129909129910129911129912129913129914129915129916129917129918129919129920129921129922129923129924129925129926129927129928129929129930129931129932129933129934129935129936129937129938129939129940129941129942129943129944129945129946129947129948129949129950129951129952129953129954129955129956129957129958129959129960129961129962129963129964129965129966129967129968129969129970129971129972129973129974129975129976129977129978129979129980129981129982129983129984129985129986129987129988129989129990129991129992129993129994129995129996129997129998129999130000130001130002130003130004130005130006130007130008130009130010130011130012130013130014130015130016130017130018130019130020130021130022130023130024130025130026130027130028130029130030130031130032130033130034130035130036130037130038130039130040130041130042130043130044130045130046130047130048130049130050130051130052130053130054130055130056130057130058130059130060130061130062130063130064130065130066130067130068130069130070130071130072130073130074130075130076130077130078130079130080130081130082130083130084130085130086130087130088130089130090130091130092130093130094130095130096130097130098130099130100130101130102130103130104130105130106130107130108130109130110130111130112130113130114130115130116130117130118130119130120130121130122130123130124130125130126130127130128130129130130130131130132130133130134130135130136130137130138130139130140130141130142130143130144130145130146130147130148130149130150130151130152130153130154130155130156130157130158130159130160130161130162130163130164130165130166130167130168130169130170130171130172130173130174130175130176130177130178130179130180130181130182130183130184130185130186130187130188130189130190130191130192130193130194130195130196130197130198130199130200130201130202130203130204130205130206130207130208130209130210130211130212130213130214130215130216130217130218130219130220130221130222130223130224130225130226130227130228130229130230130231130232130233130234130235130236130237130238130239130240130241130242130243130244130245130246130247130248130249130250130251130252130253130254130255130256130257130258130259130260130261130262130263130264130265130266130267130268130269130270130271130272130273130274130275130276130277130278130279130280130281130282130283130284130285130286130287130288130289130290130291130292130293130294130295130296130297130298130299130300130301130302130303130304130305130306130307130308130309130310130311130312130313130314130315130316130317130318130319130320130321130322130323130324130325130326130327130328130329130330130331130332130333130334130335130336130337130338130339130340130341130342130343130344130345130346130347130348130349130350130351130352130353130354130355130356130357130358130359130360130361130362130363130364130365130366130367130368130369130370130371130372130373130374130375130376130377130378130379130380130381130382130383130384130385130386130387130388130389130390130391130392130393130394130395130396130397130398130399130400130401130402130403130404130405130406130407130408130409130410130411130412130413130414130415130416130417130418130419130420130421130422130423130424130425130426130427130428130429130430130431130432130433130434130435130436130437130438130439130440130441130442130443130444130445130446130447130448130449130450130451130452130453130454130455130456130457130458130459130460130461130462130463130464130465130466130467130468130469130470130471130472130473130474130475130476130477130478130479130480130481130482130483130484130485130486130487130488130489130490130491130492130493130494130495130496130497130498130499130500130501130502130503130504130505130506130507130508130509130510130511130512130513130514130515130516130517130518130519130520130521130522130523130524130525130526130527130528130529130530130531130532130533130534130535130536130537130538130539130540130541130542130543130544130545130546130547130548130549130550130551130552130553130554130555130556130557130558130559130560130561130562130563130564130565130566130567130568130569130570130571130572130573130574130575130576130577130578130579130580130581130582130583130584130585130586130587130588130589130590130591130592130593130594130595130596130597130598130599130600130601130602130603130604130605130606130607130608130609130610130611130612130613130614130615130616130617130618130619130620130621130622130623130624130625130626130627130628130629130630130631130632130633130634130635130636130637130638130639130640130641130642130643130644130645130646130647130648130649130650130651130652130653130654130655130656130657130658130659130660130661130662130663130664130665130666130667130668130669130670130671130672130673130674130675130676130677130678130679130680130681130682130683130684130685130686130687130688130689130690130691130692130693130694130695130696130697130698130699130700130701130702130703130704130705130706130707130708130709130710130711130712130713130714130715130716130717130718130719130720130721130722130723130724130725130726130727130728130729130730130731130732130733130734130735130736130737130738130739130740130741130742130743130744130745130746130747130748130749130750130751130752130753130754130755130756130757130758130759130760130761130762130763130764130765130766130767130768130769130770130771130772130773130774130775130776130777130778130779130780130781130782130783130784130785130786130787130788130789130790130791130792130793130794130795130796130797130798130799130800130801130802130803130804130805130806130807130808130809130810130811130812130813130814130815130816130817130818130819130820130821130822130823130824130825130826130827130828130829130830130831130832130833130834130835130836130837130838130839130840130841130842130843130844130845130846130847130848130849130850130851130852130853130854130855130856130857130858130859130860130861130862130863130864130865130866130867130868130869130870130871130872130873130874130875130876130877130878130879130880130881130882130883130884130885130886130887130888130889130890130891130892130893130894130895130896130897130898130899130900130901130902130903130904130905130906130907130908130909130910130911130912130913130914130915130916130917130918130919130920130921130922130923130924130925130926130927130928130929130930130931130932130933130934130935130936130937130938130939130940130941130942130943130944130945130946130947130948130949130950130951130952130953130954130955130956130957130958130959130960130961130962130963130964130965130966130967130968130969130970130971130972130973130974130975130976130977130978130979130980130981130982130983130984130985130986130987130988130989130990130991130992130993130994130995130996130997130998130999131000131001131002131003131004131005131006131007131008131009131010131011131012131013131014131015131016131017131018131019131020131021131022131023131024131025131026131027131028131029131030131031131032131033131034131035131036131037131038131039131040131041131042131043131044131045131046131047131048131049131050131051131052131053131054131055131056131057131058131059131060131061131062131063131064131065131066131067131068131069131070131071131072131073131074131075131076131077131078131079131080131081131082131083131084131085131086131087131088131089131090131091131092131093131094131095131096131097131098131099131100131101131102131103131104131105131106131107131108131109131110131111131112131113131114131115131116131117131118131119131120131121131122131123131124131125131126131127131128131129131130131131131132131133131134131135131136131137131138131139131140131141131142131143131144131145131146131147131148131149131150131151131152131153131154131155131156131157131158131159131160131161131162131163131164131165131166131167131168131169131170131171131172131173131174131175131176131177131178131179131180131181131182131183131184131185131186131187131188131189131190131191131192131193131194131195131196131197131198131199131200131201131202131203131204131205131206131207131208131209131210131211131212131213131214131215131216131217131218131219131220131221131222131223131224131225131226131227131228131229131230131231131232131233131234131235131236131237131238131239131240131241131242131243131244131245131246131247131248131249131250131251131252131253131254131255131256131257131258131259131260131261131262131263131264131265131266131267131268131269131270131271131272131273131274131275131276131277131278131279131280131281131282131283131284131285131286131287131288131289131290131291131292131293131294131295131296131297131298131299131300131301131302131303131304131305131306131307131308131309131310131311131312131313131314131315131316131317131318131319131320131321131322131323131324131325131326131327131328131329131330131331131332131333131334131335131336131337131338131339131340131341131342131343131344131345131346131347131348131349131350131351131352131353131354131355131356131357131358131359131360131361131362131363131364131365131366131367131368131369131370131371131372131373131374131375131376131377131378131379131380131381131382131383131384131385131386131387131388131389131390131391131392131393131394131395131396131397131398131399131400131401131402131403131404131405131406131407131408131409131410131411131412131413131414131415131416131417131418131419131420131421131422131423131424131425131426131427131428131429131430131431131432131433131434131435131436131437131438131439131440131441131442131443131444131445131446131447131448131449131450131451131452131453131454131455131456131457131458131459131460131461131462131463131464131465131466131467131468131469131470131471131472131473131474131475131476131477131478131479131480131481131482131483131484131485131486131487131488131489131490131491131492131493131494131495131496131497131498131499131500131501131502131503131504131505131506131507131508131509131510131511131512131513131514131515131516131517131518131519131520131521131522131523131524131525131526131527131528131529131530131531131532131533131534131535131536131537131538131539131540131541131542131543131544131545131546131547131548131549131550131551131552131553131554131555131556131557131558131559131560131561131562131563131564131565131566131567131568131569131570131571131572131573131574131575131576131577131578131579131580131581131582131583131584131585131586131587131588131589131590131591131592131593131594131595131596131597131598131599131600131601131602131603131604131605131606131607131608131609131610131611131612131613131614131615131616131617131618131619131620131621131622131623131624131625131626131627131628131629131630131631131632131633131634131635131636131637131638131639131640131641131642131643131644131645131646131647131648131649131650131651131652131653131654131655131656131657131658131659131660131661131662131663131664131665131666131667131668131669131670131671131672131673131674131675131676131677131678131679131680131681131682131683131684131685131686131687131688131689131690131691131692131693131694131695131696131697131698131699131700131701131702131703131704131705131706131707131708131709131710131711131712131713131714131715131716131717131718131719131720131721131722131723131724131725131726131727131728131729131730131731131732131733131734131735131736131737131738131739131740131741131742131743131744131745131746131747131748131749131750131751131752131753131754131755131756131757131758131759131760131761131762131763131764131765131766131767131768131769131770131771131772131773131774131775131776131777131778131779131780131781131782131783131784131785131786131787131788131789131790131791131792131793131794131795131796131797131798131799131800131801131802131803131804131805131806131807131808131809131810131811131812131813131814131815131816131817131818131819131820131821131822131823131824131825131826131827131828131829131830131831131832131833131834131835131836131837131838131839131840131841131842131843131844131845131846131847131848131849131850131851131852131853131854131855131856131857131858131859131860131861131862131863131864131865131866131867131868131869131870131871131872131873131874131875131876131877131878131879131880131881131882131883131884131885131886131887131888131889131890131891131892131893131894131895131896131897131898131899131900131901131902131903131904131905131906131907131908131909131910131911131912131913131914131915131916131917131918131919131920131921131922131923131924131925131926131927131928131929131930131931131932131933131934131935131936131937131938131939131940131941131942131943131944131945131946131947131948131949131950131951131952131953131954131955131956131957131958131959131960131961131962131963131964131965131966131967131968131969131970131971131972131973131974131975131976131977131978131979131980131981131982131983131984131985131986131987131988131989131990131991131992131993131994131995131996131997131998131999132000132001132002132003132004132005132006132007132008132009132010132011132012132013132014132015132016132017132018132019132020132021132022132023132024132025132026132027132028132029132030132031132032132033132034132035132036132037132038132039132040132041132042132043132044132045132046132047132048132049132050132051132052132053132054132055132056132057132058132059132060132061132062132063132064132065132066132067132068132069132070132071132072132073132074132075132076132077132078132079132080132081132082132083132084132085132086132087132088132089132090132091132092132093132094132095132096132097132098132099132100132101132102132103132104132105132106132107132108132109132110132111132112132113132114132115132116132117132118132119132120132121132122132123132124132125132126132127132128132129132130132131132132132133132134132135132136132137132138132139132140132141132142132143132144132145132146132147132148132149132150132151132152132153132154132155132156132157132158132159132160132161132162132163132164132165132166132167132168132169132170132171132172132173132174132175132176132177132178132179132180132181132182132183132184132185132186132187132188132189132190132191132192132193132194132195132196132197132198132199132200132201132202132203132204132205132206132207132208132209132210132211132212132213132214132215132216132217132218132219132220132221132222132223132224132225132226132227132228132229132230132231132232132233132234132235132236132237132238132239132240132241132242132243132244132245132246132247132248132249132250132251132252132253132254132255132256132257132258132259132260132261132262132263132264132265132266132267132268132269132270132271132272132273132274132275132276132277132278132279132280132281132282132283132284132285132286132287132288132289132290132291132292132293132294132295132296132297132298132299132300132301132302132303132304132305132306132307132308132309132310132311132312132313132314132315132316132317132318132319132320132321132322132323132324132325132326132327132328132329132330132331132332132333132334132335132336132337132338132339132340132341132342132343132344132345132346132347132348132349132350132351132352132353132354132355132356132357132358132359132360132361132362132363132364132365132366132367132368132369132370132371132372132373132374132375132376132377132378132379132380132381132382132383132384132385132386132387132388132389132390132391132392132393132394132395132396132397132398132399132400132401132402132403132404132405132406132407132408132409132410132411132412132413132414132415132416132417132418132419132420132421132422132423132424132425132426132427132428132429132430132431132432132433132434132435132436132437132438132439132440132441132442132443132444132445132446132447132448132449132450132451132452132453132454132455132456132457132458132459132460132461132462132463132464132465132466132467132468132469132470132471132472132473132474132475132476132477132478132479132480132481132482132483132484132485132486132487132488132489132490132491132492132493132494132495132496132497132498132499132500132501132502132503132504132505132506132507132508132509132510132511132512132513132514132515132516132517132518132519132520132521132522132523132524132525132526132527132528132529132530132531132532132533132534132535132536132537132538132539132540132541132542132543132544132545132546132547132548132549132550132551132552132553132554132555132556132557132558132559132560132561132562132563132564132565132566132567132568132569132570132571132572132573132574132575132576132577132578132579132580132581132582132583132584132585132586132587132588132589132590132591132592132593132594132595132596132597132598132599132600132601132602132603132604132605132606132607132608132609132610132611132612132613132614132615132616132617132618132619132620132621132622132623132624132625132626132627132628132629132630132631132632132633132634132635132636132637132638132639132640132641132642132643132644132645132646132647132648132649132650132651132652132653132654132655132656132657132658132659132660132661132662132663132664132665132666132667132668132669132670132671132672132673132674132675132676132677132678132679132680132681132682132683132684132685132686132687132688132689132690132691132692132693132694132695132696132697132698132699132700132701132702132703132704132705132706132707132708132709132710132711132712132713132714132715132716132717132718132719132720132721132722132723132724132725132726132727132728132729132730132731132732132733132734132735132736132737132738132739132740132741132742132743132744132745132746132747132748132749132750132751132752132753132754132755132756132757132758132759132760132761132762132763132764132765132766132767132768132769132770132771132772132773132774132775132776132777132778132779132780132781132782132783132784132785132786132787132788132789132790132791132792132793132794132795132796132797132798132799132800132801132802132803132804132805132806132807132808132809132810132811132812132813132814132815132816132817132818132819132820132821132822132823132824132825132826132827132828132829132830132831132832132833132834132835132836132837132838132839132840132841132842132843132844132845132846132847132848132849132850132851132852132853132854132855132856132857132858132859132860132861132862132863132864132865132866132867132868132869132870132871132872132873132874132875132876132877132878132879132880132881132882132883132884132885132886132887132888132889132890132891132892132893132894132895132896132897132898132899132900132901132902132903132904132905132906132907132908132909132910132911132912132913132914132915132916132917132918132919132920132921132922132923132924132925132926132927132928132929132930132931132932132933132934132935132936132937132938132939132940132941132942132943132944132945132946132947132948132949132950132951132952132953132954132955132956132957132958132959132960132961132962132963132964132965132966132967132968132969132970132971132972132973132974132975132976132977132978132979132980132981132982132983132984132985132986132987132988132989132990132991132992132993132994132995132996132997132998132999133000133001133002133003133004133005133006133007133008133009133010133011133012133013133014133015133016133017133018133019133020133021133022133023133024133025133026133027133028133029133030133031133032133033133034133035133036133037133038133039133040133041133042133043133044133045133046133047133048133049133050133051133052133053133054133055133056133057133058133059133060133061133062133063133064133065133066133067133068133069133070133071133072133073133074133075133076133077133078133079133080133081133082133083133084133085133086133087133088133089133090133091133092133093133094133095133096133097133098133099133100133101133102133103133104133105133106133107133108133109133110133111133112133113133114133115133116133117133118133119133120133121133122133123133124133125133126133127133128133129133130133131133132133133133134133135133136133137133138133139133140133141133142133143133144133145133146133147133148133149133150133151133152133153133154133155133156133157133158133159133160133161133162133163133164133165133166133167133168133169133170133171133172133173133174133175133176133177133178133179133180133181133182133183133184133185133186133187133188133189133190133191133192133193133194133195133196133197133198133199133200133201133202133203133204133205133206133207133208133209133210133211133212133213133214133215133216133217133218133219133220133221133222133223133224133225133226133227133228133229133230133231133232133233133234133235133236133237133238133239133240133241133242133243133244133245133246133247133248133249133250133251133252133253133254133255133256133257133258133259133260133261133262133263133264133265133266133267133268133269133270133271133272133273133274133275133276133277133278133279133280133281133282133283133284133285133286133287133288133289133290133291133292133293133294133295133296133297133298133299133300133301133302133303133304133305133306133307133308133309133310133311133312133313133314133315133316133317133318133319133320133321133322133323133324133325133326133327133328133329133330133331133332133333133334133335133336133337133338133339133340133341133342133343133344133345133346133347133348133349133350133351133352133353133354133355133356133357133358133359133360133361133362133363133364133365133366133367133368133369133370133371133372133373133374133375133376133377133378133379133380133381133382133383133384133385133386133387133388133389133390133391133392133393133394133395133396133397133398133399133400133401133402133403133404133405133406133407133408133409133410133411133412133413133414133415133416133417133418133419133420133421133422133423133424133425133426133427133428133429133430133431133432133433133434133435133436133437133438133439133440133441133442133443133444133445133446133447133448133449133450133451133452133453133454133455133456133457133458133459133460133461133462133463133464133465133466133467133468133469133470133471133472133473133474133475133476133477133478133479133480133481133482133483133484133485133486133487133488133489133490133491133492133493133494133495133496133497133498133499133500133501133502133503133504133505133506133507133508133509133510133511133512133513133514133515133516133517133518133519133520133521133522133523133524133525133526133527133528133529133530133531133532133533133534133535133536133537133538133539133540133541133542133543133544133545133546133547133548133549133550133551133552133553133554133555133556133557133558133559133560133561133562133563133564133565133566133567133568133569133570133571133572133573133574133575133576133577133578133579133580133581133582133583133584133585133586133587133588133589133590133591133592133593133594133595133596133597133598133599133600133601133602133603133604133605133606133607133608133609133610133611133612133613133614133615133616133617133618133619133620133621133622133623133624133625133626133627133628133629133630133631133632133633133634133635133636133637133638133639133640133641133642133643133644133645133646133647133648133649133650133651133652133653133654133655133656133657133658133659133660133661133662133663133664133665133666133667133668133669133670133671133672133673133674133675133676133677133678133679133680133681133682133683133684133685133686133687133688133689133690133691133692133693133694133695133696133697133698133699133700133701133702133703133704133705133706133707133708133709133710133711133712133713133714133715133716133717133718133719133720133721133722133723133724133725133726133727133728133729133730133731133732133733133734133735133736133737133738133739133740133741133742133743133744133745133746133747133748133749133750133751133752133753133754133755133756133757133758133759133760133761133762133763133764133765133766133767133768133769133770133771133772133773133774133775133776133777133778133779133780133781133782133783133784133785133786133787133788133789133790133791133792133793133794133795133796133797133798133799133800133801133802133803133804133805133806133807133808133809133810133811133812133813133814133815133816133817133818133819133820133821133822133823133824133825133826133827133828133829133830133831133832133833133834133835133836133837133838133839133840133841133842133843133844133845133846133847133848133849133850133851133852133853133854133855133856133857133858133859133860133861133862133863133864133865133866133867133868133869133870133871133872133873133874133875133876133877133878133879133880133881133882133883133884133885133886133887133888133889133890133891133892133893133894133895133896133897133898133899133900133901133902133903133904133905133906133907133908133909133910133911133912133913133914133915133916133917133918133919133920133921133922133923133924133925133926133927133928133929133930133931133932133933133934133935133936133937133938133939133940133941133942133943133944133945133946133947133948133949133950133951133952133953133954133955133956133957133958133959133960133961133962133963133964133965133966133967133968133969133970133971133972133973133974133975133976133977133978133979133980133981133982133983133984133985133986133987133988133989133990133991133992133993133994133995133996133997133998133999134000134001134002134003134004134005134006134007134008134009134010134011134012134013134014134015134016134017134018134019134020134021134022134023134024134025134026134027134028134029134030134031134032134033134034134035134036134037134038134039134040134041134042134043134044134045134046134047134048134049134050134051134052134053134054134055134056134057134058134059134060134061134062134063134064134065134066134067134068134069134070134071134072134073134074134075134076134077134078134079134080134081134082134083134084134085134086134087134088134089134090134091134092134093134094134095134096134097134098134099134100134101134102134103134104134105134106134107134108134109134110134111134112134113134114134115134116134117134118134119134120134121134122134123134124134125134126134127134128134129134130134131134132134133134134134135134136134137134138134139134140134141134142134143134144134145134146134147134148134149134150134151134152134153134154134155134156134157134158134159134160134161134162134163134164134165134166134167134168134169134170134171134172134173134174134175134176134177134178134179134180134181134182134183134184134185134186134187134188134189134190134191134192134193134194134195134196134197134198134199134200134201134202134203134204134205134206134207134208134209134210134211134212134213134214134215134216134217134218134219134220134221134222134223134224134225134226134227134228134229134230134231134232134233134234134235134236134237134238134239134240134241134242134243134244134245134246134247134248134249134250134251134252134253134254134255134256134257134258134259134260134261134262134263134264134265134266134267134268134269134270134271134272134273134274134275134276134277134278134279134280134281134282134283134284134285134286134287134288134289134290134291134292134293134294134295134296134297134298134299134300134301134302134303134304134305134306134307134308134309134310134311134312134313134314134315134316134317134318134319134320134321134322134323134324134325134326134327134328134329134330134331134332134333134334134335134336134337134338134339134340134341134342134343134344134345134346134347134348134349134350134351134352134353134354134355134356134357134358134359134360134361134362134363134364134365134366134367134368134369134370134371134372134373134374134375134376134377134378134379134380134381134382134383134384134385134386134387134388134389134390134391134392134393134394134395134396134397134398134399134400134401134402134403134404134405134406134407134408134409134410134411134412134413134414134415134416134417134418134419134420134421134422134423134424134425134426134427134428134429134430134431134432134433134434134435134436134437134438134439134440134441134442134443134444134445134446134447134448134449134450134451134452134453134454134455134456134457134458134459134460134461134462134463134464134465134466134467134468134469134470134471134472134473134474134475134476134477134478134479134480134481134482134483134484134485134486134487134488134489134490134491134492134493134494134495134496134497134498134499134500134501134502134503134504134505134506134507134508134509134510134511134512134513134514134515134516134517134518134519134520134521134522134523134524134525134526134527134528134529134530134531134532134533134534134535134536134537134538134539134540134541134542134543134544134545134546134547134548134549134550134551134552134553134554134555134556134557134558134559134560134561134562134563134564134565134566134567134568134569134570134571134572134573134574134575134576134577134578134579134580134581134582134583134584134585134586134587134588134589134590134591134592134593134594134595134596134597134598134599134600134601134602134603134604134605134606134607134608134609134610134611134612134613134614134615134616134617134618134619134620134621134622134623134624134625134626134627134628134629134630134631134632134633134634134635134636134637134638134639134640134641134642134643134644134645134646134647134648134649134650134651134652134653134654134655134656134657134658134659134660134661134662134663134664134665134666134667134668134669134670134671134672134673134674134675134676134677134678134679134680134681134682134683134684134685134686134687134688134689134690134691134692134693134694134695134696134697134698134699134700134701134702134703134704134705134706134707134708134709134710134711134712134713134714134715134716134717134718134719134720134721134722134723134724134725134726134727134728134729134730134731134732134733134734134735134736134737134738134739134740134741134742134743134744134745134746134747134748134749134750134751134752134753134754134755134756134757134758134759134760134761134762134763134764134765134766134767134768134769134770134771134772134773134774134775134776134777134778134779134780134781134782134783134784134785134786134787134788134789134790134791134792134793134794134795134796134797134798134799134800134801134802134803134804134805134806134807134808134809134810134811134812134813134814134815134816134817134818134819134820134821134822134823134824134825134826134827134828134829134830134831134832134833134834134835134836134837134838134839134840134841134842134843134844134845134846134847134848134849134850134851134852134853134854134855134856134857134858134859134860134861134862134863134864134865134866134867134868134869134870134871134872134873134874134875134876134877134878134879134880134881134882134883134884134885134886134887134888134889134890134891134892134893134894134895134896134897134898134899134900134901134902134903134904134905134906134907134908134909134910134911134912134913134914134915134916134917134918134919134920134921134922134923134924134925134926134927134928134929134930134931134932134933134934134935134936134937134938134939134940134941134942134943134944134945134946134947134948134949134950134951134952134953134954134955134956134957134958134959134960134961134962134963134964134965134966134967134968134969134970134971134972134973134974134975134976134977134978134979134980134981134982134983134984134985134986134987134988134989134990134991134992134993134994134995134996134997134998134999135000135001135002135003135004135005135006135007135008135009135010135011135012135013135014135015135016135017135018135019135020135021135022135023135024135025135026135027135028135029135030135031135032135033135034135035135036135037135038135039135040135041135042135043135044135045135046135047135048135049135050135051135052135053135054135055135056135057135058135059135060135061135062135063135064135065135066135067135068135069135070135071135072135073135074135075135076135077135078135079135080135081135082135083135084135085135086135087135088135089135090135091135092135093135094135095135096135097135098135099135100135101135102135103135104135105135106135107135108135109135110135111135112135113135114135115135116135117135118135119135120135121135122135123135124135125135126135127135128135129135130135131135132135133135134135135135136135137135138135139135140135141135142135143135144135145135146135147135148135149135150135151135152135153135154135155135156135157135158135159135160135161135162135163135164135165135166135167135168135169135170135171135172135173135174135175135176135177135178135179135180135181135182135183135184135185135186135187135188135189135190135191135192135193135194135195135196135197135198135199135200135201135202135203135204135205135206135207135208135209135210135211135212135213135214135215135216135217135218135219135220135221135222135223135224135225135226135227135228135229135230135231135232135233135234135235135236135237135238135239135240135241135242135243135244135245135246135247135248135249135250135251135252135253135254135255135256135257135258135259135260135261135262135263135264135265135266135267135268135269135270135271135272135273135274135275135276135277135278135279135280135281135282135283135284135285135286135287135288135289135290135291135292135293135294135295135296135297135298135299135300135301135302135303135304135305135306135307135308135309135310135311135312135313135314135315135316135317135318135319135320135321135322135323135324135325135326135327135328135329135330135331135332135333135334135335135336135337135338135339135340135341135342135343135344135345135346135347135348135349135350135351135352135353135354135355135356135357135358135359135360135361135362135363135364135365135366135367135368135369135370135371135372135373135374135375135376135377135378135379135380135381135382135383135384135385135386135387135388135389135390135391135392135393135394135395135396135397135398135399135400135401135402135403135404135405135406135407135408135409135410135411135412135413135414135415135416135417135418135419135420135421135422135423135424135425135426135427135428135429135430135431135432135433135434135435135436135437135438135439135440135441135442135443135444135445135446135447135448135449135450135451135452135453135454135455135456135457135458135459135460135461135462135463135464135465135466135467135468135469135470135471135472135473135474135475135476135477135478135479135480135481135482135483135484135485135486135487135488135489135490135491135492135493135494135495135496135497135498135499135500135501135502135503135504135505135506135507135508135509135510135511135512135513135514135515135516135517135518135519135520135521135522135523135524135525135526135527135528135529135530135531135532135533135534135535135536135537135538135539135540135541135542135543135544135545135546135547135548135549135550135551135552135553135554135555135556135557135558135559135560135561135562135563135564135565135566135567135568135569135570135571135572135573135574135575135576135577135578135579135580135581135582135583135584135585135586135587135588135589135590135591135592135593135594135595135596135597135598135599135600135601135602135603135604135605135606135607135608135609135610135611135612135613135614135615135616135617135618135619135620135621135622135623135624135625135626135627135628135629135630135631135632135633135634135635135636135637135638135639135640135641135642135643135644135645135646135647135648135649135650135651135652135653135654135655135656135657135658135659135660135661135662135663135664135665135666135667135668135669135670135671135672135673135674135675135676135677135678135679135680135681135682135683135684135685135686135687135688135689135690135691135692135693135694135695135696135697135698135699135700135701135702135703135704135705135706135707135708135709135710135711135712135713135714135715135716135717135718135719135720135721135722135723135724135725135726135727135728135729135730135731135732135733135734135735135736135737135738135739135740135741135742135743135744135745135746135747135748135749135750135751135752135753135754135755135756135757135758135759135760135761135762135763135764135765135766135767135768135769135770135771135772135773135774135775135776135777135778135779135780135781135782135783135784135785135786135787135788135789135790135791135792135793135794135795135796135797135798135799135800135801135802135803135804135805135806135807135808135809135810135811135812135813135814135815135816135817135818135819135820135821135822135823135824135825135826135827135828135829135830135831135832135833135834135835135836135837135838135839135840135841135842135843135844135845135846135847135848135849135850135851135852135853135854135855135856135857135858135859135860135861135862135863135864135865135866135867135868135869135870135871135872135873135874135875135876135877135878135879135880135881135882135883135884135885135886135887135888135889135890135891135892135893135894135895135896135897135898135899135900135901135902135903135904135905135906135907135908135909135910135911135912135913135914135915135916135917135918135919135920135921135922135923135924135925135926135927135928135929135930135931135932135933135934135935135936135937135938135939135940135941135942135943135944135945135946135947135948135949135950135951135952135953135954135955135956135957135958135959135960135961135962135963135964135965135966135967135968135969135970135971135972135973135974135975135976135977135978135979135980135981135982135983135984135985135986135987135988135989135990135991135992135993135994135995135996135997135998135999136000136001136002136003136004136005136006136007136008136009136010136011136012136013136014136015136016136017136018136019136020136021136022136023136024136025136026136027136028136029136030136031136032136033136034136035136036136037136038136039136040136041136042136043136044136045136046136047136048136049136050136051136052136053136054136055136056136057136058136059136060136061136062136063136064136065136066136067136068136069136070136071136072136073136074136075136076136077136078136079136080136081136082136083136084136085136086136087136088136089136090136091136092136093136094136095136096136097136098136099136100136101136102136103136104136105136106136107136108136109136110136111136112136113136114136115136116136117136118136119136120136121136122136123136124136125136126136127136128136129136130136131136132136133136134136135136136136137136138136139136140136141136142136143136144136145136146136147136148136149136150136151136152136153136154136155136156136157136158136159136160136161136162136163136164136165136166136167136168136169136170136171136172136173136174136175136176136177136178136179136180136181136182136183136184136185136186136187136188136189136190136191136192136193136194136195136196136197136198136199136200136201136202136203136204136205136206136207136208136209136210136211136212136213136214136215136216136217136218136219136220136221136222136223136224136225136226136227136228136229136230136231136232136233136234136235136236136237136238136239136240136241136242136243136244136245136246136247136248136249136250136251136252136253136254136255136256136257136258136259136260136261136262136263136264136265136266136267136268136269136270136271136272136273136274136275136276136277136278136279136280136281136282136283136284136285136286136287136288136289136290136291136292136293136294136295136296136297136298136299136300136301136302136303136304136305136306136307136308136309136310136311136312136313136314136315136316136317136318136319136320136321136322136323136324136325136326136327136328136329136330136331136332136333136334136335136336136337136338136339136340136341136342136343136344136345136346136347136348136349136350136351136352136353136354136355136356136357136358136359136360136361136362136363136364136365136366136367136368136369136370136371136372136373136374136375136376136377136378136379136380136381136382136383136384136385136386136387136388136389136390136391136392136393136394136395136396136397136398136399136400136401136402136403136404136405136406136407136408136409136410136411136412136413136414136415136416136417136418136419136420136421136422136423136424136425136426136427136428136429136430136431136432136433136434136435136436136437136438136439136440136441136442136443136444136445136446136447136448136449136450136451136452136453136454136455136456136457136458136459136460136461136462136463136464136465136466136467136468136469136470136471136472136473136474136475136476136477136478136479136480136481136482136483136484136485136486136487136488136489136490136491136492136493136494136495136496136497136498136499136500136501136502136503136504136505136506136507136508136509136510136511136512136513136514136515136516136517136518136519136520136521136522136523136524136525136526136527136528136529136530136531136532136533136534136535136536136537136538136539136540136541136542136543136544136545136546136547136548136549136550136551136552136553136554136555136556136557136558136559136560136561136562136563136564136565136566136567136568136569136570136571136572136573136574136575136576136577136578136579136580136581136582136583136584136585136586136587136588136589136590136591136592136593136594136595136596136597136598136599136600136601136602136603136604136605136606136607136608136609136610136611136612136613136614136615136616136617136618136619136620136621136622136623136624136625136626136627136628136629136630136631136632136633136634136635136636136637136638136639136640136641136642136643136644136645136646136647136648136649136650136651136652136653136654136655136656136657136658136659136660136661136662136663136664136665136666136667136668136669136670136671136672136673136674136675136676136677136678136679136680136681136682136683136684136685136686136687136688136689136690136691136692136693136694136695136696136697136698136699136700136701136702136703136704136705136706136707136708136709136710136711136712136713136714136715136716136717136718136719136720136721136722136723136724136725136726136727136728136729136730136731136732136733136734136735136736136737136738136739136740136741136742136743136744136745136746136747136748136749136750136751136752136753136754136755136756136757136758136759136760136761136762136763136764136765136766136767136768136769136770136771136772136773136774136775136776136777136778136779136780136781136782136783136784136785136786136787136788136789136790136791136792136793136794136795136796136797136798136799136800136801136802136803136804136805136806136807136808136809136810136811136812136813136814136815136816136817136818136819136820136821136822136823136824136825136826136827136828136829136830136831136832136833136834136835136836136837136838136839136840136841136842136843136844136845136846136847136848136849136850136851136852136853136854136855136856136857136858136859136860136861136862136863136864136865136866136867136868136869136870136871136872136873136874136875136876136877136878136879136880136881136882136883136884136885136886136887136888136889136890136891136892136893136894136895136896136897136898136899136900136901136902136903136904136905136906136907136908136909136910136911136912136913136914136915136916136917136918136919136920136921136922136923136924136925136926136927136928136929136930136931136932136933136934136935136936136937136938136939136940136941136942136943136944136945136946136947136948136949136950136951136952136953136954136955136956136957136958136959136960136961136962136963136964136965136966136967136968136969136970136971136972136973136974136975136976136977136978136979136980136981136982136983136984136985136986136987136988136989136990136991136992136993136994136995136996136997136998136999137000137001137002137003137004137005137006137007137008137009137010137011137012137013137014137015137016137017137018137019137020137021137022137023137024137025137026137027137028137029137030137031137032137033137034137035137036137037137038137039137040137041137042137043137044137045137046137047137048137049137050137051137052137053137054137055137056137057137058137059137060137061137062137063137064137065137066137067137068137069137070137071137072137073137074137075137076137077137078137079137080137081137082137083137084137085137086137087137088137089137090137091137092137093137094137095137096137097137098137099137100137101137102137103137104137105137106137107137108137109137110137111137112137113137114137115137116137117137118137119137120137121137122137123137124137125137126137127137128137129137130137131137132137133137134137135137136137137137138137139137140137141137142137143137144137145137146137147137148137149137150137151137152137153137154137155137156137157137158137159137160137161137162137163137164137165137166137167137168137169137170137171137172137173137174137175137176137177137178137179137180137181137182137183137184137185137186137187137188137189137190137191137192137193137194137195137196137197137198137199137200137201137202137203137204137205137206137207137208137209137210137211137212137213137214137215137216137217137218137219137220137221137222137223137224137225137226137227137228137229137230137231137232137233137234137235137236137237137238137239137240137241137242137243137244137245137246137247137248137249137250137251137252137253137254137255137256137257137258137259137260137261137262137263137264137265137266137267137268137269137270137271137272137273137274137275137276137277137278137279137280137281137282137283137284137285137286137287137288137289137290137291137292137293137294137295137296137297137298137299137300137301137302137303137304137305137306137307137308137309137310137311137312137313137314137315137316137317137318137319137320137321137322137323137324137325137326137327137328137329137330137331137332137333137334137335137336137337137338137339137340137341137342137343137344137345137346137347137348137349137350137351137352137353137354137355137356137357137358137359137360137361137362137363137364137365137366137367137368137369137370137371137372137373137374137375137376137377137378137379137380137381137382137383137384137385137386137387137388137389137390137391137392137393137394137395137396137397137398137399137400137401137402137403137404137405137406137407137408137409137410137411137412137413137414137415137416137417137418137419137420137421137422137423137424137425137426137427137428137429137430137431137432137433137434137435137436137437137438137439137440137441137442137443137444137445137446137447137448137449137450137451137452137453137454137455137456137457137458137459137460137461137462137463137464137465137466137467137468137469137470137471137472137473137474137475137476137477137478137479137480137481137482137483137484137485137486137487137488137489137490137491137492137493137494137495137496137497137498137499137500137501137502137503137504137505137506137507137508137509137510137511137512137513137514137515137516137517137518137519137520137521137522137523137524137525137526137527137528137529137530137531137532137533137534137535137536137537137538137539137540137541137542137543137544137545137546137547137548137549137550137551137552137553137554137555137556137557137558137559137560137561137562137563137564137565137566137567137568137569137570137571137572137573137574137575137576137577137578137579137580137581137582137583137584137585137586137587137588137589137590137591137592137593137594137595137596137597137598137599137600137601137602137603137604137605137606137607137608137609137610137611137612137613137614137615137616137617137618137619137620137621137622137623137624137625137626137627137628137629137630137631137632137633137634137635137636137637137638137639137640137641137642137643137644137645137646137647137648137649137650137651137652137653137654137655137656137657137658137659137660137661137662137663137664137665137666137667137668137669137670137671137672137673137674137675137676137677137678137679137680137681137682137683137684137685137686137687137688137689137690137691137692137693137694137695137696137697137698137699137700137701137702137703137704137705137706137707137708137709137710137711137712137713137714137715137716137717137718137719137720137721137722137723137724137725137726137727137728137729137730137731137732137733137734137735137736137737137738137739137740137741137742137743137744137745137746137747137748137749137750137751137752137753137754137755137756137757137758137759137760137761137762137763137764137765137766137767137768137769137770137771137772137773137774137775137776137777137778137779137780137781137782137783137784137785137786137787137788137789137790137791137792137793137794137795137796137797137798137799137800137801137802137803137804137805137806137807137808137809137810137811137812137813137814137815137816137817137818137819137820137821137822137823137824137825137826137827137828137829137830137831137832137833137834137835137836137837137838137839137840137841137842137843137844137845137846137847137848137849137850137851137852137853137854137855137856137857137858137859137860137861137862137863137864137865137866137867137868137869137870137871137872137873137874137875137876137877137878137879137880137881137882137883137884137885137886137887137888137889137890137891137892137893137894137895137896137897137898137899137900137901137902137903137904137905137906137907137908137909137910137911137912137913137914137915137916137917137918137919137920137921137922137923137924137925137926137927137928137929137930137931137932137933137934137935137936137937137938137939137940137941137942137943137944137945137946137947137948137949137950137951137952137953137954137955137956137957137958137959137960137961137962137963137964137965137966137967137968137969137970137971137972137973137974137975137976137977137978137979137980137981137982137983137984137985137986137987137988137989137990137991137992137993137994137995137996137997137998137999138000138001138002138003138004138005138006138007138008138009138010138011138012138013138014138015138016138017138018138019138020138021138022138023138024138025138026138027138028138029138030138031138032138033138034138035138036138037138038138039138040138041138042138043138044138045138046138047138048138049138050138051138052138053138054138055138056138057138058138059138060138061138062138063138064138065138066138067138068138069138070138071138072138073138074138075138076138077138078138079138080138081138082138083138084138085138086138087138088138089138090138091138092138093138094138095138096138097138098138099138100138101138102138103138104138105138106138107138108138109138110138111138112138113138114138115138116138117138118138119138120138121138122138123138124138125138126138127138128138129138130138131138132138133138134138135138136138137138138138139138140138141138142138143138144138145138146138147138148138149138150138151138152138153138154138155138156138157138158138159138160138161138162138163138164138165138166138167138168138169138170138171138172138173138174138175138176138177138178138179138180138181138182138183138184138185138186138187138188138189138190138191138192138193138194138195138196138197138198138199138200138201138202138203138204138205138206138207138208138209138210138211138212138213138214138215138216138217138218138219138220138221138222138223138224138225138226138227138228138229138230138231138232138233138234138235138236138237138238138239138240138241138242138243138244138245138246138247138248138249138250138251138252138253138254138255138256138257138258138259138260138261138262138263138264138265138266138267138268138269138270138271138272138273138274138275138276138277138278138279138280138281138282138283138284138285138286138287138288138289138290138291138292138293138294138295138296138297138298138299138300138301138302138303138304138305138306138307138308138309138310138311138312138313138314138315138316138317138318138319138320138321138322138323138324138325138326138327138328138329138330138331138332138333138334138335138336138337138338138339138340138341138342138343138344138345138346138347138348138349138350138351138352138353138354138355138356138357138358138359138360138361138362138363138364138365138366138367138368138369138370138371138372138373138374138375138376138377138378138379138380138381138382138383138384138385138386138387138388138389138390138391138392138393138394138395138396138397138398138399138400138401138402138403138404138405138406138407138408138409138410138411138412138413138414138415138416138417138418138419138420138421138422138423138424138425138426138427138428138429138430138431138432138433138434138435138436138437138438138439138440138441138442138443138444138445138446138447138448138449138450138451138452138453138454138455138456138457138458138459138460138461138462138463138464138465138466138467138468138469138470138471138472138473138474138475138476138477138478138479138480138481138482138483138484138485138486138487138488138489138490138491138492138493138494138495138496138497138498138499138500138501138502138503138504138505138506138507138508138509138510138511138512138513138514138515138516138517138518138519138520138521138522138523138524138525138526138527138528138529138530138531138532138533138534138535138536138537138538138539138540138541138542138543138544138545138546138547138548138549138550138551138552138553138554138555138556138557138558138559138560138561138562138563138564138565138566138567138568138569138570138571138572138573138574138575138576138577138578138579138580138581138582138583138584138585138586138587138588138589138590138591138592138593138594138595138596138597138598138599138600138601138602138603138604138605138606138607138608138609138610138611138612138613138614138615138616138617138618138619138620138621138622138623138624138625138626138627138628138629138630138631138632138633138634138635138636138637138638138639138640138641138642138643138644138645138646138647138648138649138650138651138652138653138654138655138656138657138658138659138660138661138662138663138664138665138666138667138668138669138670138671138672138673138674138675138676138677138678138679138680138681138682138683138684138685138686138687138688138689138690138691138692138693138694138695138696138697138698138699138700138701138702138703138704138705138706138707138708138709138710138711138712138713138714138715138716138717138718138719138720138721138722138723138724138725138726138727138728138729138730138731138732138733138734138735138736138737138738138739138740138741138742138743138744138745138746138747138748138749138750138751138752138753138754138755138756138757138758138759138760138761138762138763138764138765138766138767138768138769138770138771138772138773138774138775138776138777138778138779138780138781138782138783138784138785138786138787138788138789138790138791138792138793138794138795138796138797138798138799138800138801138802138803138804138805138806138807138808138809138810138811138812138813138814138815138816138817138818138819138820138821138822138823138824138825138826138827138828138829138830138831138832138833138834138835138836138837138838138839138840138841138842138843138844138845138846138847138848138849138850138851138852138853138854138855138856138857138858138859138860138861138862138863138864138865138866138867138868138869138870138871138872138873138874138875138876138877138878138879138880138881138882138883138884138885138886138887138888138889138890138891138892138893138894138895138896138897138898138899138900138901138902138903138904138905138906138907138908138909138910138911138912138913138914138915138916138917138918138919138920138921138922138923138924138925138926138927138928138929138930138931138932138933138934138935138936138937138938138939138940138941138942138943138944138945138946138947138948138949138950138951138952138953138954138955138956138957138958138959138960138961138962138963138964138965138966138967138968138969138970138971138972138973138974138975138976138977138978138979138980138981138982138983138984138985138986138987138988138989138990138991138992138993138994138995138996138997138998138999139000139001139002139003139004139005139006139007139008139009139010139011139012139013139014139015139016139017139018139019139020139021139022139023139024139025139026139027139028139029139030139031139032139033139034139035139036139037139038139039139040139041139042139043139044139045139046139047139048139049139050139051139052139053139054139055139056139057139058139059139060139061139062139063139064139065139066139067139068139069139070139071139072139073139074139075139076139077139078139079139080139081139082139083139084139085139086139087139088139089139090139091139092139093139094139095139096139097139098139099139100139101139102139103139104139105139106139107139108139109139110139111139112139113139114139115139116139117139118139119139120139121139122139123139124139125139126139127139128139129139130139131139132139133139134139135139136139137139138139139139140139141139142139143139144139145139146139147139148139149139150139151139152139153139154139155139156139157139158139159139160139161139162139163139164139165139166139167139168139169139170139171139172139173139174139175139176139177139178139179139180139181139182139183139184139185139186139187139188139189139190139191139192139193139194139195139196139197139198139199139200139201139202139203139204139205139206139207139208139209139210139211139212139213139214139215139216139217139218139219139220139221139222139223139224139225139226139227139228139229139230139231139232139233139234139235139236139237139238139239139240139241139242139243139244139245139246139247139248139249139250139251139252139253139254139255139256139257139258139259139260139261139262139263139264139265139266139267139268139269139270139271139272139273139274139275139276139277139278139279139280139281139282139283139284139285139286139287139288139289139290139291139292139293139294139295139296139297139298139299139300139301139302139303139304139305139306139307139308139309139310139311139312139313139314139315139316139317139318139319139320139321139322139323139324139325139326139327139328139329139330139331139332139333139334139335139336139337139338139339139340139341139342139343139344139345139346139347139348139349139350139351139352139353139354139355139356139357139358139359139360139361139362139363139364139365139366139367139368139369139370139371139372139373139374139375139376139377139378139379139380139381139382139383139384139385139386139387139388139389139390139391139392139393139394139395139396139397139398139399139400139401139402139403139404139405139406139407139408139409139410139411139412139413139414139415139416139417139418139419139420139421139422139423139424139425139426139427139428139429139430139431139432139433139434139435139436139437139438139439139440139441139442139443139444139445139446139447139448139449139450139451139452139453139454139455139456139457139458139459139460139461139462139463139464139465139466139467139468139469139470139471139472139473139474139475139476139477139478139479139480139481139482139483139484139485139486139487139488139489139490139491139492139493139494139495139496139497139498139499139500139501139502139503139504139505139506139507139508139509139510139511139512139513139514139515139516139517139518139519139520139521139522139523139524139525139526139527139528139529139530139531139532139533139534139535139536139537139538139539139540139541139542139543139544139545139546139547139548139549139550139551139552139553139554139555139556139557139558139559139560139561139562139563139564139565139566139567139568139569139570139571139572139573139574139575139576139577139578139579139580139581139582139583139584139585139586139587139588139589139590139591139592139593139594139595139596139597139598139599139600139601139602139603139604139605139606139607139608139609139610139611139612139613139614139615139616139617139618139619139620139621139622139623139624139625139626139627139628139629139630139631139632139633139634139635139636139637139638139639139640139641139642139643139644139645139646139647139648139649139650139651139652139653139654139655139656139657139658139659139660139661139662139663139664139665139666139667139668139669139670139671139672139673139674139675139676139677139678139679139680139681139682139683139684139685139686139687139688139689139690139691139692139693139694139695139696139697139698139699139700139701139702139703139704139705139706139707139708139709139710139711139712139713139714139715139716139717139718139719139720139721139722139723139724139725139726139727139728139729139730139731139732139733139734139735139736139737139738139739139740139741139742139743139744139745139746139747139748139749139750139751139752139753139754139755139756139757139758139759139760139761139762139763139764139765139766139767139768139769139770139771139772139773139774139775139776139777139778139779139780139781139782139783139784139785139786139787139788139789139790139791139792139793139794139795139796139797139798139799139800139801139802139803139804139805139806139807139808139809139810139811139812139813139814139815139816139817139818139819139820139821139822139823139824139825139826139827139828139829139830139831139832139833139834139835139836139837139838139839139840139841139842139843139844139845139846139847139848139849139850139851139852139853139854139855139856139857139858139859139860139861139862139863139864139865139866139867139868139869139870139871139872139873139874139875139876139877139878139879139880139881139882139883139884139885139886139887139888139889139890139891139892139893139894139895139896139897139898139899139900139901139902139903139904139905139906139907139908139909139910139911139912139913139914139915139916139917139918139919139920139921139922139923139924139925139926139927139928139929139930139931139932139933139934139935139936139937139938139939139940139941139942139943139944139945139946139947139948139949139950139951139952139953139954139955139956139957139958139959139960139961139962139963139964139965139966139967139968139969139970139971139972139973139974139975139976139977139978139979139980139981139982139983139984139985139986139987139988139989139990139991139992139993139994139995139996139997139998139999140000140001140002140003140004140005140006140007140008140009140010140011140012140013140014140015140016140017140018140019140020140021140022140023140024140025140026140027140028140029140030140031140032140033140034140035140036140037140038140039140040140041140042140043140044140045140046140047140048140049140050140051140052140053140054140055140056140057140058140059140060140061140062140063140064140065140066140067140068140069140070140071140072140073140074140075140076140077140078140079140080140081140082140083140084140085140086140087140088140089140090140091140092140093140094140095140096140097140098140099140100140101140102140103140104140105140106140107140108140109140110140111140112140113140114140115140116140117140118140119140120140121140122140123140124140125140126140127140128140129140130140131140132140133140134140135140136140137140138140139140140140141140142140143140144140145140146140147140148140149140150140151140152140153140154140155140156140157140158140159140160140161140162140163140164140165140166140167140168140169140170140171140172140173140174140175140176140177140178140179140180140181140182140183140184140185140186140187140188140189140190140191140192140193140194140195140196140197140198140199140200140201140202140203140204140205140206140207140208140209140210140211140212140213140214140215140216140217140218140219140220140221140222140223140224140225140226140227140228140229140230140231140232140233140234140235140236140237140238140239140240140241140242140243140244140245140246140247140248140249140250140251140252140253140254140255140256140257140258140259140260140261140262140263140264140265140266140267140268140269140270140271140272140273140274140275140276140277140278140279140280140281140282140283140284140285140286140287140288140289140290140291140292140293140294140295140296140297140298140299140300140301140302140303140304140305140306140307140308140309140310140311140312140313140314140315140316140317140318140319140320140321140322140323140324140325140326140327140328140329140330140331140332140333140334140335140336140337140338140339140340140341140342140343140344140345140346140347140348140349140350140351140352140353140354140355140356140357140358140359140360140361140362140363140364140365140366140367140368140369140370140371140372140373140374140375140376140377140378140379140380140381140382140383140384140385140386140387140388140389140390140391140392140393140394140395140396140397140398140399140400140401140402140403140404140405140406140407140408140409140410140411140412140413140414140415140416140417140418140419140420140421140422140423140424140425140426140427140428140429140430140431140432140433140434140435140436140437140438140439140440140441140442140443140444140445140446140447140448140449140450140451140452140453140454140455140456140457140458140459140460140461140462140463140464140465140466140467140468140469140470140471140472140473140474140475140476140477140478140479140480140481140482140483140484140485140486140487140488140489140490140491140492140493140494140495140496140497140498140499140500140501140502140503140504140505140506140507140508140509140510140511140512140513140514140515140516140517140518140519140520140521140522140523140524140525140526140527140528140529140530140531140532140533140534140535140536140537140538140539140540140541140542140543140544140545140546140547140548140549140550140551140552140553140554140555140556140557140558140559140560140561140562140563140564140565140566140567140568140569140570140571140572140573140574140575140576140577140578140579140580140581140582140583140584140585140586140587140588140589140590140591140592140593140594140595140596140597140598140599140600140601140602140603140604140605140606140607140608140609140610140611140612140613140614140615140616140617140618140619140620140621140622140623140624140625140626140627140628140629140630140631140632140633140634140635140636140637140638140639140640140641140642140643140644140645140646140647140648140649140650140651140652140653140654140655140656140657140658140659140660140661140662140663140664140665140666140667140668140669140670140671140672140673140674140675140676140677140678140679140680140681140682140683140684140685140686140687140688140689140690140691140692140693140694140695140696140697140698140699140700140701140702140703140704140705140706140707140708140709140710140711140712140713140714140715140716140717140718140719140720140721140722140723140724140725140726140727140728140729140730140731140732140733140734140735140736140737140738140739140740140741140742140743140744140745140746140747140748140749140750140751140752140753140754140755140756140757140758140759140760140761140762140763140764140765140766140767140768140769140770140771140772140773140774140775140776140777140778140779140780140781140782140783140784140785140786140787140788140789140790140791140792140793140794140795140796140797140798140799140800140801140802140803140804140805140806140807140808140809140810140811140812140813140814140815140816140817140818140819140820140821140822140823140824140825140826140827140828140829140830140831140832140833140834140835140836140837140838140839140840140841140842140843140844140845140846140847140848140849140850140851140852140853140854140855140856140857140858140859140860140861140862140863140864140865140866140867140868140869140870140871140872140873140874140875140876140877140878140879140880140881140882140883140884140885140886140887140888140889140890140891140892140893140894140895140896140897140898140899140900140901140902140903140904140905140906140907140908140909140910140911140912140913140914140915140916140917140918140919140920140921140922140923140924140925140926140927140928140929140930140931140932140933140934140935140936140937140938140939140940140941140942140943140944140945140946140947140948140949140950140951140952140953140954140955140956140957140958140959140960140961140962140963140964140965140966140967140968140969140970140971140972140973140974140975140976140977140978140979140980140981140982140983140984140985140986140987140988140989140990140991140992140993140994140995140996140997140998140999141000141001141002141003141004141005141006141007141008141009141010141011141012141013141014141015141016141017141018141019141020141021141022141023141024141025141026141027141028141029141030141031141032141033141034141035141036141037141038141039141040141041141042141043141044141045141046141047141048141049141050141051141052141053141054141055141056141057141058141059141060141061141062141063141064141065141066141067141068141069141070141071141072141073141074141075141076141077141078141079141080141081141082141083141084141085141086141087141088141089141090141091141092141093141094141095141096141097141098141099141100141101141102141103141104141105141106141107141108141109141110141111141112141113141114141115141116141117141118141119141120141121141122141123141124141125141126141127141128141129141130141131141132141133141134141135141136141137141138141139141140141141141142141143141144141145141146141147141148141149141150141151141152141153141154141155141156141157141158141159141160141161141162141163141164141165141166141167141168141169141170141171141172141173141174141175141176141177141178141179141180141181141182141183141184141185141186141187141188141189141190141191141192141193141194141195141196141197141198141199141200141201141202141203141204141205141206141207141208141209141210141211141212141213141214141215141216141217141218141219141220141221141222141223141224141225141226141227141228141229141230141231141232141233141234141235141236141237141238141239141240141241141242141243141244141245141246141247141248141249141250141251141252141253141254141255141256141257141258141259141260141261141262141263141264141265141266141267141268141269141270141271141272141273141274141275141276141277141278141279141280141281141282141283141284141285141286141287141288141289141290141291141292141293141294141295141296141297141298141299141300141301141302141303141304141305141306141307141308141309141310141311141312141313141314141315141316141317141318141319141320141321141322141323141324141325141326141327141328141329141330141331141332141333141334141335141336141337141338141339141340141341141342141343141344141345141346141347141348141349141350141351141352141353141354141355141356141357141358141359141360141361141362141363141364141365141366141367141368141369141370141371141372141373141374141375141376141377141378141379141380141381141382141383141384141385141386141387141388141389141390141391141392141393141394141395141396141397141398141399141400141401141402141403141404141405141406141407141408141409141410141411141412141413141414141415141416141417141418141419141420141421141422141423141424141425141426141427141428141429141430141431141432141433141434141435141436141437141438141439141440141441141442141443141444141445141446141447141448141449141450141451141452141453141454141455141456141457141458141459141460141461141462141463141464141465141466141467141468141469141470141471141472141473141474141475141476141477141478141479141480141481141482141483141484141485141486141487141488141489141490141491141492141493141494141495141496141497141498141499141500141501141502141503141504141505141506141507141508141509141510141511141512141513141514141515141516141517141518141519141520141521141522141523141524141525141526141527141528141529141530141531141532141533141534141535141536141537141538141539141540141541141542141543141544141545141546141547141548141549141550141551141552141553141554141555141556141557141558141559141560141561141562141563141564141565141566141567141568141569141570141571141572141573141574141575141576141577141578141579141580141581141582141583141584141585141586141587141588141589141590141591141592141593141594141595141596141597141598141599141600141601141602141603141604141605141606141607141608141609141610141611141612141613141614141615141616141617141618141619141620141621141622141623141624141625141626141627141628141629141630141631141632141633141634141635141636141637141638141639141640141641141642141643141644141645141646141647141648141649141650141651141652141653141654141655141656141657141658141659141660141661141662141663141664141665141666141667141668141669141670141671141672141673141674141675141676141677141678141679141680141681141682141683141684141685141686141687141688141689141690141691141692141693141694141695141696141697141698141699141700141701141702141703141704141705141706141707141708141709141710141711141712141713141714141715141716141717141718141719141720141721141722141723141724141725141726141727141728141729141730141731141732141733141734141735141736141737141738141739141740141741141742141743141744141745141746141747141748141749141750141751141752141753141754141755141756141757141758141759141760141761141762141763141764141765141766141767141768141769141770141771141772141773141774141775141776141777141778141779141780141781141782141783141784141785141786141787141788141789141790141791141792141793141794141795141796141797141798141799141800141801141802141803141804141805141806141807141808141809141810141811141812141813141814141815141816141817141818141819141820141821141822141823141824141825141826141827141828141829141830141831141832141833141834141835141836141837141838141839141840141841141842141843141844141845141846141847141848141849141850141851141852141853141854141855141856141857141858141859141860141861141862141863141864141865141866141867141868141869141870141871141872141873141874141875141876141877141878141879141880141881141882141883141884141885141886141887141888141889141890141891141892141893141894141895141896141897141898141899141900141901141902141903141904141905141906141907141908141909141910141911141912141913141914141915141916141917141918141919141920141921141922141923141924141925141926141927141928141929141930141931141932141933141934141935141936141937141938141939141940141941141942141943141944141945141946141947141948141949141950141951141952141953141954141955141956141957141958141959141960141961141962141963141964141965141966141967141968141969141970141971141972141973141974141975141976141977141978141979141980141981141982141983141984141985141986141987141988141989141990141991141992141993141994141995141996141997141998141999142000142001142002142003142004142005142006142007142008142009142010142011142012142013142014142015142016142017142018142019142020142021142022142023142024142025142026142027142028142029142030142031142032142033142034142035142036142037142038142039142040142041142042142043142044142045142046142047142048142049142050142051142052142053142054142055142056142057142058142059142060142061142062142063142064142065142066142067142068142069142070142071142072142073142074142075142076142077142078142079142080142081142082142083142084142085142086142087142088142089142090142091142092142093142094142095142096142097142098142099142100142101142102142103142104142105142106142107142108142109142110142111142112142113142114142115142116142117142118142119142120142121142122142123142124142125142126142127142128142129142130142131142132142133142134142135142136142137142138142139142140142141142142142143142144142145142146142147142148142149142150142151142152142153142154142155142156142157142158142159142160142161142162142163142164142165142166142167142168142169142170142171142172142173142174142175142176142177142178142179142180142181142182142183142184142185142186142187142188142189142190142191142192142193142194142195142196142197142198142199142200142201142202142203142204142205142206142207142208142209142210142211142212142213142214142215142216142217142218142219142220142221142222142223142224142225142226142227142228142229142230142231142232142233142234142235142236142237142238142239142240142241142242142243142244142245142246142247142248142249142250142251142252142253142254142255142256142257142258142259142260142261142262142263142264142265142266142267142268142269142270142271142272142273142274142275142276142277142278142279142280142281142282142283142284142285142286142287142288142289142290142291142292142293142294142295142296142297142298142299142300142301142302142303142304142305142306142307142308142309142310142311142312142313142314142315142316142317142318142319142320142321142322142323142324142325142326142327142328142329142330142331142332142333142334142335142336142337142338142339142340142341142342142343142344142345142346142347142348142349142350142351142352142353142354142355142356142357142358142359142360142361142362142363142364142365142366142367142368142369142370142371142372142373142374142375142376142377142378142379142380142381142382142383142384142385142386142387142388142389142390142391142392142393142394142395142396142397142398142399142400142401142402142403142404142405142406142407142408142409142410142411142412142413142414142415142416142417142418142419142420142421142422142423142424142425142426142427142428142429142430142431142432142433142434142435142436142437142438142439142440142441142442142443142444142445142446142447142448142449142450142451142452142453142454142455142456142457142458142459142460142461142462142463142464142465142466142467142468142469142470142471142472142473142474142475142476142477142478142479142480142481142482142483142484142485142486142487142488142489142490142491142492142493142494142495142496142497142498142499142500142501142502142503142504142505142506142507142508142509142510142511142512142513142514142515142516142517142518142519142520142521142522142523142524142525142526142527142528142529142530142531142532142533142534142535142536142537142538142539142540142541142542142543142544142545142546142547142548142549142550142551142552142553142554142555142556142557142558142559142560142561142562142563142564142565142566142567142568142569142570142571142572142573142574142575142576142577142578142579142580142581142582142583142584142585142586142587142588142589142590142591142592142593142594142595142596142597142598142599142600142601142602142603142604142605142606142607142608142609142610142611142612142613142614142615142616142617142618142619142620142621142622142623142624142625142626142627142628142629142630142631142632142633142634142635142636142637142638142639142640142641142642142643142644142645142646142647142648142649142650142651142652142653142654142655142656142657142658142659142660142661142662142663142664142665142666142667142668142669142670142671142672142673142674142675142676142677142678142679142680142681142682142683142684142685142686142687142688142689142690142691142692142693142694142695142696142697142698142699142700142701142702142703142704142705142706142707142708142709142710142711142712142713142714142715142716142717142718142719142720142721142722142723142724142725142726142727142728142729142730142731142732142733142734142735142736142737142738142739142740142741142742142743142744142745142746142747142748142749142750142751142752142753142754142755142756142757142758142759142760142761142762142763142764142765142766142767142768142769142770142771142772142773142774142775142776142777142778142779142780142781142782142783142784142785142786142787142788142789142790142791142792142793142794142795142796142797142798142799142800142801142802142803142804142805142806142807142808142809142810142811142812142813142814142815142816142817142818142819142820142821142822142823142824142825142826142827142828142829142830142831142832142833142834142835142836142837142838142839142840142841142842142843142844142845142846142847142848142849142850142851142852142853142854142855142856142857142858142859142860142861142862142863142864142865142866142867142868142869142870142871142872142873142874142875142876142877142878142879142880142881142882142883142884142885142886142887142888142889142890142891142892142893142894142895142896142897142898142899142900142901142902142903142904142905142906142907142908142909142910142911142912142913142914142915142916142917142918142919142920142921142922142923142924142925142926142927142928142929142930142931142932142933142934142935142936142937142938142939142940142941142942142943142944142945142946142947142948142949142950142951142952142953142954142955142956142957142958142959142960142961142962142963142964142965142966142967142968142969142970142971142972142973142974142975142976142977142978142979142980142981142982142983142984142985142986142987142988142989142990142991142992142993142994142995142996142997142998142999143000143001143002143003143004143005143006143007143008143009143010143011143012143013143014143015143016143017143018143019143020143021143022143023143024143025143026143027143028143029143030143031143032143033143034143035143036143037143038143039143040143041143042143043143044143045143046143047143048143049143050143051143052143053143054143055143056143057143058143059143060143061143062143063143064143065143066143067143068143069143070143071143072143073143074143075143076143077143078143079143080143081143082143083143084143085143086143087143088143089143090143091143092143093143094143095143096143097143098143099143100143101143102143103143104143105143106143107143108143109143110143111143112143113143114143115143116143117143118143119143120143121143122143123143124143125143126143127143128143129143130143131143132143133143134143135143136143137143138143139143140143141143142143143143144143145143146143147143148143149143150143151143152143153143154143155143156143157143158143159143160143161143162143163143164143165143166143167143168143169143170143171143172143173143174143175143176143177143178143179143180143181143182143183143184143185143186143187143188143189143190143191143192143193143194143195143196143197143198143199143200143201143202143203143204143205143206143207143208143209143210143211143212143213143214143215143216143217143218143219143220143221143222143223143224143225143226143227143228143229143230143231143232143233143234143235143236143237143238143239143240143241143242143243143244143245143246143247143248143249143250143251143252143253143254143255143256143257143258143259143260143261143262143263143264143265143266143267143268143269143270143271143272143273143274143275143276143277143278143279143280143281143282143283143284143285143286143287143288143289143290143291143292143293143294143295143296143297143298143299143300143301143302143303143304143305143306143307143308143309143310143311143312143313143314143315143316143317143318143319143320143321143322143323143324143325143326143327143328143329143330143331143332143333143334143335143336143337143338143339143340143341143342143343143344143345143346143347143348143349143350143351143352143353143354143355143356143357143358143359143360143361143362143363143364143365143366143367143368143369143370143371143372143373143374143375143376143377143378143379143380143381143382143383143384143385143386143387143388143389143390143391143392143393143394143395143396143397143398143399143400143401143402143403143404143405143406143407143408143409143410143411143412143413143414143415143416143417143418143419143420143421143422143423143424143425143426143427143428143429143430143431143432143433143434143435143436143437143438143439143440143441143442143443143444143445143446143447143448143449143450143451143452143453143454143455143456143457143458143459143460143461143462143463143464143465143466143467143468143469143470143471143472143473143474143475143476143477143478143479143480143481143482143483143484143485143486143487143488143489143490143491143492143493143494143495143496143497143498143499143500143501143502143503143504143505143506143507143508143509143510143511143512143513143514143515143516143517143518143519143520143521143522143523143524143525143526143527143528143529143530143531143532143533143534143535143536143537143538143539143540143541143542143543143544143545143546143547143548143549143550143551143552143553143554143555143556143557143558143559143560143561143562143563143564143565143566143567143568143569143570143571143572143573143574143575143576143577143578143579143580143581143582143583143584143585143586143587143588143589143590143591143592143593143594143595143596143597143598143599143600143601143602143603143604143605143606143607143608143609143610143611143612143613143614143615143616143617143618143619143620143621143622143623143624143625143626143627143628143629143630143631143632143633143634143635143636143637143638143639143640143641143642143643143644143645143646143647143648143649143650143651143652143653143654143655143656143657143658143659143660143661143662143663143664143665143666143667143668143669143670143671143672143673143674143675143676143677143678143679143680143681143682143683143684143685143686143687143688143689143690143691143692143693143694143695143696143697143698143699143700143701143702143703143704143705143706143707143708143709143710143711143712143713143714143715143716143717143718143719143720143721143722143723143724143725143726143727143728143729143730143731143732143733143734143735143736143737143738143739143740143741143742143743143744143745143746143747143748143749143750143751143752143753143754143755143756143757143758143759143760143761143762143763143764143765143766143767143768143769143770143771143772143773143774143775143776143777143778143779143780143781143782143783143784143785143786143787143788143789143790143791143792143793143794143795143796143797143798143799143800143801143802143803143804143805143806143807143808143809143810143811143812143813143814143815143816143817143818143819143820143821143822143823143824143825143826143827143828143829143830143831143832143833143834143835143836143837143838143839143840143841143842143843143844143845143846143847143848143849143850143851143852143853143854143855143856143857143858143859143860143861143862143863143864143865143866143867143868143869143870143871143872143873143874143875143876143877143878143879143880143881143882143883143884143885143886143887143888143889143890143891143892143893143894143895143896143897143898143899143900143901143902143903143904143905143906143907143908143909143910143911143912143913143914143915143916143917143918143919143920143921143922143923143924143925143926143927143928143929143930143931143932143933143934143935143936143937143938143939143940143941143942143943143944143945143946143947143948143949143950143951143952143953143954143955143956143957143958143959143960143961143962143963143964143965143966143967143968143969143970143971143972143973143974143975143976143977143978143979143980143981143982143983143984143985143986143987143988143989143990143991143992143993143994143995143996143997143998143999144000144001144002144003144004144005144006144007144008144009144010144011144012144013144014144015144016144017144018144019144020144021144022144023144024144025144026144027144028144029144030144031144032144033144034144035144036144037144038144039144040144041144042144043144044144045144046144047144048144049144050144051144052144053144054144055144056144057144058144059144060144061144062144063144064144065144066144067144068144069144070144071144072144073144074144075144076144077144078144079144080144081144082144083144084144085144086144087144088144089144090144091144092144093144094144095144096144097144098144099144100144101144102144103144104144105144106144107144108144109144110144111144112144113144114144115144116144117144118144119144120144121144122144123144124144125144126144127144128144129144130144131144132144133144134144135144136144137144138144139144140144141144142144143144144144145144146144147144148144149144150144151144152144153144154144155144156144157144158144159144160144161144162144163144164144165144166144167144168144169144170144171144172144173144174144175144176144177144178144179144180144181144182144183144184144185144186144187144188144189144190144191144192144193144194144195144196144197144198144199144200144201144202144203144204144205144206144207144208144209144210144211144212144213144214144215144216144217144218144219144220144221144222144223144224144225144226144227144228144229144230144231144232144233144234144235144236144237144238144239144240144241144242144243144244144245144246144247144248144249144250144251144252144253144254144255144256144257144258144259144260144261144262144263144264144265144266144267144268144269144270144271144272144273144274144275144276144277144278144279144280144281144282144283144284144285144286144287144288144289144290144291144292144293144294144295144296144297144298144299144300144301144302144303144304144305144306144307144308144309144310144311144312144313144314144315144316144317144318144319144320144321144322144323144324144325144326144327144328144329144330144331144332144333144334144335144336144337144338144339144340144341144342144343144344144345144346144347144348144349144350144351144352144353144354144355144356144357144358144359144360144361144362144363144364144365144366144367144368144369144370144371144372144373144374144375144376144377144378144379144380144381144382144383144384144385144386144387144388144389144390144391144392144393144394144395144396144397144398144399144400144401144402144403144404144405144406144407144408144409144410144411144412144413144414144415144416144417144418144419144420144421144422144423144424144425144426144427144428144429144430144431144432144433144434144435144436144437144438144439144440144441144442144443144444144445144446144447144448144449144450144451144452144453144454144455144456144457144458144459144460144461144462144463144464144465144466144467144468144469144470144471144472144473144474144475144476144477144478144479144480144481144482144483144484144485144486144487144488144489144490144491144492144493144494144495144496144497144498144499144500144501144502144503144504144505144506144507144508144509144510144511144512144513144514144515144516144517144518144519144520144521144522144523144524144525144526144527144528144529144530144531144532144533144534144535144536144537144538144539144540144541144542144543144544144545144546144547144548144549144550144551144552144553144554144555144556144557144558144559144560144561144562144563144564144565144566144567144568144569144570144571144572144573144574144575144576144577144578144579144580144581144582144583144584144585144586144587144588144589144590144591144592144593144594144595144596144597144598144599144600144601144602144603144604144605144606144607144608144609144610144611144612144613144614144615144616144617144618144619144620144621144622144623144624144625144626144627144628144629144630144631144632144633144634144635144636144637144638144639144640144641144642144643144644144645144646144647144648144649144650144651144652144653144654144655144656144657144658144659144660144661144662144663144664144665144666144667144668144669144670144671144672144673144674144675144676144677144678144679144680144681144682144683144684144685144686144687144688144689144690144691144692144693144694144695144696144697144698144699144700144701144702144703144704144705144706144707144708144709144710144711144712144713144714144715144716144717144718144719144720144721144722144723144724144725144726144727144728144729144730144731144732144733144734144735144736144737144738144739144740144741144742144743144744144745144746144747144748144749144750144751144752144753144754144755144756144757144758144759144760144761144762144763144764144765144766144767144768144769144770144771144772144773144774144775144776144777144778144779144780144781144782144783144784144785144786144787144788144789144790144791144792144793144794144795144796144797144798144799144800144801144802144803144804144805144806144807144808144809144810144811144812144813144814144815144816144817144818144819144820144821144822144823144824144825144826144827144828144829144830144831144832144833144834144835144836144837144838144839144840144841144842144843144844144845144846144847144848144849144850144851144852144853144854144855144856144857144858144859144860144861144862144863144864144865144866144867144868144869144870144871144872144873144874144875144876144877144878144879144880144881144882144883144884144885144886144887144888144889144890144891144892144893144894144895144896144897144898144899144900144901144902144903144904144905144906144907144908144909144910144911144912144913144914144915144916144917144918144919144920144921144922144923144924144925144926144927144928144929144930144931144932144933144934144935144936144937144938144939144940144941144942144943144944144945144946144947144948144949144950144951144952144953144954144955144956144957144958144959144960144961144962144963144964144965144966144967144968144969144970144971144972144973144974144975144976144977144978144979144980144981144982144983144984144985144986144987144988144989144990144991144992144993144994144995144996144997144998144999145000145001145002145003145004145005145006145007145008145009145010145011145012145013145014145015145016145017145018145019145020145021145022145023145024145025145026145027145028145029145030145031145032145033145034145035145036145037145038145039145040145041145042145043145044145045145046145047145048145049145050145051145052145053145054145055145056145057145058145059145060145061145062145063145064145065145066145067145068145069145070145071145072145073145074145075145076145077145078145079145080145081145082145083145084145085145086145087145088145089145090145091145092145093145094145095145096145097145098145099145100145101145102145103145104145105145106145107145108145109145110145111145112145113145114145115145116145117145118145119145120145121145122145123145124145125145126145127145128145129145130145131145132145133145134145135145136145137145138145139145140145141145142145143145144145145145146145147145148145149145150145151145152145153145154145155145156145157145158145159145160145161145162145163145164145165145166145167145168145169145170145171145172145173145174145175145176145177145178145179145180145181145182145183145184145185145186145187145188145189145190145191145192145193145194145195145196145197145198145199145200145201145202145203145204145205145206145207145208145209145210145211145212145213145214145215145216145217145218145219145220145221145222145223145224145225145226145227145228145229145230145231145232145233145234145235145236145237145238145239145240145241145242145243145244145245145246145247145248145249145250145251145252145253145254145255145256145257145258145259145260145261145262145263145264145265145266145267145268145269145270145271145272145273145274145275145276145277145278145279145280145281145282145283145284145285145286145287145288145289145290145291145292145293145294145295145296145297145298145299145300145301145302145303145304145305145306145307145308145309145310145311145312145313145314145315145316145317145318145319145320145321145322145323145324145325145326145327145328145329145330145331145332145333145334145335145336145337145338145339145340145341145342145343145344145345145346145347145348145349145350145351145352145353145354145355145356145357145358145359145360145361145362145363145364145365145366145367145368145369145370145371145372145373145374145375145376145377145378145379145380145381145382145383145384145385145386145387145388145389145390145391145392145393145394145395145396145397145398145399145400145401145402145403145404145405145406145407145408145409145410145411145412145413145414145415145416145417145418145419145420145421145422145423145424145425145426145427145428145429145430145431145432145433145434145435145436145437145438145439145440145441145442145443145444145445145446145447145448145449145450145451145452145453145454145455145456145457145458145459145460145461145462145463145464145465145466145467145468145469145470145471145472145473145474145475145476145477145478145479145480145481145482145483145484145485145486145487145488145489145490145491145492145493145494145495145496145497145498145499145500145501145502145503145504145505145506145507145508145509145510145511145512145513145514145515145516145517145518145519145520145521145522145523145524145525145526145527145528145529145530145531145532145533145534145535145536145537145538145539145540145541145542145543145544145545145546145547145548145549145550145551145552145553145554145555145556145557145558145559145560145561145562145563145564145565145566145567145568145569145570145571145572145573145574145575145576145577145578145579145580145581145582145583145584145585145586145587145588145589145590145591145592145593145594145595145596145597145598145599145600145601145602145603145604145605145606145607145608145609145610145611145612145613145614145615145616145617145618145619145620145621145622145623145624145625145626145627145628145629145630145631145632145633145634145635145636145637145638145639145640145641145642145643145644145645145646145647145648145649145650145651145652145653145654145655145656145657145658145659145660145661145662145663145664145665145666145667145668145669145670145671145672145673145674145675145676145677145678145679145680145681145682145683145684145685145686145687145688145689145690145691145692145693145694145695145696145697145698145699145700145701145702145703145704145705145706145707145708145709145710145711145712145713145714145715145716145717145718145719145720145721145722145723145724145725145726145727145728145729145730145731145732145733145734145735145736145737145738145739145740145741145742145743145744145745145746145747145748145749145750145751145752145753145754145755145756145757145758145759145760145761145762145763145764145765145766145767145768145769145770145771145772145773145774145775145776145777145778145779145780145781145782145783145784145785145786145787145788145789145790145791145792145793145794145795145796145797145798145799145800145801145802145803145804145805145806145807145808145809145810145811145812145813145814145815145816145817145818145819145820145821145822145823145824145825145826145827145828145829145830145831145832145833145834145835145836145837145838145839145840145841145842145843145844145845145846145847145848145849145850145851145852145853145854145855145856145857145858145859145860145861145862145863145864145865145866145867145868145869145870145871145872145873145874145875145876145877145878145879145880145881145882145883145884145885145886145887145888145889145890145891145892145893145894145895145896145897145898145899145900145901145902145903145904145905145906145907145908145909145910145911145912145913145914145915145916145917145918145919145920145921145922145923145924145925145926145927145928145929145930145931145932145933145934145935145936145937145938145939145940145941145942145943145944145945145946145947145948145949145950145951145952145953145954145955145956145957145958145959145960145961145962145963145964145965145966145967145968145969145970145971145972145973145974145975145976145977145978145979145980145981145982145983145984145985145986145987145988145989145990145991145992145993145994145995145996145997145998145999146000146001146002146003146004146005146006146007146008146009146010146011146012146013146014146015146016146017146018146019146020146021146022146023146024146025146026146027146028146029146030146031146032146033146034146035146036146037146038146039146040146041146042146043146044146045146046146047146048146049146050146051146052146053146054146055146056146057146058146059146060146061146062146063146064146065146066146067146068146069146070146071146072146073146074146075146076146077146078146079146080146081146082146083146084146085146086146087146088146089146090146091146092146093146094146095146096146097146098146099146100146101146102146103146104146105146106146107146108146109146110146111146112146113146114146115146116146117146118146119146120146121146122146123146124146125146126146127146128146129146130146131146132146133146134146135146136146137146138146139146140146141146142146143146144146145146146146147146148146149146150146151146152146153146154146155146156146157146158146159146160146161146162146163146164146165146166146167146168146169146170146171146172146173146174146175146176146177146178146179146180146181146182146183146184146185146186146187146188146189146190146191146192146193146194146195146196146197146198146199146200146201146202146203146204146205146206146207146208146209146210146211146212146213146214146215146216146217146218146219146220146221146222146223146224146225146226146227146228146229146230146231146232146233146234146235146236146237146238146239146240146241146242146243146244146245146246146247146248146249146250146251146252146253146254146255146256146257146258146259146260146261146262146263146264146265146266146267146268146269146270146271146272146273146274146275146276146277146278146279146280146281146282146283146284146285146286146287146288146289146290146291146292146293146294146295146296146297146298146299146300146301146302146303146304146305146306146307146308146309146310146311146312146313146314146315146316146317146318146319146320146321146322146323146324146325146326146327146328146329146330146331146332146333146334146335146336146337146338146339146340146341146342146343146344146345146346146347146348146349146350146351146352146353146354146355146356146357146358146359146360146361146362146363146364146365146366146367146368146369146370146371146372146373146374146375146376146377146378146379146380146381146382146383146384146385146386146387146388146389146390146391146392146393146394146395146396146397146398146399146400146401146402146403146404146405146406146407146408146409146410146411146412146413146414146415146416146417146418146419146420146421146422146423146424146425146426146427146428146429146430146431146432146433146434146435146436146437146438146439146440146441146442146443146444146445146446146447146448146449146450146451146452146453146454146455146456146457146458146459146460146461146462146463146464146465146466146467146468146469146470146471146472146473146474146475146476146477146478146479146480146481146482146483146484146485146486146487146488146489146490146491146492146493146494146495146496146497146498146499146500146501146502146503146504146505146506146507146508146509146510146511146512146513146514146515146516146517146518146519146520146521146522146523146524146525146526146527146528146529146530146531146532146533146534146535146536146537146538146539146540146541146542146543146544146545146546146547146548146549146550146551146552146553146554146555146556146557146558146559146560146561146562146563146564146565146566146567146568146569146570146571146572146573146574146575146576146577146578146579146580146581146582146583146584146585146586146587146588146589146590146591146592146593146594146595146596146597146598146599146600146601146602146603146604146605146606146607146608146609146610146611146612146613146614146615146616146617146618146619146620146621146622146623146624146625146626146627146628146629146630146631146632146633146634146635146636146637146638146639146640146641146642146643146644146645146646146647146648146649146650146651146652146653146654146655146656146657146658146659146660146661146662146663146664146665146666146667146668146669146670146671146672146673146674146675146676146677146678146679146680146681146682146683146684146685146686146687146688146689146690146691146692146693146694146695146696146697146698146699146700146701146702146703146704146705146706146707146708146709146710146711146712146713146714146715146716146717146718146719146720146721146722146723146724146725146726146727146728146729146730146731146732146733146734146735146736146737146738146739146740146741146742146743146744146745146746146747146748146749146750146751146752146753146754146755146756146757146758146759146760146761146762146763146764146765146766146767146768146769146770146771146772146773146774146775146776146777146778146779146780146781146782146783146784146785146786146787146788146789146790146791146792146793146794146795146796146797146798146799146800146801146802146803146804146805146806146807146808146809146810146811146812146813146814146815146816146817146818146819146820146821146822146823146824146825146826146827146828146829146830146831146832146833146834146835146836146837146838146839146840146841146842146843146844146845146846146847146848146849146850146851146852146853146854146855146856146857146858146859146860146861146862146863146864146865146866146867146868146869146870146871146872146873146874146875146876146877146878146879146880146881146882146883146884146885146886146887146888146889146890146891146892146893146894146895146896146897146898146899146900146901146902146903146904146905146906146907146908146909146910146911146912146913146914146915146916146917146918146919146920146921146922146923146924146925146926146927146928146929146930146931146932146933146934146935146936146937146938146939146940146941146942146943146944146945146946146947146948146949146950146951146952146953146954146955146956146957146958146959146960146961146962146963146964146965146966146967146968146969146970146971146972146973146974146975146976146977146978146979146980146981146982146983146984146985146986146987146988146989146990146991146992146993146994146995146996146997146998146999147000147001147002147003147004147005147006147007147008147009147010147011147012147013147014147015147016147017147018147019147020147021147022147023147024147025147026147027147028147029147030147031147032147033147034147035147036147037147038147039147040147041147042147043147044147045147046147047147048147049147050147051147052147053147054147055147056147057147058147059147060147061147062147063147064147065147066147067147068147069147070147071147072147073147074147075147076147077147078147079147080147081147082147083147084147085147086147087147088147089147090147091147092147093147094147095147096147097147098147099147100147101147102147103147104147105147106147107147108147109147110147111147112147113147114147115147116147117147118147119147120147121147122147123147124147125147126147127147128147129147130147131147132147133147134147135147136147137147138147139147140147141147142147143147144147145147146147147147148147149147150147151147152147153147154147155147156147157147158147159147160147161147162147163147164147165147166147167147168147169147170147171147172147173147174147175147176147177147178147179147180147181147182147183147184147185147186147187147188147189147190147191147192147193147194147195147196147197147198147199147200147201147202147203147204147205147206147207147208147209147210147211147212147213147214147215147216147217147218147219147220147221147222147223147224147225147226147227147228147229147230147231147232147233147234147235147236147237147238147239147240147241147242147243147244147245147246147247147248147249147250147251147252147253147254147255147256147257147258147259147260147261147262147263147264147265147266147267147268147269147270147271147272147273147274147275147276147277147278147279147280147281147282147283147284147285147286147287147288147289147290147291147292147293147294147295147296147297147298147299147300147301147302147303147304147305147306147307147308147309147310147311147312147313147314147315147316147317147318147319147320147321147322147323147324147325147326147327147328147329147330147331147332147333147334147335147336147337147338147339147340147341147342147343147344147345147346147347147348147349147350147351147352147353147354147355147356147357147358147359147360147361147362147363147364147365147366147367147368147369147370147371147372147373147374147375147376147377147378147379147380147381147382147383147384147385147386147387147388147389147390147391147392147393147394147395147396147397147398147399147400147401147402147403147404147405147406147407147408147409147410147411147412147413147414147415147416147417147418147419147420147421147422147423147424147425147426147427147428147429147430147431147432147433147434147435147436147437147438147439147440147441147442147443147444147445147446147447147448147449147450147451147452147453147454147455147456147457147458147459147460147461147462147463147464147465147466147467147468147469147470147471147472147473147474147475147476147477147478147479147480147481147482147483147484147485147486147487147488147489147490147491147492147493147494147495147496147497147498147499147500147501147502147503147504147505147506147507147508147509147510147511147512147513147514147515147516147517147518147519147520147521147522147523147524147525147526147527147528147529147530147531147532147533147534147535147536147537147538147539147540147541147542147543147544147545147546147547147548147549147550147551147552147553147554147555147556147557147558147559147560147561147562147563147564147565147566147567147568147569147570147571147572147573147574147575147576147577147578147579147580147581147582147583147584147585147586147587147588147589147590147591147592147593147594147595147596147597147598147599147600147601147602147603147604147605147606147607147608147609147610147611147612147613147614147615147616147617147618147619147620147621147622147623147624147625147626147627147628147629147630147631147632147633147634147635147636147637147638147639147640147641147642147643147644147645147646147647147648147649147650147651147652147653147654147655147656147657147658147659147660147661147662147663147664147665147666147667147668147669147670147671147672147673147674147675147676147677147678147679147680147681147682147683147684147685147686147687147688147689147690147691147692147693147694147695147696147697147698147699147700147701147702147703147704147705147706147707147708147709147710147711147712147713147714147715147716147717147718147719147720147721147722147723147724147725147726147727147728147729147730147731147732147733147734147735147736147737147738147739147740147741147742147743147744147745147746147747147748147749147750147751147752147753147754147755147756147757147758147759147760147761147762147763147764147765147766147767147768147769147770147771147772147773147774147775147776147777147778147779147780147781147782147783147784147785147786147787147788147789147790147791147792147793147794147795147796147797147798147799147800147801147802147803147804147805147806147807147808147809147810147811147812147813147814147815147816147817147818147819147820147821147822147823147824147825147826147827147828147829147830147831147832147833147834147835147836147837147838147839147840147841147842147843147844147845147846147847147848147849147850147851147852147853147854147855147856147857147858147859147860147861147862147863147864147865147866147867147868147869147870147871147872147873147874147875147876147877147878147879147880147881147882147883147884147885147886147887147888147889147890147891147892147893147894147895147896147897147898147899147900147901147902147903147904147905147906147907147908147909147910147911147912147913147914147915147916147917147918147919147920147921147922147923147924147925147926147927147928147929147930147931147932147933147934147935147936147937147938147939147940147941147942147943147944147945147946147947147948147949147950147951147952147953147954147955147956147957147958147959147960147961147962147963147964147965147966147967147968147969147970147971147972147973147974147975147976147977147978147979147980147981147982147983147984147985147986147987147988147989147990147991147992147993147994147995147996147997147998147999148000148001148002148003148004148005148006148007148008148009148010148011148012148013148014148015148016148017148018148019148020148021148022148023148024148025148026148027148028148029148030148031148032148033148034148035148036148037148038148039148040148041148042148043148044148045148046148047148048148049148050148051148052148053148054148055148056148057148058148059148060148061148062148063148064148065148066148067148068148069148070148071148072148073148074148075148076148077148078148079148080148081148082148083148084148085148086148087148088148089148090148091148092148093148094148095148096148097148098148099148100148101148102148103148104148105148106148107148108148109148110148111148112148113148114148115148116148117148118148119148120148121148122148123148124148125148126148127148128148129148130148131148132148133148134148135148136148137148138148139148140148141148142148143148144148145148146148147148148148149148150148151148152148153148154148155148156148157148158148159148160148161148162148163148164148165148166148167148168148169148170148171148172148173148174148175148176148177148178148179148180148181148182148183148184148185148186148187148188148189148190148191148192148193148194148195148196148197148198148199148200148201148202148203148204148205148206148207148208148209148210148211148212148213148214148215148216148217148218148219148220148221148222148223148224148225148226148227148228148229148230148231148232148233148234148235148236148237148238148239148240148241148242148243148244148245148246148247148248148249148250148251148252148253148254148255148256148257148258148259148260148261148262148263148264148265148266148267148268148269148270148271148272148273148274148275148276148277148278148279148280148281148282148283148284148285148286148287148288148289148290148291148292148293148294148295148296148297148298148299148300148301148302148303148304148305148306148307148308148309148310148311148312148313148314148315148316148317148318148319148320148321148322148323148324148325148326148327148328148329148330148331148332148333148334148335148336148337148338148339148340148341148342148343148344148345148346148347148348148349148350148351148352148353148354148355148356148357148358148359148360148361148362148363148364148365148366148367148368148369148370148371148372148373148374148375148376148377148378148379148380148381148382148383148384148385148386148387148388148389148390148391148392148393148394148395148396148397148398148399148400148401148402148403148404148405148406148407148408148409148410148411148412148413148414148415148416148417148418148419148420148421148422148423148424148425148426148427148428148429148430148431148432148433148434148435148436148437148438148439148440148441148442148443148444148445148446148447148448148449148450148451148452148453148454148455148456148457148458148459148460148461148462148463148464148465148466148467148468148469148470148471148472148473148474148475148476148477148478148479148480148481148482148483148484148485148486148487148488148489148490148491148492148493148494148495148496148497148498148499148500148501148502148503148504148505148506148507148508148509148510148511148512148513148514148515148516148517148518148519148520148521148522148523148524148525148526148527148528148529148530148531148532148533148534148535148536148537148538148539148540148541148542148543148544148545148546148547148548148549148550148551148552148553148554148555148556148557148558148559148560148561148562148563148564148565148566148567148568148569148570148571148572148573148574148575148576148577148578148579148580148581148582148583148584148585148586148587148588148589148590148591148592148593148594148595148596148597148598148599148600148601148602148603148604148605148606148607148608148609148610148611148612148613148614148615148616148617148618148619148620148621148622148623148624148625148626148627148628148629148630148631148632148633148634148635148636148637148638148639148640148641148642148643148644148645148646148647148648148649148650148651148652148653148654148655148656148657148658148659148660148661148662148663148664148665148666148667148668148669148670148671148672148673148674148675148676148677148678148679148680148681148682148683148684148685148686148687148688148689148690148691148692148693148694148695148696148697148698148699148700148701148702148703148704148705148706148707148708148709148710148711148712148713148714148715148716148717148718148719148720148721148722148723148724148725148726148727148728148729148730148731148732148733148734148735148736148737148738148739148740148741148742148743148744148745148746148747148748148749148750148751148752148753148754148755148756148757148758148759148760148761148762148763148764148765148766148767148768148769148770148771148772148773148774148775148776148777148778148779148780148781148782148783148784148785148786148787148788148789148790148791148792148793148794148795148796148797148798148799148800148801148802148803148804148805148806148807148808148809148810148811148812148813148814148815148816148817148818148819148820148821148822148823148824148825148826148827148828148829148830148831148832148833148834148835148836148837148838148839148840148841148842148843148844148845148846148847148848148849148850148851148852148853148854148855148856148857148858148859148860148861148862148863148864148865148866148867148868148869148870148871148872148873148874148875148876148877148878148879148880148881148882148883148884148885148886148887148888148889148890148891148892148893148894148895148896148897148898148899148900148901148902148903148904148905148906148907148908148909148910148911148912148913148914148915148916148917148918148919148920148921148922148923148924148925148926148927148928148929148930148931148932148933148934148935148936148937148938148939148940148941148942148943148944148945148946148947148948148949148950148951148952148953148954148955148956148957148958148959148960148961148962148963148964148965148966148967148968148969148970148971148972148973148974148975148976148977148978148979148980148981148982148983148984148985148986148987148988148989148990148991148992148993148994148995148996148997148998148999149000149001149002149003149004149005149006149007149008149009149010149011149012149013149014149015149016149017149018149019149020149021149022149023149024149025149026149027149028149029149030149031149032149033149034149035149036149037149038149039149040149041149042149043149044149045149046149047149048149049149050149051149052149053149054149055149056149057149058149059149060149061149062149063149064149065149066149067149068149069149070149071149072149073149074149075149076149077149078149079149080149081149082149083149084149085149086149087149088149089149090149091149092149093149094149095149096149097149098149099149100149101149102149103149104149105149106149107149108149109149110149111149112149113149114149115149116149117149118149119149120149121149122149123149124149125149126149127149128149129149130149131149132149133149134149135149136149137149138149139149140149141149142149143149144149145149146149147149148149149149150149151149152149153149154149155149156149157149158149159149160149161149162149163149164149165149166149167149168149169149170149171149172149173149174149175149176149177149178149179149180149181149182149183149184149185149186149187149188149189149190149191149192149193149194149195149196149197149198149199149200149201149202149203149204149205149206149207149208149209149210149211149212149213149214149215149216149217149218149219149220149221149222149223149224149225149226149227149228149229149230149231149232149233149234149235149236149237149238149239149240149241149242149243149244149245149246149247149248149249149250149251149252149253149254149255149256149257149258149259149260149261149262149263149264149265149266149267149268149269149270149271149272149273149274149275149276149277149278149279149280149281149282149283149284149285149286149287149288149289149290149291149292149293149294149295149296149297149298149299149300149301149302149303149304149305149306149307149308149309149310149311149312149313149314149315149316149317149318149319149320149321149322149323149324149325149326149327149328149329149330149331149332149333149334149335149336149337149338149339149340149341149342149343149344149345149346149347149348149349149350149351149352149353149354149355149356149357149358149359149360149361149362149363149364149365149366149367149368149369149370149371149372149373149374149375149376149377149378149379149380149381149382149383149384149385149386149387149388149389149390149391149392149393149394149395149396149397149398149399149400149401149402149403149404149405149406149407149408149409149410149411149412149413149414149415149416149417149418149419149420149421149422149423149424149425149426149427149428149429149430149431149432149433149434149435149436149437149438149439149440149441149442149443149444149445149446149447149448149449149450149451149452149453149454149455149456149457149458149459149460149461149462149463149464149465149466149467149468149469149470149471149472149473149474149475149476149477149478149479149480149481149482149483149484149485149486149487149488149489149490149491149492149493149494149495149496149497149498149499149500149501149502149503149504149505149506149507149508149509149510149511149512149513149514149515149516149517149518149519149520149521149522149523149524149525149526149527149528149529149530149531149532149533149534149535149536149537149538149539149540149541149542149543149544149545149546149547149548149549149550149551149552149553149554149555149556149557149558149559149560149561149562149563149564149565149566149567149568149569149570149571149572149573149574149575149576149577149578149579149580149581149582149583149584149585149586149587149588149589149590149591149592149593149594149595149596149597149598149599149600149601149602149603149604149605149606149607149608149609149610149611149612149613149614149615149616149617149618149619149620149621149622149623149624149625149626149627149628149629149630149631149632149633149634149635149636149637149638149639149640149641149642149643149644149645149646149647149648149649149650149651149652149653149654149655149656149657149658149659149660149661149662149663149664149665149666149667149668149669149670149671149672149673149674149675149676149677149678149679149680149681149682149683149684149685149686149687149688149689149690149691149692149693149694149695149696149697149698149699149700149701149702149703149704149705149706149707149708149709149710149711149712149713149714149715149716149717149718149719149720149721149722149723149724149725149726149727149728149729149730149731149732149733149734149735149736149737149738149739149740149741149742149743149744149745149746149747149748149749149750149751149752149753149754149755149756149757149758149759149760149761149762149763149764149765149766149767149768149769149770149771149772149773149774149775149776149777149778149779149780149781149782149783149784149785149786149787149788149789149790149791149792149793149794149795149796149797149798149799149800149801149802149803149804149805149806149807149808149809149810149811149812149813149814149815149816149817149818149819149820149821149822149823149824149825149826149827149828149829149830149831149832149833149834149835149836149837149838149839149840149841149842149843149844149845149846149847149848149849149850149851149852149853149854149855149856149857149858149859149860149861149862149863149864149865149866149867149868149869149870149871149872149873149874149875149876149877149878149879149880149881149882149883149884149885149886149887149888149889149890149891149892149893149894149895149896149897149898149899149900149901149902149903149904149905149906149907149908149909149910149911149912149913149914149915149916149917149918149919149920149921149922149923149924149925149926149927149928149929149930149931149932149933149934149935149936149937149938149939149940149941149942149943149944149945149946149947149948149949149950149951149952149953149954149955149956149957149958149959149960149961149962149963149964149965149966149967149968149969149970149971149972149973149974149975149976149977149978149979149980149981149982149983149984149985149986149987149988149989149990149991149992149993149994149995149996149997149998149999150000150001150002150003150004150005150006150007150008150009150010150011150012150013150014150015150016150017150018150019150020150021150022150023150024150025150026150027150028150029150030150031150032150033150034150035150036150037150038150039150040150041150042150043150044150045150046150047150048150049150050150051150052150053150054150055150056150057150058150059150060150061150062150063150064150065150066150067150068150069150070150071150072150073150074150075150076150077150078150079150080150081150082150083150084150085150086150087150088150089150090150091150092150093150094150095150096150097150098150099150100150101150102150103150104150105150106150107150108150109150110150111150112150113150114150115150116150117150118150119150120150121150122150123150124150125150126150127150128150129150130150131150132150133150134150135150136150137150138150139150140150141150142150143150144150145150146150147150148150149150150150151150152150153150154150155150156150157150158150159150160150161150162150163150164150165150166150167150168150169150170150171150172150173150174150175150176150177150178150179150180150181150182150183150184150185150186150187150188150189150190150191150192150193150194150195150196150197150198150199150200150201150202150203150204150205150206150207150208150209150210150211150212150213150214150215150216150217150218150219150220150221150222150223150224150225150226150227150228150229150230150231150232150233150234150235150236150237150238150239150240150241150242150243150244150245150246150247150248150249150250150251150252150253150254150255150256150257150258150259150260150261150262150263150264150265150266150267150268150269150270150271150272150273150274150275150276150277150278150279150280150281150282150283150284150285150286150287150288150289150290150291150292150293150294150295150296150297150298150299150300150301150302150303150304150305150306150307150308150309150310150311150312150313150314150315150316150317150318150319150320150321150322150323150324150325150326150327150328150329150330150331150332150333150334150335150336150337150338150339150340150341150342150343150344150345150346150347150348150349150350150351150352150353150354150355150356150357150358150359150360150361150362150363150364150365150366150367150368150369150370150371150372150373150374150375150376150377150378150379150380150381150382150383150384150385150386150387150388150389150390150391150392150393150394150395150396150397150398150399150400150401150402150403150404150405150406150407150408150409150410150411150412150413150414150415150416150417150418150419150420150421150422150423150424150425150426150427150428150429150430150431150432150433150434150435150436150437150438150439150440150441150442150443150444150445150446150447150448150449150450150451150452150453150454150455150456150457150458150459150460150461150462150463150464150465150466150467150468150469150470150471150472150473150474150475150476150477150478150479150480150481150482150483150484150485150486150487150488150489150490150491150492150493150494150495150496150497150498150499150500150501150502150503150504150505150506150507150508150509150510150511150512150513150514150515150516150517150518150519150520150521150522150523150524150525150526150527150528150529150530150531150532150533150534150535150536150537150538150539150540150541150542150543150544150545150546150547150548150549150550150551150552150553150554150555150556150557150558150559150560150561150562150563150564150565150566150567150568150569150570150571150572150573150574150575150576150577150578150579150580150581150582150583150584150585150586150587150588150589150590150591150592150593150594150595150596150597150598150599150600150601150602150603150604150605150606150607150608150609150610150611150612150613150614150615150616150617150618150619150620150621150622150623150624150625150626150627150628150629150630150631150632150633150634150635150636150637150638150639150640150641150642150643150644150645150646150647150648150649150650150651150652150653150654150655150656150657150658150659150660150661150662150663150664150665150666150667150668150669150670150671150672150673150674150675150676150677150678150679150680150681150682150683150684150685150686150687150688150689150690150691150692150693150694150695150696150697150698150699150700150701150702150703150704150705150706150707150708150709150710150711150712150713150714150715150716150717150718150719150720150721150722150723150724150725150726150727150728150729150730150731150732150733150734150735150736150737150738150739150740150741150742150743150744150745150746150747150748150749150750150751150752150753150754150755150756150757150758150759150760150761150762150763150764150765150766150767150768150769150770150771150772150773150774150775150776150777150778150779150780150781150782150783150784150785150786150787150788150789150790150791150792150793150794150795150796150797150798150799150800150801150802150803150804150805150806150807150808150809150810150811150812150813150814150815150816150817150818150819150820150821150822150823150824150825150826150827150828150829150830150831150832150833150834150835150836150837150838150839150840150841150842150843150844150845150846150847150848150849150850150851150852150853150854150855150856150857150858150859150860150861150862150863150864150865150866150867150868150869150870150871150872150873150874150875150876150877150878150879150880150881150882150883150884150885150886150887150888150889150890150891150892150893150894150895150896150897150898150899150900150901150902150903150904150905150906150907150908150909150910150911150912150913150914150915150916150917150918150919150920150921150922150923150924150925150926150927150928150929150930150931150932150933150934150935150936150937150938150939150940150941150942150943150944150945150946150947150948150949150950150951150952150953150954150955150956150957150958150959150960150961150962150963150964150965150966150967150968150969150970150971150972150973150974150975150976150977150978150979150980150981150982150983150984150985150986150987150988150989150990150991150992150993150994150995150996150997150998150999151000151001151002151003151004151005151006151007151008151009151010151011151012151013151014151015151016151017151018151019151020151021151022151023151024151025151026151027151028151029151030151031151032151033151034151035151036151037151038151039151040151041151042151043151044151045151046151047151048151049151050151051151052151053151054151055151056151057151058151059151060151061151062151063151064151065151066151067151068151069151070151071151072151073151074151075151076151077151078151079151080151081151082151083151084151085151086151087151088151089151090151091151092151093151094151095151096151097151098151099151100151101151102151103151104151105151106151107151108151109151110151111151112151113151114151115151116151117151118151119151120151121151122151123151124151125151126151127151128151129151130151131151132151133151134151135151136151137151138151139151140151141151142151143151144151145151146151147151148151149151150151151151152151153151154151155151156151157151158151159151160151161151162151163151164151165151166151167151168151169151170151171151172151173151174151175151176151177151178151179151180151181151182151183151184151185151186151187151188151189151190151191151192151193151194151195151196151197151198151199151200151201151202151203151204151205151206151207151208151209151210151211151212151213151214151215151216151217151218151219151220151221151222151223151224151225151226151227151228151229151230151231151232151233151234151235151236151237151238151239151240151241151242151243151244151245151246151247151248151249151250151251151252151253151254151255151256151257151258151259151260151261151262151263151264151265151266151267151268151269151270151271151272151273151274151275151276151277151278151279151280151281151282151283151284151285151286151287151288151289151290151291151292151293151294151295151296151297151298151299151300151301151302151303151304151305151306151307151308151309151310151311151312151313151314151315151316151317151318151319151320151321151322151323151324151325151326151327151328151329151330151331151332151333151334151335151336151337151338151339151340151341151342151343151344151345151346151347151348151349151350151351151352151353151354151355151356151357151358151359151360151361151362151363151364151365151366151367151368151369151370151371151372151373151374151375151376151377151378151379151380151381151382151383151384151385151386151387151388151389151390151391151392151393151394151395151396151397151398151399151400151401151402151403151404151405151406151407151408151409151410151411151412151413151414151415151416151417151418151419151420151421151422151423151424151425151426151427151428151429151430151431151432151433151434151435151436151437151438151439151440151441151442151443151444151445151446151447151448151449151450151451151452151453151454151455151456151457151458151459151460151461151462151463151464151465151466151467151468151469151470151471151472151473151474151475151476151477151478151479151480151481151482151483151484151485151486151487151488151489151490151491151492151493151494151495151496151497151498151499151500151501151502151503151504151505151506151507151508151509151510151511151512151513151514151515151516151517151518151519151520151521151522151523151524151525151526151527151528151529151530151531151532151533151534151535151536151537151538151539151540151541151542151543151544151545151546151547151548151549151550151551151552151553151554151555151556151557151558151559151560151561151562151563151564151565151566151567151568151569151570151571151572151573151574151575151576151577151578151579151580151581151582151583151584151585151586151587151588151589151590151591151592151593151594151595151596151597151598151599151600151601151602151603151604151605151606151607151608151609151610151611151612151613151614151615151616151617151618151619151620151621151622151623151624151625151626151627151628151629151630151631151632151633151634151635151636151637151638151639151640151641151642151643151644151645151646151647151648151649151650151651151652151653151654151655151656151657151658151659151660151661151662151663151664151665151666151667151668151669151670151671151672151673151674151675151676151677151678151679151680151681151682151683151684151685151686151687151688151689151690151691151692151693151694151695151696151697151698151699151700151701151702151703151704151705151706151707151708151709151710151711151712151713151714151715151716151717151718151719151720151721151722151723151724151725151726151727151728151729151730151731151732151733151734151735151736151737151738151739151740151741151742151743151744151745151746151747151748151749151750151751151752151753151754151755151756151757151758151759151760151761151762151763151764151765151766151767151768151769151770151771151772151773151774151775151776151777151778151779151780151781151782151783151784151785151786151787151788151789151790151791151792151793151794151795151796151797151798151799151800151801151802151803151804151805151806151807151808151809151810151811151812151813151814151815151816151817151818151819151820151821151822151823151824151825151826151827151828151829151830151831151832151833151834151835151836151837151838151839151840151841151842151843151844151845151846151847151848151849151850151851151852151853151854151855151856151857151858151859151860151861151862151863151864151865151866151867151868151869151870151871151872151873151874151875151876151877151878151879151880151881151882151883151884151885151886151887151888151889151890151891151892151893151894151895151896151897151898151899151900151901151902151903151904151905151906151907151908151909151910151911151912151913151914151915151916151917151918151919151920151921151922151923151924151925151926151927151928151929151930151931151932151933151934151935151936151937151938151939151940151941151942151943151944151945151946151947151948151949151950151951151952151953151954151955151956151957151958151959151960151961151962151963151964151965151966151967151968151969151970151971151972151973151974151975151976151977151978151979151980151981151982151983151984151985151986151987151988151989151990151991151992151993151994151995151996151997151998151999152000152001152002152003152004152005152006152007152008152009152010152011152012152013152014152015152016152017152018152019152020152021152022152023152024152025152026152027152028152029152030152031152032152033152034152035152036152037152038152039152040152041152042152043152044152045152046152047152048152049152050152051152052152053152054152055152056152057152058152059152060152061152062152063152064152065152066152067152068152069152070152071152072152073152074152075152076152077152078152079152080152081152082152083152084152085152086152087152088152089152090152091152092152093152094152095152096152097152098152099152100152101152102152103152104152105152106152107152108152109152110152111152112152113152114152115152116152117152118152119152120152121152122152123152124152125152126152127152128152129152130152131152132152133152134152135152136152137152138152139152140152141152142152143152144152145152146152147152148152149152150152151152152152153152154152155152156152157152158152159152160152161152162152163152164152165152166152167152168152169152170152171152172152173152174152175152176152177152178152179152180152181152182152183152184152185152186152187152188152189152190152191152192152193152194152195152196152197152198152199152200152201152202152203152204152205152206152207152208152209152210152211152212152213152214152215152216152217152218152219152220152221152222152223152224152225152226152227152228152229152230152231152232152233152234152235152236152237152238152239152240152241152242152243152244152245152246152247152248152249152250152251152252152253152254152255152256152257152258152259152260152261152262152263152264152265152266152267152268152269152270152271152272152273152274152275152276152277152278152279152280152281152282152283152284152285152286152287152288152289152290152291152292152293152294152295152296152297152298152299152300152301152302152303152304152305152306152307152308152309152310152311152312152313152314152315152316152317152318152319152320152321152322152323152324152325152326152327152328152329152330152331152332152333152334152335152336152337152338152339152340152341152342152343152344152345152346152347152348152349152350152351152352152353152354152355152356152357152358152359152360152361152362152363152364152365152366152367152368152369152370152371152372152373152374152375152376152377152378152379152380152381152382152383152384152385152386152387152388152389152390152391152392152393152394152395152396152397152398152399152400152401152402152403152404152405152406152407152408152409152410152411152412152413152414152415152416152417152418152419152420152421152422152423152424152425152426152427152428152429152430152431152432152433152434152435152436152437152438152439152440152441152442152443152444152445152446152447152448152449152450152451152452152453152454152455152456152457152458152459152460152461152462152463152464152465152466152467152468152469152470152471152472152473152474152475152476152477152478152479152480152481152482152483152484152485152486152487152488152489152490152491152492152493152494152495152496152497152498152499152500152501152502152503152504152505152506152507152508152509152510152511152512152513152514152515152516152517152518152519152520152521152522152523152524152525152526152527152528152529152530152531152532152533152534152535152536152537152538152539152540152541152542152543152544152545152546152547152548152549152550152551152552152553152554152555152556152557152558152559152560152561152562152563152564152565152566152567152568152569152570152571152572152573152574152575152576152577152578152579152580152581152582152583152584152585152586152587152588152589152590152591152592152593152594152595152596152597152598152599152600152601152602152603152604152605152606152607152608152609152610152611152612152613152614152615152616152617152618152619152620152621152622152623152624152625152626152627152628152629152630152631152632152633152634152635152636152637152638152639152640152641152642152643152644152645152646152647152648152649152650152651152652152653152654152655152656152657152658152659152660152661152662152663152664152665152666152667152668152669152670152671152672152673152674152675152676152677152678152679152680152681152682152683152684152685152686152687152688152689152690152691152692152693152694152695152696152697152698152699152700152701152702152703152704152705152706152707152708152709152710152711152712152713152714152715152716152717152718152719152720152721152722152723152724152725152726152727152728152729152730152731152732152733152734152735152736152737152738152739152740152741152742152743152744152745152746152747152748152749152750152751152752152753152754152755152756152757152758152759152760152761152762152763152764152765152766152767152768152769152770152771152772152773152774152775152776152777152778152779152780152781152782152783152784152785152786152787152788152789152790152791152792152793152794152795152796152797152798152799152800152801152802152803152804152805152806152807152808152809152810152811152812152813152814152815152816152817152818152819152820152821152822152823152824152825152826152827152828152829152830152831152832152833152834152835152836152837152838152839152840152841152842152843152844152845152846152847152848152849152850152851152852152853152854152855152856152857152858152859152860152861152862152863152864152865152866152867152868152869152870152871152872152873152874152875152876152877152878152879152880152881152882152883152884152885152886152887152888152889152890152891152892152893152894152895152896152897152898152899152900152901152902152903152904152905152906152907152908152909152910152911152912152913152914152915152916152917152918152919152920152921152922152923152924152925152926152927152928152929152930152931152932152933152934152935152936152937152938152939152940152941152942152943152944152945152946152947152948152949152950152951152952152953152954152955152956152957152958152959152960152961152962152963152964152965152966152967152968152969152970152971152972152973152974152975152976152977152978152979152980152981152982152983152984152985152986152987152988152989152990152991152992152993152994152995152996152997152998152999153000153001153002153003153004153005153006153007153008153009153010153011153012153013153014153015153016153017153018153019153020153021153022153023153024153025153026153027153028153029153030153031153032153033153034153035153036153037153038153039153040153041153042153043153044153045153046153047153048153049153050153051153052153053153054153055153056153057153058153059153060153061153062153063153064153065153066153067153068153069153070153071153072153073153074153075153076153077153078153079153080153081153082153083153084153085153086153087153088153089153090153091153092153093153094153095153096153097153098153099153100153101153102153103153104153105153106153107153108153109153110153111153112153113153114153115153116153117153118153119153120153121153122153123153124153125153126153127153128153129153130153131153132153133153134153135153136153137153138153139153140153141153142153143153144153145153146153147153148153149153150153151153152153153153154153155153156153157153158153159153160153161153162153163153164153165153166153167153168153169153170153171153172153173153174153175153176153177153178153179153180153181153182153183153184153185153186153187153188153189153190153191153192153193153194153195153196153197153198153199153200153201153202153203153204153205153206153207153208153209153210153211153212153213153214153215153216153217153218153219153220153221153222153223153224153225153226153227153228153229153230153231153232153233153234153235153236153237153238153239153240153241153242153243153244153245153246153247153248153249153250153251153252153253153254153255153256153257153258153259153260153261153262153263153264153265153266153267153268153269153270153271153272153273153274153275153276153277153278153279153280153281153282153283153284153285153286153287153288153289153290153291153292153293153294153295153296153297153298153299153300153301153302153303153304153305153306153307153308153309153310153311153312153313153314153315153316153317153318153319153320153321153322153323153324153325153326153327153328153329153330153331153332153333153334153335153336153337153338153339153340153341153342153343153344153345153346153347153348153349153350153351153352153353153354153355153356153357153358153359153360153361153362153363153364153365153366153367153368153369153370153371153372153373153374153375153376153377153378153379153380153381153382153383153384153385153386153387153388153389153390153391153392153393153394153395153396153397153398153399153400153401153402153403153404153405153406153407153408153409153410153411153412153413153414153415153416153417153418153419153420153421153422153423153424153425153426153427153428153429153430153431153432153433153434153435153436153437153438153439153440153441153442153443153444153445153446153447153448153449153450153451153452153453153454153455153456153457153458153459153460153461153462153463153464153465153466153467153468153469153470153471153472153473153474153475153476153477153478153479153480153481153482153483153484153485153486153487153488153489153490153491153492153493153494153495153496153497153498153499153500153501153502153503153504153505153506153507153508153509153510153511153512153513153514153515153516153517153518153519153520153521153522153523153524153525153526153527153528153529153530153531153532153533153534153535153536153537153538153539153540153541153542153543153544153545153546153547153548153549153550153551153552153553153554153555153556153557153558153559153560153561153562153563153564153565153566153567153568153569153570153571153572153573153574153575153576153577153578153579153580153581153582153583153584153585153586153587153588153589153590153591153592153593153594153595153596153597153598153599153600153601153602153603153604153605153606153607153608153609153610153611153612153613153614153615153616153617153618153619153620153621153622153623153624153625153626153627153628153629153630153631153632153633153634153635153636153637153638153639153640153641153642153643153644153645153646153647153648153649153650153651153652153653153654153655153656153657153658153659153660153661153662153663153664153665153666153667153668153669153670153671153672153673153674153675153676153677153678153679153680153681153682153683153684153685153686153687153688153689153690153691153692153693153694153695153696153697153698153699153700153701153702153703153704153705153706153707153708153709153710153711153712153713153714153715153716153717153718153719153720153721153722153723153724153725153726153727153728153729153730153731153732153733153734153735153736153737153738153739153740153741153742153743153744153745153746153747153748153749153750153751153752153753153754153755153756153757153758153759153760153761153762153763153764153765153766153767153768153769153770153771153772153773153774153775153776153777153778153779153780153781153782153783153784153785153786153787153788153789153790153791153792153793153794153795153796153797153798153799153800153801153802153803153804153805153806153807153808153809153810153811153812153813153814153815153816153817153818153819153820153821153822153823153824153825153826153827153828153829153830153831153832153833153834153835153836153837153838153839153840153841153842153843153844153845153846153847153848153849153850153851153852153853153854153855153856153857153858153859153860153861153862153863153864153865153866153867153868153869153870153871153872153873153874153875153876153877153878153879153880153881153882153883153884153885153886153887153888153889153890153891153892153893153894153895153896153897153898153899153900153901153902153903153904153905153906153907153908153909153910153911153912153913153914153915153916153917153918153919153920153921153922153923153924153925153926153927153928153929153930153931153932153933153934153935153936153937153938153939153940153941153942153943153944153945153946153947153948153949153950153951153952153953153954153955153956153957153958153959153960153961153962153963153964153965153966153967153968153969153970153971153972153973153974153975153976153977153978153979153980153981153982153983153984153985153986153987153988153989153990153991153992153993153994153995153996153997153998153999154000154001154002154003154004154005154006154007154008154009154010154011154012154013154014154015154016154017154018154019154020154021154022154023154024154025154026154027154028154029154030154031154032154033154034154035154036154037154038154039154040154041154042154043154044154045154046154047154048154049154050154051154052154053154054154055154056154057154058154059154060154061154062154063154064154065154066154067154068154069154070154071154072154073154074154075154076154077154078154079154080154081154082154083154084154085154086154087154088154089154090154091154092154093154094154095154096154097154098154099154100154101154102154103154104154105154106154107154108154109154110154111154112154113154114154115154116154117154118154119154120154121154122154123154124154125154126154127154128154129154130154131154132154133154134154135154136154137154138154139154140154141154142154143154144154145154146154147154148154149154150154151154152154153154154154155154156154157154158154159154160154161154162154163154164154165154166154167154168154169154170154171154172154173154174154175154176154177154178154179154180154181154182154183154184154185154186154187154188154189154190154191154192154193154194154195154196154197154198154199154200154201154202154203154204154205154206154207154208154209154210154211154212154213154214154215154216154217154218154219154220154221154222154223154224154225154226154227154228154229154230154231154232154233154234154235154236154237154238154239154240154241154242154243154244154245154246154247154248154249154250154251154252154253154254154255154256154257154258154259154260154261154262154263154264154265154266154267154268154269154270154271154272154273154274154275154276154277154278154279154280154281154282154283154284154285154286154287154288154289154290154291154292154293154294154295154296154297154298154299154300154301154302154303154304154305154306154307154308154309154310154311154312154313154314154315154316154317154318154319154320154321154322154323154324154325154326154327154328154329154330154331154332154333154334154335154336154337154338154339154340154341154342154343154344154345154346154347154348154349154350154351154352154353154354154355154356154357154358154359154360154361154362154363154364154365154366154367154368154369154370154371154372154373154374154375154376154377154378154379154380154381154382154383154384154385154386154387154388154389154390154391154392154393154394154395154396154397154398154399154400154401154402154403154404154405154406154407154408154409154410154411154412154413154414154415154416154417154418154419154420154421154422154423154424154425154426154427154428154429154430154431154432154433154434154435154436154437154438154439154440154441154442154443154444154445154446154447154448154449154450154451154452154453154454154455154456154457154458154459154460154461154462154463154464154465154466154467154468154469154470154471154472154473154474154475154476154477154478154479154480154481154482154483154484154485154486154487154488154489154490154491154492154493154494154495154496154497154498154499154500154501154502154503154504154505154506154507154508154509154510154511154512154513154514154515154516154517154518154519154520154521154522154523154524154525154526154527154528154529154530154531154532154533154534154535154536154537154538154539154540154541154542154543154544154545154546154547154548154549154550154551154552154553154554154555154556154557154558154559154560154561154562154563154564154565154566154567154568154569154570154571154572154573154574154575154576154577154578154579154580154581154582154583154584154585154586154587154588154589154590154591154592154593154594154595154596154597154598154599154600154601154602154603154604154605154606154607154608154609154610154611154612154613154614154615154616154617154618154619154620154621154622154623154624154625154626154627154628154629154630154631154632154633154634154635154636154637154638154639154640154641154642154643154644154645154646154647154648154649154650154651154652154653154654154655154656154657154658154659154660154661154662154663154664154665154666154667154668154669154670154671154672154673154674154675154676154677154678154679154680154681154682154683154684154685154686154687154688154689154690154691154692154693154694154695154696154697154698154699154700154701154702154703154704154705154706154707154708154709154710154711154712154713154714154715154716154717154718154719154720154721154722154723154724154725154726154727154728154729154730154731154732154733154734154735154736154737154738154739154740154741154742154743154744154745154746154747154748154749154750154751154752154753154754154755154756154757154758154759154760154761154762154763154764154765154766154767154768154769154770154771154772154773154774154775154776154777154778154779154780154781154782154783154784154785154786154787154788154789154790154791154792154793154794154795154796154797154798154799154800154801154802154803154804154805154806154807154808154809154810154811154812154813154814154815154816154817154818154819154820154821154822154823154824154825154826154827154828154829154830154831154832154833154834154835154836154837154838154839154840154841154842154843154844154845154846154847154848154849154850154851154852154853154854154855154856154857154858154859154860154861154862154863154864154865154866154867154868154869154870154871154872154873154874154875154876154877154878154879154880154881154882154883154884154885154886154887154888154889154890154891154892154893154894154895154896154897154898154899154900154901154902154903154904154905154906154907154908154909154910154911154912154913154914154915154916154917154918154919154920154921154922154923154924154925154926154927154928154929154930154931154932154933154934154935154936154937154938154939154940154941154942154943154944154945154946154947154948154949154950154951154952154953154954154955154956154957154958154959154960154961154962154963154964154965154966154967154968154969154970154971154972154973154974154975154976154977154978154979154980154981154982154983154984154985154986154987154988154989154990154991154992154993154994154995154996154997154998154999155000155001155002155003155004155005155006155007155008155009155010155011155012155013155014155015155016155017155018155019155020155021155022155023155024155025155026155027155028155029155030155031155032155033155034155035155036155037155038155039155040155041155042155043155044155045155046155047155048155049155050155051155052155053155054155055155056155057155058155059155060155061155062155063155064155065155066155067155068155069155070155071155072155073155074155075155076155077155078155079155080155081155082155083155084155085155086155087155088155089155090155091155092155093155094155095155096155097155098155099155100155101155102155103155104155105155106155107155108155109155110155111155112155113155114155115155116155117155118155119155120155121155122155123155124155125155126155127155128155129155130155131155132155133155134155135155136155137155138155139155140155141155142155143155144155145155146155147155148155149155150155151155152155153155154155155155156155157155158155159155160155161155162155163155164155165155166155167155168155169155170155171155172155173155174155175155176155177155178155179155180155181155182155183155184155185155186155187155188155189155190155191155192155193155194155195155196155197155198155199155200155201155202155203155204155205155206155207155208155209155210155211155212155213155214155215155216155217155218155219155220155221155222155223155224155225155226155227155228155229155230155231155232155233155234155235155236155237155238155239155240155241155242155243155244155245155246155247155248155249155250155251155252155253155254155255155256155257155258155259155260155261155262155263155264155265155266155267155268155269155270155271155272155273155274155275155276155277155278155279155280155281155282155283155284155285155286155287155288155289155290155291155292155293155294155295155296155297155298155299155300155301155302155303155304155305155306155307155308155309155310155311155312155313155314155315155316155317155318155319155320155321155322155323155324155325155326155327155328155329155330155331155332155333155334155335155336155337155338155339155340155341155342155343155344155345155346155347155348155349155350155351155352155353155354155355155356155357155358155359155360155361155362155363155364155365155366155367155368155369155370155371155372155373155374155375155376155377155378155379155380155381155382155383155384155385155386155387155388155389155390155391155392155393155394155395155396155397155398155399155400155401155402155403155404155405155406155407155408155409155410155411155412155413155414155415155416155417155418155419155420155421155422155423155424155425155426155427155428155429155430155431155432155433155434155435155436155437155438155439155440155441155442155443155444155445155446155447155448155449155450155451155452155453155454155455155456155457155458155459155460155461155462155463155464155465155466155467155468155469155470155471155472155473155474155475155476155477155478155479155480155481155482155483155484155485155486155487155488155489155490155491155492155493155494155495155496155497155498155499155500155501155502155503155504155505155506155507155508155509155510155511155512155513155514155515155516155517155518155519155520155521155522155523155524155525155526155527155528155529155530155531155532155533155534155535155536155537155538155539155540155541155542155543155544155545155546155547155548155549155550155551155552155553155554155555155556155557155558155559155560155561155562155563155564155565155566155567155568155569155570155571155572155573155574155575155576155577155578155579155580155581155582155583155584155585155586155587155588155589155590155591155592155593155594155595155596155597155598155599155600155601155602155603155604155605155606155607155608155609155610155611155612155613155614155615155616155617155618155619155620155621155622155623155624155625155626155627155628155629155630155631155632155633155634155635155636155637155638155639155640155641155642155643155644155645155646155647155648155649155650155651155652155653155654155655155656155657155658155659155660155661155662155663155664155665155666155667155668155669155670155671155672155673155674155675155676155677155678155679155680155681155682155683155684155685155686155687155688155689155690155691155692155693155694155695155696155697155698155699155700155701155702155703155704155705155706155707155708155709155710155711155712155713155714155715155716155717155718155719155720155721155722155723155724155725155726155727155728155729155730155731155732155733155734155735155736155737155738155739155740155741155742155743155744155745155746155747155748155749155750155751155752155753155754155755155756155757155758155759155760155761155762155763155764155765155766155767155768155769155770155771155772155773155774155775155776155777155778155779155780155781155782155783155784155785155786155787155788155789155790155791155792155793155794155795155796155797155798155799155800155801155802155803155804155805155806155807155808155809155810155811155812155813155814155815155816155817155818155819155820155821155822155823155824155825155826155827155828155829155830155831155832155833155834155835155836155837155838155839155840155841155842155843155844155845155846155847155848155849155850155851155852155853155854155855155856155857155858155859155860155861155862155863155864155865155866155867155868155869155870155871155872155873155874155875155876155877155878155879155880155881155882155883155884155885155886155887155888155889155890155891155892155893155894155895155896155897155898155899155900155901155902155903155904155905155906155907155908155909155910155911155912155913155914155915155916155917155918155919155920155921155922155923155924155925155926155927155928155929155930155931155932155933155934155935155936155937155938155939155940155941155942155943155944155945155946155947155948155949155950155951155952155953155954155955155956155957155958155959155960155961155962155963155964155965155966155967155968155969155970155971155972155973155974155975155976155977155978155979155980155981155982155983155984155985155986155987155988155989155990155991155992155993155994155995155996155997155998155999156000156001156002156003156004156005156006156007156008156009156010156011156012156013156014156015156016156017156018156019156020156021156022156023156024156025156026156027156028156029156030156031156032156033156034156035156036156037156038156039156040156041156042156043156044156045156046156047156048156049156050156051156052156053156054156055156056156057156058156059156060156061156062156063156064156065156066156067156068156069156070156071156072156073156074156075156076156077156078156079156080156081156082156083156084156085156086156087156088156089156090156091156092156093156094156095156096156097156098156099156100156101156102156103156104156105156106156107156108156109156110156111156112156113156114156115156116156117156118156119156120156121156122156123156124156125156126156127156128156129156130156131156132156133156134156135156136156137156138156139156140156141156142156143156144156145156146156147156148156149156150156151156152156153156154156155156156156157156158156159156160156161156162156163156164156165156166156167156168156169156170156171156172156173156174156175156176156177156178156179156180156181156182156183156184156185156186156187156188156189156190156191156192156193156194156195156196156197156198156199156200156201156202156203156204156205156206156207156208156209156210156211156212156213156214156215156216156217156218156219156220
  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/Meshes/Builders/capsuleBuilder" {
  6862. import { Vector3 } from "babylonjs/Maths/math.vector";
  6863. import { Mesh } from "babylonjs/Meshes/mesh";
  6864. /**
  6865. * The options Interface for creating a Capsule Mesh
  6866. */
  6867. export interface ICreateCapsuleOptions {
  6868. /** The Orientation of the capsule. Default : Vector3.Up() */
  6869. orientation?: Vector3;
  6870. /** Number of sub segments on the tube section of the capsule running parallel to orientation. */
  6871. subdivisions: number;
  6872. /** Number of cylindrical segments on the capsule. */
  6873. tessellation: number;
  6874. /** Height or Length of the capsule. */
  6875. height: number;
  6876. /** Radius of the capsule. */
  6877. radius: number;
  6878. /** Height or Length of the capsule. */
  6879. capSubdivisions: number;
  6880. /** Overwrite for the top radius. */
  6881. radiusTop?: number;
  6882. /** Overwrite for the bottom radius. */
  6883. radiusBottom?: number;
  6884. /** Overwrite for the top capSubdivisions. */
  6885. topCapSubdivisions?: number;
  6886. /** Overwrite for the bottom capSubdivisions. */
  6887. bottomCapSubdivisions?: number;
  6888. }
  6889. /**
  6890. * Class containing static functions to help procedurally build meshes
  6891. */
  6892. export class CapsuleBuilder {
  6893. /**
  6894. * Creates a capsule or a pill mesh
  6895. * @param name defines the name of the mesh
  6896. * @param options The constructors options.
  6897. * @param scene The scene the mesh is scoped to.
  6898. * @returns Capsule Mesh
  6899. */
  6900. static CreateCapsule(name: string, options: ICreateCapsuleOptions | undefined, scene: any): Mesh;
  6901. }
  6902. }
  6903. declare module "babylonjs/Collisions/intersectionInfo" {
  6904. import { Nullable } from "babylonjs/types";
  6905. /**
  6906. * @hidden
  6907. */
  6908. export class IntersectionInfo {
  6909. bu: Nullable<number>;
  6910. bv: Nullable<number>;
  6911. distance: number;
  6912. faceId: number;
  6913. subMeshId: number;
  6914. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6915. }
  6916. }
  6917. declare module "babylonjs/Culling/boundingSphere" {
  6918. import { DeepImmutable } from "babylonjs/types";
  6919. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6920. import { Plane } from "babylonjs/Maths/math.plane";
  6921. /**
  6922. * Class used to store bounding sphere information
  6923. */
  6924. export class BoundingSphere {
  6925. /**
  6926. * Gets the center of the bounding sphere in local space
  6927. */
  6928. readonly center: Vector3;
  6929. /**
  6930. * Radius of the bounding sphere in local space
  6931. */
  6932. radius: number;
  6933. /**
  6934. * Gets the center of the bounding sphere in world space
  6935. */
  6936. readonly centerWorld: Vector3;
  6937. /**
  6938. * Radius of the bounding sphere in world space
  6939. */
  6940. radiusWorld: number;
  6941. /**
  6942. * Gets the minimum vector in local space
  6943. */
  6944. readonly minimum: Vector3;
  6945. /**
  6946. * Gets the maximum vector in local space
  6947. */
  6948. readonly maximum: Vector3;
  6949. private _worldMatrix;
  6950. private static readonly TmpVector3;
  6951. /**
  6952. * Creates a new bounding sphere
  6953. * @param min defines the minimum vector (in local space)
  6954. * @param max defines the maximum vector (in local space)
  6955. * @param worldMatrix defines the new world matrix
  6956. */
  6957. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6958. /**
  6959. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6960. * @param min defines the new minimum vector (in local space)
  6961. * @param max defines the new maximum vector (in local space)
  6962. * @param worldMatrix defines the new world matrix
  6963. */
  6964. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6965. /**
  6966. * Scale the current bounding sphere by applying a scale factor
  6967. * @param factor defines the scale factor to apply
  6968. * @returns the current bounding box
  6969. */
  6970. scale(factor: number): BoundingSphere;
  6971. /**
  6972. * Gets the world matrix of the bounding box
  6973. * @returns a matrix
  6974. */
  6975. getWorldMatrix(): DeepImmutable<Matrix>;
  6976. /** @hidden */
  6977. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6978. /**
  6979. * Tests if the bounding sphere is intersecting the frustum planes
  6980. * @param frustumPlanes defines the frustum planes to test
  6981. * @returns true if there is an intersection
  6982. */
  6983. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6984. /**
  6985. * Tests if the bounding sphere center is in between the frustum planes.
  6986. * Used for optimistic fast inclusion.
  6987. * @param frustumPlanes defines the frustum planes to test
  6988. * @returns true if the sphere center is in between the frustum planes
  6989. */
  6990. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6991. /**
  6992. * Tests if a point is inside the bounding sphere
  6993. * @param point defines the point to test
  6994. * @returns true if the point is inside the bounding sphere
  6995. */
  6996. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6997. /**
  6998. * Checks if two sphere intersct
  6999. * @param sphere0 sphere 0
  7000. * @param sphere1 sphere 1
  7001. * @returns true if the speres intersect
  7002. */
  7003. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  7004. }
  7005. }
  7006. declare module "babylonjs/Culling/boundingBox" {
  7007. import { DeepImmutable } from "babylonjs/types";
  7008. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7009. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  7010. import { ICullable } from "babylonjs/Culling/boundingInfo";
  7011. import { Plane } from "babylonjs/Maths/math.plane";
  7012. /**
  7013. * Class used to store bounding box information
  7014. */
  7015. export class BoundingBox implements ICullable {
  7016. /**
  7017. * Gets the 8 vectors representing the bounding box in local space
  7018. */
  7019. readonly vectors: Vector3[];
  7020. /**
  7021. * Gets the center of the bounding box in local space
  7022. */
  7023. readonly center: Vector3;
  7024. /**
  7025. * Gets the center of the bounding box in world space
  7026. */
  7027. readonly centerWorld: Vector3;
  7028. /**
  7029. * Gets the extend size in local space
  7030. */
  7031. readonly extendSize: Vector3;
  7032. /**
  7033. * Gets the extend size in world space
  7034. */
  7035. readonly extendSizeWorld: Vector3;
  7036. /**
  7037. * Gets the OBB (object bounding box) directions
  7038. */
  7039. readonly directions: Vector3[];
  7040. /**
  7041. * Gets the 8 vectors representing the bounding box in world space
  7042. */
  7043. readonly vectorsWorld: Vector3[];
  7044. /**
  7045. * Gets the minimum vector in world space
  7046. */
  7047. readonly minimumWorld: Vector3;
  7048. /**
  7049. * Gets the maximum vector in world space
  7050. */
  7051. readonly maximumWorld: Vector3;
  7052. /**
  7053. * Gets the minimum vector in local space
  7054. */
  7055. readonly minimum: Vector3;
  7056. /**
  7057. * Gets the maximum vector in local space
  7058. */
  7059. readonly maximum: Vector3;
  7060. private _worldMatrix;
  7061. private static readonly TmpVector3;
  7062. /**
  7063. * @hidden
  7064. */
  7065. _tag: number;
  7066. /**
  7067. * Creates a new bounding box
  7068. * @param min defines the minimum vector (in local space)
  7069. * @param max defines the maximum vector (in local space)
  7070. * @param worldMatrix defines the new world matrix
  7071. */
  7072. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7073. /**
  7074. * Recreates the entire bounding box from scratch as if we call the constructor in place
  7075. * @param min defines the new minimum vector (in local space)
  7076. * @param max defines the new maximum vector (in local space)
  7077. * @param worldMatrix defines the new world matrix
  7078. */
  7079. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7080. /**
  7081. * Scale the current bounding box by applying a scale factor
  7082. * @param factor defines the scale factor to apply
  7083. * @returns the current bounding box
  7084. */
  7085. scale(factor: number): BoundingBox;
  7086. /**
  7087. * Gets the world matrix of the bounding box
  7088. * @returns a matrix
  7089. */
  7090. getWorldMatrix(): DeepImmutable<Matrix>;
  7091. /** @hidden */
  7092. _update(world: DeepImmutable<Matrix>): void;
  7093. /**
  7094. * Tests if the bounding box is intersecting the frustum planes
  7095. * @param frustumPlanes defines the frustum planes to test
  7096. * @returns true if there is an intersection
  7097. */
  7098. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7099. /**
  7100. * Tests if the bounding box is entirely inside the frustum planes
  7101. * @param frustumPlanes defines the frustum planes to test
  7102. * @returns true if there is an inclusion
  7103. */
  7104. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7105. /**
  7106. * Tests if a point is inside the bounding box
  7107. * @param point defines the point to test
  7108. * @returns true if the point is inside the bounding box
  7109. */
  7110. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7111. /**
  7112. * Tests if the bounding box intersects with a bounding sphere
  7113. * @param sphere defines the sphere to test
  7114. * @returns true if there is an intersection
  7115. */
  7116. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  7117. /**
  7118. * Tests if the bounding box intersects with a box defined by a min and max vectors
  7119. * @param min defines the min vector to use
  7120. * @param max defines the max vector to use
  7121. * @returns true if there is an intersection
  7122. */
  7123. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  7124. /**
  7125. * Tests if two bounding boxes are intersections
  7126. * @param box0 defines the first box to test
  7127. * @param box1 defines the second box to test
  7128. * @returns true if there is an intersection
  7129. */
  7130. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  7131. /**
  7132. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  7133. * @param minPoint defines the minimum vector of the bounding box
  7134. * @param maxPoint defines the maximum vector of the bounding box
  7135. * @param sphereCenter defines the sphere center
  7136. * @param sphereRadius defines the sphere radius
  7137. * @returns true if there is an intersection
  7138. */
  7139. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  7140. /**
  7141. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  7142. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7143. * @param frustumPlanes defines the frustum planes to test
  7144. * @return true if there is an inclusion
  7145. */
  7146. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7147. /**
  7148. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7149. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7150. * @param frustumPlanes defines the frustum planes to test
  7151. * @return true if there is an intersection
  7152. */
  7153. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7154. }
  7155. }
  7156. declare module "babylonjs/Collisions/collider" {
  7157. import { Nullable, IndicesArray } from "babylonjs/types";
  7158. import { Vector3 } from "babylonjs/Maths/math.vector";
  7159. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  7160. import { Plane } from "babylonjs/Maths/math.plane";
  7161. /** @hidden */
  7162. export class Collider {
  7163. /** Define if a collision was found */
  7164. collisionFound: boolean;
  7165. /**
  7166. * Define last intersection point in local space
  7167. */
  7168. intersectionPoint: Vector3;
  7169. /**
  7170. * Define last collided mesh
  7171. */
  7172. collidedMesh: Nullable<AbstractMesh>;
  7173. private _collisionPoint;
  7174. private _planeIntersectionPoint;
  7175. private _tempVector;
  7176. private _tempVector2;
  7177. private _tempVector3;
  7178. private _tempVector4;
  7179. private _edge;
  7180. private _baseToVertex;
  7181. private _destinationPoint;
  7182. private _slidePlaneNormal;
  7183. private _displacementVector;
  7184. /** @hidden */
  7185. _radius: Vector3;
  7186. /** @hidden */
  7187. _retry: number;
  7188. private _velocity;
  7189. private _basePoint;
  7190. private _epsilon;
  7191. /** @hidden */
  7192. _velocityWorldLength: number;
  7193. /** @hidden */
  7194. _basePointWorld: Vector3;
  7195. private _velocityWorld;
  7196. private _normalizedVelocity;
  7197. /** @hidden */
  7198. _initialVelocity: Vector3;
  7199. /** @hidden */
  7200. _initialPosition: Vector3;
  7201. private _nearestDistance;
  7202. private _collisionMask;
  7203. get collisionMask(): number;
  7204. set collisionMask(mask: number);
  7205. /**
  7206. * Gets the plane normal used to compute the sliding response (in local space)
  7207. */
  7208. get slidePlaneNormal(): Vector3;
  7209. /** @hidden */
  7210. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7211. /** @hidden */
  7212. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7213. /** @hidden */
  7214. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7215. /** @hidden */
  7216. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7217. /** @hidden */
  7218. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7219. /** @hidden */
  7220. _getResponse(pos: Vector3, vel: Vector3): void;
  7221. }
  7222. }
  7223. declare module "babylonjs/Culling/boundingInfo" {
  7224. import { DeepImmutable } from "babylonjs/types";
  7225. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7226. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  7227. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  7228. import { Plane } from "babylonjs/Maths/math.plane";
  7229. import { Collider } from "babylonjs/Collisions/collider";
  7230. /**
  7231. * Interface for cullable objects
  7232. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7233. */
  7234. export interface ICullable {
  7235. /**
  7236. * Checks if the object or part of the object is in the frustum
  7237. * @param frustumPlanes Camera near/planes
  7238. * @returns true if the object is in frustum otherwise false
  7239. */
  7240. isInFrustum(frustumPlanes: Plane[]): boolean;
  7241. /**
  7242. * Checks if a cullable object (mesh...) is in the camera frustum
  7243. * Unlike isInFrustum this cheks the full bounding box
  7244. * @param frustumPlanes Camera near/planes
  7245. * @returns true if the object is in frustum otherwise false
  7246. */
  7247. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7248. }
  7249. /**
  7250. * Info for a bounding data of a mesh
  7251. */
  7252. export class BoundingInfo implements ICullable {
  7253. /**
  7254. * Bounding box for the mesh
  7255. */
  7256. readonly boundingBox: BoundingBox;
  7257. /**
  7258. * Bounding sphere for the mesh
  7259. */
  7260. readonly boundingSphere: BoundingSphere;
  7261. private _isLocked;
  7262. private static readonly TmpVector3;
  7263. /**
  7264. * Constructs bounding info
  7265. * @param minimum min vector of the bounding box/sphere
  7266. * @param maximum max vector of the bounding box/sphere
  7267. * @param worldMatrix defines the new world matrix
  7268. */
  7269. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7270. /**
  7271. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7272. * @param min defines the new minimum vector (in local space)
  7273. * @param max defines the new maximum vector (in local space)
  7274. * @param worldMatrix defines the new world matrix
  7275. */
  7276. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7277. /**
  7278. * min vector of the bounding box/sphere
  7279. */
  7280. get minimum(): Vector3;
  7281. /**
  7282. * max vector of the bounding box/sphere
  7283. */
  7284. get maximum(): Vector3;
  7285. /**
  7286. * If the info is locked and won't be updated to avoid perf overhead
  7287. */
  7288. get isLocked(): boolean;
  7289. set isLocked(value: boolean);
  7290. /**
  7291. * Updates the bounding sphere and box
  7292. * @param world world matrix to be used to update
  7293. */
  7294. update(world: DeepImmutable<Matrix>): void;
  7295. /**
  7296. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7297. * @param center New center of the bounding info
  7298. * @param extend New extend of the bounding info
  7299. * @returns the current bounding info
  7300. */
  7301. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7302. /**
  7303. * Scale the current bounding info by applying a scale factor
  7304. * @param factor defines the scale factor to apply
  7305. * @returns the current bounding info
  7306. */
  7307. scale(factor: number): BoundingInfo;
  7308. /**
  7309. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7310. * @param frustumPlanes defines the frustum to test
  7311. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7312. * @returns true if the bounding info is in the frustum planes
  7313. */
  7314. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7315. /**
  7316. * Gets the world distance between the min and max points of the bounding box
  7317. */
  7318. get diagonalLength(): number;
  7319. /**
  7320. * Checks if a cullable object (mesh...) is in the camera frustum
  7321. * Unlike isInFrustum this cheks the full bounding box
  7322. * @param frustumPlanes Camera near/planes
  7323. * @returns true if the object is in frustum otherwise false
  7324. */
  7325. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7326. /** @hidden */
  7327. _checkCollision(collider: Collider): boolean;
  7328. /**
  7329. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7330. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7331. * @param point the point to check intersection with
  7332. * @returns if the point intersects
  7333. */
  7334. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7335. /**
  7336. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7337. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7338. * @param boundingInfo the bounding info to check intersection with
  7339. * @param precise if the intersection should be done using OBB
  7340. * @returns if the bounding info intersects
  7341. */
  7342. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7343. }
  7344. }
  7345. declare module "babylonjs/Maths/math.functions" {
  7346. import { FloatArray, Nullable, IndicesArray } from "babylonjs/types";
  7347. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  7348. /**
  7349. * Extracts minimum and maximum values from a list of indexed positions
  7350. * @param positions defines the positions to use
  7351. * @param indices defines the indices to the positions
  7352. * @param indexStart defines the start index
  7353. * @param indexCount defines the end index
  7354. * @param bias defines bias value to add to the result
  7355. * @return minimum and maximum values
  7356. */
  7357. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7358. minimum: Vector3;
  7359. maximum: Vector3;
  7360. };
  7361. /**
  7362. * Extracts minimum and maximum values from a list of positions
  7363. * @param positions defines the positions to use
  7364. * @param start defines the start index in the positions array
  7365. * @param count defines the number of positions to handle
  7366. * @param bias defines bias value to add to the result
  7367. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7368. * @return minimum and maximum values
  7369. */
  7370. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7371. minimum: Vector3;
  7372. maximum: Vector3;
  7373. };
  7374. }
  7375. declare module "babylonjs/Meshes/WebGL/webGLDataBuffer" {
  7376. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7377. /** @hidden */
  7378. export class WebGLDataBuffer extends DataBuffer {
  7379. private _buffer;
  7380. constructor(resource: WebGLBuffer);
  7381. get underlyingResource(): any;
  7382. }
  7383. }
  7384. declare module "babylonjs/Engines/WebGL/webGLPipelineContext" {
  7385. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  7386. import { Nullable } from "babylonjs/types";
  7387. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  7388. /** @hidden */
  7389. export class WebGLPipelineContext implements IPipelineContext {
  7390. engine: ThinEngine;
  7391. program: Nullable<WebGLProgram>;
  7392. context?: WebGLRenderingContext;
  7393. vertexShader?: WebGLShader;
  7394. fragmentShader?: WebGLShader;
  7395. isParallelCompiled: boolean;
  7396. onCompiled?: () => void;
  7397. transformFeedback?: WebGLTransformFeedback | null;
  7398. vertexCompilationError: Nullable<string>;
  7399. fragmentCompilationError: Nullable<string>;
  7400. programLinkError: Nullable<string>;
  7401. programValidationError: Nullable<string>;
  7402. get isAsync(): boolean;
  7403. get isReady(): boolean;
  7404. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  7405. _getVertexShaderCode(): string | null;
  7406. _getFragmentShaderCode(): string | null;
  7407. }
  7408. }
  7409. declare module "babylonjs/Engines/Extensions/engine.uniformBuffer" {
  7410. import { FloatArray, Nullable } from "babylonjs/types";
  7411. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7412. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  7413. module "babylonjs/Engines/thinEngine" {
  7414. interface ThinEngine {
  7415. /**
  7416. * Create an uniform buffer
  7417. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7418. * @param elements defines the content of the uniform buffer
  7419. * @returns the webGL uniform buffer
  7420. */
  7421. createUniformBuffer(elements: FloatArray): DataBuffer;
  7422. /**
  7423. * Create a dynamic uniform buffer
  7424. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7425. * @param elements defines the content of the uniform buffer
  7426. * @returns the webGL uniform buffer
  7427. */
  7428. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  7429. /**
  7430. * Update an existing uniform buffer
  7431. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7432. * @param uniformBuffer defines the target uniform buffer
  7433. * @param elements defines the content to update
  7434. * @param offset defines the offset in the uniform buffer where update should start
  7435. * @param count defines the size of the data to update
  7436. */
  7437. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  7438. /**
  7439. * Bind an uniform buffer to the current webGL context
  7440. * @param buffer defines the buffer to bind
  7441. */
  7442. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  7443. /**
  7444. * Bind a buffer to the current webGL context at a given location
  7445. * @param buffer defines the buffer to bind
  7446. * @param location defines the index where to bind the buffer
  7447. */
  7448. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  7449. /**
  7450. * Bind a specific block at a given index in a specific shader program
  7451. * @param pipelineContext defines the pipeline context to use
  7452. * @param blockName defines the block name
  7453. * @param index defines the index where to bind the block
  7454. */
  7455. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  7456. }
  7457. }
  7458. }
  7459. declare module "babylonjs/Materials/uniformBuffer" {
  7460. import { Nullable, FloatArray } from "babylonjs/types";
  7461. import { Matrix, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  7462. import { Engine } from "babylonjs/Engines/engine";
  7463. import { Effect } from "babylonjs/Materials/effect";
  7464. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7465. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7466. import { Color3 } from "babylonjs/Maths/math.color";
  7467. import "babylonjs/Engines/Extensions/engine.uniformBuffer";
  7468. /**
  7469. * Uniform buffer objects.
  7470. *
  7471. * Handles blocks of uniform on the GPU.
  7472. *
  7473. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7474. *
  7475. * For more information, please refer to :
  7476. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7477. */
  7478. export class UniformBuffer {
  7479. private _engine;
  7480. private _buffer;
  7481. private _data;
  7482. private _bufferData;
  7483. private _dynamic?;
  7484. private _uniformLocations;
  7485. private _uniformSizes;
  7486. private _uniformLocationPointer;
  7487. private _needSync;
  7488. private _noUBO;
  7489. private _currentEffect;
  7490. /** @hidden */
  7491. _alreadyBound: boolean;
  7492. private static _MAX_UNIFORM_SIZE;
  7493. private static _tempBuffer;
  7494. /**
  7495. * Lambda to Update a 3x3 Matrix 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. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  7500. /**
  7501. * Lambda to Update a 2x2 Matrix 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. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  7506. /**
  7507. * Lambda to Update a single float 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. updateFloat: (name: string, x: number) => void;
  7512. /**
  7513. * Lambda to Update a vec2 of float 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. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  7518. /**
  7519. * Lambda to Update a vec3 of float in a uniform buffer.
  7520. * This is dynamic to allow compat with webgl 1 and 2.
  7521. * You will need to pass the name of the uniform as well as the value.
  7522. */
  7523. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  7524. /**
  7525. * Lambda to Update a vec4 of float in a uniform buffer.
  7526. * This is dynamic to allow compat with webgl 1 and 2.
  7527. * You will need to pass the name of the uniform as well as the value.
  7528. */
  7529. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  7530. /**
  7531. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  7532. * This is dynamic to allow compat with webgl 1 and 2.
  7533. * You will need to pass the name of the uniform as well as the value.
  7534. */
  7535. updateMatrix: (name: string, mat: Matrix) => void;
  7536. /**
  7537. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  7538. * This is dynamic to allow compat with webgl 1 and 2.
  7539. * You will need to pass the name of the uniform as well as the value.
  7540. */
  7541. updateVector3: (name: string, vector: Vector3) => void;
  7542. /**
  7543. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  7544. * This is dynamic to allow compat with webgl 1 and 2.
  7545. * You will need to pass the name of the uniform as well as the value.
  7546. */
  7547. updateVector4: (name: string, vector: Vector4) => void;
  7548. /**
  7549. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  7550. * This is dynamic to allow compat with webgl 1 and 2.
  7551. * You will need to pass the name of the uniform as well as the value.
  7552. */
  7553. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  7554. /**
  7555. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  7556. * This is dynamic to allow compat with webgl 1 and 2.
  7557. * You will need to pass the name of the uniform as well as the value.
  7558. */
  7559. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  7560. /**
  7561. * Instantiates a new Uniform buffer objects.
  7562. *
  7563. * Handles blocks of uniform on the GPU.
  7564. *
  7565. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7566. *
  7567. * For more information, please refer to :
  7568. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7569. * @param engine Define the engine the buffer is associated with
  7570. * @param data Define the data contained in the buffer
  7571. * @param dynamic Define if the buffer is updatable
  7572. */
  7573. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  7574. /**
  7575. * Indicates if the buffer is using the WebGL2 UBO implementation,
  7576. * or just falling back on setUniformXXX calls.
  7577. */
  7578. get useUbo(): boolean;
  7579. /**
  7580. * Indicates if the WebGL underlying uniform buffer is in sync
  7581. * with the javascript cache data.
  7582. */
  7583. get isSync(): boolean;
  7584. /**
  7585. * Indicates if the WebGL underlying uniform buffer is dynamic.
  7586. * Also, a dynamic UniformBuffer will disable cache verification and always
  7587. * update the underlying WebGL uniform buffer to the GPU.
  7588. * @returns if Dynamic, otherwise false
  7589. */
  7590. isDynamic(): boolean;
  7591. /**
  7592. * The data cache on JS side.
  7593. * @returns the underlying data as a float array
  7594. */
  7595. getData(): Float32Array;
  7596. /**
  7597. * The underlying WebGL Uniform buffer.
  7598. * @returns the webgl buffer
  7599. */
  7600. getBuffer(): Nullable<DataBuffer>;
  7601. /**
  7602. * std140 layout specifies how to align data within an UBO structure.
  7603. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  7604. * for specs.
  7605. */
  7606. private _fillAlignment;
  7607. /**
  7608. * Adds an uniform in the buffer.
  7609. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  7610. * for the layout to be correct !
  7611. * @param name Name of the uniform, as used in the uniform block in the shader.
  7612. * @param size Data size, or data directly.
  7613. */
  7614. addUniform(name: string, size: number | number[]): void;
  7615. /**
  7616. * Adds a Matrix 4x4 to the uniform buffer.
  7617. * @param name Name of the uniform, as used in the uniform block in the shader.
  7618. * @param mat A 4x4 matrix.
  7619. */
  7620. addMatrix(name: string, mat: Matrix): void;
  7621. /**
  7622. * Adds a vec2 to the uniform buffer.
  7623. * @param name Name of the uniform, as used in the uniform block in the shader.
  7624. * @param x Define the x component value of the vec2
  7625. * @param y Define the y component value of the vec2
  7626. */
  7627. addFloat2(name: string, x: number, y: number): void;
  7628. /**
  7629. * Adds a vec3 to the uniform buffer.
  7630. * @param name Name of the uniform, as used in the uniform block in the shader.
  7631. * @param x Define the x component value of the vec3
  7632. * @param y Define the y component value of the vec3
  7633. * @param z Define the z component value of the vec3
  7634. */
  7635. addFloat3(name: string, x: number, y: number, z: number): void;
  7636. /**
  7637. * Adds a vec3 to the uniform buffer.
  7638. * @param name Name of the uniform, as used in the uniform block in the shader.
  7639. * @param color Define the vec3 from a Color
  7640. */
  7641. addColor3(name: string, color: Color3): void;
  7642. /**
  7643. * Adds a vec4 to the uniform buffer.
  7644. * @param name Name of the uniform, as used in the uniform block in the shader.
  7645. * @param color Define the rgb components from a Color
  7646. * @param alpha Define the a component of the vec4
  7647. */
  7648. addColor4(name: string, color: Color3, alpha: number): void;
  7649. /**
  7650. * Adds a vec3 to the uniform buffer.
  7651. * @param name Name of the uniform, as used in the uniform block in the shader.
  7652. * @param vector Define the vec3 components from a Vector
  7653. */
  7654. addVector3(name: string, vector: Vector3): void;
  7655. /**
  7656. * Adds a Matrix 3x3 to the uniform buffer.
  7657. * @param name Name of the uniform, as used in the uniform block in the shader.
  7658. */
  7659. addMatrix3x3(name: string): void;
  7660. /**
  7661. * Adds a Matrix 2x2 to the uniform buffer.
  7662. * @param name Name of the uniform, as used in the uniform block in the shader.
  7663. */
  7664. addMatrix2x2(name: string): void;
  7665. /**
  7666. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  7667. */
  7668. create(): void;
  7669. /** @hidden */
  7670. _rebuild(): void;
  7671. /**
  7672. * Updates the WebGL Uniform Buffer on the GPU.
  7673. * If the `dynamic` flag is set to true, no cache comparison is done.
  7674. * Otherwise, the buffer will be updated only if the cache differs.
  7675. */
  7676. update(): void;
  7677. /**
  7678. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  7679. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7680. * @param data Define the flattened data
  7681. * @param size Define the size of the data.
  7682. */
  7683. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  7684. private _valueCache;
  7685. private _cacheMatrix;
  7686. private _updateMatrix3x3ForUniform;
  7687. private _updateMatrix3x3ForEffect;
  7688. private _updateMatrix2x2ForEffect;
  7689. private _updateMatrix2x2ForUniform;
  7690. private _updateFloatForEffect;
  7691. private _updateFloatForUniform;
  7692. private _updateFloat2ForEffect;
  7693. private _updateFloat2ForUniform;
  7694. private _updateFloat3ForEffect;
  7695. private _updateFloat3ForUniform;
  7696. private _updateFloat4ForEffect;
  7697. private _updateFloat4ForUniform;
  7698. private _updateMatrixForEffect;
  7699. private _updateMatrixForUniform;
  7700. private _updateVector3ForEffect;
  7701. private _updateVector3ForUniform;
  7702. private _updateVector4ForEffect;
  7703. private _updateVector4ForUniform;
  7704. private _updateColor3ForEffect;
  7705. private _updateColor3ForUniform;
  7706. private _updateColor4ForEffect;
  7707. private _updateColor4ForUniform;
  7708. /**
  7709. * Sets a sampler uniform on the effect.
  7710. * @param name Define the name of the sampler.
  7711. * @param texture Define the texture to set in the sampler
  7712. */
  7713. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  7714. /**
  7715. * Directly updates the value of the uniform in the cache AND on the GPU.
  7716. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7717. * @param data Define the flattened data
  7718. */
  7719. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  7720. /**
  7721. * Binds this uniform buffer to an effect.
  7722. * @param effect Define the effect to bind the buffer to
  7723. * @param name Name of the uniform block in the shader.
  7724. */
  7725. bindToEffect(effect: Effect, name: string): void;
  7726. /**
  7727. * Disposes the uniform buffer.
  7728. */
  7729. dispose(): void;
  7730. }
  7731. }
  7732. declare module "babylonjs/Misc/iInspectable" {
  7733. /**
  7734. * Enum that determines the text-wrapping mode to use.
  7735. */
  7736. export enum InspectableType {
  7737. /**
  7738. * Checkbox for booleans
  7739. */
  7740. Checkbox = 0,
  7741. /**
  7742. * Sliders for numbers
  7743. */
  7744. Slider = 1,
  7745. /**
  7746. * Vector3
  7747. */
  7748. Vector3 = 2,
  7749. /**
  7750. * Quaternions
  7751. */
  7752. Quaternion = 3,
  7753. /**
  7754. * Color3
  7755. */
  7756. Color3 = 4,
  7757. /**
  7758. * String
  7759. */
  7760. String = 5
  7761. }
  7762. /**
  7763. * Interface used to define custom inspectable properties.
  7764. * This interface is used by the inspector to display custom property grids
  7765. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7766. */
  7767. export interface IInspectable {
  7768. /**
  7769. * Gets the label to display
  7770. */
  7771. label: string;
  7772. /**
  7773. * Gets the name of the property to edit
  7774. */
  7775. propertyName: string;
  7776. /**
  7777. * Gets the type of the editor to use
  7778. */
  7779. type: InspectableType;
  7780. /**
  7781. * Gets the minimum value of the property when using in "slider" mode
  7782. */
  7783. min?: number;
  7784. /**
  7785. * Gets the maximum value of the property when using in "slider" mode
  7786. */
  7787. max?: number;
  7788. /**
  7789. * Gets the setp to use when using in "slider" mode
  7790. */
  7791. step?: number;
  7792. }
  7793. }
  7794. declare module "babylonjs/Misc/timingTools" {
  7795. /**
  7796. * Class used to provide helper for timing
  7797. */
  7798. export class TimingTools {
  7799. /**
  7800. * Polyfill for setImmediate
  7801. * @param action defines the action to execute after the current execution block
  7802. */
  7803. static SetImmediate(action: () => void): void;
  7804. }
  7805. }
  7806. declare module "babylonjs/Misc/instantiationTools" {
  7807. /**
  7808. * Class used to enable instatition of objects by class name
  7809. */
  7810. export class InstantiationTools {
  7811. /**
  7812. * Use this object to register external classes like custom textures or material
  7813. * to allow the laoders to instantiate them
  7814. */
  7815. static RegisteredExternalClasses: {
  7816. [key: string]: Object;
  7817. };
  7818. /**
  7819. * Tries to instantiate a new object from a given class name
  7820. * @param className defines the class name to instantiate
  7821. * @returns the new object or null if the system was not able to do the instantiation
  7822. */
  7823. static Instantiate(className: string): any;
  7824. }
  7825. }
  7826. declare module "babylonjs/Engines/depthTextureCreationOptions" {
  7827. /**
  7828. * Define options used to create a depth texture
  7829. */
  7830. export class DepthTextureCreationOptions {
  7831. /** Specifies whether or not a stencil should be allocated in the texture */
  7832. generateStencil?: boolean;
  7833. /** Specifies whether or not bilinear filtering is enable on the texture */
  7834. bilinearFiltering?: boolean;
  7835. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  7836. comparisonFunction?: number;
  7837. /** Specifies if the created texture is a cube texture */
  7838. isCube?: boolean;
  7839. }
  7840. }
  7841. declare module "babylonjs/Engines/Extensions/engine.cubeTexture" {
  7842. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  7843. import { Nullable } from "babylonjs/types";
  7844. import { Scene } from "babylonjs/scene";
  7845. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  7846. module "babylonjs/Engines/thinEngine" {
  7847. interface ThinEngine {
  7848. /**
  7849. * Creates a depth stencil cube texture.
  7850. * This is only available in WebGL 2.
  7851. * @param size The size of face edge in the cube texture.
  7852. * @param options The options defining the cube texture.
  7853. * @returns The cube texture
  7854. */
  7855. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7856. /**
  7857. * Creates a cube texture
  7858. * @param rootUrl defines the url where the files to load is located
  7859. * @param scene defines the current scene
  7860. * @param files defines the list of files to load (1 per face)
  7861. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7862. * @param onLoad defines an optional callback raised when the texture is loaded
  7863. * @param onError defines an optional callback raised if there is an issue to load the texture
  7864. * @param format defines the format of the data
  7865. * @param forcedExtension defines the extension to use to pick the right loader
  7866. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7867. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7868. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7869. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7870. * @returns the cube texture as an InternalTexture
  7871. */
  7872. 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;
  7873. /**
  7874. * Creates a cube texture
  7875. * @param rootUrl defines the url where the files to load is located
  7876. * @param scene defines the current scene
  7877. * @param files defines the list of files to load (1 per face)
  7878. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7879. * @param onLoad defines an optional callback raised when the texture is loaded
  7880. * @param onError defines an optional callback raised if there is an issue to load the texture
  7881. * @param format defines the format of the data
  7882. * @param forcedExtension defines the extension to use to pick the right loader
  7883. * @returns the cube texture as an InternalTexture
  7884. */
  7885. 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;
  7886. /**
  7887. * Creates a cube texture
  7888. * @param rootUrl defines the url where the files to load is located
  7889. * @param scene defines the current scene
  7890. * @param files defines the list of files to load (1 per face)
  7891. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7892. * @param onLoad defines an optional callback raised when the texture is loaded
  7893. * @param onError defines an optional callback raised if there is an issue to load the texture
  7894. * @param format defines the format of the data
  7895. * @param forcedExtension defines the extension to use to pick the right loader
  7896. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7897. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7898. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7899. * @returns the cube texture as an InternalTexture
  7900. */
  7901. 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;
  7902. /** @hidden */
  7903. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7904. /** @hidden */
  7905. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7906. /** @hidden */
  7907. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7908. /** @hidden */
  7909. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7910. /**
  7911. * @hidden
  7912. */
  7913. _setCubeMapTextureParams(loadMipmap: boolean): void;
  7914. }
  7915. }
  7916. }
  7917. declare module "babylonjs/Materials/Textures/cubeTexture" {
  7918. import { Nullable } from "babylonjs/types";
  7919. import { Scene } from "babylonjs/scene";
  7920. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7921. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7922. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  7923. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  7924. import { Observable } from "babylonjs/Misc/observable";
  7925. /**
  7926. * Class for creating a cube texture
  7927. */
  7928. export class CubeTexture extends BaseTexture {
  7929. private _delayedOnLoad;
  7930. /**
  7931. * Observable triggered once the texture has been loaded.
  7932. */
  7933. onLoadObservable: Observable<CubeTexture>;
  7934. /**
  7935. * The url of the texture
  7936. */
  7937. url: string;
  7938. /**
  7939. * Gets or sets the center of the bounding box associated with the cube texture.
  7940. * It must define where the camera used to render the texture was set
  7941. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7942. */
  7943. boundingBoxPosition: Vector3;
  7944. private _boundingBoxSize;
  7945. /**
  7946. * Gets or sets the size of the bounding box associated with the cube texture
  7947. * When defined, the cubemap will switch to local mode
  7948. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7949. * @example https://www.babylonjs-playground.com/#RNASML
  7950. */
  7951. set boundingBoxSize(value: Vector3);
  7952. /**
  7953. * Returns the bounding box size
  7954. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7955. */
  7956. get boundingBoxSize(): Vector3;
  7957. protected _rotationY: number;
  7958. /**
  7959. * Sets texture matrix rotation angle around Y axis in radians.
  7960. */
  7961. set rotationY(value: number);
  7962. /**
  7963. * Gets texture matrix rotation angle around Y axis radians.
  7964. */
  7965. get rotationY(): number;
  7966. /**
  7967. * Are mip maps generated for this texture or not.
  7968. */
  7969. get noMipmap(): boolean;
  7970. private _noMipmap;
  7971. private _files;
  7972. protected _forcedExtension: Nullable<string>;
  7973. private _extensions;
  7974. private _textureMatrix;
  7975. private _format;
  7976. private _createPolynomials;
  7977. /**
  7978. * Creates a cube texture from an array of image urls
  7979. * @param files defines an array of image urls
  7980. * @param scene defines the hosting scene
  7981. * @param noMipmap specifies if mip maps are not used
  7982. * @returns a cube texture
  7983. */
  7984. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7985. /**
  7986. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7987. * @param url defines the url of the prefiltered texture
  7988. * @param scene defines the scene the texture is attached to
  7989. * @param forcedExtension defines the extension of the file if different from the url
  7990. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7991. * @return the prefiltered texture
  7992. */
  7993. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7994. /**
  7995. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7996. * as prefiltered data.
  7997. * @param rootUrl defines the url of the texture or the root name of the six images
  7998. * @param null defines the scene or engine the texture is attached to
  7999. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  8000. * @param noMipmap defines if mipmaps should be created or not
  8001. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  8002. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  8003. * @param onError defines a callback triggered in case of error during load
  8004. * @param format defines the internal format to use for the texture once loaded
  8005. * @param prefiltered defines whether or not the texture is created from prefiltered data
  8006. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  8007. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  8008. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  8009. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  8010. * @return the cube texture
  8011. */
  8012. 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);
  8013. /**
  8014. * Get the current class name of the texture useful for serialization or dynamic coding.
  8015. * @returns "CubeTexture"
  8016. */
  8017. getClassName(): string;
  8018. /**
  8019. * Update the url (and optional buffer) of this texture if url was null during construction.
  8020. * @param url the url of the texture
  8021. * @param forcedExtension defines the extension to use
  8022. * @param onLoad callback called when the texture is loaded (defaults to null)
  8023. * @param prefiltered Defines whether the updated texture is prefiltered or not
  8024. */
  8025. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  8026. /**
  8027. * Delays loading of the cube texture
  8028. * @param forcedExtension defines the extension to use
  8029. */
  8030. delayLoad(forcedExtension?: string): void;
  8031. /**
  8032. * Returns the reflection texture matrix
  8033. * @returns the reflection texture matrix
  8034. */
  8035. getReflectionTextureMatrix(): Matrix;
  8036. /**
  8037. * Sets the reflection texture matrix
  8038. * @param value Reflection texture matrix
  8039. */
  8040. setReflectionTextureMatrix(value: Matrix): void;
  8041. /**
  8042. * Parses text to create a cube texture
  8043. * @param parsedTexture define the serialized text to read from
  8044. * @param scene defines the hosting scene
  8045. * @param rootUrl defines the root url of the cube texture
  8046. * @returns a cube texture
  8047. */
  8048. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  8049. /**
  8050. * Makes a clone, or deep copy, of the cube texture
  8051. * @returns a new cube texture
  8052. */
  8053. clone(): CubeTexture;
  8054. }
  8055. }
  8056. declare module "babylonjs/Materials/materialDefines" {
  8057. /**
  8058. * Manages the defines for the Material
  8059. */
  8060. export class MaterialDefines {
  8061. /** @hidden */
  8062. protected _keys: string[];
  8063. private _isDirty;
  8064. /** @hidden */
  8065. _renderId: number;
  8066. /** @hidden */
  8067. _areLightsDirty: boolean;
  8068. /** @hidden */
  8069. _areLightsDisposed: boolean;
  8070. /** @hidden */
  8071. _areAttributesDirty: boolean;
  8072. /** @hidden */
  8073. _areTexturesDirty: boolean;
  8074. /** @hidden */
  8075. _areFresnelDirty: boolean;
  8076. /** @hidden */
  8077. _areMiscDirty: boolean;
  8078. /** @hidden */
  8079. _areImageProcessingDirty: boolean;
  8080. /** @hidden */
  8081. _normals: boolean;
  8082. /** @hidden */
  8083. _uvs: boolean;
  8084. /** @hidden */
  8085. _needNormals: boolean;
  8086. /** @hidden */
  8087. _needUVs: boolean;
  8088. [id: string]: any;
  8089. /**
  8090. * Specifies if the material needs to be re-calculated
  8091. */
  8092. get isDirty(): boolean;
  8093. /**
  8094. * Marks the material to indicate that it has been re-calculated
  8095. */
  8096. markAsProcessed(): void;
  8097. /**
  8098. * Marks the material to indicate that it needs to be re-calculated
  8099. */
  8100. markAsUnprocessed(): void;
  8101. /**
  8102. * Marks the material to indicate all of its defines need to be re-calculated
  8103. */
  8104. markAllAsDirty(): void;
  8105. /**
  8106. * Marks the material to indicate that image processing needs to be re-calculated
  8107. */
  8108. markAsImageProcessingDirty(): void;
  8109. /**
  8110. * Marks the material to indicate the lights need to be re-calculated
  8111. * @param disposed Defines whether the light is dirty due to dispose or not
  8112. */
  8113. markAsLightDirty(disposed?: boolean): void;
  8114. /**
  8115. * Marks the attribute state as changed
  8116. */
  8117. markAsAttributesDirty(): void;
  8118. /**
  8119. * Marks the texture state as changed
  8120. */
  8121. markAsTexturesDirty(): void;
  8122. /**
  8123. * Marks the fresnel state as changed
  8124. */
  8125. markAsFresnelDirty(): void;
  8126. /**
  8127. * Marks the misc state as changed
  8128. */
  8129. markAsMiscDirty(): void;
  8130. /**
  8131. * Rebuilds the material defines
  8132. */
  8133. rebuild(): void;
  8134. /**
  8135. * Specifies if two material defines are equal
  8136. * @param other - A material define instance to compare to
  8137. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  8138. */
  8139. isEqual(other: MaterialDefines): boolean;
  8140. /**
  8141. * Clones this instance's defines to another instance
  8142. * @param other - material defines to clone values to
  8143. */
  8144. cloneTo(other: MaterialDefines): void;
  8145. /**
  8146. * Resets the material define values
  8147. */
  8148. reset(): void;
  8149. /**
  8150. * Converts the material define values to a string
  8151. * @returns - String of material define information
  8152. */
  8153. toString(): string;
  8154. }
  8155. }
  8156. declare module "babylonjs/Materials/colorCurves" {
  8157. import { Effect } from "babylonjs/Materials/effect";
  8158. /**
  8159. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  8160. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  8161. * 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;
  8162. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  8163. */
  8164. export class ColorCurves {
  8165. private _dirty;
  8166. private _tempColor;
  8167. private _globalCurve;
  8168. private _highlightsCurve;
  8169. private _midtonesCurve;
  8170. private _shadowsCurve;
  8171. private _positiveCurve;
  8172. private _negativeCurve;
  8173. private _globalHue;
  8174. private _globalDensity;
  8175. private _globalSaturation;
  8176. private _globalExposure;
  8177. /**
  8178. * Gets the global Hue value.
  8179. * 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).
  8180. */
  8181. get globalHue(): number;
  8182. /**
  8183. * Sets the global Hue value.
  8184. * 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).
  8185. */
  8186. set globalHue(value: number);
  8187. /**
  8188. * Gets the global Density value.
  8189. * 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.
  8190. * Values less than zero provide a filter of opposite hue.
  8191. */
  8192. get globalDensity(): number;
  8193. /**
  8194. * Sets the global Density value.
  8195. * 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.
  8196. * Values less than zero provide a filter of opposite hue.
  8197. */
  8198. set globalDensity(value: number);
  8199. /**
  8200. * Gets the global Saturation value.
  8201. * 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.
  8202. */
  8203. get globalSaturation(): number;
  8204. /**
  8205. * Sets the global Saturation value.
  8206. * 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.
  8207. */
  8208. set globalSaturation(value: number);
  8209. /**
  8210. * Gets the global Exposure value.
  8211. * 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.
  8212. */
  8213. get globalExposure(): number;
  8214. /**
  8215. * Sets the global Exposure value.
  8216. * 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.
  8217. */
  8218. set globalExposure(value: number);
  8219. private _highlightsHue;
  8220. private _highlightsDensity;
  8221. private _highlightsSaturation;
  8222. private _highlightsExposure;
  8223. /**
  8224. * Gets the highlights Hue value.
  8225. * 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).
  8226. */
  8227. get highlightsHue(): number;
  8228. /**
  8229. * Sets the highlights Hue value.
  8230. * 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).
  8231. */
  8232. set highlightsHue(value: number);
  8233. /**
  8234. * Gets the highlights Density value.
  8235. * 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.
  8236. * Values less than zero provide a filter of opposite hue.
  8237. */
  8238. get highlightsDensity(): number;
  8239. /**
  8240. * Sets the highlights Density value.
  8241. * 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.
  8242. * Values less than zero provide a filter of opposite hue.
  8243. */
  8244. set highlightsDensity(value: number);
  8245. /**
  8246. * Gets the highlights Saturation value.
  8247. * 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.
  8248. */
  8249. get highlightsSaturation(): number;
  8250. /**
  8251. * Sets the highlights Saturation value.
  8252. * 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.
  8253. */
  8254. set highlightsSaturation(value: number);
  8255. /**
  8256. * Gets the highlights Exposure value.
  8257. * 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.
  8258. */
  8259. get highlightsExposure(): number;
  8260. /**
  8261. * Sets the highlights Exposure value.
  8262. * 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.
  8263. */
  8264. set highlightsExposure(value: number);
  8265. private _midtonesHue;
  8266. private _midtonesDensity;
  8267. private _midtonesSaturation;
  8268. private _midtonesExposure;
  8269. /**
  8270. * Gets the midtones Hue value.
  8271. * 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).
  8272. */
  8273. get midtonesHue(): number;
  8274. /**
  8275. * Sets the midtones Hue value.
  8276. * 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).
  8277. */
  8278. set midtonesHue(value: number);
  8279. /**
  8280. * Gets the midtones Density value.
  8281. * 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.
  8282. * Values less than zero provide a filter of opposite hue.
  8283. */
  8284. get midtonesDensity(): number;
  8285. /**
  8286. * Sets the midtones Density value.
  8287. * 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.
  8288. * Values less than zero provide a filter of opposite hue.
  8289. */
  8290. set midtonesDensity(value: number);
  8291. /**
  8292. * Gets the midtones Saturation value.
  8293. * 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.
  8294. */
  8295. get midtonesSaturation(): number;
  8296. /**
  8297. * Sets the midtones Saturation value.
  8298. * 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.
  8299. */
  8300. set midtonesSaturation(value: number);
  8301. /**
  8302. * Gets the midtones Exposure value.
  8303. * 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.
  8304. */
  8305. get midtonesExposure(): number;
  8306. /**
  8307. * Sets the midtones Exposure value.
  8308. * 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.
  8309. */
  8310. set midtonesExposure(value: number);
  8311. private _shadowsHue;
  8312. private _shadowsDensity;
  8313. private _shadowsSaturation;
  8314. private _shadowsExposure;
  8315. /**
  8316. * Gets the shadows Hue value.
  8317. * 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).
  8318. */
  8319. get shadowsHue(): number;
  8320. /**
  8321. * Sets the shadows Hue value.
  8322. * 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).
  8323. */
  8324. set shadowsHue(value: number);
  8325. /**
  8326. * Gets the shadows Density value.
  8327. * 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.
  8328. * Values less than zero provide a filter of opposite hue.
  8329. */
  8330. get shadowsDensity(): number;
  8331. /**
  8332. * Sets the shadows Density value.
  8333. * 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.
  8334. * Values less than zero provide a filter of opposite hue.
  8335. */
  8336. set shadowsDensity(value: number);
  8337. /**
  8338. * Gets the shadows Saturation value.
  8339. * 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.
  8340. */
  8341. get shadowsSaturation(): number;
  8342. /**
  8343. * Sets the shadows Saturation value.
  8344. * 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.
  8345. */
  8346. set shadowsSaturation(value: number);
  8347. /**
  8348. * Gets the shadows Exposure value.
  8349. * 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.
  8350. */
  8351. get shadowsExposure(): number;
  8352. /**
  8353. * Sets the shadows Exposure value.
  8354. * 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.
  8355. */
  8356. set shadowsExposure(value: number);
  8357. /**
  8358. * Returns the class name
  8359. * @returns The class name
  8360. */
  8361. getClassName(): string;
  8362. /**
  8363. * Binds the color curves to the shader.
  8364. * @param colorCurves The color curve to bind
  8365. * @param effect The effect to bind to
  8366. * @param positiveUniform The positive uniform shader parameter
  8367. * @param neutralUniform The neutral uniform shader parameter
  8368. * @param negativeUniform The negative uniform shader parameter
  8369. */
  8370. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  8371. /**
  8372. * Prepare the list of uniforms associated with the ColorCurves effects.
  8373. * @param uniformsList The list of uniforms used in the effect
  8374. */
  8375. static PrepareUniforms(uniformsList: string[]): void;
  8376. /**
  8377. * Returns color grading data based on a hue, density, saturation and exposure value.
  8378. * @param filterHue The hue of the color filter.
  8379. * @param filterDensity The density of the color filter.
  8380. * @param saturation The saturation.
  8381. * @param exposure The exposure.
  8382. * @param result The result data container.
  8383. */
  8384. private getColorGradingDataToRef;
  8385. /**
  8386. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  8387. * @param value The input slider value in range [-100,100].
  8388. * @returns Adjusted value.
  8389. */
  8390. private static applyColorGradingSliderNonlinear;
  8391. /**
  8392. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  8393. * @param hue The hue (H) input.
  8394. * @param saturation The saturation (S) input.
  8395. * @param brightness The brightness (B) input.
  8396. * @result An RGBA color represented as Vector4.
  8397. */
  8398. private static fromHSBToRef;
  8399. /**
  8400. * Returns a value clamped between min and max
  8401. * @param value The value to clamp
  8402. * @param min The minimum of value
  8403. * @param max The maximum of value
  8404. * @returns The clamped value.
  8405. */
  8406. private static clamp;
  8407. /**
  8408. * Clones the current color curve instance.
  8409. * @return The cloned curves
  8410. */
  8411. clone(): ColorCurves;
  8412. /**
  8413. * Serializes the current color curve instance to a json representation.
  8414. * @return a JSON representation
  8415. */
  8416. serialize(): any;
  8417. /**
  8418. * Parses the color curve from a json representation.
  8419. * @param source the JSON source to parse
  8420. * @return The parsed curves
  8421. */
  8422. static Parse(source: any): ColorCurves;
  8423. }
  8424. }
  8425. declare module "babylonjs/Materials/imageProcessingConfiguration" {
  8426. import { Observable } from "babylonjs/Misc/observable";
  8427. import { Nullable } from "babylonjs/types";
  8428. import { Color4 } from "babylonjs/Maths/math.color";
  8429. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  8430. import { Effect } from "babylonjs/Materials/effect";
  8431. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  8432. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  8433. /**
  8434. * Interface to follow in your material defines to integrate easily the
  8435. * Image proccessing functions.
  8436. * @hidden
  8437. */
  8438. export interface IImageProcessingConfigurationDefines {
  8439. IMAGEPROCESSING: boolean;
  8440. VIGNETTE: boolean;
  8441. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8442. VIGNETTEBLENDMODEOPAQUE: boolean;
  8443. TONEMAPPING: boolean;
  8444. TONEMAPPING_ACES: boolean;
  8445. CONTRAST: boolean;
  8446. EXPOSURE: boolean;
  8447. COLORCURVES: boolean;
  8448. COLORGRADING: boolean;
  8449. COLORGRADING3D: boolean;
  8450. SAMPLER3DGREENDEPTH: boolean;
  8451. SAMPLER3DBGRMAP: boolean;
  8452. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8453. }
  8454. /**
  8455. * @hidden
  8456. */
  8457. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  8458. IMAGEPROCESSING: boolean;
  8459. VIGNETTE: boolean;
  8460. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8461. VIGNETTEBLENDMODEOPAQUE: boolean;
  8462. TONEMAPPING: boolean;
  8463. TONEMAPPING_ACES: boolean;
  8464. CONTRAST: boolean;
  8465. COLORCURVES: boolean;
  8466. COLORGRADING: boolean;
  8467. COLORGRADING3D: boolean;
  8468. SAMPLER3DGREENDEPTH: boolean;
  8469. SAMPLER3DBGRMAP: boolean;
  8470. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8471. EXPOSURE: boolean;
  8472. constructor();
  8473. }
  8474. /**
  8475. * This groups together the common properties used for image processing either in direct forward pass
  8476. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8477. * or not.
  8478. */
  8479. export class ImageProcessingConfiguration {
  8480. /**
  8481. * Default tone mapping applied in BabylonJS.
  8482. */
  8483. static readonly TONEMAPPING_STANDARD: number;
  8484. /**
  8485. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8486. * to other engines rendering to increase portability.
  8487. */
  8488. static readonly TONEMAPPING_ACES: number;
  8489. /**
  8490. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8491. */
  8492. colorCurves: Nullable<ColorCurves>;
  8493. private _colorCurvesEnabled;
  8494. /**
  8495. * Gets wether the color curves effect is enabled.
  8496. */
  8497. get colorCurvesEnabled(): boolean;
  8498. /**
  8499. * Sets wether the color curves effect is enabled.
  8500. */
  8501. set colorCurvesEnabled(value: boolean);
  8502. private _colorGradingTexture;
  8503. /**
  8504. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8505. */
  8506. get colorGradingTexture(): Nullable<BaseTexture>;
  8507. /**
  8508. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8509. */
  8510. set colorGradingTexture(value: Nullable<BaseTexture>);
  8511. private _colorGradingEnabled;
  8512. /**
  8513. * Gets wether the color grading effect is enabled.
  8514. */
  8515. get colorGradingEnabled(): boolean;
  8516. /**
  8517. * Sets wether the color grading effect is enabled.
  8518. */
  8519. set colorGradingEnabled(value: boolean);
  8520. private _colorGradingWithGreenDepth;
  8521. /**
  8522. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8523. */
  8524. get colorGradingWithGreenDepth(): boolean;
  8525. /**
  8526. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8527. */
  8528. set colorGradingWithGreenDepth(value: boolean);
  8529. private _colorGradingBGR;
  8530. /**
  8531. * Gets wether the color grading texture contains BGR values.
  8532. */
  8533. get colorGradingBGR(): boolean;
  8534. /**
  8535. * Sets wether the color grading texture contains BGR values.
  8536. */
  8537. set colorGradingBGR(value: boolean);
  8538. /** @hidden */
  8539. _exposure: number;
  8540. /**
  8541. * Gets the Exposure used in the effect.
  8542. */
  8543. get exposure(): number;
  8544. /**
  8545. * Sets the Exposure used in the effect.
  8546. */
  8547. set exposure(value: number);
  8548. private _toneMappingEnabled;
  8549. /**
  8550. * Gets wether the tone mapping effect is enabled.
  8551. */
  8552. get toneMappingEnabled(): boolean;
  8553. /**
  8554. * Sets wether the tone mapping effect is enabled.
  8555. */
  8556. set toneMappingEnabled(value: boolean);
  8557. private _toneMappingType;
  8558. /**
  8559. * Gets the type of tone mapping effect.
  8560. */
  8561. get toneMappingType(): number;
  8562. /**
  8563. * Sets the type of tone mapping effect used in BabylonJS.
  8564. */
  8565. set toneMappingType(value: number);
  8566. protected _contrast: number;
  8567. /**
  8568. * Gets the contrast used in the effect.
  8569. */
  8570. get contrast(): number;
  8571. /**
  8572. * Sets the contrast used in the effect.
  8573. */
  8574. set contrast(value: number);
  8575. /**
  8576. * Vignette stretch size.
  8577. */
  8578. vignetteStretch: number;
  8579. /**
  8580. * Vignette centre X Offset.
  8581. */
  8582. vignetteCentreX: number;
  8583. /**
  8584. * Vignette centre Y Offset.
  8585. */
  8586. vignetteCentreY: number;
  8587. /**
  8588. * Vignette weight or intensity of the vignette effect.
  8589. */
  8590. vignetteWeight: number;
  8591. /**
  8592. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8593. * if vignetteEnabled is set to true.
  8594. */
  8595. vignetteColor: Color4;
  8596. /**
  8597. * Camera field of view used by the Vignette effect.
  8598. */
  8599. vignetteCameraFov: number;
  8600. private _vignetteBlendMode;
  8601. /**
  8602. * Gets the vignette blend mode allowing different kind of effect.
  8603. */
  8604. get vignetteBlendMode(): number;
  8605. /**
  8606. * Sets the vignette blend mode allowing different kind of effect.
  8607. */
  8608. set vignetteBlendMode(value: number);
  8609. private _vignetteEnabled;
  8610. /**
  8611. * Gets wether the vignette effect is enabled.
  8612. */
  8613. get vignetteEnabled(): boolean;
  8614. /**
  8615. * Sets wether the vignette effect is enabled.
  8616. */
  8617. set vignetteEnabled(value: boolean);
  8618. private _applyByPostProcess;
  8619. /**
  8620. * Gets wether the image processing is applied through a post process or not.
  8621. */
  8622. get applyByPostProcess(): boolean;
  8623. /**
  8624. * Sets wether the image processing is applied through a post process or not.
  8625. */
  8626. set applyByPostProcess(value: boolean);
  8627. private _isEnabled;
  8628. /**
  8629. * Gets wether the image processing is enabled or not.
  8630. */
  8631. get isEnabled(): boolean;
  8632. /**
  8633. * Sets wether the image processing is enabled or not.
  8634. */
  8635. set isEnabled(value: boolean);
  8636. /**
  8637. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8638. */
  8639. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8640. /**
  8641. * Method called each time the image processing information changes requires to recompile the effect.
  8642. */
  8643. protected _updateParameters(): void;
  8644. /**
  8645. * Gets the current class name.
  8646. * @return "ImageProcessingConfiguration"
  8647. */
  8648. getClassName(): string;
  8649. /**
  8650. * Prepare the list of uniforms associated with the Image Processing effects.
  8651. * @param uniforms The list of uniforms used in the effect
  8652. * @param defines the list of defines currently in use
  8653. */
  8654. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8655. /**
  8656. * Prepare the list of samplers associated with the Image Processing effects.
  8657. * @param samplersList The list of uniforms used in the effect
  8658. * @param defines the list of defines currently in use
  8659. */
  8660. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8661. /**
  8662. * Prepare the list of defines associated to the shader.
  8663. * @param defines the list of defines to complete
  8664. * @param forPostProcess Define if we are currently in post process mode or not
  8665. */
  8666. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8667. /**
  8668. * Returns true if all the image processing information are ready.
  8669. * @returns True if ready, otherwise, false
  8670. */
  8671. isReady(): boolean;
  8672. /**
  8673. * Binds the image processing to the shader.
  8674. * @param effect The effect to bind to
  8675. * @param overrideAspectRatio Override the aspect ratio of the effect
  8676. */
  8677. bind(effect: Effect, overrideAspectRatio?: number): void;
  8678. /**
  8679. * Clones the current image processing instance.
  8680. * @return The cloned image processing
  8681. */
  8682. clone(): ImageProcessingConfiguration;
  8683. /**
  8684. * Serializes the current image processing instance to a json representation.
  8685. * @return a JSON representation
  8686. */
  8687. serialize(): any;
  8688. /**
  8689. * Parses the image processing from a json representation.
  8690. * @param source the JSON source to parse
  8691. * @return The parsed image processing
  8692. */
  8693. static Parse(source: any): ImageProcessingConfiguration;
  8694. private static _VIGNETTEMODE_MULTIPLY;
  8695. private static _VIGNETTEMODE_OPAQUE;
  8696. /**
  8697. * Used to apply the vignette as a mix with the pixel color.
  8698. */
  8699. static get VIGNETTEMODE_MULTIPLY(): number;
  8700. /**
  8701. * Used to apply the vignette as a replacement of the pixel color.
  8702. */
  8703. static get VIGNETTEMODE_OPAQUE(): number;
  8704. }
  8705. }
  8706. declare module "babylonjs/Shaders/postprocess.vertex" {
  8707. /** @hidden */
  8708. export var postprocessVertexShader: {
  8709. name: string;
  8710. shader: string;
  8711. };
  8712. }
  8713. declare module "babylonjs/Engines/Extensions/engine.renderTarget" {
  8714. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  8715. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  8716. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  8717. /**
  8718. * Type used to define a render target texture size (either with a number or with a rect width and height)
  8719. */
  8720. export type RenderTargetTextureSize = number | {
  8721. width: number;
  8722. height: number;
  8723. layers?: number;
  8724. };
  8725. module "babylonjs/Engines/thinEngine" {
  8726. interface ThinEngine {
  8727. /**
  8728. * Creates a new render target texture
  8729. * @param size defines the size of the texture
  8730. * @param options defines the options used to create the texture
  8731. * @returns a new render target texture stored in an InternalTexture
  8732. */
  8733. createRenderTargetTexture(size: RenderTargetTextureSize, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8734. /**
  8735. * Creates a depth stencil texture.
  8736. * This is only available in WebGL 2 or with the depth texture extension available.
  8737. * @param size The size of face edge in the texture.
  8738. * @param options The options defining the texture.
  8739. * @returns The texture
  8740. */
  8741. createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): InternalTexture;
  8742. /** @hidden */
  8743. _createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): InternalTexture;
  8744. }
  8745. }
  8746. }
  8747. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes" {
  8748. /**
  8749. * Defines the kind of connection point for node based material
  8750. */
  8751. export enum NodeMaterialBlockConnectionPointTypes {
  8752. /** Float */
  8753. Float = 1,
  8754. /** Int */
  8755. Int = 2,
  8756. /** Vector2 */
  8757. Vector2 = 4,
  8758. /** Vector3 */
  8759. Vector3 = 8,
  8760. /** Vector4 */
  8761. Vector4 = 16,
  8762. /** Color3 */
  8763. Color3 = 32,
  8764. /** Color4 */
  8765. Color4 = 64,
  8766. /** Matrix */
  8767. Matrix = 128,
  8768. /** Custom object */
  8769. Object = 256,
  8770. /** Detect type based on connection */
  8771. AutoDetect = 1024,
  8772. /** Output type that will be defined by input type */
  8773. BasedOnInput = 2048
  8774. }
  8775. }
  8776. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets" {
  8777. /**
  8778. * Enum used to define the target of a block
  8779. */
  8780. export enum NodeMaterialBlockTargets {
  8781. /** Vertex shader */
  8782. Vertex = 1,
  8783. /** Fragment shader */
  8784. Fragment = 2,
  8785. /** Neutral */
  8786. Neutral = 4,
  8787. /** Vertex and Fragment */
  8788. VertexAndFragment = 3
  8789. }
  8790. }
  8791. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode" {
  8792. /**
  8793. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  8794. */
  8795. export enum NodeMaterialBlockConnectionPointMode {
  8796. /** Value is an uniform */
  8797. Uniform = 0,
  8798. /** Value is a mesh attribute */
  8799. Attribute = 1,
  8800. /** Value is a varying between vertex and fragment shaders */
  8801. Varying = 2,
  8802. /** Mode is undefined */
  8803. Undefined = 3
  8804. }
  8805. }
  8806. declare module "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues" {
  8807. /**
  8808. * Enum used to define system values e.g. values automatically provided by the system
  8809. */
  8810. export enum NodeMaterialSystemValues {
  8811. /** World */
  8812. World = 1,
  8813. /** View */
  8814. View = 2,
  8815. /** Projection */
  8816. Projection = 3,
  8817. /** ViewProjection */
  8818. ViewProjection = 4,
  8819. /** WorldView */
  8820. WorldView = 5,
  8821. /** WorldViewProjection */
  8822. WorldViewProjection = 6,
  8823. /** CameraPosition */
  8824. CameraPosition = 7,
  8825. /** Fog Color */
  8826. FogColor = 8,
  8827. /** Delta time */
  8828. DeltaTime = 9
  8829. }
  8830. }
  8831. declare module "babylonjs/Maths/math.axis" {
  8832. import { Vector3 } from "babylonjs/Maths/math.vector";
  8833. /** Defines supported spaces */
  8834. export enum Space {
  8835. /** Local (object) space */
  8836. LOCAL = 0,
  8837. /** World space */
  8838. WORLD = 1,
  8839. /** Bone space */
  8840. BONE = 2
  8841. }
  8842. /** Defines the 3 main axes */
  8843. export class Axis {
  8844. /** X axis */
  8845. static X: Vector3;
  8846. /** Y axis */
  8847. static Y: Vector3;
  8848. /** Z axis */
  8849. static Z: Vector3;
  8850. }
  8851. }
  8852. declare module "babylonjs/Maths/math.frustum" {
  8853. import { Matrix } from "babylonjs/Maths/math.vector";
  8854. import { DeepImmutable } from "babylonjs/types";
  8855. import { Plane } from "babylonjs/Maths/math.plane";
  8856. /**
  8857. * Represents a camera frustum
  8858. */
  8859. export class Frustum {
  8860. /**
  8861. * Gets the planes representing the frustum
  8862. * @param transform matrix to be applied to the returned planes
  8863. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  8864. */
  8865. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  8866. /**
  8867. * Gets the near frustum plane transformed by the transform matrix
  8868. * @param transform transformation matrix to be applied to the resulting frustum plane
  8869. * @param frustumPlane the resuling frustum plane
  8870. */
  8871. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8872. /**
  8873. * Gets the far frustum plane transformed by the transform matrix
  8874. * @param transform transformation matrix to be applied to the resulting frustum plane
  8875. * @param frustumPlane the resuling frustum plane
  8876. */
  8877. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8878. /**
  8879. * Gets the left frustum plane transformed by the transform matrix
  8880. * @param transform transformation matrix to be applied to the resulting frustum plane
  8881. * @param frustumPlane the resuling frustum plane
  8882. */
  8883. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8884. /**
  8885. * Gets the right frustum plane transformed by the transform matrix
  8886. * @param transform transformation matrix to be applied to the resulting frustum plane
  8887. * @param frustumPlane the resuling frustum plane
  8888. */
  8889. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8890. /**
  8891. * Gets the top frustum plane transformed by the transform matrix
  8892. * @param transform transformation matrix to be applied to the resulting frustum plane
  8893. * @param frustumPlane the resuling frustum plane
  8894. */
  8895. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8896. /**
  8897. * Gets the bottom frustum plane transformed by the transform matrix
  8898. * @param transform transformation matrix to be applied to the resulting frustum plane
  8899. * @param frustumPlane the resuling frustum plane
  8900. */
  8901. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8902. /**
  8903. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  8904. * @param transform transformation matrix to be applied to the resulting frustum planes
  8905. * @param frustumPlanes the resuling frustum planes
  8906. */
  8907. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  8908. }
  8909. }
  8910. declare module "babylonjs/Maths/math.size" {
  8911. /**
  8912. * Interface for the size containing width and height
  8913. */
  8914. export interface ISize {
  8915. /**
  8916. * Width
  8917. */
  8918. width: number;
  8919. /**
  8920. * Heighht
  8921. */
  8922. height: number;
  8923. }
  8924. /**
  8925. * Size containing widht and height
  8926. */
  8927. export class Size implements ISize {
  8928. /**
  8929. * Width
  8930. */
  8931. width: number;
  8932. /**
  8933. * Height
  8934. */
  8935. height: number;
  8936. /**
  8937. * Creates a Size object from the given width and height (floats).
  8938. * @param width width of the new size
  8939. * @param height height of the new size
  8940. */
  8941. constructor(width: number, height: number);
  8942. /**
  8943. * Returns a string with the Size width and height
  8944. * @returns a string with the Size width and height
  8945. */
  8946. toString(): string;
  8947. /**
  8948. * "Size"
  8949. * @returns the string "Size"
  8950. */
  8951. getClassName(): string;
  8952. /**
  8953. * Returns the Size hash code.
  8954. * @returns a hash code for a unique width and height
  8955. */
  8956. getHashCode(): number;
  8957. /**
  8958. * Updates the current size from the given one.
  8959. * @param src the given size
  8960. */
  8961. copyFrom(src: Size): void;
  8962. /**
  8963. * Updates in place the current Size from the given floats.
  8964. * @param width width of the new size
  8965. * @param height height of the new size
  8966. * @returns the updated Size.
  8967. */
  8968. copyFromFloats(width: number, height: number): Size;
  8969. /**
  8970. * Updates in place the current Size from the given floats.
  8971. * @param width width to set
  8972. * @param height height to set
  8973. * @returns the updated Size.
  8974. */
  8975. set(width: number, height: number): Size;
  8976. /**
  8977. * Multiplies the width and height by numbers
  8978. * @param w factor to multiple the width by
  8979. * @param h factor to multiple the height by
  8980. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  8981. */
  8982. multiplyByFloats(w: number, h: number): Size;
  8983. /**
  8984. * Clones the size
  8985. * @returns a new Size copied from the given one.
  8986. */
  8987. clone(): Size;
  8988. /**
  8989. * True if the current Size and the given one width and height are strictly equal.
  8990. * @param other the other size to compare against
  8991. * @returns True if the current Size and the given one width and height are strictly equal.
  8992. */
  8993. equals(other: Size): boolean;
  8994. /**
  8995. * The surface of the Size : width * height (float).
  8996. */
  8997. get surface(): number;
  8998. /**
  8999. * Create a new size of zero
  9000. * @returns a new Size set to (0.0, 0.0)
  9001. */
  9002. static Zero(): Size;
  9003. /**
  9004. * Sums the width and height of two sizes
  9005. * @param otherSize size to add to this size
  9006. * @returns a new Size set as the addition result of the current Size and the given one.
  9007. */
  9008. add(otherSize: Size): Size;
  9009. /**
  9010. * Subtracts the width and height of two
  9011. * @param otherSize size to subtract to this size
  9012. * @returns a new Size set as the subtraction result of the given one from the current Size.
  9013. */
  9014. subtract(otherSize: Size): Size;
  9015. /**
  9016. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  9017. * @param start starting size to lerp between
  9018. * @param end end size to lerp between
  9019. * @param amount amount to lerp between the start and end values
  9020. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  9021. */
  9022. static Lerp(start: Size, end: Size, amount: number): Size;
  9023. }
  9024. }
  9025. declare module "babylonjs/Maths/math.vertexFormat" {
  9026. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  9027. /**
  9028. * Contains position and normal vectors for a vertex
  9029. */
  9030. export class PositionNormalVertex {
  9031. /** the position of the vertex (defaut: 0,0,0) */
  9032. position: Vector3;
  9033. /** the normal of the vertex (defaut: 0,1,0) */
  9034. normal: Vector3;
  9035. /**
  9036. * Creates a PositionNormalVertex
  9037. * @param position the position of the vertex (defaut: 0,0,0)
  9038. * @param normal the normal of the vertex (defaut: 0,1,0)
  9039. */
  9040. constructor(
  9041. /** the position of the vertex (defaut: 0,0,0) */
  9042. position?: Vector3,
  9043. /** the normal of the vertex (defaut: 0,1,0) */
  9044. normal?: Vector3);
  9045. /**
  9046. * Clones the PositionNormalVertex
  9047. * @returns the cloned PositionNormalVertex
  9048. */
  9049. clone(): PositionNormalVertex;
  9050. }
  9051. /**
  9052. * Contains position, normal and uv vectors for a vertex
  9053. */
  9054. export class PositionNormalTextureVertex {
  9055. /** the position of the vertex (defaut: 0,0,0) */
  9056. position: Vector3;
  9057. /** the normal of the vertex (defaut: 0,1,0) */
  9058. normal: Vector3;
  9059. /** the uv of the vertex (default: 0,0) */
  9060. uv: Vector2;
  9061. /**
  9062. * Creates a PositionNormalTextureVertex
  9063. * @param position the position of the vertex (defaut: 0,0,0)
  9064. * @param normal the normal of the vertex (defaut: 0,1,0)
  9065. * @param uv the uv of the vertex (default: 0,0)
  9066. */
  9067. constructor(
  9068. /** the position of the vertex (defaut: 0,0,0) */
  9069. position?: Vector3,
  9070. /** the normal of the vertex (defaut: 0,1,0) */
  9071. normal?: Vector3,
  9072. /** the uv of the vertex (default: 0,0) */
  9073. uv?: Vector2);
  9074. /**
  9075. * Clones the PositionNormalTextureVertex
  9076. * @returns the cloned PositionNormalTextureVertex
  9077. */
  9078. clone(): PositionNormalTextureVertex;
  9079. }
  9080. }
  9081. declare module "babylonjs/Maths/math" {
  9082. export * from "babylonjs/Maths/math.axis";
  9083. export * from "babylonjs/Maths/math.color";
  9084. export * from "babylonjs/Maths/math.constants";
  9085. export * from "babylonjs/Maths/math.frustum";
  9086. export * from "babylonjs/Maths/math.path";
  9087. export * from "babylonjs/Maths/math.plane";
  9088. export * from "babylonjs/Maths/math.size";
  9089. export * from "babylonjs/Maths/math.vector";
  9090. export * from "babylonjs/Maths/math.vertexFormat";
  9091. export * from "babylonjs/Maths/math.viewport";
  9092. }
  9093. declare module "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes" {
  9094. /**
  9095. * Enum defining the type of animations supported by InputBlock
  9096. */
  9097. export enum AnimatedInputBlockTypes {
  9098. /** No animation */
  9099. None = 0,
  9100. /** Time based animation. Will only work for floats */
  9101. Time = 1
  9102. }
  9103. }
  9104. declare module "babylonjs/Lights/shadowLight" {
  9105. import { Camera } from "babylonjs/Cameras/camera";
  9106. import { Scene } from "babylonjs/scene";
  9107. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  9108. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9109. import { Light } from "babylonjs/Lights/light";
  9110. /**
  9111. * Interface describing all the common properties and methods a shadow light needs to implement.
  9112. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  9113. * as well as binding the different shadow properties to the effects.
  9114. */
  9115. export interface IShadowLight extends Light {
  9116. /**
  9117. * The light id in the scene (used in scene.findLighById for instance)
  9118. */
  9119. id: string;
  9120. /**
  9121. * The position the shdow will be casted from.
  9122. */
  9123. position: Vector3;
  9124. /**
  9125. * In 2d mode (needCube being false), the direction used to cast the shadow.
  9126. */
  9127. direction: Vector3;
  9128. /**
  9129. * The transformed position. Position of the light in world space taking parenting in account.
  9130. */
  9131. transformedPosition: Vector3;
  9132. /**
  9133. * The transformed direction. Direction of the light in world space taking parenting in account.
  9134. */
  9135. transformedDirection: Vector3;
  9136. /**
  9137. * The friendly name of the light in the scene.
  9138. */
  9139. name: string;
  9140. /**
  9141. * Defines the shadow projection clipping minimum z value.
  9142. */
  9143. shadowMinZ: number;
  9144. /**
  9145. * Defines the shadow projection clipping maximum z value.
  9146. */
  9147. shadowMaxZ: number;
  9148. /**
  9149. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9150. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9151. */
  9152. computeTransformedInformation(): boolean;
  9153. /**
  9154. * Gets the scene the light belongs to.
  9155. * @returns The scene
  9156. */
  9157. getScene(): Scene;
  9158. /**
  9159. * Callback defining a custom Projection Matrix Builder.
  9160. * This can be used to override the default projection matrix computation.
  9161. */
  9162. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9163. /**
  9164. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9165. * @param matrix The materix to updated with the projection information
  9166. * @param viewMatrix The transform matrix of the light
  9167. * @param renderList The list of mesh to render in the map
  9168. * @returns The current light
  9169. */
  9170. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9171. /**
  9172. * Gets the current depth scale used in ESM.
  9173. * @returns The scale
  9174. */
  9175. getDepthScale(): number;
  9176. /**
  9177. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9178. * @returns true if a cube texture needs to be use
  9179. */
  9180. needCube(): boolean;
  9181. /**
  9182. * Detects if the projection matrix requires to be recomputed this frame.
  9183. * @returns true if it requires to be recomputed otherwise, false.
  9184. */
  9185. needProjectionMatrixCompute(): boolean;
  9186. /**
  9187. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9188. */
  9189. forceProjectionMatrixCompute(): void;
  9190. /**
  9191. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9192. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9193. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9194. */
  9195. getShadowDirection(faceIndex?: number): Vector3;
  9196. /**
  9197. * Gets the minZ used for shadow according to both the scene and the light.
  9198. * @param activeCamera The camera we are returning the min for
  9199. * @returns the depth min z
  9200. */
  9201. getDepthMinZ(activeCamera: Camera): number;
  9202. /**
  9203. * Gets the maxZ used for shadow according to both the scene and the light.
  9204. * @param activeCamera The camera we are returning the max for
  9205. * @returns the depth max z
  9206. */
  9207. getDepthMaxZ(activeCamera: Camera): number;
  9208. }
  9209. /**
  9210. * Base implementation IShadowLight
  9211. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  9212. */
  9213. export abstract class ShadowLight extends Light implements IShadowLight {
  9214. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  9215. protected _position: Vector3;
  9216. protected _setPosition(value: Vector3): void;
  9217. /**
  9218. * Sets the position the shadow will be casted from. Also use as the light position for both
  9219. * point and spot lights.
  9220. */
  9221. get position(): Vector3;
  9222. /**
  9223. * Sets the position the shadow will be casted from. Also use as the light position for both
  9224. * point and spot lights.
  9225. */
  9226. set position(value: Vector3);
  9227. protected _direction: Vector3;
  9228. protected _setDirection(value: Vector3): void;
  9229. /**
  9230. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  9231. * Also use as the light direction on spot and directional lights.
  9232. */
  9233. get direction(): Vector3;
  9234. /**
  9235. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  9236. * Also use as the light direction on spot and directional lights.
  9237. */
  9238. set direction(value: Vector3);
  9239. protected _shadowMinZ: number;
  9240. /**
  9241. * Gets the shadow projection clipping minimum z value.
  9242. */
  9243. get shadowMinZ(): number;
  9244. /**
  9245. * Sets the shadow projection clipping minimum z value.
  9246. */
  9247. set shadowMinZ(value: number);
  9248. protected _shadowMaxZ: number;
  9249. /**
  9250. * Sets the shadow projection clipping maximum z value.
  9251. */
  9252. get shadowMaxZ(): number;
  9253. /**
  9254. * Gets the shadow projection clipping maximum z value.
  9255. */
  9256. set shadowMaxZ(value: number);
  9257. /**
  9258. * Callback defining a custom Projection Matrix Builder.
  9259. * This can be used to override the default projection matrix computation.
  9260. */
  9261. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9262. /**
  9263. * The transformed position. Position of the light in world space taking parenting in account.
  9264. */
  9265. transformedPosition: Vector3;
  9266. /**
  9267. * The transformed direction. Direction of the light in world space taking parenting in account.
  9268. */
  9269. transformedDirection: Vector3;
  9270. private _needProjectionMatrixCompute;
  9271. /**
  9272. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9273. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9274. */
  9275. computeTransformedInformation(): boolean;
  9276. /**
  9277. * Return the depth scale used for the shadow map.
  9278. * @returns the depth scale.
  9279. */
  9280. getDepthScale(): number;
  9281. /**
  9282. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9283. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9284. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9285. */
  9286. getShadowDirection(faceIndex?: number): Vector3;
  9287. /**
  9288. * Returns the ShadowLight absolute position in the World.
  9289. * @returns the position vector in world space
  9290. */
  9291. getAbsolutePosition(): Vector3;
  9292. /**
  9293. * Sets the ShadowLight direction toward the passed target.
  9294. * @param target The point to target in local space
  9295. * @returns the updated ShadowLight direction
  9296. */
  9297. setDirectionToTarget(target: Vector3): Vector3;
  9298. /**
  9299. * Returns the light rotation in euler definition.
  9300. * @returns the x y z rotation in local space.
  9301. */
  9302. getRotation(): Vector3;
  9303. /**
  9304. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9305. * @returns true if a cube texture needs to be use
  9306. */
  9307. needCube(): boolean;
  9308. /**
  9309. * Detects if the projection matrix requires to be recomputed this frame.
  9310. * @returns true if it requires to be recomputed otherwise, false.
  9311. */
  9312. needProjectionMatrixCompute(): boolean;
  9313. /**
  9314. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9315. */
  9316. forceProjectionMatrixCompute(): void;
  9317. /** @hidden */
  9318. _initCache(): void;
  9319. /** @hidden */
  9320. _isSynchronized(): boolean;
  9321. /**
  9322. * Computes the world matrix of the node
  9323. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9324. * @returns the world matrix
  9325. */
  9326. computeWorldMatrix(force?: boolean): Matrix;
  9327. /**
  9328. * Gets the minZ used for shadow according to both the scene and the light.
  9329. * @param activeCamera The camera we are returning the min for
  9330. * @returns the depth min z
  9331. */
  9332. getDepthMinZ(activeCamera: Camera): number;
  9333. /**
  9334. * Gets the maxZ used for shadow according to both the scene and the light.
  9335. * @param activeCamera The camera we are returning the max for
  9336. * @returns the depth max z
  9337. */
  9338. getDepthMaxZ(activeCamera: Camera): number;
  9339. /**
  9340. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9341. * @param matrix The materix to updated with the projection information
  9342. * @param viewMatrix The transform matrix of the light
  9343. * @param renderList The list of mesh to render in the map
  9344. * @returns The current light
  9345. */
  9346. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9347. }
  9348. }
  9349. declare module "babylonjs/Shaders/ShadersInclude/packingFunctions" {
  9350. /** @hidden */
  9351. export var packingFunctions: {
  9352. name: string;
  9353. shader: string;
  9354. };
  9355. }
  9356. declare module "babylonjs/Shaders/ShadersInclude/bayerDitherFunctions" {
  9357. /** @hidden */
  9358. export var bayerDitherFunctions: {
  9359. name: string;
  9360. shader: string;
  9361. };
  9362. }
  9363. declare module "babylonjs/Shaders/ShadersInclude/shadowMapFragmentDeclaration" {
  9364. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  9365. import "babylonjs/Shaders/ShadersInclude/bayerDitherFunctions";
  9366. /** @hidden */
  9367. export var shadowMapFragmentDeclaration: {
  9368. name: string;
  9369. shader: string;
  9370. };
  9371. }
  9372. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration" {
  9373. /** @hidden */
  9374. export var clipPlaneFragmentDeclaration: {
  9375. name: string;
  9376. shader: string;
  9377. };
  9378. }
  9379. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragment" {
  9380. /** @hidden */
  9381. export var clipPlaneFragment: {
  9382. name: string;
  9383. shader: string;
  9384. };
  9385. }
  9386. declare module "babylonjs/Shaders/ShadersInclude/shadowMapFragment" {
  9387. /** @hidden */
  9388. export var shadowMapFragment: {
  9389. name: string;
  9390. shader: string;
  9391. };
  9392. }
  9393. declare module "babylonjs/Shaders/shadowMap.fragment" {
  9394. import "babylonjs/Shaders/ShadersInclude/shadowMapFragmentDeclaration";
  9395. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  9396. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  9397. import "babylonjs/Shaders/ShadersInclude/shadowMapFragment";
  9398. /** @hidden */
  9399. export var shadowMapPixelShader: {
  9400. name: string;
  9401. shader: string;
  9402. };
  9403. }
  9404. declare module "babylonjs/Shaders/ShadersInclude/bonesDeclaration" {
  9405. /** @hidden */
  9406. export var bonesDeclaration: {
  9407. name: string;
  9408. shader: string;
  9409. };
  9410. }
  9411. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration" {
  9412. /** @hidden */
  9413. export var morphTargetsVertexGlobalDeclaration: {
  9414. name: string;
  9415. shader: string;
  9416. };
  9417. }
  9418. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration" {
  9419. /** @hidden */
  9420. export var morphTargetsVertexDeclaration: {
  9421. name: string;
  9422. shader: string;
  9423. };
  9424. }
  9425. declare module "babylonjs/Shaders/ShadersInclude/instancesDeclaration" {
  9426. /** @hidden */
  9427. export var instancesDeclaration: {
  9428. name: string;
  9429. shader: string;
  9430. };
  9431. }
  9432. declare module "babylonjs/Shaders/ShadersInclude/helperFunctions" {
  9433. /** @hidden */
  9434. export var helperFunctions: {
  9435. name: string;
  9436. shader: string;
  9437. };
  9438. }
  9439. declare module "babylonjs/Shaders/ShadersInclude/shadowMapVertexDeclaration" {
  9440. /** @hidden */
  9441. export var shadowMapVertexDeclaration: {
  9442. name: string;
  9443. shader: string;
  9444. };
  9445. }
  9446. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration" {
  9447. /** @hidden */
  9448. export var clipPlaneVertexDeclaration: {
  9449. name: string;
  9450. shader: string;
  9451. };
  9452. }
  9453. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertex" {
  9454. /** @hidden */
  9455. export var morphTargetsVertex: {
  9456. name: string;
  9457. shader: string;
  9458. };
  9459. }
  9460. declare module "babylonjs/Shaders/ShadersInclude/instancesVertex" {
  9461. /** @hidden */
  9462. export var instancesVertex: {
  9463. name: string;
  9464. shader: string;
  9465. };
  9466. }
  9467. declare module "babylonjs/Shaders/ShadersInclude/bonesVertex" {
  9468. /** @hidden */
  9469. export var bonesVertex: {
  9470. name: string;
  9471. shader: string;
  9472. };
  9473. }
  9474. declare module "babylonjs/Shaders/ShadersInclude/shadowMapVertexNormalBias" {
  9475. /** @hidden */
  9476. export var shadowMapVertexNormalBias: {
  9477. name: string;
  9478. shader: string;
  9479. };
  9480. }
  9481. declare module "babylonjs/Shaders/ShadersInclude/shadowMapVertexMetric" {
  9482. /** @hidden */
  9483. export var shadowMapVertexMetric: {
  9484. name: string;
  9485. shader: string;
  9486. };
  9487. }
  9488. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertex" {
  9489. /** @hidden */
  9490. export var clipPlaneVertex: {
  9491. name: string;
  9492. shader: string;
  9493. };
  9494. }
  9495. declare module "babylonjs/Shaders/shadowMap.vertex" {
  9496. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  9497. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  9498. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  9499. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  9500. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  9501. import "babylonjs/Shaders/ShadersInclude/shadowMapVertexDeclaration";
  9502. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  9503. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  9504. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  9505. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  9506. import "babylonjs/Shaders/ShadersInclude/shadowMapVertexNormalBias";
  9507. import "babylonjs/Shaders/ShadersInclude/shadowMapVertexMetric";
  9508. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  9509. /** @hidden */
  9510. export var shadowMapVertexShader: {
  9511. name: string;
  9512. shader: string;
  9513. };
  9514. }
  9515. declare module "babylonjs/Shaders/depthBoxBlur.fragment" {
  9516. /** @hidden */
  9517. export var depthBoxBlurPixelShader: {
  9518. name: string;
  9519. shader: string;
  9520. };
  9521. }
  9522. declare module "babylonjs/Shaders/ShadersInclude/shadowMapFragmentSoftTransparentShadow" {
  9523. /** @hidden */
  9524. export var shadowMapFragmentSoftTransparentShadow: {
  9525. name: string;
  9526. shader: string;
  9527. };
  9528. }
  9529. declare module "babylonjs/Materials/effectFallbacks" {
  9530. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  9531. import { Effect } from "babylonjs/Materials/effect";
  9532. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9533. /**
  9534. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  9535. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  9536. */
  9537. export class EffectFallbacks implements IEffectFallbacks {
  9538. private _defines;
  9539. private _currentRank;
  9540. private _maxRank;
  9541. private _mesh;
  9542. /**
  9543. * Removes the fallback from the bound mesh.
  9544. */
  9545. unBindMesh(): void;
  9546. /**
  9547. * Adds a fallback on the specified property.
  9548. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9549. * @param define The name of the define in the shader
  9550. */
  9551. addFallback(rank: number, define: string): void;
  9552. /**
  9553. * Sets the mesh to use CPU skinning when needing to fallback.
  9554. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9555. * @param mesh The mesh to use the fallbacks.
  9556. */
  9557. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  9558. /**
  9559. * Checks to see if more fallbacks are still availible.
  9560. */
  9561. get hasMoreFallbacks(): boolean;
  9562. /**
  9563. * Removes the defines that should be removed when falling back.
  9564. * @param currentDefines defines the current define statements for the shader.
  9565. * @param effect defines the current effect we try to compile
  9566. * @returns The resulting defines with defines of the current rank removed.
  9567. */
  9568. reduce(currentDefines: string, effect: Effect): string;
  9569. }
  9570. }
  9571. declare module "babylonjs/Actions/action" {
  9572. import { Observable } from "babylonjs/Misc/observable";
  9573. import { Condition } from "babylonjs/Actions/condition";
  9574. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  9575. import { Nullable } from "babylonjs/types";
  9576. import { Scene } from "babylonjs/scene";
  9577. import { ActionManager } from "babylonjs/Actions/actionManager";
  9578. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  9579. import { Node } from "babylonjs/node";
  9580. /**
  9581. * Interface used to define Action
  9582. */
  9583. export interface IAction {
  9584. /**
  9585. * Trigger for the action
  9586. */
  9587. trigger: number;
  9588. /** Options of the trigger */
  9589. triggerOptions: any;
  9590. /**
  9591. * Gets the trigger parameters
  9592. * @returns the trigger parameters
  9593. */
  9594. getTriggerParameter(): any;
  9595. /**
  9596. * Internal only - executes current action event
  9597. * @hidden
  9598. */
  9599. _executeCurrent(evt?: ActionEvent): void;
  9600. /**
  9601. * Serialize placeholder for child classes
  9602. * @param parent of child
  9603. * @returns the serialized object
  9604. */
  9605. serialize(parent: any): any;
  9606. /**
  9607. * Internal only
  9608. * @hidden
  9609. */
  9610. _prepare(): void;
  9611. /**
  9612. * Internal only - manager for action
  9613. * @hidden
  9614. */
  9615. _actionManager: Nullable<AbstractActionManager>;
  9616. /**
  9617. * Adds action to chain of actions, may be a DoNothingAction
  9618. * @param action defines the next action to execute
  9619. * @returns The action passed in
  9620. * @see https://www.babylonjs-playground.com/#1T30HR#0
  9621. */
  9622. then(action: IAction): IAction;
  9623. }
  9624. /**
  9625. * The action to be carried out following a trigger
  9626. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  9627. */
  9628. export class Action implements IAction {
  9629. /** the trigger, with or without parameters, for the action */
  9630. triggerOptions: any;
  9631. /**
  9632. * Trigger for the action
  9633. */
  9634. trigger: number;
  9635. /**
  9636. * Internal only - manager for action
  9637. * @hidden
  9638. */
  9639. _actionManager: ActionManager;
  9640. private _nextActiveAction;
  9641. private _child;
  9642. private _condition?;
  9643. private _triggerParameter;
  9644. /**
  9645. * An event triggered prior to action being executed.
  9646. */
  9647. onBeforeExecuteObservable: Observable<Action>;
  9648. /**
  9649. * Creates a new Action
  9650. * @param triggerOptions the trigger, with or without parameters, for the action
  9651. * @param condition an optional determinant of action
  9652. */
  9653. constructor(
  9654. /** the trigger, with or without parameters, for the action */
  9655. triggerOptions: any, condition?: Condition);
  9656. /**
  9657. * Internal only
  9658. * @hidden
  9659. */
  9660. _prepare(): void;
  9661. /**
  9662. * Gets the trigger parameters
  9663. * @returns the trigger parameters
  9664. */
  9665. getTriggerParameter(): any;
  9666. /**
  9667. * Internal only - executes current action event
  9668. * @hidden
  9669. */
  9670. _executeCurrent(evt?: ActionEvent): void;
  9671. /**
  9672. * Execute placeholder for child classes
  9673. * @param evt optional action event
  9674. */
  9675. execute(evt?: ActionEvent): void;
  9676. /**
  9677. * Skips to next active action
  9678. */
  9679. skipToNextActiveAction(): void;
  9680. /**
  9681. * Adds action to chain of actions, may be a DoNothingAction
  9682. * @param action defines the next action to execute
  9683. * @returns The action passed in
  9684. * @see https://www.babylonjs-playground.com/#1T30HR#0
  9685. */
  9686. then(action: Action): Action;
  9687. /**
  9688. * Internal only
  9689. * @hidden
  9690. */
  9691. _getProperty(propertyPath: string): string;
  9692. /**
  9693. * Internal only
  9694. * @hidden
  9695. */
  9696. _getEffectiveTarget(target: any, propertyPath: string): any;
  9697. /**
  9698. * Serialize placeholder for child classes
  9699. * @param parent of child
  9700. * @returns the serialized object
  9701. */
  9702. serialize(parent: any): any;
  9703. /**
  9704. * Internal only called by serialize
  9705. * @hidden
  9706. */
  9707. protected _serialize(serializedAction: any, parent?: any): any;
  9708. /**
  9709. * Internal only
  9710. * @hidden
  9711. */
  9712. static _SerializeValueAsString: (value: any) => string;
  9713. /**
  9714. * Internal only
  9715. * @hidden
  9716. */
  9717. static _GetTargetProperty: (target: Scene | Node) => {
  9718. name: string;
  9719. targetType: string;
  9720. value: string;
  9721. };
  9722. }
  9723. }
  9724. declare module "babylonjs/Actions/condition" {
  9725. import { ActionManager } from "babylonjs/Actions/actionManager";
  9726. /**
  9727. * A Condition applied to an Action
  9728. */
  9729. export class Condition {
  9730. /**
  9731. * Internal only - manager for action
  9732. * @hidden
  9733. */
  9734. _actionManager: ActionManager;
  9735. /**
  9736. * Internal only
  9737. * @hidden
  9738. */
  9739. _evaluationId: number;
  9740. /**
  9741. * Internal only
  9742. * @hidden
  9743. */
  9744. _currentResult: boolean;
  9745. /**
  9746. * Creates a new Condition
  9747. * @param actionManager the manager of the action the condition is applied to
  9748. */
  9749. constructor(actionManager: ActionManager);
  9750. /**
  9751. * Check if the current condition is valid
  9752. * @returns a boolean
  9753. */
  9754. isValid(): boolean;
  9755. /**
  9756. * Internal only
  9757. * @hidden
  9758. */
  9759. _getProperty(propertyPath: string): string;
  9760. /**
  9761. * Internal only
  9762. * @hidden
  9763. */
  9764. _getEffectiveTarget(target: any, propertyPath: string): any;
  9765. /**
  9766. * Serialize placeholder for child classes
  9767. * @returns the serialized object
  9768. */
  9769. serialize(): any;
  9770. /**
  9771. * Internal only
  9772. * @hidden
  9773. */
  9774. protected _serialize(serializedCondition: any): any;
  9775. }
  9776. /**
  9777. * Defines specific conditional operators as extensions of Condition
  9778. */
  9779. export class ValueCondition extends Condition {
  9780. /** path to specify the property of the target the conditional operator uses */
  9781. propertyPath: string;
  9782. /** the value compared by the conditional operator against the current value of the property */
  9783. value: any;
  9784. /** the conditional operator, default ValueCondition.IsEqual */
  9785. operator: number;
  9786. /**
  9787. * Internal only
  9788. * @hidden
  9789. */
  9790. private static _IsEqual;
  9791. /**
  9792. * Internal only
  9793. * @hidden
  9794. */
  9795. private static _IsDifferent;
  9796. /**
  9797. * Internal only
  9798. * @hidden
  9799. */
  9800. private static _IsGreater;
  9801. /**
  9802. * Internal only
  9803. * @hidden
  9804. */
  9805. private static _IsLesser;
  9806. /**
  9807. * returns the number for IsEqual
  9808. */
  9809. static get IsEqual(): number;
  9810. /**
  9811. * Returns the number for IsDifferent
  9812. */
  9813. static get IsDifferent(): number;
  9814. /**
  9815. * Returns the number for IsGreater
  9816. */
  9817. static get IsGreater(): number;
  9818. /**
  9819. * Returns the number for IsLesser
  9820. */
  9821. static get IsLesser(): number;
  9822. /**
  9823. * Internal only The action manager for the condition
  9824. * @hidden
  9825. */
  9826. _actionManager: ActionManager;
  9827. /**
  9828. * Internal only
  9829. * @hidden
  9830. */
  9831. private _target;
  9832. /**
  9833. * Internal only
  9834. * @hidden
  9835. */
  9836. private _effectiveTarget;
  9837. /**
  9838. * Internal only
  9839. * @hidden
  9840. */
  9841. private _property;
  9842. /**
  9843. * Creates a new ValueCondition
  9844. * @param actionManager manager for the action the condition applies to
  9845. * @param target for the action
  9846. * @param propertyPath path to specify the property of the target the conditional operator uses
  9847. * @param value the value compared by the conditional operator against the current value of the property
  9848. * @param operator the conditional operator, default ValueCondition.IsEqual
  9849. */
  9850. constructor(actionManager: ActionManager, target: any,
  9851. /** path to specify the property of the target the conditional operator uses */
  9852. propertyPath: string,
  9853. /** the value compared by the conditional operator against the current value of the property */
  9854. value: any,
  9855. /** the conditional operator, default ValueCondition.IsEqual */
  9856. operator?: number);
  9857. /**
  9858. * Compares the given value with the property value for the specified conditional operator
  9859. * @returns the result of the comparison
  9860. */
  9861. isValid(): boolean;
  9862. /**
  9863. * Serialize the ValueCondition into a JSON compatible object
  9864. * @returns serialization object
  9865. */
  9866. serialize(): any;
  9867. /**
  9868. * Gets the name of the conditional operator for the ValueCondition
  9869. * @param operator the conditional operator
  9870. * @returns the name
  9871. */
  9872. static GetOperatorName(operator: number): string;
  9873. }
  9874. /**
  9875. * Defines a predicate condition as an extension of Condition
  9876. */
  9877. export class PredicateCondition extends Condition {
  9878. /** defines the predicate function used to validate the condition */
  9879. predicate: () => boolean;
  9880. /**
  9881. * Internal only - manager for action
  9882. * @hidden
  9883. */
  9884. _actionManager: ActionManager;
  9885. /**
  9886. * Creates a new PredicateCondition
  9887. * @param actionManager manager for the action the condition applies to
  9888. * @param predicate defines the predicate function used to validate the condition
  9889. */
  9890. constructor(actionManager: ActionManager,
  9891. /** defines the predicate function used to validate the condition */
  9892. predicate: () => boolean);
  9893. /**
  9894. * @returns the validity of the predicate condition
  9895. */
  9896. isValid(): boolean;
  9897. }
  9898. /**
  9899. * Defines a state condition as an extension of Condition
  9900. */
  9901. export class StateCondition extends Condition {
  9902. /** Value to compare with target state */
  9903. value: string;
  9904. /**
  9905. * Internal only - manager for action
  9906. * @hidden
  9907. */
  9908. _actionManager: ActionManager;
  9909. /**
  9910. * Internal only
  9911. * @hidden
  9912. */
  9913. private _target;
  9914. /**
  9915. * Creates a new StateCondition
  9916. * @param actionManager manager for the action the condition applies to
  9917. * @param target of the condition
  9918. * @param value to compare with target state
  9919. */
  9920. constructor(actionManager: ActionManager, target: any,
  9921. /** Value to compare with target state */
  9922. value: string);
  9923. /**
  9924. * Gets a boolean indicating if the current condition is met
  9925. * @returns the validity of the state
  9926. */
  9927. isValid(): boolean;
  9928. /**
  9929. * Serialize the StateCondition into a JSON compatible object
  9930. * @returns serialization object
  9931. */
  9932. serialize(): any;
  9933. }
  9934. }
  9935. declare module "babylonjs/Actions/directActions" {
  9936. import { Action } from "babylonjs/Actions/action";
  9937. import { Condition } from "babylonjs/Actions/condition";
  9938. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  9939. /**
  9940. * This defines an action responsible to toggle a boolean once triggered.
  9941. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9942. */
  9943. export class SwitchBooleanAction extends Action {
  9944. /**
  9945. * The path to the boolean property in the target object
  9946. */
  9947. propertyPath: string;
  9948. private _target;
  9949. private _effectiveTarget;
  9950. private _property;
  9951. /**
  9952. * Instantiate the action
  9953. * @param triggerOptions defines the trigger options
  9954. * @param target defines the object containing the boolean
  9955. * @param propertyPath defines the path to the boolean property in the target object
  9956. * @param condition defines the trigger related conditions
  9957. */
  9958. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  9959. /** @hidden */
  9960. _prepare(): void;
  9961. /**
  9962. * Execute the action toggle the boolean value.
  9963. */
  9964. execute(): void;
  9965. /**
  9966. * Serializes the actions and its related information.
  9967. * @param parent defines the object to serialize in
  9968. * @returns the serialized object
  9969. */
  9970. serialize(parent: any): any;
  9971. }
  9972. /**
  9973. * This defines an action responsible to set a the state field of the target
  9974. * to a desired value once triggered.
  9975. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9976. */
  9977. export class SetStateAction extends Action {
  9978. /**
  9979. * The value to store in the state field.
  9980. */
  9981. value: string;
  9982. private _target;
  9983. /**
  9984. * Instantiate the action
  9985. * @param triggerOptions defines the trigger options
  9986. * @param target defines the object containing the state property
  9987. * @param value defines the value to store in the state field
  9988. * @param condition defines the trigger related conditions
  9989. */
  9990. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  9991. /**
  9992. * Execute the action and store the value on the target state property.
  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 set a property of the target
  10004. * to a desired value once triggered.
  10005. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10006. */
  10007. export class SetValueAction extends Action {
  10008. /**
  10009. * The path of the property to set in the target.
  10010. */
  10011. propertyPath: string;
  10012. /**
  10013. * The value to set in the property
  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 set in the target
  10024. * @param value defines the value to set in the property
  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 set the targetted property to the desired value.
  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 increment the target value
  10043. * to a desired value once triggered.
  10044. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10045. */
  10046. export class IncrementValueAction extends Action {
  10047. /**
  10048. * The path of the property to increment in the target.
  10049. */
  10050. propertyPath: string;
  10051. /**
  10052. * The value we should increment the property by.
  10053. */
  10054. value: any;
  10055. private _target;
  10056. private _effectiveTarget;
  10057. private _property;
  10058. /**
  10059. * Instantiate the action
  10060. * @param triggerOptions defines the trigger options
  10061. * @param target defines the object containing the property
  10062. * @param propertyPath defines the path of the property to increment in the target
  10063. * @param value defines the value value we should increment the property by
  10064. * @param condition defines the trigger related conditions
  10065. */
  10066. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10067. /** @hidden */
  10068. _prepare(): void;
  10069. /**
  10070. * Execute the action and increment the target of the value amount.
  10071. */
  10072. execute(): void;
  10073. /**
  10074. * Serializes the actions and its related information.
  10075. * @param parent defines the object to serialize in
  10076. * @returns the serialized object
  10077. */
  10078. serialize(parent: any): any;
  10079. }
  10080. /**
  10081. * This defines an action responsible to start an animation once triggered.
  10082. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10083. */
  10084. export class PlayAnimationAction extends Action {
  10085. /**
  10086. * Where the animation should start (animation frame)
  10087. */
  10088. from: number;
  10089. /**
  10090. * Where the animation should stop (animation frame)
  10091. */
  10092. to: number;
  10093. /**
  10094. * Define if the animation should loop or stop after the first play.
  10095. */
  10096. loop?: boolean;
  10097. private _target;
  10098. /**
  10099. * Instantiate the action
  10100. * @param triggerOptions defines the trigger options
  10101. * @param target defines the target animation or animation name
  10102. * @param from defines from where the animation should start (animation frame)
  10103. * @param end defines where the animation should stop (animation frame)
  10104. * @param loop defines if the animation should loop or stop after the first play
  10105. * @param condition defines the trigger related conditions
  10106. */
  10107. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  10108. /** @hidden */
  10109. _prepare(): void;
  10110. /**
  10111. * Execute the action and play the animation.
  10112. */
  10113. execute(): void;
  10114. /**
  10115. * Serializes the actions and its related information.
  10116. * @param parent defines the object to serialize in
  10117. * @returns the serialized object
  10118. */
  10119. serialize(parent: any): any;
  10120. }
  10121. /**
  10122. * This defines an action responsible to stop an animation once triggered.
  10123. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10124. */
  10125. export class StopAnimationAction extends Action {
  10126. private _target;
  10127. /**
  10128. * Instantiate the action
  10129. * @param triggerOptions defines the trigger options
  10130. * @param target defines the target animation or animation name
  10131. * @param condition defines the trigger related conditions
  10132. */
  10133. constructor(triggerOptions: any, target: any, condition?: Condition);
  10134. /** @hidden */
  10135. _prepare(): void;
  10136. /**
  10137. * Execute the action and stop the animation.
  10138. */
  10139. execute(): void;
  10140. /**
  10141. * Serializes the actions and its related information.
  10142. * @param parent defines the object to serialize in
  10143. * @returns the serialized object
  10144. */
  10145. serialize(parent: any): any;
  10146. }
  10147. /**
  10148. * This defines an action responsible that does nothing once triggered.
  10149. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10150. */
  10151. export class DoNothingAction extends Action {
  10152. /**
  10153. * Instantiate the action
  10154. * @param triggerOptions defines the trigger options
  10155. * @param condition defines the trigger related conditions
  10156. */
  10157. constructor(triggerOptions?: any, condition?: Condition);
  10158. /**
  10159. * Execute the action and do nothing.
  10160. */
  10161. execute(): void;
  10162. /**
  10163. * Serializes the actions and its related information.
  10164. * @param parent defines the object to serialize in
  10165. * @returns the serialized object
  10166. */
  10167. serialize(parent: any): any;
  10168. }
  10169. /**
  10170. * This defines an action responsible to trigger several actions once triggered.
  10171. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10172. */
  10173. export class CombineAction extends Action {
  10174. /**
  10175. * The list of aggregated animations to run.
  10176. */
  10177. children: Action[];
  10178. /**
  10179. * Instantiate the action
  10180. * @param triggerOptions defines the trigger options
  10181. * @param children defines the list of aggregated animations to run
  10182. * @param condition defines the trigger related conditions
  10183. */
  10184. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  10185. /** @hidden */
  10186. _prepare(): void;
  10187. /**
  10188. * Execute the action and executes all the aggregated actions.
  10189. */
  10190. execute(evt: ActionEvent): void;
  10191. /**
  10192. * Serializes the actions and its related information.
  10193. * @param parent defines the object to serialize in
  10194. * @returns the serialized object
  10195. */
  10196. serialize(parent: any): any;
  10197. }
  10198. /**
  10199. * This defines an action responsible to run code (external event) once triggered.
  10200. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10201. */
  10202. export class ExecuteCodeAction extends Action {
  10203. /**
  10204. * The callback function to run.
  10205. */
  10206. func: (evt: ActionEvent) => void;
  10207. /**
  10208. * Instantiate the action
  10209. * @param triggerOptions defines the trigger options
  10210. * @param func defines the callback function to run
  10211. * @param condition defines the trigger related conditions
  10212. */
  10213. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  10214. /**
  10215. * Execute the action and run the attached code.
  10216. */
  10217. execute(evt: ActionEvent): void;
  10218. }
  10219. /**
  10220. * This defines an action responsible to set the parent property of the target once triggered.
  10221. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10222. */
  10223. export class SetParentAction extends Action {
  10224. private _parent;
  10225. private _target;
  10226. /**
  10227. * Instantiate the action
  10228. * @param triggerOptions defines the trigger options
  10229. * @param target defines the target containing the parent property
  10230. * @param parent defines from where the animation should start (animation frame)
  10231. * @param condition defines the trigger related conditions
  10232. */
  10233. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  10234. /** @hidden */
  10235. _prepare(): void;
  10236. /**
  10237. * Execute the action and set the parent property.
  10238. */
  10239. execute(): void;
  10240. /**
  10241. * Serializes the actions and its related information.
  10242. * @param parent defines the object to serialize in
  10243. * @returns the serialized object
  10244. */
  10245. serialize(parent: any): any;
  10246. }
  10247. }
  10248. declare module "babylonjs/Actions/actionManager" {
  10249. import { Nullable } from "babylonjs/types";
  10250. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10251. import { Scene } from "babylonjs/scene";
  10252. import { IAction } from "babylonjs/Actions/action";
  10253. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  10254. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  10255. /**
  10256. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  10257. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  10258. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10259. */
  10260. export class ActionManager extends AbstractActionManager {
  10261. /**
  10262. * Nothing
  10263. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10264. */
  10265. static readonly NothingTrigger: number;
  10266. /**
  10267. * On pick
  10268. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10269. */
  10270. static readonly OnPickTrigger: number;
  10271. /**
  10272. * On left pick
  10273. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10274. */
  10275. static readonly OnLeftPickTrigger: number;
  10276. /**
  10277. * On right pick
  10278. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10279. */
  10280. static readonly OnRightPickTrigger: number;
  10281. /**
  10282. * On center pick
  10283. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10284. */
  10285. static readonly OnCenterPickTrigger: number;
  10286. /**
  10287. * On pick down
  10288. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10289. */
  10290. static readonly OnPickDownTrigger: number;
  10291. /**
  10292. * On double pick
  10293. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10294. */
  10295. static readonly OnDoublePickTrigger: number;
  10296. /**
  10297. * On pick up
  10298. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10299. */
  10300. static readonly OnPickUpTrigger: number;
  10301. /**
  10302. * On pick out.
  10303. * This trigger will only be raised if you also declared a OnPickDown
  10304. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10305. */
  10306. static readonly OnPickOutTrigger: number;
  10307. /**
  10308. * On long press
  10309. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10310. */
  10311. static readonly OnLongPressTrigger: number;
  10312. /**
  10313. * On pointer over
  10314. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10315. */
  10316. static readonly OnPointerOverTrigger: number;
  10317. /**
  10318. * On pointer out
  10319. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10320. */
  10321. static readonly OnPointerOutTrigger: number;
  10322. /**
  10323. * On every frame
  10324. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10325. */
  10326. static readonly OnEveryFrameTrigger: number;
  10327. /**
  10328. * On intersection enter
  10329. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10330. */
  10331. static readonly OnIntersectionEnterTrigger: number;
  10332. /**
  10333. * On intersection exit
  10334. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10335. */
  10336. static readonly OnIntersectionExitTrigger: number;
  10337. /**
  10338. * On key down
  10339. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10340. */
  10341. static readonly OnKeyDownTrigger: number;
  10342. /**
  10343. * On key up
  10344. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10345. */
  10346. static readonly OnKeyUpTrigger: number;
  10347. private _scene;
  10348. /**
  10349. * Creates a new action manager
  10350. * @param scene defines the hosting scene
  10351. */
  10352. constructor(scene: Scene);
  10353. /**
  10354. * Releases all associated resources
  10355. */
  10356. dispose(): void;
  10357. /**
  10358. * Gets hosting scene
  10359. * @returns the hosting scene
  10360. */
  10361. getScene(): Scene;
  10362. /**
  10363. * Does this action manager handles actions of any of the given triggers
  10364. * @param triggers defines the triggers to be tested
  10365. * @return a boolean indicating whether one (or more) of the triggers is handled
  10366. */
  10367. hasSpecificTriggers(triggers: number[]): boolean;
  10368. /**
  10369. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  10370. * speed.
  10371. * @param triggerA defines the trigger to be tested
  10372. * @param triggerB defines the trigger to be tested
  10373. * @return a boolean indicating whether one (or more) of the triggers is handled
  10374. */
  10375. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  10376. /**
  10377. * Does this action manager handles actions of a given trigger
  10378. * @param trigger defines the trigger to be tested
  10379. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  10380. * @return whether the trigger is handled
  10381. */
  10382. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  10383. /**
  10384. * Does this action manager has pointer triggers
  10385. */
  10386. get hasPointerTriggers(): boolean;
  10387. /**
  10388. * Does this action manager has pick triggers
  10389. */
  10390. get hasPickTriggers(): boolean;
  10391. /**
  10392. * Registers an action to this action manager
  10393. * @param action defines the action to be registered
  10394. * @return the action amended (prepared) after registration
  10395. */
  10396. registerAction(action: IAction): Nullable<IAction>;
  10397. /**
  10398. * Unregisters an action to this action manager
  10399. * @param action defines the action to be unregistered
  10400. * @return a boolean indicating whether the action has been unregistered
  10401. */
  10402. unregisterAction(action: IAction): Boolean;
  10403. /**
  10404. * Process a specific trigger
  10405. * @param trigger defines the trigger to process
  10406. * @param evt defines the event details to be processed
  10407. */
  10408. processTrigger(trigger: number, evt?: IActionEvent): void;
  10409. /** @hidden */
  10410. _getEffectiveTarget(target: any, propertyPath: string): any;
  10411. /** @hidden */
  10412. _getProperty(propertyPath: string): string;
  10413. /**
  10414. * Serialize this manager to a JSON object
  10415. * @param name defines the property name to store this manager
  10416. * @returns a JSON representation of this manager
  10417. */
  10418. serialize(name: string): any;
  10419. /**
  10420. * Creates a new ActionManager from a JSON data
  10421. * @param parsedActions defines the JSON data to read from
  10422. * @param object defines the hosting mesh
  10423. * @param scene defines the hosting scene
  10424. */
  10425. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  10426. /**
  10427. * Get a trigger name by index
  10428. * @param trigger defines the trigger index
  10429. * @returns a trigger name
  10430. */
  10431. static GetTriggerName(trigger: number): string;
  10432. }
  10433. }
  10434. declare module "babylonjs/Sprites/sprite" {
  10435. import { Vector3 } from "babylonjs/Maths/math.vector";
  10436. import { Nullable } from "babylonjs/types";
  10437. import { ActionManager } from "babylonjs/Actions/actionManager";
  10438. import { ISpriteManager, SpriteManager } from "babylonjs/Sprites/spriteManager";
  10439. import { Color4 } from "babylonjs/Maths/math.color";
  10440. import { Observable } from "babylonjs/Misc/observable";
  10441. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  10442. import { Animation } from "babylonjs/Animations/animation";
  10443. /**
  10444. * Class used to represent a sprite
  10445. * @see https://doc.babylonjs.com/babylon101/sprites
  10446. */
  10447. export class Sprite implements IAnimatable {
  10448. /** defines the name */
  10449. name: string;
  10450. /** Gets or sets the current world position */
  10451. position: Vector3;
  10452. /** Gets or sets the main color */
  10453. color: Color4;
  10454. /** Gets or sets the width */
  10455. width: number;
  10456. /** Gets or sets the height */
  10457. height: number;
  10458. /** Gets or sets rotation angle */
  10459. angle: number;
  10460. /** Gets or sets the cell index in the sprite sheet */
  10461. cellIndex: number;
  10462. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  10463. cellRef: string;
  10464. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  10465. invertU: boolean;
  10466. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  10467. invertV: boolean;
  10468. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  10469. disposeWhenFinishedAnimating: boolean;
  10470. /** Gets the list of attached animations */
  10471. animations: Nullable<Array<Animation>>;
  10472. /** Gets or sets a boolean indicating if the sprite can be picked */
  10473. isPickable: boolean;
  10474. /** Gets or sets a boolean indicating that sprite texture alpha will be used for precise picking (false by default) */
  10475. useAlphaForPicking: boolean;
  10476. /** @hidden */
  10477. _xOffset: number;
  10478. /** @hidden */
  10479. _yOffset: number;
  10480. /** @hidden */
  10481. _xSize: number;
  10482. /** @hidden */
  10483. _ySize: number;
  10484. /**
  10485. * Gets or sets the associated action manager
  10486. */
  10487. actionManager: Nullable<ActionManager>;
  10488. /**
  10489. * An event triggered when the control has been disposed
  10490. */
  10491. onDisposeObservable: Observable<Sprite>;
  10492. private _animationStarted;
  10493. private _loopAnimation;
  10494. private _fromIndex;
  10495. private _toIndex;
  10496. private _delay;
  10497. private _direction;
  10498. private _manager;
  10499. private _time;
  10500. private _onAnimationEnd;
  10501. /**
  10502. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  10503. */
  10504. isVisible: boolean;
  10505. /**
  10506. * Gets or sets the sprite size
  10507. */
  10508. get size(): number;
  10509. set size(value: number);
  10510. /**
  10511. * Returns a boolean indicating if the animation is started
  10512. */
  10513. get animationStarted(): boolean;
  10514. /**
  10515. * Gets or sets the unique id of the sprite
  10516. */
  10517. uniqueId: number;
  10518. /**
  10519. * Gets the manager of this sprite
  10520. */
  10521. get manager(): ISpriteManager;
  10522. /**
  10523. * Creates a new Sprite
  10524. * @param name defines the name
  10525. * @param manager defines the manager
  10526. */
  10527. constructor(
  10528. /** defines the name */
  10529. name: string, manager: ISpriteManager);
  10530. /**
  10531. * Returns the string "Sprite"
  10532. * @returns "Sprite"
  10533. */
  10534. getClassName(): string;
  10535. /** Gets or sets the initial key for the animation (setting it will restart the animation) */
  10536. get fromIndex(): number;
  10537. set fromIndex(value: number);
  10538. /** Gets or sets the end key for the animation (setting it will restart the animation) */
  10539. get toIndex(): number;
  10540. set toIndex(value: number);
  10541. /** Gets or sets a boolean indicating if the animation is looping (setting it will restart the animation) */
  10542. get loopAnimation(): boolean;
  10543. set loopAnimation(value: boolean);
  10544. /** Gets or sets the delay between cell changes (setting it will restart the animation) */
  10545. get delay(): number;
  10546. set delay(value: number);
  10547. /**
  10548. * Starts an animation
  10549. * @param from defines the initial key
  10550. * @param to defines the end key
  10551. * @param loop defines if the animation must loop
  10552. * @param delay defines the start delay (in ms)
  10553. * @param onAnimationEnd defines a callback to call when animation ends
  10554. */
  10555. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd?: Nullable<() => void>): void;
  10556. /** Stops current animation (if any) */
  10557. stopAnimation(): void;
  10558. /** @hidden */
  10559. _animate(deltaTime: number): void;
  10560. /** Release associated resources */
  10561. dispose(): void;
  10562. /**
  10563. * Serializes the sprite to a JSON object
  10564. * @returns the JSON object
  10565. */
  10566. serialize(): any;
  10567. /**
  10568. * Parses a JSON object to create a new sprite
  10569. * @param parsedSprite The JSON object to parse
  10570. * @param manager defines the hosting manager
  10571. * @returns the new sprite
  10572. */
  10573. static Parse(parsedSprite: any, manager: SpriteManager): Sprite;
  10574. }
  10575. }
  10576. declare module "babylonjs/Collisions/pickingInfo" {
  10577. import { Nullable } from "babylonjs/types";
  10578. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  10579. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10580. import { Sprite } from "babylonjs/Sprites/sprite";
  10581. import { Ray } from "babylonjs/Culling/ray";
  10582. /**
  10583. * Information about the result of picking within a scene
  10584. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  10585. */
  10586. export class PickingInfo {
  10587. /** @hidden */
  10588. _pickingUnavailable: boolean;
  10589. /**
  10590. * If the pick collided with an object
  10591. */
  10592. hit: boolean;
  10593. /**
  10594. * Distance away where the pick collided
  10595. */
  10596. distance: number;
  10597. /**
  10598. * The location of pick collision
  10599. */
  10600. pickedPoint: Nullable<Vector3>;
  10601. /**
  10602. * The mesh corresponding the the pick collision
  10603. */
  10604. pickedMesh: Nullable<AbstractMesh>;
  10605. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  10606. bu: number;
  10607. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  10608. bv: number;
  10609. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  10610. faceId: number;
  10611. /** The index of the face on the subMesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  10612. subMeshFaceId: number;
  10613. /** Id of the the submesh that was picked */
  10614. subMeshId: number;
  10615. /** If a sprite was picked, this will be the sprite the pick collided with */
  10616. pickedSprite: Nullable<Sprite>;
  10617. /** If we are pikcing a mesh with thin instance, this will give you the picked thin instance */
  10618. thinInstanceIndex: number;
  10619. /**
  10620. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  10621. */
  10622. originMesh: Nullable<AbstractMesh>;
  10623. /**
  10624. * The ray that was used to perform the picking.
  10625. */
  10626. ray: Nullable<Ray>;
  10627. /**
  10628. * Gets the normal correspodning to the face the pick collided with
  10629. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  10630. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  10631. * @returns The normal correspodning to the face the pick collided with
  10632. */
  10633. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  10634. /**
  10635. * Gets the texture coordinates of where the pick occured
  10636. * @returns the vector containing the coordnates of the texture
  10637. */
  10638. getTextureCoordinates(): Nullable<Vector2>;
  10639. }
  10640. }
  10641. declare module "babylonjs/Culling/ray" {
  10642. import { DeepImmutable, Nullable, float } from "babylonjs/types";
  10643. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  10644. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10645. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  10646. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  10647. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  10648. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  10649. import { Plane } from "babylonjs/Maths/math.plane";
  10650. /**
  10651. * Class representing a ray with position and direction
  10652. */
  10653. export class Ray {
  10654. /** origin point */
  10655. origin: Vector3;
  10656. /** direction */
  10657. direction: Vector3;
  10658. /** length of the ray */
  10659. length: number;
  10660. private static readonly _TmpVector3;
  10661. private _tmpRay;
  10662. /**
  10663. * Creates a new ray
  10664. * @param origin origin point
  10665. * @param direction direction
  10666. * @param length length of the ray
  10667. */
  10668. constructor(
  10669. /** origin point */
  10670. origin: Vector3,
  10671. /** direction */
  10672. direction: Vector3,
  10673. /** length of the ray */
  10674. length?: number);
  10675. /**
  10676. * Checks if the ray intersects a box
  10677. * This does not account for the ray lenght by design to improve perfs.
  10678. * @param minimum bound of the box
  10679. * @param maximum bound of the box
  10680. * @param intersectionTreshold extra extend to be added to the box in all direction
  10681. * @returns if the box was hit
  10682. */
  10683. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  10684. /**
  10685. * Checks if the ray intersects a box
  10686. * This does not account for the ray lenght by design to improve perfs.
  10687. * @param box the bounding box to check
  10688. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  10689. * @returns if the box was hit
  10690. */
  10691. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  10692. /**
  10693. * If the ray hits a sphere
  10694. * @param sphere the bounding sphere to check
  10695. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  10696. * @returns true if it hits the sphere
  10697. */
  10698. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  10699. /**
  10700. * If the ray hits a triange
  10701. * @param vertex0 triangle vertex
  10702. * @param vertex1 triangle vertex
  10703. * @param vertex2 triangle vertex
  10704. * @returns intersection information if hit
  10705. */
  10706. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  10707. /**
  10708. * Checks if ray intersects a plane
  10709. * @param plane the plane to check
  10710. * @returns the distance away it was hit
  10711. */
  10712. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  10713. /**
  10714. * Calculate the intercept of a ray on a given axis
  10715. * @param axis to check 'x' | 'y' | 'z'
  10716. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  10717. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  10718. */
  10719. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  10720. /**
  10721. * Checks if ray intersects a mesh
  10722. * @param mesh the mesh to check
  10723. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10724. * @returns picking info of the intersecton
  10725. */
  10726. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  10727. /**
  10728. * Checks if ray intersects a mesh
  10729. * @param meshes the meshes to check
  10730. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10731. * @param results array to store result in
  10732. * @returns Array of picking infos
  10733. */
  10734. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  10735. private _comparePickingInfo;
  10736. private static smallnum;
  10737. private static rayl;
  10738. /**
  10739. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  10740. * @param sega the first point of the segment to test the intersection against
  10741. * @param segb the second point of the segment to test the intersection against
  10742. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  10743. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  10744. */
  10745. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  10746. /**
  10747. * Update the ray from viewport position
  10748. * @param x position
  10749. * @param y y position
  10750. * @param viewportWidth viewport width
  10751. * @param viewportHeight viewport height
  10752. * @param world world matrix
  10753. * @param view view matrix
  10754. * @param projection projection matrix
  10755. * @returns this ray updated
  10756. */
  10757. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10758. /**
  10759. * Creates a ray with origin and direction of 0,0,0
  10760. * @returns the new ray
  10761. */
  10762. static Zero(): Ray;
  10763. /**
  10764. * Creates a new ray from screen space and viewport
  10765. * @param x position
  10766. * @param y y position
  10767. * @param viewportWidth viewport width
  10768. * @param viewportHeight viewport height
  10769. * @param world world matrix
  10770. * @param view view matrix
  10771. * @param projection projection matrix
  10772. * @returns new ray
  10773. */
  10774. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10775. /**
  10776. * 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
  10777. * transformed to the given world matrix.
  10778. * @param origin The origin point
  10779. * @param end The end point
  10780. * @param world a matrix to transform the ray to. Default is the identity matrix.
  10781. * @returns the new ray
  10782. */
  10783. static CreateNewFromTo(origin: Vector3, end: Vector3, world?: DeepImmutable<Matrix>): Ray;
  10784. /**
  10785. * Transforms a ray by a matrix
  10786. * @param ray ray to transform
  10787. * @param matrix matrix to apply
  10788. * @returns the resulting new ray
  10789. */
  10790. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  10791. /**
  10792. * Transforms a ray by a matrix
  10793. * @param ray ray to transform
  10794. * @param matrix matrix to apply
  10795. * @param result ray to store result in
  10796. */
  10797. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  10798. /**
  10799. * Unproject a ray from screen space to object space
  10800. * @param sourceX defines the screen space x coordinate to use
  10801. * @param sourceY defines the screen space y coordinate to use
  10802. * @param viewportWidth defines the current width of the viewport
  10803. * @param viewportHeight defines the current height of the viewport
  10804. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  10805. * @param view defines the view matrix to use
  10806. * @param projection defines the projection matrix to use
  10807. */
  10808. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  10809. }
  10810. /**
  10811. * Type used to define predicate used to select faces when a mesh intersection is detected
  10812. */
  10813. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  10814. module "babylonjs/scene" {
  10815. interface Scene {
  10816. /** @hidden */
  10817. _tempPickingRay: Nullable<Ray>;
  10818. /** @hidden */
  10819. _cachedRayForTransform: Ray;
  10820. /** @hidden */
  10821. _pickWithRayInverseMatrix: Matrix;
  10822. /** @hidden */
  10823. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  10824. /** @hidden */
  10825. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  10826. /** @hidden */
  10827. _internalPickForMesh(pickingInfo: Nullable<PickingInfo>, rayFunction: (world: Matrix) => Ray, mesh: AbstractMesh, world: Matrix, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  10828. }
  10829. }
  10830. }
  10831. declare module "babylonjs/sceneComponent" {
  10832. import { Scene } from "babylonjs/scene";
  10833. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10834. import { SubMesh } from "babylonjs/Meshes/subMesh";
  10835. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  10836. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  10837. import { Nullable } from "babylonjs/types";
  10838. import { Camera } from "babylonjs/Cameras/camera";
  10839. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  10840. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  10841. import { AbstractScene } from "babylonjs/abstractScene";
  10842. import { Mesh } from "babylonjs/Meshes/mesh";
  10843. /**
  10844. * Groups all the scene component constants in one place to ease maintenance.
  10845. * @hidden
  10846. */
  10847. export class SceneComponentConstants {
  10848. static readonly NAME_EFFECTLAYER: string;
  10849. static readonly NAME_LAYER: string;
  10850. static readonly NAME_LENSFLARESYSTEM: string;
  10851. static readonly NAME_BOUNDINGBOXRENDERER: string;
  10852. static readonly NAME_PARTICLESYSTEM: string;
  10853. static readonly NAME_GAMEPAD: string;
  10854. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  10855. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  10856. static readonly NAME_PREPASSRENDERER: string;
  10857. static readonly NAME_DEPTHRENDERER: string;
  10858. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  10859. static readonly NAME_SPRITE: string;
  10860. static readonly NAME_OUTLINERENDERER: string;
  10861. static readonly NAME_PROCEDURALTEXTURE: string;
  10862. static readonly NAME_SHADOWGENERATOR: string;
  10863. static readonly NAME_OCTREE: string;
  10864. static readonly NAME_PHYSICSENGINE: string;
  10865. static readonly NAME_AUDIO: string;
  10866. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  10867. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10868. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  10869. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10870. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  10871. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  10872. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  10873. static readonly STEP_BEFORECAMERADRAW_PREPASS: number;
  10874. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  10875. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  10876. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  10877. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  10878. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  10879. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  10880. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  10881. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  10882. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  10883. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  10884. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  10885. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  10886. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  10887. static readonly STEP_AFTERCAMERADRAW_PREPASS: number;
  10888. static readonly STEP_AFTERRENDER_AUDIO: number;
  10889. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  10890. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  10891. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  10892. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  10893. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  10894. static readonly STEP_BEFORECLEARSTAGE_PREPASS: number;
  10895. static readonly STEP_POINTERMOVE_SPRITE: number;
  10896. static readonly STEP_POINTERDOWN_SPRITE: number;
  10897. static readonly STEP_POINTERUP_SPRITE: number;
  10898. }
  10899. /**
  10900. * This represents a scene component.
  10901. *
  10902. * This is used to decouple the dependency the scene is having on the different workloads like
  10903. * layers, post processes...
  10904. */
  10905. export interface ISceneComponent {
  10906. /**
  10907. * The name of the component. Each component must have a unique name.
  10908. */
  10909. name: string;
  10910. /**
  10911. * The scene the component belongs to.
  10912. */
  10913. scene: Scene;
  10914. /**
  10915. * Register the component to one instance of a scene.
  10916. */
  10917. register(): void;
  10918. /**
  10919. * Rebuilds the elements related to this component in case of
  10920. * context lost for instance.
  10921. */
  10922. rebuild(): void;
  10923. /**
  10924. * Disposes the component and the associated ressources.
  10925. */
  10926. dispose(): void;
  10927. }
  10928. /**
  10929. * This represents a SERIALIZABLE scene component.
  10930. *
  10931. * This extends Scene Component to add Serialization methods on top.
  10932. */
  10933. export interface ISceneSerializableComponent extends ISceneComponent {
  10934. /**
  10935. * Adds all the elements from the container to the scene
  10936. * @param container the container holding the elements
  10937. */
  10938. addFromContainer(container: AbstractScene): void;
  10939. /**
  10940. * Removes all the elements in the container from the scene
  10941. * @param container contains the elements to remove
  10942. * @param dispose if the removed element should be disposed (default: false)
  10943. */
  10944. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  10945. /**
  10946. * Serializes the component data to the specified json object
  10947. * @param serializationObject The object to serialize to
  10948. */
  10949. serialize(serializationObject: any): void;
  10950. }
  10951. /**
  10952. * Strong typing of a Mesh related stage step action
  10953. */
  10954. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  10955. /**
  10956. * Strong typing of a Evaluate Sub Mesh related stage step action
  10957. */
  10958. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  10959. /**
  10960. * Strong typing of a Active Mesh related stage step action
  10961. */
  10962. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  10963. /**
  10964. * Strong typing of a Camera related stage step action
  10965. */
  10966. export type CameraStageAction = (camera: Camera) => void;
  10967. /**
  10968. * Strong typing of a Camera Frame buffer related stage step action
  10969. */
  10970. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  10971. /**
  10972. * Strong typing of a Render Target related stage step action
  10973. */
  10974. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  10975. /**
  10976. * Strong typing of a RenderingGroup related stage step action
  10977. */
  10978. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  10979. /**
  10980. * Strong typing of a Mesh Render related stage step action
  10981. */
  10982. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  10983. /**
  10984. * Strong typing of a simple stage step action
  10985. */
  10986. export type SimpleStageAction = () => void;
  10987. /**
  10988. * Strong typing of a render target action.
  10989. */
  10990. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  10991. /**
  10992. * Strong typing of a pointer move action.
  10993. */
  10994. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  10995. /**
  10996. * Strong typing of a pointer up/down action.
  10997. */
  10998. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  10999. /**
  11000. * Representation of a stage in the scene (Basically a list of ordered steps)
  11001. * @hidden
  11002. */
  11003. export class Stage<T extends Function> extends Array<{
  11004. index: number;
  11005. component: ISceneComponent;
  11006. action: T;
  11007. }> {
  11008. /**
  11009. * Hide ctor from the rest of the world.
  11010. * @param items The items to add.
  11011. */
  11012. private constructor();
  11013. /**
  11014. * Creates a new Stage.
  11015. * @returns A new instance of a Stage
  11016. */
  11017. static Create<T extends Function>(): Stage<T>;
  11018. /**
  11019. * Registers a step in an ordered way in the targeted stage.
  11020. * @param index Defines the position to register the step in
  11021. * @param component Defines the component attached to the step
  11022. * @param action Defines the action to launch during the step
  11023. */
  11024. registerStep(index: number, component: ISceneComponent, action: T): void;
  11025. /**
  11026. * Clears all the steps from the stage.
  11027. */
  11028. clear(): void;
  11029. }
  11030. }
  11031. declare module "babylonjs/Sprites/spriteSceneComponent" {
  11032. import { Nullable } from "babylonjs/types";
  11033. import { Observable } from "babylonjs/Misc/observable";
  11034. import { Scene } from "babylonjs/scene";
  11035. import { Sprite } from "babylonjs/Sprites/sprite";
  11036. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  11037. import { Ray } from "babylonjs/Culling/ray";
  11038. import { Camera } from "babylonjs/Cameras/camera";
  11039. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11040. import { ISceneComponent } from "babylonjs/sceneComponent";
  11041. module "babylonjs/scene" {
  11042. interface Scene {
  11043. /** @hidden */
  11044. _pointerOverSprite: Nullable<Sprite>;
  11045. /** @hidden */
  11046. _pickedDownSprite: Nullable<Sprite>;
  11047. /** @hidden */
  11048. _tempSpritePickingRay: Nullable<Ray>;
  11049. /**
  11050. * All of the sprite managers added to this scene
  11051. * @see https://doc.babylonjs.com/babylon101/sprites
  11052. */
  11053. spriteManagers: Array<ISpriteManager>;
  11054. /**
  11055. * An event triggered when sprites rendering is about to start
  11056. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11057. */
  11058. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11059. /**
  11060. * An event triggered when sprites rendering is done
  11061. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11062. */
  11063. onAfterSpritesRenderingObservable: Observable<Scene>;
  11064. /** @hidden */
  11065. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11066. /** Launch a ray to try to pick a sprite in the scene
  11067. * @param x position on screen
  11068. * @param y position on screen
  11069. * @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
  11070. * @param fastCheck defines if the first intersection will be used (and not the closest)
  11071. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11072. * @returns a PickingInfo
  11073. */
  11074. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11075. /** Use the given ray to pick a sprite in the scene
  11076. * @param ray The ray (in world space) to use to pick meshes
  11077. * @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
  11078. * @param fastCheck defines if the first intersection will be used (and not the closest)
  11079. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11080. * @returns a PickingInfo
  11081. */
  11082. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11083. /** @hidden */
  11084. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11085. /** Launch a ray to try to pick sprites in the scene
  11086. * @param x position on screen
  11087. * @param y position on screen
  11088. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  11089. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11090. * @returns a PickingInfo array
  11091. */
  11092. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11093. /** Use the given ray to pick sprites in the scene
  11094. * @param ray The ray (in world space) to use to pick meshes
  11095. * @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
  11096. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11097. * @returns a PickingInfo array
  11098. */
  11099. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11100. /**
  11101. * Force the sprite under the pointer
  11102. * @param sprite defines the sprite to use
  11103. */
  11104. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11105. /**
  11106. * Gets the sprite under the pointer
  11107. * @returns a Sprite or null if no sprite is under the pointer
  11108. */
  11109. getPointerOverSprite(): Nullable<Sprite>;
  11110. }
  11111. }
  11112. /**
  11113. * Defines the sprite scene component responsible to manage sprites
  11114. * in a given scene.
  11115. */
  11116. export class SpriteSceneComponent implements ISceneComponent {
  11117. /**
  11118. * The component name helpfull to identify the component in the list of scene components.
  11119. */
  11120. readonly name: string;
  11121. /**
  11122. * The scene the component belongs to.
  11123. */
  11124. scene: Scene;
  11125. /** @hidden */
  11126. private _spritePredicate;
  11127. /**
  11128. * Creates a new instance of the component for the given scene
  11129. * @param scene Defines the scene to register the component in
  11130. */
  11131. constructor(scene: Scene);
  11132. /**
  11133. * Registers the component in a given scene
  11134. */
  11135. register(): void;
  11136. /**
  11137. * Rebuilds the elements related to this component in case of
  11138. * context lost for instance.
  11139. */
  11140. rebuild(): void;
  11141. /**
  11142. * Disposes the component and the associated ressources.
  11143. */
  11144. dispose(): void;
  11145. private _pickSpriteButKeepRay;
  11146. private _pointerMove;
  11147. private _pointerDown;
  11148. private _pointerUp;
  11149. }
  11150. }
  11151. declare module "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration" {
  11152. /** @hidden */
  11153. export var fogFragmentDeclaration: {
  11154. name: string;
  11155. shader: string;
  11156. };
  11157. }
  11158. declare module "babylonjs/Shaders/ShadersInclude/fogFragment" {
  11159. /** @hidden */
  11160. export var fogFragment: {
  11161. name: string;
  11162. shader: string;
  11163. };
  11164. }
  11165. declare module "babylonjs/Shaders/sprites.fragment" {
  11166. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  11167. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  11168. /** @hidden */
  11169. export var spritesPixelShader: {
  11170. name: string;
  11171. shader: string;
  11172. };
  11173. }
  11174. declare module "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration" {
  11175. /** @hidden */
  11176. export var fogVertexDeclaration: {
  11177. name: string;
  11178. shader: string;
  11179. };
  11180. }
  11181. declare module "babylonjs/Shaders/sprites.vertex" {
  11182. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  11183. /** @hidden */
  11184. export var spritesVertexShader: {
  11185. name: string;
  11186. shader: string;
  11187. };
  11188. }
  11189. declare module "babylonjs/Sprites/spriteManager" {
  11190. import { IDisposable, Scene } from "babylonjs/scene";
  11191. import { Nullable } from "babylonjs/types";
  11192. import { Observable } from "babylonjs/Misc/observable";
  11193. import { Sprite } from "babylonjs/Sprites/sprite";
  11194. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11195. import { Camera } from "babylonjs/Cameras/camera";
  11196. import { Texture } from "babylonjs/Materials/Textures/texture";
  11197. import "babylonjs/Shaders/sprites.fragment";
  11198. import "babylonjs/Shaders/sprites.vertex";
  11199. import { Ray } from "babylonjs/Culling/ray";
  11200. /**
  11201. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11202. */
  11203. export interface ISpriteManager extends IDisposable {
  11204. /**
  11205. * Gets manager's name
  11206. */
  11207. name: string;
  11208. /**
  11209. * Restricts the camera to viewing objects with the same layerMask.
  11210. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11211. */
  11212. layerMask: number;
  11213. /**
  11214. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11215. */
  11216. isPickable: boolean;
  11217. /**
  11218. * Gets the hosting scene
  11219. */
  11220. scene: Scene;
  11221. /**
  11222. * Specifies the rendering group id for this mesh (0 by default)
  11223. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11224. */
  11225. renderingGroupId: number;
  11226. /**
  11227. * Defines the list of sprites managed by the manager.
  11228. */
  11229. sprites: Array<Sprite>;
  11230. /**
  11231. * Gets or sets the spritesheet texture
  11232. */
  11233. texture: Texture;
  11234. /** Defines the default width of a cell in the spritesheet */
  11235. cellWidth: number;
  11236. /** Defines the default height of a cell in the spritesheet */
  11237. cellHeight: number;
  11238. /**
  11239. * Tests the intersection of a sprite with a specific ray.
  11240. * @param ray The ray we are sending to test the collision
  11241. * @param camera The camera space we are sending rays in
  11242. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11243. * @param fastCheck defines if the first intersection will be used (and not the closest)
  11244. * @returns picking info or null.
  11245. */
  11246. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11247. /**
  11248. * Intersects the sprites with a ray
  11249. * @param ray defines the ray to intersect with
  11250. * @param camera defines the current active camera
  11251. * @param predicate defines a predicate used to select candidate sprites
  11252. * @returns null if no hit or a PickingInfo array
  11253. */
  11254. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11255. /**
  11256. * Renders the list of sprites on screen.
  11257. */
  11258. render(): void;
  11259. }
  11260. /**
  11261. * Class used to manage multiple sprites on the same spritesheet
  11262. * @see https://doc.babylonjs.com/babylon101/sprites
  11263. */
  11264. export class SpriteManager implements ISpriteManager {
  11265. /** defines the manager's name */
  11266. name: string;
  11267. /** Define the Url to load snippets */
  11268. static SnippetUrl: string;
  11269. /** Snippet ID if the manager was created from the snippet server */
  11270. snippetId: string;
  11271. /** Gets the list of sprites */
  11272. sprites: Sprite[];
  11273. /** Gets or sets the rendering group id (0 by default) */
  11274. renderingGroupId: number;
  11275. /** Gets or sets camera layer mask */
  11276. layerMask: number;
  11277. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11278. fogEnabled: boolean;
  11279. /** Gets or sets a boolean indicating if the sprites are pickable */
  11280. isPickable: boolean;
  11281. /** Defines the default width of a cell in the spritesheet */
  11282. cellWidth: number;
  11283. /** Defines the default height of a cell in the spritesheet */
  11284. cellHeight: number;
  11285. /** Associative array from JSON sprite data file */
  11286. private _cellData;
  11287. /** Array of sprite names from JSON sprite data file */
  11288. private _spriteMap;
  11289. /** True when packed cell data from JSON file is ready*/
  11290. private _packedAndReady;
  11291. private _textureContent;
  11292. private _useInstancing;
  11293. /**
  11294. * An event triggered when the manager is disposed.
  11295. */
  11296. onDisposeObservable: Observable<SpriteManager>;
  11297. private _onDisposeObserver;
  11298. /**
  11299. * Callback called when the manager is disposed
  11300. */
  11301. set onDispose(callback: () => void);
  11302. private _capacity;
  11303. private _fromPacked;
  11304. private _spriteTexture;
  11305. private _epsilon;
  11306. private _scene;
  11307. private _vertexData;
  11308. private _buffer;
  11309. private _vertexBuffers;
  11310. private _spriteBuffer;
  11311. private _indexBuffer;
  11312. private _effectBase;
  11313. private _effectFog;
  11314. private _vertexBufferSize;
  11315. /**
  11316. * Gets or sets the unique id of the sprite
  11317. */
  11318. uniqueId: number;
  11319. /**
  11320. * Gets the array of sprites
  11321. */
  11322. get children(): Sprite[];
  11323. /**
  11324. * Gets the hosting scene
  11325. */
  11326. get scene(): Scene;
  11327. /**
  11328. * Gets the capacity of the manager
  11329. */
  11330. get capacity(): number;
  11331. /**
  11332. * Gets or sets the spritesheet texture
  11333. */
  11334. get texture(): Texture;
  11335. set texture(value: Texture);
  11336. private _blendMode;
  11337. /**
  11338. * Blend mode use to render the particle, it can be any of
  11339. * the static Constants.ALPHA_x properties provided in this class.
  11340. * Default value is Constants.ALPHA_COMBINE
  11341. */
  11342. get blendMode(): number;
  11343. set blendMode(blendMode: number);
  11344. /** Disables writing to the depth buffer when rendering the sprites.
  11345. * It can be handy to disable depth writing when using textures without alpha channel
  11346. * and setting some specific blend modes.
  11347. */
  11348. disableDepthWrite: boolean;
  11349. /**
  11350. * Creates a new sprite manager
  11351. * @param name defines the manager's name
  11352. * @param imgUrl defines the sprite sheet url
  11353. * @param capacity defines the maximum allowed number of sprites
  11354. * @param cellSize defines the size of a sprite cell
  11355. * @param scene defines the hosting scene
  11356. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11357. * @param samplingMode defines the smapling mode to use with spritesheet
  11358. * @param fromPacked set to false; do not alter
  11359. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  11360. */
  11361. constructor(
  11362. /** defines the manager's name */
  11363. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  11364. /**
  11365. * Returns the string "SpriteManager"
  11366. * @returns "SpriteManager"
  11367. */
  11368. getClassName(): string;
  11369. private _makePacked;
  11370. private _appendSpriteVertex;
  11371. private _checkTextureAlpha;
  11372. /**
  11373. * Intersects the sprites with a ray
  11374. * @param ray defines the ray to intersect with
  11375. * @param camera defines the current active camera
  11376. * @param predicate defines a predicate used to select candidate sprites
  11377. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11378. * @returns null if no hit or a PickingInfo
  11379. */
  11380. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11381. /**
  11382. * Intersects the sprites with a ray
  11383. * @param ray defines the ray to intersect with
  11384. * @param camera defines the current active camera
  11385. * @param predicate defines a predicate used to select candidate sprites
  11386. * @returns null if no hit or a PickingInfo array
  11387. */
  11388. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11389. /**
  11390. * Render all child sprites
  11391. */
  11392. render(): void;
  11393. /**
  11394. * Release associated resources
  11395. */
  11396. dispose(): void;
  11397. /**
  11398. * Serializes the sprite manager to a JSON object
  11399. * @param serializeTexture defines if the texture must be serialized as well
  11400. * @returns the JSON object
  11401. */
  11402. serialize(serializeTexture?: boolean): any;
  11403. /**
  11404. * Parses a JSON object to create a new sprite manager.
  11405. * @param parsedManager The JSON object to parse
  11406. * @param scene The scene to create the sprite managerin
  11407. * @param rootUrl The root url to use to load external dependencies like texture
  11408. * @returns the new sprite manager
  11409. */
  11410. static Parse(parsedManager: any, scene: Scene, rootUrl: string): SpriteManager;
  11411. /**
  11412. * Creates a sprite manager from a snippet saved in a remote file
  11413. * @param name defines the name of the sprite manager to create (can be null or empty to use the one from the json data)
  11414. * @param url defines the url to load from
  11415. * @param scene defines the hosting scene
  11416. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  11417. * @returns a promise that will resolve to the new sprite manager
  11418. */
  11419. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  11420. /**
  11421. * Creates a sprite manager from a snippet saved by the sprite editor
  11422. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  11423. * @param scene defines the hosting scene
  11424. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  11425. * @returns a promise that will resolve to the new sprite manager
  11426. */
  11427. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  11428. }
  11429. }
  11430. declare module "babylonjs/Misc/gradients" {
  11431. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  11432. /** Interface used by value gradients (color, factor, ...) */
  11433. export interface IValueGradient {
  11434. /**
  11435. * Gets or sets the gradient value (between 0 and 1)
  11436. */
  11437. gradient: number;
  11438. }
  11439. /** Class used to store color4 gradient */
  11440. export class ColorGradient implements IValueGradient {
  11441. /**
  11442. * Gets or sets the gradient value (between 0 and 1)
  11443. */
  11444. gradient: number;
  11445. /**
  11446. * Gets or sets first associated color
  11447. */
  11448. color1: Color4;
  11449. /**
  11450. * Gets or sets second associated color
  11451. */
  11452. color2?: Color4 | undefined;
  11453. /**
  11454. * Creates a new color4 gradient
  11455. * @param gradient gets or sets the gradient value (between 0 and 1)
  11456. * @param color1 gets or sets first associated color
  11457. * @param color2 gets or sets first second color
  11458. */
  11459. constructor(
  11460. /**
  11461. * Gets or sets the gradient value (between 0 and 1)
  11462. */
  11463. gradient: number,
  11464. /**
  11465. * Gets or sets first associated color
  11466. */
  11467. color1: Color4,
  11468. /**
  11469. * Gets or sets second associated color
  11470. */
  11471. color2?: Color4 | undefined);
  11472. /**
  11473. * Will get a color picked randomly between color1 and color2.
  11474. * If color2 is undefined then color1 will be used
  11475. * @param result defines the target Color4 to store the result in
  11476. */
  11477. getColorToRef(result: Color4): void;
  11478. }
  11479. /** Class used to store color 3 gradient */
  11480. export class Color3Gradient implements IValueGradient {
  11481. /**
  11482. * Gets or sets the gradient value (between 0 and 1)
  11483. */
  11484. gradient: number;
  11485. /**
  11486. * Gets or sets the associated color
  11487. */
  11488. color: Color3;
  11489. /**
  11490. * Creates a new color3 gradient
  11491. * @param gradient gets or sets the gradient value (between 0 and 1)
  11492. * @param color gets or sets associated color
  11493. */
  11494. constructor(
  11495. /**
  11496. * Gets or sets the gradient value (between 0 and 1)
  11497. */
  11498. gradient: number,
  11499. /**
  11500. * Gets or sets the associated color
  11501. */
  11502. color: Color3);
  11503. }
  11504. /** Class used to store factor gradient */
  11505. export class FactorGradient implements IValueGradient {
  11506. /**
  11507. * Gets or sets the gradient value (between 0 and 1)
  11508. */
  11509. gradient: number;
  11510. /**
  11511. * Gets or sets first associated factor
  11512. */
  11513. factor1: number;
  11514. /**
  11515. * Gets or sets second associated factor
  11516. */
  11517. factor2?: number | undefined;
  11518. /**
  11519. * Creates a new factor gradient
  11520. * @param gradient gets or sets the gradient value (between 0 and 1)
  11521. * @param factor1 gets or sets first associated factor
  11522. * @param factor2 gets or sets second associated factor
  11523. */
  11524. constructor(
  11525. /**
  11526. * Gets or sets the gradient value (between 0 and 1)
  11527. */
  11528. gradient: number,
  11529. /**
  11530. * Gets or sets first associated factor
  11531. */
  11532. factor1: number,
  11533. /**
  11534. * Gets or sets second associated factor
  11535. */
  11536. factor2?: number | undefined);
  11537. /**
  11538. * Will get a number picked randomly between factor1 and factor2.
  11539. * If factor2 is undefined then factor1 will be used
  11540. * @returns the picked number
  11541. */
  11542. getFactor(): number;
  11543. }
  11544. /**
  11545. * Helper used to simplify some generic gradient tasks
  11546. */
  11547. export class GradientHelper {
  11548. /**
  11549. * Gets the current gradient from an array of IValueGradient
  11550. * @param ratio defines the current ratio to get
  11551. * @param gradients defines the array of IValueGradient
  11552. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  11553. */
  11554. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  11555. }
  11556. }
  11557. declare module "babylonjs/Engines/Extensions/engine.rawTexture" {
  11558. import { Nullable } from "babylonjs/types";
  11559. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  11560. import { Scene } from "babylonjs/scene";
  11561. module "babylonjs/Engines/thinEngine" {
  11562. interface ThinEngine {
  11563. /**
  11564. * Creates a raw texture
  11565. * @param data defines the data to store in the texture
  11566. * @param width defines the width of the texture
  11567. * @param height defines the height of the texture
  11568. * @param format defines the format of the data
  11569. * @param generateMipMaps defines if the engine should generate the mip levels
  11570. * @param invertY defines if data must be stored with Y axis inverted
  11571. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  11572. * @param compression defines the compression used (null by default)
  11573. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11574. * @returns the raw texture inside an InternalTexture
  11575. */
  11576. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  11577. /**
  11578. * Update a raw texture
  11579. * @param texture defines the texture to update
  11580. * @param data defines the data to store in the texture
  11581. * @param format defines the format of the data
  11582. * @param invertY defines if data must be stored with Y axis inverted
  11583. */
  11584. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11585. /**
  11586. * Update a raw texture
  11587. * @param texture defines the texture to update
  11588. * @param data defines the data to store in the texture
  11589. * @param format defines the format of the data
  11590. * @param invertY defines if data must be stored with Y axis inverted
  11591. * @param compression defines the compression used (null by default)
  11592. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11593. */
  11594. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  11595. /**
  11596. * Creates a new raw cube texture
  11597. * @param data defines the array of data to use to create each face
  11598. * @param size defines the size of the textures
  11599. * @param format defines the format of the data
  11600. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11601. * @param generateMipMaps defines if the engine should generate the mip levels
  11602. * @param invertY defines if data must be stored with Y axis inverted
  11603. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11604. * @param compression defines the compression used (null by default)
  11605. * @returns the cube texture as an InternalTexture
  11606. */
  11607. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  11608. /**
  11609. * Update a raw cube texture
  11610. * @param texture defines the texture to udpdate
  11611. * @param data defines the data to store
  11612. * @param format defines the data format
  11613. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11614. * @param invertY defines if data must be stored with Y axis inverted
  11615. */
  11616. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  11617. /**
  11618. * Update a raw cube texture
  11619. * @param texture defines the texture to udpdate
  11620. * @param data defines the data to store
  11621. * @param format defines the data format
  11622. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11623. * @param invertY defines if data must be stored with Y axis inverted
  11624. * @param compression defines the compression used (null by default)
  11625. */
  11626. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  11627. /**
  11628. * Update a raw cube texture
  11629. * @param texture defines the texture to udpdate
  11630. * @param data defines the data to store
  11631. * @param format defines the data format
  11632. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11633. * @param invertY defines if data must be stored with Y axis inverted
  11634. * @param compression defines the compression used (null by default)
  11635. * @param level defines which level of the texture to update
  11636. */
  11637. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  11638. /**
  11639. * Creates a new raw cube texture from a specified url
  11640. * @param url defines the url where the data is located
  11641. * @param scene defines the current scene
  11642. * @param size defines the size of the textures
  11643. * @param format defines the format of the data
  11644. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11645. * @param noMipmap defines if the engine should avoid generating the mip levels
  11646. * @param callback defines a callback used to extract texture data from loaded data
  11647. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  11648. * @param onLoad defines a callback called when texture is loaded
  11649. * @param onError defines a callback called if there is an error
  11650. * @returns the cube texture as an InternalTexture
  11651. */
  11652. 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;
  11653. /**
  11654. * Creates a new raw cube texture from a specified url
  11655. * @param url defines the url where the data is located
  11656. * @param scene defines the current scene
  11657. * @param size defines the size of the textures
  11658. * @param format defines the format of the data
  11659. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11660. * @param noMipmap defines if the engine should avoid generating the mip levels
  11661. * @param callback defines a callback used to extract texture data from loaded data
  11662. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  11663. * @param onLoad defines a callback called when texture is loaded
  11664. * @param onError defines a callback called if there is an error
  11665. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11666. * @param invertY defines if data must be stored with Y axis inverted
  11667. * @returns the cube texture as an InternalTexture
  11668. */
  11669. 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;
  11670. /**
  11671. * Creates a new raw 3D texture
  11672. * @param data defines the data used to create the texture
  11673. * @param width defines the width of the texture
  11674. * @param height defines the height of the texture
  11675. * @param depth defines the depth of the texture
  11676. * @param format defines the format of the texture
  11677. * @param generateMipMaps defines if the engine must generate mip levels
  11678. * @param invertY defines if data must be stored with Y axis inverted
  11679. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11680. * @param compression defines the compressed used (can be null)
  11681. * @param textureType defines the compressed used (can be null)
  11682. * @returns a new raw 3D texture (stored in an InternalTexture)
  11683. */
  11684. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  11685. /**
  11686. * Update a raw 3D texture
  11687. * @param texture defines the texture to update
  11688. * @param data defines the data to store
  11689. * @param format defines the data format
  11690. * @param invertY defines if data must be stored with Y axis inverted
  11691. */
  11692. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11693. /**
  11694. * Update a raw 3D texture
  11695. * @param texture defines the texture to update
  11696. * @param data defines the data to store
  11697. * @param format defines the data format
  11698. * @param invertY defines if data must be stored with Y axis inverted
  11699. * @param compression defines the used compression (can be null)
  11700. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  11701. */
  11702. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  11703. /**
  11704. * Creates a new raw 2D array texture
  11705. * @param data defines the data used to create the texture
  11706. * @param width defines the width of the texture
  11707. * @param height defines the height of the texture
  11708. * @param depth defines the number of layers of the texture
  11709. * @param format defines the format of the texture
  11710. * @param generateMipMaps defines if the engine must generate mip levels
  11711. * @param invertY defines if data must be stored with Y axis inverted
  11712. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11713. * @param compression defines the compressed used (can be null)
  11714. * @param textureType defines the compressed used (can be null)
  11715. * @returns a new raw 2D array texture (stored in an InternalTexture)
  11716. */
  11717. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  11718. /**
  11719. * Update a raw 2D array texture
  11720. * @param texture defines the texture to update
  11721. * @param data defines the data to store
  11722. * @param format defines the data format
  11723. * @param invertY defines if data must be stored with Y axis inverted
  11724. */
  11725. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11726. /**
  11727. * Update a raw 2D array texture
  11728. * @param texture defines the texture to update
  11729. * @param data defines the data to store
  11730. * @param format defines the data format
  11731. * @param invertY defines if data must be stored with Y axis inverted
  11732. * @param compression defines the used compression (can be null)
  11733. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  11734. */
  11735. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  11736. }
  11737. }
  11738. }
  11739. declare module "babylonjs/Materials/Textures/rawTexture" {
  11740. import { Texture } from "babylonjs/Materials/Textures/texture";
  11741. import "babylonjs/Engines/Extensions/engine.rawTexture";
  11742. import { Nullable } from "babylonjs/types";
  11743. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  11744. import { Scene } from "babylonjs/scene";
  11745. /**
  11746. * Raw texture can help creating a texture directly from an array of data.
  11747. * This can be super useful if you either get the data from an uncompressed source or
  11748. * if you wish to create your texture pixel by pixel.
  11749. */
  11750. export class RawTexture extends Texture {
  11751. /**
  11752. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11753. */
  11754. format: number;
  11755. /**
  11756. * Instantiates a new RawTexture.
  11757. * Raw texture can help creating a texture directly from an array of data.
  11758. * This can be super useful if you either get the data from an uncompressed source or
  11759. * if you wish to create your texture pixel by pixel.
  11760. * @param data define the array of data to use to create the texture
  11761. * @param width define the width of the texture
  11762. * @param height define the height of the texture
  11763. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11764. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11765. * @param generateMipMaps define whether mip maps should be generated or not
  11766. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11767. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11768. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11769. */
  11770. constructor(data: ArrayBufferView, width: number, height: number,
  11771. /**
  11772. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11773. */
  11774. format: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  11775. /**
  11776. * Updates the texture underlying data.
  11777. * @param data Define the new data of the texture
  11778. */
  11779. update(data: ArrayBufferView): void;
  11780. /**
  11781. * Creates a luminance texture from some data.
  11782. * @param data Define the texture data
  11783. * @param width Define the width of the texture
  11784. * @param height Define the height of the texture
  11785. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11786. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11787. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11788. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11789. * @returns the luminance texture
  11790. */
  11791. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11792. /**
  11793. * Creates a luminance alpha texture from some data.
  11794. * @param data Define the texture data
  11795. * @param width Define the width of the texture
  11796. * @param height Define the height of the texture
  11797. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11798. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11799. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11800. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11801. * @returns the luminance alpha texture
  11802. */
  11803. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11804. /**
  11805. * Creates an alpha texture from some data.
  11806. * @param data Define the texture data
  11807. * @param width Define the width of the texture
  11808. * @param height Define the height of the texture
  11809. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11810. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11811. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11812. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11813. * @returns the alpha texture
  11814. */
  11815. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11816. /**
  11817. * Creates a RGB texture from some data.
  11818. * @param data Define the texture data
  11819. * @param width Define the width of the texture
  11820. * @param height Define the height of the texture
  11821. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11822. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11823. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11824. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11825. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11826. * @returns the RGB alpha texture
  11827. */
  11828. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11829. /**
  11830. * Creates a RGBA texture from some data.
  11831. * @param data Define the texture data
  11832. * @param width Define the width of the texture
  11833. * @param height Define the height of the texture
  11834. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11835. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11836. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11837. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11838. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11839. * @returns the RGBA texture
  11840. */
  11841. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11842. /**
  11843. * Creates a R texture from some data.
  11844. * @param data Define the texture data
  11845. * @param width Define the width of the texture
  11846. * @param height Define the height of the texture
  11847. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11848. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11849. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11850. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11851. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11852. * @returns the R texture
  11853. */
  11854. static CreateRTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11855. }
  11856. }
  11857. declare module "babylonjs/Engines/Extensions/engine.dynamicBuffer" {
  11858. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  11859. import { IndicesArray, DataArray } from "babylonjs/types";
  11860. module "babylonjs/Engines/thinEngine" {
  11861. interface ThinEngine {
  11862. /**
  11863. * Update a dynamic index buffer
  11864. * @param indexBuffer defines the target index buffer
  11865. * @param indices defines the data to update
  11866. * @param offset defines the offset in the target index buffer where update should start
  11867. */
  11868. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  11869. /**
  11870. * Updates a dynamic vertex buffer.
  11871. * @param vertexBuffer the vertex buffer to update
  11872. * @param data the data used to update the vertex buffer
  11873. * @param byteOffset the byte offset of the data
  11874. * @param byteLength the byte length of the data
  11875. */
  11876. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  11877. }
  11878. }
  11879. }
  11880. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent" {
  11881. import { Scene } from "babylonjs/scene";
  11882. import { ISceneComponent } from "babylonjs/sceneComponent";
  11883. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  11884. module "babylonjs/abstractScene" {
  11885. interface AbstractScene {
  11886. /**
  11887. * The list of procedural textures added to the scene
  11888. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11889. */
  11890. proceduralTextures: Array<ProceduralTexture>;
  11891. }
  11892. }
  11893. /**
  11894. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  11895. * in a given scene.
  11896. */
  11897. export class ProceduralTextureSceneComponent implements ISceneComponent {
  11898. /**
  11899. * The component name helpfull to identify the component in the list of scene components.
  11900. */
  11901. readonly name: string;
  11902. /**
  11903. * The scene the component belongs to.
  11904. */
  11905. scene: Scene;
  11906. /**
  11907. * Creates a new instance of the component for the given scene
  11908. * @param scene Defines the scene to register the component in
  11909. */
  11910. constructor(scene: Scene);
  11911. /**
  11912. * Registers the component in a given scene
  11913. */
  11914. register(): void;
  11915. /**
  11916. * Rebuilds the elements related to this component in case of
  11917. * context lost for instance.
  11918. */
  11919. rebuild(): void;
  11920. /**
  11921. * Disposes the component and the associated ressources.
  11922. */
  11923. dispose(): void;
  11924. private _beforeClear;
  11925. }
  11926. }
  11927. declare module "babylonjs/Engines/Extensions/engine.renderTargetCube" {
  11928. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  11929. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  11930. module "babylonjs/Engines/thinEngine" {
  11931. interface ThinEngine {
  11932. /**
  11933. * Creates a new render target cube texture
  11934. * @param size defines the size of the texture
  11935. * @param options defines the options used to create the texture
  11936. * @returns a new render target cube texture stored in an InternalTexture
  11937. */
  11938. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  11939. }
  11940. }
  11941. }
  11942. declare module "babylonjs/Shaders/procedural.vertex" {
  11943. /** @hidden */
  11944. export var proceduralVertexShader: {
  11945. name: string;
  11946. shader: string;
  11947. };
  11948. }
  11949. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTexture" {
  11950. import { Observable } from "babylonjs/Misc/observable";
  11951. import { Nullable } from "babylonjs/types";
  11952. import { Scene } from "babylonjs/scene";
  11953. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  11954. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  11955. import { Effect } from "babylonjs/Materials/effect";
  11956. import { Texture } from "babylonjs/Materials/Textures/texture";
  11957. import "babylonjs/Engines/Extensions/engine.renderTarget";
  11958. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  11959. import "babylonjs/Shaders/procedural.vertex";
  11960. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  11961. import { RenderTargetTextureSize } from "babylonjs/Engines/Extensions/engine.renderTarget";
  11962. /**
  11963. * 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.
  11964. * This is the base class of any Procedural texture and contains most of the shareable code.
  11965. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11966. */
  11967. export class ProceduralTexture extends Texture {
  11968. /**
  11969. * Define if the texture is enabled or not (disabled texture will not render)
  11970. */
  11971. isEnabled: boolean;
  11972. /**
  11973. * Define if the texture must be cleared before rendering (default is true)
  11974. */
  11975. autoClear: boolean;
  11976. /**
  11977. * Callback called when the texture is generated
  11978. */
  11979. onGenerated: () => void;
  11980. /**
  11981. * Event raised when the texture is generated
  11982. */
  11983. onGeneratedObservable: Observable<ProceduralTexture>;
  11984. /**
  11985. * Event raised before the texture is generated
  11986. */
  11987. onBeforeGenerationObservable: Observable<ProceduralTexture>;
  11988. /**
  11989. * Gets or sets the node material used to create this texture (null if the texture was manually created)
  11990. */
  11991. nodeMaterialSource: Nullable<NodeMaterial>;
  11992. /** @hidden */
  11993. _generateMipMaps: boolean;
  11994. /** @hidden **/
  11995. _effect: Effect;
  11996. /** @hidden */
  11997. _textures: {
  11998. [key: string]: Texture;
  11999. };
  12000. /** @hidden */
  12001. protected _fallbackTexture: Nullable<Texture>;
  12002. private _size;
  12003. private _currentRefreshId;
  12004. private _frameId;
  12005. private _refreshRate;
  12006. private _vertexBuffers;
  12007. private _indexBuffer;
  12008. private _uniforms;
  12009. private _samplers;
  12010. private _fragment;
  12011. private _floats;
  12012. private _ints;
  12013. private _floatsArrays;
  12014. private _colors3;
  12015. private _colors4;
  12016. private _vectors2;
  12017. private _vectors3;
  12018. private _matrices;
  12019. private _fallbackTextureUsed;
  12020. private _fullEngine;
  12021. private _cachedDefines;
  12022. private _contentUpdateId;
  12023. private _contentData;
  12024. /**
  12025. * Instantiates a new procedural texture.
  12026. * 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.
  12027. * This is the base class of any Procedural texture and contains most of the shareable code.
  12028. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  12029. * @param name Define the name of the texture
  12030. * @param size Define the size of the texture to create
  12031. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  12032. * @param scene Define the scene the texture belongs to
  12033. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  12034. * @param generateMipMaps Define if the texture should creates mip maps or not
  12035. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  12036. */
  12037. constructor(name: string, size: RenderTargetTextureSize, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  12038. /**
  12039. * The effect that is created when initializing the post process.
  12040. * @returns The created effect corresponding the the postprocess.
  12041. */
  12042. getEffect(): Effect;
  12043. /**
  12044. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  12045. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  12046. */
  12047. getContent(): Nullable<ArrayBufferView>;
  12048. private _createIndexBuffer;
  12049. /** @hidden */
  12050. _rebuild(): void;
  12051. /**
  12052. * Resets the texture in order to recreate its associated resources.
  12053. * This can be called in case of context loss
  12054. */
  12055. reset(): void;
  12056. protected _getDefines(): string;
  12057. /**
  12058. * Is the texture ready to be used ? (rendered at least once)
  12059. * @returns true if ready, otherwise, false.
  12060. */
  12061. isReady(): boolean;
  12062. /**
  12063. * Resets the refresh counter of the texture and start bak from scratch.
  12064. * Could be useful to regenerate the texture if it is setup to render only once.
  12065. */
  12066. resetRefreshCounter(): void;
  12067. /**
  12068. * Set the fragment shader to use in order to render the texture.
  12069. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  12070. */
  12071. setFragment(fragment: any): void;
  12072. /**
  12073. * Define the refresh rate of the texture or the rendering frequency.
  12074. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  12075. */
  12076. get refreshRate(): number;
  12077. set refreshRate(value: number);
  12078. /** @hidden */
  12079. _shouldRender(): boolean;
  12080. /**
  12081. * Get the size the texture is rendering at.
  12082. * @returns the size (on cube texture it is always squared)
  12083. */
  12084. getRenderSize(): RenderTargetTextureSize;
  12085. /**
  12086. * Resize the texture to new value.
  12087. * @param size Define the new size the texture should have
  12088. * @param generateMipMaps Define whether the new texture should create mip maps
  12089. */
  12090. resize(size: number, generateMipMaps: boolean): void;
  12091. private _checkUniform;
  12092. /**
  12093. * Set a texture in the shader program used to render.
  12094. * @param name Define the name of the uniform samplers as defined in the shader
  12095. * @param texture Define the texture to bind to this sampler
  12096. * @return the texture itself allowing "fluent" like uniform updates
  12097. */
  12098. setTexture(name: string, texture: Texture): ProceduralTexture;
  12099. /**
  12100. * Set a float in the shader.
  12101. * @param name Define the name of the uniform as defined in the shader
  12102. * @param value Define the value to give to the uniform
  12103. * @return the texture itself allowing "fluent" like uniform updates
  12104. */
  12105. setFloat(name: string, value: number): ProceduralTexture;
  12106. /**
  12107. * Set a int in the shader.
  12108. * @param name Define the name of the uniform as defined in the shader
  12109. * @param value Define the value to give to the uniform
  12110. * @return the texture itself allowing "fluent" like uniform updates
  12111. */
  12112. setInt(name: string, value: number): ProceduralTexture;
  12113. /**
  12114. * Set an array of floats in the shader.
  12115. * @param name Define the name of the uniform as defined in the shader
  12116. * @param value Define the value to give to the uniform
  12117. * @return the texture itself allowing "fluent" like uniform updates
  12118. */
  12119. setFloats(name: string, value: number[]): ProceduralTexture;
  12120. /**
  12121. * Set a vec3 in the shader from a Color3.
  12122. * @param name Define the name of the uniform as defined in the shader
  12123. * @param value Define the value to give to the uniform
  12124. * @return the texture itself allowing "fluent" like uniform updates
  12125. */
  12126. setColor3(name: string, value: Color3): ProceduralTexture;
  12127. /**
  12128. * Set a vec4 in the shader from a Color4.
  12129. * @param name Define the name of the uniform as defined in the shader
  12130. * @param value Define the value to give to the uniform
  12131. * @return the texture itself allowing "fluent" like uniform updates
  12132. */
  12133. setColor4(name: string, value: Color4): ProceduralTexture;
  12134. /**
  12135. * Set a vec2 in the shader from a Vector2.
  12136. * @param name Define the name of the uniform as defined in the shader
  12137. * @param value Define the value to give to the uniform
  12138. * @return the texture itself allowing "fluent" like uniform updates
  12139. */
  12140. setVector2(name: string, value: Vector2): ProceduralTexture;
  12141. /**
  12142. * Set a vec3 in the shader from a Vector3.
  12143. * @param name Define the name of the uniform as defined in the shader
  12144. * @param value Define the value to give to the uniform
  12145. * @return the texture itself allowing "fluent" like uniform updates
  12146. */
  12147. setVector3(name: string, value: Vector3): ProceduralTexture;
  12148. /**
  12149. * Set a mat4 in the shader from a MAtrix.
  12150. * @param name Define the name of the uniform as defined in the shader
  12151. * @param value Define the value to give to the uniform
  12152. * @return the texture itself allowing "fluent" like uniform updates
  12153. */
  12154. setMatrix(name: string, value: Matrix): ProceduralTexture;
  12155. /**
  12156. * Render the texture to its associated render target.
  12157. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  12158. */
  12159. render(useCameraPostProcess?: boolean): void;
  12160. /**
  12161. * Clone the texture.
  12162. * @returns the cloned texture
  12163. */
  12164. clone(): ProceduralTexture;
  12165. /**
  12166. * Dispose the texture and release its asoociated resources.
  12167. */
  12168. dispose(): void;
  12169. }
  12170. }
  12171. declare module "babylonjs/Particles/baseParticleSystem" {
  12172. import { Nullable } from "babylonjs/types";
  12173. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  12174. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12175. import { ImageProcessingConfiguration, ImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  12176. import { ColorGradient, FactorGradient, Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  12177. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  12178. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  12179. import { Color4 } from "babylonjs/Maths/math.color";
  12180. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  12181. import "babylonjs/Engines/Extensions/engine.dynamicBuffer";
  12182. import { Animation } from "babylonjs/Animations/animation";
  12183. import { Scene } from "babylonjs/scene";
  12184. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  12185. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  12186. /**
  12187. * This represents the base class for particle system in Babylon.
  12188. * 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.
  12189. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  12190. * @example https://doc.babylonjs.com/babylon101/particles
  12191. */
  12192. export class BaseParticleSystem {
  12193. /**
  12194. * Source color is added to the destination color without alpha affecting the result
  12195. */
  12196. static BLENDMODE_ONEONE: number;
  12197. /**
  12198. * Blend current color and particle color using particle’s alpha
  12199. */
  12200. static BLENDMODE_STANDARD: number;
  12201. /**
  12202. * Add current color and particle color multiplied by particle’s alpha
  12203. */
  12204. static BLENDMODE_ADD: number;
  12205. /**
  12206. * Multiply current color with particle color
  12207. */
  12208. static BLENDMODE_MULTIPLY: number;
  12209. /**
  12210. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  12211. */
  12212. static BLENDMODE_MULTIPLYADD: number;
  12213. /**
  12214. * List of animations used by the particle system.
  12215. */
  12216. animations: Animation[];
  12217. /**
  12218. * Gets or sets the unique id of the particle system
  12219. */
  12220. uniqueId: number;
  12221. /**
  12222. * The id of the Particle system.
  12223. */
  12224. id: string;
  12225. /**
  12226. * The friendly name of the Particle system.
  12227. */
  12228. name: string;
  12229. /**
  12230. * Snippet ID if the particle system was created from the snippet server
  12231. */
  12232. snippetId: string;
  12233. /**
  12234. * The rendering group used by the Particle system to chose when to render.
  12235. */
  12236. renderingGroupId: number;
  12237. /**
  12238. * The emitter represents the Mesh or position we are attaching the particle system to.
  12239. */
  12240. emitter: Nullable<AbstractMesh | Vector3>;
  12241. /**
  12242. * The maximum number of particles to emit per frame
  12243. */
  12244. emitRate: number;
  12245. /**
  12246. * If you want to launch only a few particles at once, that can be done, as well.
  12247. */
  12248. manualEmitCount: number;
  12249. /**
  12250. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  12251. */
  12252. updateSpeed: number;
  12253. /**
  12254. * The amount of time the particle system is running (depends of the overall update speed).
  12255. */
  12256. targetStopDuration: number;
  12257. /**
  12258. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  12259. */
  12260. disposeOnStop: boolean;
  12261. /**
  12262. * Minimum power of emitting particles.
  12263. */
  12264. minEmitPower: number;
  12265. /**
  12266. * Maximum power of emitting particles.
  12267. */
  12268. maxEmitPower: number;
  12269. /**
  12270. * Minimum life time of emitting particles.
  12271. */
  12272. minLifeTime: number;
  12273. /**
  12274. * Maximum life time of emitting particles.
  12275. */
  12276. maxLifeTime: number;
  12277. /**
  12278. * Minimum Size of emitting particles.
  12279. */
  12280. minSize: number;
  12281. /**
  12282. * Maximum Size of emitting particles.
  12283. */
  12284. maxSize: number;
  12285. /**
  12286. * Minimum scale of emitting particles on X axis.
  12287. */
  12288. minScaleX: number;
  12289. /**
  12290. * Maximum scale of emitting particles on X axis.
  12291. */
  12292. maxScaleX: number;
  12293. /**
  12294. * Minimum scale of emitting particles on Y axis.
  12295. */
  12296. minScaleY: number;
  12297. /**
  12298. * Maximum scale of emitting particles on Y axis.
  12299. */
  12300. maxScaleY: number;
  12301. /**
  12302. * Gets or sets the minimal initial rotation in radians.
  12303. */
  12304. minInitialRotation: number;
  12305. /**
  12306. * Gets or sets the maximal initial rotation in radians.
  12307. */
  12308. maxInitialRotation: number;
  12309. /**
  12310. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  12311. */
  12312. minAngularSpeed: number;
  12313. /**
  12314. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  12315. */
  12316. maxAngularSpeed: number;
  12317. /**
  12318. * The texture used to render each particle. (this can be a spritesheet)
  12319. */
  12320. particleTexture: Nullable<BaseTexture>;
  12321. /**
  12322. * The layer mask we are rendering the particles through.
  12323. */
  12324. layerMask: number;
  12325. /**
  12326. * This can help using your own shader to render the particle system.
  12327. * The according effect will be created
  12328. */
  12329. customShader: any;
  12330. /**
  12331. * By default particle system starts as soon as they are created. This prevents the
  12332. * automatic start to happen and let you decide when to start emitting particles.
  12333. */
  12334. preventAutoStart: boolean;
  12335. private _noiseTexture;
  12336. /**
  12337. * Gets or sets a texture used to add random noise to particle positions
  12338. */
  12339. get noiseTexture(): Nullable<ProceduralTexture>;
  12340. set noiseTexture(value: Nullable<ProceduralTexture>);
  12341. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  12342. noiseStrength: Vector3;
  12343. /**
  12344. * Callback triggered when the particle animation is ending.
  12345. */
  12346. onAnimationEnd: Nullable<() => void>;
  12347. /**
  12348. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  12349. */
  12350. blendMode: number;
  12351. /**
  12352. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  12353. * to override the particles.
  12354. */
  12355. forceDepthWrite: boolean;
  12356. /** 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 */
  12357. preWarmCycles: number;
  12358. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  12359. preWarmStepOffset: number;
  12360. /**
  12361. * 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)
  12362. */
  12363. spriteCellChangeSpeed: number;
  12364. /**
  12365. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  12366. */
  12367. startSpriteCellID: number;
  12368. /**
  12369. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  12370. */
  12371. endSpriteCellID: number;
  12372. /**
  12373. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  12374. */
  12375. spriteCellWidth: number;
  12376. /**
  12377. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  12378. */
  12379. spriteCellHeight: number;
  12380. /**
  12381. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  12382. */
  12383. spriteRandomStartCell: boolean;
  12384. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  12385. translationPivot: Vector2;
  12386. /** @hidden */
  12387. protected _isAnimationSheetEnabled: boolean;
  12388. /**
  12389. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  12390. */
  12391. beginAnimationOnStart: boolean;
  12392. /**
  12393. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  12394. */
  12395. beginAnimationFrom: number;
  12396. /**
  12397. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  12398. */
  12399. beginAnimationTo: number;
  12400. /**
  12401. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  12402. */
  12403. beginAnimationLoop: boolean;
  12404. /**
  12405. * Gets or sets a world offset applied to all particles
  12406. */
  12407. worldOffset: Vector3;
  12408. /**
  12409. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  12410. */
  12411. get isAnimationSheetEnabled(): boolean;
  12412. set isAnimationSheetEnabled(value: boolean);
  12413. /**
  12414. * Get hosting scene
  12415. * @returns the scene
  12416. */
  12417. getScene(): Nullable<Scene>;
  12418. /**
  12419. * You can use gravity if you want to give an orientation to your particles.
  12420. */
  12421. gravity: Vector3;
  12422. protected _colorGradients: Nullable<Array<ColorGradient>>;
  12423. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  12424. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  12425. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  12426. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  12427. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  12428. protected _dragGradients: Nullable<Array<FactorGradient>>;
  12429. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  12430. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  12431. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  12432. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  12433. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  12434. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  12435. /**
  12436. * Defines the delay in milliseconds before starting the system (0 by default)
  12437. */
  12438. startDelay: number;
  12439. /**
  12440. * Gets the current list of drag gradients.
  12441. * You must use addDragGradient and removeDragGradient to udpate this list
  12442. * @returns the list of drag gradients
  12443. */
  12444. getDragGradients(): Nullable<Array<FactorGradient>>;
  12445. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  12446. limitVelocityDamping: number;
  12447. /**
  12448. * Gets the current list of limit velocity gradients.
  12449. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  12450. * @returns the list of limit velocity gradients
  12451. */
  12452. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  12453. /**
  12454. * Gets the current list of color gradients.
  12455. * You must use addColorGradient and removeColorGradient to udpate this list
  12456. * @returns the list of color gradients
  12457. */
  12458. getColorGradients(): Nullable<Array<ColorGradient>>;
  12459. /**
  12460. * Gets the current list of size gradients.
  12461. * You must use addSizeGradient and removeSizeGradient to udpate this list
  12462. * @returns the list of size gradients
  12463. */
  12464. getSizeGradients(): Nullable<Array<FactorGradient>>;
  12465. /**
  12466. * Gets the current list of color remap gradients.
  12467. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  12468. * @returns the list of color remap gradients
  12469. */
  12470. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  12471. /**
  12472. * Gets the current list of alpha remap gradients.
  12473. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  12474. * @returns the list of alpha remap gradients
  12475. */
  12476. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  12477. /**
  12478. * Gets the current list of life time gradients.
  12479. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  12480. * @returns the list of life time gradients
  12481. */
  12482. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  12483. /**
  12484. * Gets the current list of angular speed gradients.
  12485. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  12486. * @returns the list of angular speed gradients
  12487. */
  12488. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  12489. /**
  12490. * Gets the current list of velocity gradients.
  12491. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  12492. * @returns the list of velocity gradients
  12493. */
  12494. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  12495. /**
  12496. * Gets the current list of start size gradients.
  12497. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  12498. * @returns the list of start size gradients
  12499. */
  12500. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  12501. /**
  12502. * Gets the current list of emit rate gradients.
  12503. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  12504. * @returns the list of emit rate gradients
  12505. */
  12506. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  12507. /**
  12508. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12509. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12510. */
  12511. get direction1(): Vector3;
  12512. set direction1(value: Vector3);
  12513. /**
  12514. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12515. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12516. */
  12517. get direction2(): Vector3;
  12518. set direction2(value: Vector3);
  12519. /**
  12520. * 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.
  12521. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12522. */
  12523. get minEmitBox(): Vector3;
  12524. set minEmitBox(value: Vector3);
  12525. /**
  12526. * 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.
  12527. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12528. */
  12529. get maxEmitBox(): Vector3;
  12530. set maxEmitBox(value: Vector3);
  12531. /**
  12532. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  12533. */
  12534. color1: Color4;
  12535. /**
  12536. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  12537. */
  12538. color2: Color4;
  12539. /**
  12540. * Color the particle will have at the end of its lifetime
  12541. */
  12542. colorDead: Color4;
  12543. /**
  12544. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  12545. */
  12546. textureMask: Color4;
  12547. /**
  12548. * The particle emitter type defines the emitter used by the particle system.
  12549. * It can be for example box, sphere, or cone...
  12550. */
  12551. particleEmitterType: IParticleEmitterType;
  12552. /** @hidden */
  12553. _isSubEmitter: boolean;
  12554. /**
  12555. * Gets or sets the billboard mode to use when isBillboardBased = true.
  12556. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  12557. */
  12558. billboardMode: number;
  12559. protected _isBillboardBased: boolean;
  12560. /**
  12561. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  12562. */
  12563. get isBillboardBased(): boolean;
  12564. set isBillboardBased(value: boolean);
  12565. /**
  12566. * The scene the particle system belongs to.
  12567. */
  12568. protected _scene: Nullable<Scene>;
  12569. /**
  12570. * The engine the particle system belongs to.
  12571. */
  12572. protected _engine: ThinEngine;
  12573. /**
  12574. * Local cache of defines for image processing.
  12575. */
  12576. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  12577. /**
  12578. * Default configuration related to image processing available in the standard Material.
  12579. */
  12580. protected _imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  12581. /**
  12582. * Gets the image processing configuration used either in this material.
  12583. */
  12584. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  12585. /**
  12586. * Sets the Default image processing configuration used either in the this material.
  12587. *
  12588. * If sets to null, the scene one is in use.
  12589. */
  12590. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  12591. /**
  12592. * Attaches a new image processing configuration to the Standard Material.
  12593. * @param configuration
  12594. */
  12595. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  12596. /** @hidden */
  12597. protected _reset(): void;
  12598. /** @hidden */
  12599. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  12600. /**
  12601. * Instantiates a particle system.
  12602. * 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.
  12603. * @param name The name of the particle system
  12604. */
  12605. constructor(name: string);
  12606. /**
  12607. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  12608. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  12609. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  12610. * @returns the emitter
  12611. */
  12612. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  12613. /**
  12614. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  12615. * @param radius The radius of the hemisphere to emit from
  12616. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  12617. * @returns the emitter
  12618. */
  12619. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  12620. /**
  12621. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  12622. * @param radius The radius of the sphere to emit from
  12623. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  12624. * @returns the emitter
  12625. */
  12626. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  12627. /**
  12628. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  12629. * @param radius The radius of the sphere to emit from
  12630. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  12631. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  12632. * @returns the emitter
  12633. */
  12634. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  12635. /**
  12636. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  12637. * @param radius The radius of the emission cylinder
  12638. * @param height The height of the emission cylinder
  12639. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  12640. * @param directionRandomizer How much to randomize the particle direction [0-1]
  12641. * @returns the emitter
  12642. */
  12643. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  12644. /**
  12645. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  12646. * @param radius The radius of the cylinder to emit from
  12647. * @param height The height of the emission cylinder
  12648. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12649. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  12650. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  12651. * @returns the emitter
  12652. */
  12653. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  12654. /**
  12655. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  12656. * @param radius The radius of the cone to emit from
  12657. * @param angle The base angle of the cone
  12658. * @returns the emitter
  12659. */
  12660. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  12661. /**
  12662. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  12663. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  12664. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  12665. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  12666. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  12667. * @returns the emitter
  12668. */
  12669. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  12670. }
  12671. }
  12672. declare module "babylonjs/Particles/subEmitter" {
  12673. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  12674. import { Scene } from "babylonjs/scene";
  12675. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  12676. /**
  12677. * Type of sub emitter
  12678. */
  12679. export enum SubEmitterType {
  12680. /**
  12681. * Attached to the particle over it's lifetime
  12682. */
  12683. ATTACHED = 0,
  12684. /**
  12685. * Created when the particle dies
  12686. */
  12687. END = 1
  12688. }
  12689. /**
  12690. * Sub emitter class used to emit particles from an existing particle
  12691. */
  12692. export class SubEmitter {
  12693. /**
  12694. * the particle system to be used by the sub emitter
  12695. */
  12696. particleSystem: ParticleSystem;
  12697. /**
  12698. * Type of the submitter (Default: END)
  12699. */
  12700. type: SubEmitterType;
  12701. /**
  12702. * 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)
  12703. * Note: This only is supported when using an emitter of type Mesh
  12704. */
  12705. inheritDirection: boolean;
  12706. /**
  12707. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  12708. */
  12709. inheritedVelocityAmount: number;
  12710. /**
  12711. * Creates a sub emitter
  12712. * @param particleSystem the particle system to be used by the sub emitter
  12713. */
  12714. constructor(
  12715. /**
  12716. * the particle system to be used by the sub emitter
  12717. */
  12718. particleSystem: ParticleSystem);
  12719. /**
  12720. * Clones the sub emitter
  12721. * @returns the cloned sub emitter
  12722. */
  12723. clone(): SubEmitter;
  12724. /**
  12725. * Serialize current object to a JSON object
  12726. * @returns the serialized object
  12727. */
  12728. serialize(): any;
  12729. /** @hidden */
  12730. static _ParseParticleSystem(system: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): ParticleSystem;
  12731. /**
  12732. * Creates a new SubEmitter from a serialized JSON version
  12733. * @param serializationObject defines the JSON object to read from
  12734. * @param sceneOrEngine defines the hosting scene or the hosting engine
  12735. * @param rootUrl defines the rootUrl for data loading
  12736. * @returns a new SubEmitter
  12737. */
  12738. static Parse(serializationObject: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): SubEmitter;
  12739. /** Release associated resources */
  12740. dispose(): void;
  12741. }
  12742. }
  12743. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration" {
  12744. /** @hidden */
  12745. export var imageProcessingDeclaration: {
  12746. name: string;
  12747. shader: string;
  12748. };
  12749. }
  12750. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions" {
  12751. /** @hidden */
  12752. export var imageProcessingFunctions: {
  12753. name: string;
  12754. shader: string;
  12755. };
  12756. }
  12757. declare module "babylonjs/Shaders/particles.fragment" {
  12758. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  12759. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  12760. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  12761. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  12762. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  12763. /** @hidden */
  12764. export var particlesPixelShader: {
  12765. name: string;
  12766. shader: string;
  12767. };
  12768. }
  12769. declare module "babylonjs/Shaders/particles.vertex" {
  12770. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  12771. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  12772. /** @hidden */
  12773. export var particlesVertexShader: {
  12774. name: string;
  12775. shader: string;
  12776. };
  12777. }
  12778. declare module "babylonjs/Misc/interfaces/iClipPlanesHolder" {
  12779. import { Nullable } from "babylonjs/types";
  12780. import { Plane } from "babylonjs/Maths/math";
  12781. /**
  12782. * Interface used to define entities containing multiple clip planes
  12783. */
  12784. export interface IClipPlanesHolder {
  12785. /**
  12786. * Gets or sets the active clipplane 1
  12787. */
  12788. clipPlane: Nullable<Plane>;
  12789. /**
  12790. * Gets or sets the active clipplane 2
  12791. */
  12792. clipPlane2: Nullable<Plane>;
  12793. /**
  12794. * Gets or sets the active clipplane 3
  12795. */
  12796. clipPlane3: Nullable<Plane>;
  12797. /**
  12798. * Gets or sets the active clipplane 4
  12799. */
  12800. clipPlane4: Nullable<Plane>;
  12801. /**
  12802. * Gets or sets the active clipplane 5
  12803. */
  12804. clipPlane5: Nullable<Plane>;
  12805. /**
  12806. * Gets or sets the active clipplane 6
  12807. */
  12808. clipPlane6: Nullable<Plane>;
  12809. }
  12810. }
  12811. declare module "babylonjs/Materials/thinMaterialHelper" {
  12812. import { Effect } from "babylonjs/Materials/effect";
  12813. import { IClipPlanesHolder } from "babylonjs/Misc/interfaces/iClipPlanesHolder";
  12814. /**
  12815. * "Static Class" containing a few commonly used helper while dealing with material for rendering purpose.
  12816. *
  12817. * It is complementary with MaterialHelper but provides completely independent functions (for tree shaking sake)
  12818. *
  12819. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  12820. */
  12821. export class ThinMaterialHelper {
  12822. /**
  12823. * Binds the clip plane information from the holder to the effect.
  12824. * @param effect The effect we are binding the data to
  12825. * @param holder The entity containing the clip plane information
  12826. */
  12827. static BindClipPlane(effect: Effect, holder: IClipPlanesHolder): void;
  12828. }
  12829. }
  12830. declare module "babylonjs/Engines/Extensions/engine.alpha" {
  12831. module "babylonjs/Engines/thinEngine" {
  12832. interface ThinEngine {
  12833. /**
  12834. * Sets alpha constants used by some alpha blending modes
  12835. * @param r defines the red component
  12836. * @param g defines the green component
  12837. * @param b defines the blue component
  12838. * @param a defines the alpha component
  12839. */
  12840. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  12841. /**
  12842. * Sets the current alpha mode
  12843. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  12844. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  12845. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  12846. */
  12847. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  12848. /**
  12849. * Gets the current alpha mode
  12850. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  12851. * @returns the current alpha mode
  12852. */
  12853. getAlphaMode(): number;
  12854. /**
  12855. * Sets the current alpha equation
  12856. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  12857. */
  12858. setAlphaEquation(equation: number): void;
  12859. /**
  12860. * Gets the current alpha equation.
  12861. * @returns the current alpha equation
  12862. */
  12863. getAlphaEquation(): number;
  12864. }
  12865. }
  12866. }
  12867. declare module "babylonjs/Particles/particleSystem" {
  12868. import { Nullable } from "babylonjs/types";
  12869. import { FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  12870. import { Observable } from "babylonjs/Misc/observable";
  12871. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  12872. import { Effect } from "babylonjs/Materials/effect";
  12873. import { IDisposable } from "babylonjs/scene";
  12874. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  12875. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  12876. import { Particle } from "babylonjs/Particles/particle";
  12877. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  12878. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  12879. import "babylonjs/Shaders/particles.fragment";
  12880. import "babylonjs/Shaders/particles.vertex";
  12881. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  12882. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  12883. import "babylonjs/Engines/Extensions/engine.alpha";
  12884. import { Scene } from "babylonjs/scene";
  12885. /**
  12886. * This represents a particle system in Babylon.
  12887. * 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.
  12888. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  12889. * @example https://doc.babylonjs.com/babylon101/particles
  12890. */
  12891. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  12892. /**
  12893. * Billboard mode will only apply to Y axis
  12894. */
  12895. static readonly BILLBOARDMODE_Y: number;
  12896. /**
  12897. * Billboard mode will apply to all axes
  12898. */
  12899. static readonly BILLBOARDMODE_ALL: number;
  12900. /**
  12901. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  12902. */
  12903. static readonly BILLBOARDMODE_STRETCHED: number;
  12904. /**
  12905. * This function can be defined to provide custom update for active particles.
  12906. * This function will be called instead of regular update (age, position, color, etc.).
  12907. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  12908. */
  12909. updateFunction: (particles: Particle[]) => void;
  12910. private _emitterWorldMatrix;
  12911. /**
  12912. * This function can be defined to specify initial direction for every new particle.
  12913. * It by default use the emitterType defined function
  12914. */
  12915. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  12916. /**
  12917. * This function can be defined to specify initial position for every new particle.
  12918. * It by default use the emitterType defined function
  12919. */
  12920. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  12921. /**
  12922. * @hidden
  12923. */
  12924. _inheritedVelocityOffset: Vector3;
  12925. /**
  12926. * An event triggered when the system is disposed
  12927. */
  12928. onDisposeObservable: Observable<IParticleSystem>;
  12929. private _onDisposeObserver;
  12930. /**
  12931. * Sets a callback that will be triggered when the system is disposed
  12932. */
  12933. set onDispose(callback: () => void);
  12934. private _particles;
  12935. private _epsilon;
  12936. private _capacity;
  12937. private _stockParticles;
  12938. private _newPartsExcess;
  12939. private _vertexData;
  12940. private _vertexBuffer;
  12941. private _vertexBuffers;
  12942. private _spriteBuffer;
  12943. private _indexBuffer;
  12944. private _effect;
  12945. private _customEffect;
  12946. private _cachedDefines;
  12947. private _scaledColorStep;
  12948. private _colorDiff;
  12949. private _scaledDirection;
  12950. private _scaledGravity;
  12951. private _currentRenderId;
  12952. private _alive;
  12953. private _useInstancing;
  12954. private _started;
  12955. private _stopped;
  12956. private _actualFrame;
  12957. private _scaledUpdateSpeed;
  12958. private _vertexBufferSize;
  12959. /** @hidden */
  12960. _currentEmitRateGradient: Nullable<FactorGradient>;
  12961. /** @hidden */
  12962. _currentEmitRate1: number;
  12963. /** @hidden */
  12964. _currentEmitRate2: number;
  12965. /** @hidden */
  12966. _currentStartSizeGradient: Nullable<FactorGradient>;
  12967. /** @hidden */
  12968. _currentStartSize1: number;
  12969. /** @hidden */
  12970. _currentStartSize2: number;
  12971. private readonly _rawTextureWidth;
  12972. private _rampGradientsTexture;
  12973. private _useRampGradients;
  12974. /** Gets or sets a matrix to use to compute projection */
  12975. defaultProjectionMatrix: Matrix;
  12976. /** Gets or sets a matrix to use to compute view */
  12977. defaultViewMatrix: Matrix;
  12978. /** Gets or sets a boolean indicating that ramp gradients must be used
  12979. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  12980. */
  12981. get useRampGradients(): boolean;
  12982. set useRampGradients(value: boolean);
  12983. /**
  12984. * 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.
  12985. * 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: [])
  12986. */
  12987. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  12988. private _subEmitters;
  12989. /**
  12990. * @hidden
  12991. * If the particle systems emitter should be disposed when the particle system is disposed
  12992. */
  12993. _disposeEmitterOnDispose: boolean;
  12994. /**
  12995. * The current active Sub-systems, this property is used by the root particle system only.
  12996. */
  12997. activeSubSystems: Array<ParticleSystem>;
  12998. /**
  12999. * Specifies if the particles are updated in emitter local space or world space
  13000. */
  13001. isLocal: boolean;
  13002. private _rootParticleSystem;
  13003. /**
  13004. * Gets the current list of active particles
  13005. */
  13006. get particles(): Particle[];
  13007. /**
  13008. * Gets the number of particles active at the same time.
  13009. * @returns The number of active particles.
  13010. */
  13011. getActiveCount(): number;
  13012. /**
  13013. * Returns the string "ParticleSystem"
  13014. * @returns a string containing the class name
  13015. */
  13016. getClassName(): string;
  13017. /**
  13018. * Gets a boolean indicating that the system is stopping
  13019. * @returns true if the system is currently stopping
  13020. */
  13021. isStopping(): boolean;
  13022. /**
  13023. * Gets the custom effect used to render the particles
  13024. * @param blendMode Blend mode for which the effect should be retrieved
  13025. * @returns The effect
  13026. */
  13027. getCustomEffect(blendMode?: number): Nullable<Effect>;
  13028. /**
  13029. * Sets the custom effect used to render the particles
  13030. * @param effect The effect to set
  13031. * @param blendMode Blend mode for which the effect should be set
  13032. */
  13033. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  13034. /** @hidden */
  13035. private _onBeforeDrawParticlesObservable;
  13036. /**
  13037. * Observable that will be called just before the particles are drawn
  13038. */
  13039. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  13040. /**
  13041. * Gets the name of the particle vertex shader
  13042. */
  13043. get vertexShaderName(): string;
  13044. /**
  13045. * Instantiates a particle system.
  13046. * 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.
  13047. * @param name The name of the particle system
  13048. * @param capacity The max number of particles alive at the same time
  13049. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  13050. * @param customEffect a custom effect used to change the way particles are rendered by default
  13051. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  13052. * @param epsilon Offset used to render the particles
  13053. */
  13054. constructor(name: string, capacity: number, sceneOrEngine: Scene | ThinEngine, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  13055. private _addFactorGradient;
  13056. private _removeFactorGradient;
  13057. /**
  13058. * Adds a new life time gradient
  13059. * @param gradient defines the gradient to use (between 0 and 1)
  13060. * @param factor defines the life time factor to affect to the specified gradient
  13061. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13062. * @returns the current particle system
  13063. */
  13064. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13065. /**
  13066. * Remove a specific life time gradient
  13067. * @param gradient defines the gradient to remove
  13068. * @returns the current particle system
  13069. */
  13070. removeLifeTimeGradient(gradient: number): IParticleSystem;
  13071. /**
  13072. * Adds a new size gradient
  13073. * @param gradient defines the gradient to use (between 0 and 1)
  13074. * @param factor defines the size factor to affect to the specified gradient
  13075. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13076. * @returns the current particle system
  13077. */
  13078. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13079. /**
  13080. * Remove a specific size gradient
  13081. * @param gradient defines the gradient to remove
  13082. * @returns the current particle system
  13083. */
  13084. removeSizeGradient(gradient: number): IParticleSystem;
  13085. /**
  13086. * Adds a new color remap gradient
  13087. * @param gradient defines the gradient to use (between 0 and 1)
  13088. * @param min defines the color remap minimal range
  13089. * @param max defines the color remap maximal range
  13090. * @returns the current particle system
  13091. */
  13092. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  13093. /**
  13094. * Remove a specific color remap gradient
  13095. * @param gradient defines the gradient to remove
  13096. * @returns the current particle system
  13097. */
  13098. removeColorRemapGradient(gradient: number): IParticleSystem;
  13099. /**
  13100. * Adds a new alpha remap gradient
  13101. * @param gradient defines the gradient to use (between 0 and 1)
  13102. * @param min defines the alpha remap minimal range
  13103. * @param max defines the alpha remap maximal range
  13104. * @returns the current particle system
  13105. */
  13106. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  13107. /**
  13108. * Remove a specific alpha remap gradient
  13109. * @param gradient defines the gradient to remove
  13110. * @returns the current particle system
  13111. */
  13112. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  13113. /**
  13114. * Adds a new angular speed gradient
  13115. * @param gradient defines the gradient to use (between 0 and 1)
  13116. * @param factor defines the angular speed to affect to the specified gradient
  13117. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13118. * @returns the current particle system
  13119. */
  13120. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13121. /**
  13122. * Remove a specific angular speed gradient
  13123. * @param gradient defines the gradient to remove
  13124. * @returns the current particle system
  13125. */
  13126. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  13127. /**
  13128. * Adds a new velocity gradient
  13129. * @param gradient defines the gradient to use (between 0 and 1)
  13130. * @param factor defines the velocity to affect to the specified gradient
  13131. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13132. * @returns the current particle system
  13133. */
  13134. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13135. /**
  13136. * Remove a specific velocity gradient
  13137. * @param gradient defines the gradient to remove
  13138. * @returns the current particle system
  13139. */
  13140. removeVelocityGradient(gradient: number): IParticleSystem;
  13141. /**
  13142. * Adds a new limit velocity gradient
  13143. * @param gradient defines the gradient to use (between 0 and 1)
  13144. * @param factor defines the limit velocity value to affect to the specified gradient
  13145. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13146. * @returns the current particle system
  13147. */
  13148. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13149. /**
  13150. * Remove a specific limit velocity gradient
  13151. * @param gradient defines the gradient to remove
  13152. * @returns the current particle system
  13153. */
  13154. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  13155. /**
  13156. * Adds a new drag gradient
  13157. * @param gradient defines the gradient to use (between 0 and 1)
  13158. * @param factor defines the drag value to affect to the specified gradient
  13159. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13160. * @returns the current particle system
  13161. */
  13162. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13163. /**
  13164. * Remove a specific drag gradient
  13165. * @param gradient defines the gradient to remove
  13166. * @returns the current particle system
  13167. */
  13168. removeDragGradient(gradient: number): IParticleSystem;
  13169. /**
  13170. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  13171. * @param gradient defines the gradient to use (between 0 and 1)
  13172. * @param factor defines the emit rate value to affect to the specified gradient
  13173. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13174. * @returns the current particle system
  13175. */
  13176. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13177. /**
  13178. * Remove a specific emit rate gradient
  13179. * @param gradient defines the gradient to remove
  13180. * @returns the current particle system
  13181. */
  13182. removeEmitRateGradient(gradient: number): IParticleSystem;
  13183. /**
  13184. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  13185. * @param gradient defines the gradient to use (between 0 and 1)
  13186. * @param factor defines the start size value to affect to the specified gradient
  13187. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13188. * @returns the current particle system
  13189. */
  13190. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13191. /**
  13192. * Remove a specific start size gradient
  13193. * @param gradient defines the gradient to remove
  13194. * @returns the current particle system
  13195. */
  13196. removeStartSizeGradient(gradient: number): IParticleSystem;
  13197. private _createRampGradientTexture;
  13198. /**
  13199. * Gets the current list of ramp gradients.
  13200. * You must use addRampGradient and removeRampGradient to udpate this list
  13201. * @returns the list of ramp gradients
  13202. */
  13203. getRampGradients(): Nullable<Array<Color3Gradient>>;
  13204. /** Force the system to rebuild all gradients that need to be resync */
  13205. forceRefreshGradients(): void;
  13206. private _syncRampGradientTexture;
  13207. /**
  13208. * Adds a new ramp gradient used to remap particle colors
  13209. * @param gradient defines the gradient to use (between 0 and 1)
  13210. * @param color defines the color to affect to the specified gradient
  13211. * @returns the current particle system
  13212. */
  13213. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  13214. /**
  13215. * Remove a specific ramp gradient
  13216. * @param gradient defines the gradient to remove
  13217. * @returns the current particle system
  13218. */
  13219. removeRampGradient(gradient: number): ParticleSystem;
  13220. /**
  13221. * Adds a new color gradient
  13222. * @param gradient defines the gradient to use (between 0 and 1)
  13223. * @param color1 defines the color to affect to the specified gradient
  13224. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  13225. * @returns this particle system
  13226. */
  13227. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  13228. /**
  13229. * Remove a specific color gradient
  13230. * @param gradient defines the gradient to remove
  13231. * @returns this particle system
  13232. */
  13233. removeColorGradient(gradient: number): IParticleSystem;
  13234. private _fetchR;
  13235. protected _reset(): void;
  13236. private _resetEffect;
  13237. private _createVertexBuffers;
  13238. private _createIndexBuffer;
  13239. /**
  13240. * Gets the maximum number of particles active at the same time.
  13241. * @returns The max number of active particles.
  13242. */
  13243. getCapacity(): number;
  13244. /**
  13245. * Gets whether there are still active particles in the system.
  13246. * @returns True if it is alive, otherwise false.
  13247. */
  13248. isAlive(): boolean;
  13249. /**
  13250. * Gets if the system has been started. (Note: this will still be true after stop is called)
  13251. * @returns True if it has been started, otherwise false.
  13252. */
  13253. isStarted(): boolean;
  13254. private _prepareSubEmitterInternalArray;
  13255. /**
  13256. * Starts the particle system and begins to emit
  13257. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  13258. */
  13259. start(delay?: number): void;
  13260. /**
  13261. * Stops the particle system.
  13262. * @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.
  13263. */
  13264. stop(stopSubEmitters?: boolean): void;
  13265. /**
  13266. * Remove all active particles
  13267. */
  13268. reset(): void;
  13269. /**
  13270. * @hidden (for internal use only)
  13271. */
  13272. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  13273. /**
  13274. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  13275. * Its lifetime will start back at 0.
  13276. */
  13277. recycleParticle: (particle: Particle) => void;
  13278. private _stopSubEmitters;
  13279. private _createParticle;
  13280. private _removeFromRoot;
  13281. private _emitFromParticle;
  13282. private _update;
  13283. /** @hidden */
  13284. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  13285. /** @hidden */
  13286. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  13287. /**
  13288. * Fill the defines array according to the current settings of the particle system
  13289. * @param defines Array to be updated
  13290. * @param blendMode blend mode to take into account when updating the array
  13291. */
  13292. fillDefines(defines: Array<string>, blendMode: number): void;
  13293. /**
  13294. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  13295. * @param uniforms Uniforms array to fill
  13296. * @param attributes Attributes array to fill
  13297. * @param samplers Samplers array to fill
  13298. */
  13299. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  13300. /** @hidden */
  13301. private _getEffect;
  13302. /**
  13303. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  13304. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  13305. */
  13306. animate(preWarmOnly?: boolean): void;
  13307. private _appendParticleVertices;
  13308. /**
  13309. * Rebuilds the particle system.
  13310. */
  13311. rebuild(): void;
  13312. /**
  13313. * Is this system ready to be used/rendered
  13314. * @return true if the system is ready
  13315. */
  13316. isReady(): boolean;
  13317. private _render;
  13318. /**
  13319. * Renders the particle system in its current state.
  13320. * @returns the current number of particles
  13321. */
  13322. render(): number;
  13323. /**
  13324. * Disposes the particle system and free the associated resources
  13325. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  13326. */
  13327. dispose(disposeTexture?: boolean): void;
  13328. /**
  13329. * Clones the particle system.
  13330. * @param name The name of the cloned object
  13331. * @param newEmitter The new emitter to use
  13332. * @returns the cloned particle system
  13333. */
  13334. clone(name: string, newEmitter: any): ParticleSystem;
  13335. /**
  13336. * Serializes the particle system to a JSON object
  13337. * @param serializeTexture defines if the texture must be serialized as well
  13338. * @returns the JSON object
  13339. */
  13340. serialize(serializeTexture?: boolean): any;
  13341. /** @hidden */
  13342. static _Serialize(serializationObject: any, particleSystem: IParticleSystem, serializeTexture: boolean): void;
  13343. /** @hidden */
  13344. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, sceneOrEngine: Scene | ThinEngine, rootUrl: string): void;
  13345. /**
  13346. * Parses a JSON object to create a particle system.
  13347. * @param parsedParticleSystem The JSON object to parse
  13348. * @param sceneOrEngine The scene or the engine to create the particle system in
  13349. * @param rootUrl The root url to use to load external dependencies like texture
  13350. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  13351. * @returns the Parsed particle system
  13352. */
  13353. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  13354. }
  13355. }
  13356. declare module "babylonjs/Particles/particle" {
  13357. import { Nullable } from "babylonjs/types";
  13358. import { Vector2, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  13359. import { Color4 } from "babylonjs/Maths/math.color";
  13360. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  13361. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  13362. import { ColorGradient, FactorGradient } from "babylonjs/Misc/gradients";
  13363. /**
  13364. * A particle represents one of the element emitted by a particle system.
  13365. * This is mainly define by its coordinates, direction, velocity and age.
  13366. */
  13367. export class Particle {
  13368. /**
  13369. * The particle system the particle belongs to.
  13370. */
  13371. particleSystem: ParticleSystem;
  13372. private static _Count;
  13373. /**
  13374. * Unique ID of the particle
  13375. */
  13376. id: number;
  13377. /**
  13378. * The world position of the particle in the scene.
  13379. */
  13380. position: Vector3;
  13381. /**
  13382. * The world direction of the particle in the scene.
  13383. */
  13384. direction: Vector3;
  13385. /**
  13386. * The color of the particle.
  13387. */
  13388. color: Color4;
  13389. /**
  13390. * The color change of the particle per step.
  13391. */
  13392. colorStep: Color4;
  13393. /**
  13394. * Defines how long will the life of the particle be.
  13395. */
  13396. lifeTime: number;
  13397. /**
  13398. * The current age of the particle.
  13399. */
  13400. age: number;
  13401. /**
  13402. * The current size of the particle.
  13403. */
  13404. size: number;
  13405. /**
  13406. * The current scale of the particle.
  13407. */
  13408. scale: Vector2;
  13409. /**
  13410. * The current angle of the particle.
  13411. */
  13412. angle: number;
  13413. /**
  13414. * Defines how fast is the angle changing.
  13415. */
  13416. angularSpeed: number;
  13417. /**
  13418. * Defines the cell index used by the particle to be rendered from a sprite.
  13419. */
  13420. cellIndex: number;
  13421. /**
  13422. * The information required to support color remapping
  13423. */
  13424. remapData: Vector4;
  13425. /** @hidden */
  13426. _randomCellOffset?: number;
  13427. /** @hidden */
  13428. _initialDirection: Nullable<Vector3>;
  13429. /** @hidden */
  13430. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  13431. /** @hidden */
  13432. _initialStartSpriteCellID: number;
  13433. /** @hidden */
  13434. _initialEndSpriteCellID: number;
  13435. /** @hidden */
  13436. _currentColorGradient: Nullable<ColorGradient>;
  13437. /** @hidden */
  13438. _currentColor1: Color4;
  13439. /** @hidden */
  13440. _currentColor2: Color4;
  13441. /** @hidden */
  13442. _currentSizeGradient: Nullable<FactorGradient>;
  13443. /** @hidden */
  13444. _currentSize1: number;
  13445. /** @hidden */
  13446. _currentSize2: number;
  13447. /** @hidden */
  13448. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  13449. /** @hidden */
  13450. _currentAngularSpeed1: number;
  13451. /** @hidden */
  13452. _currentAngularSpeed2: number;
  13453. /** @hidden */
  13454. _currentVelocityGradient: Nullable<FactorGradient>;
  13455. /** @hidden */
  13456. _currentVelocity1: number;
  13457. /** @hidden */
  13458. _currentVelocity2: number;
  13459. /** @hidden */
  13460. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  13461. /** @hidden */
  13462. _currentLimitVelocity1: number;
  13463. /** @hidden */
  13464. _currentLimitVelocity2: number;
  13465. /** @hidden */
  13466. _currentDragGradient: Nullable<FactorGradient>;
  13467. /** @hidden */
  13468. _currentDrag1: number;
  13469. /** @hidden */
  13470. _currentDrag2: number;
  13471. /** @hidden */
  13472. _randomNoiseCoordinates1: Vector3;
  13473. /** @hidden */
  13474. _randomNoiseCoordinates2: Vector3;
  13475. /** @hidden */
  13476. _localPosition?: Vector3;
  13477. /**
  13478. * Creates a new instance Particle
  13479. * @param particleSystem the particle system the particle belongs to
  13480. */
  13481. constructor(
  13482. /**
  13483. * The particle system the particle belongs to.
  13484. */
  13485. particleSystem: ParticleSystem);
  13486. private updateCellInfoFromSystem;
  13487. /**
  13488. * Defines how the sprite cell index is updated for the particle
  13489. */
  13490. updateCellIndex(): void;
  13491. /** @hidden */
  13492. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  13493. /** @hidden */
  13494. _inheritParticleInfoToSubEmitters(): void;
  13495. /** @hidden */
  13496. _reset(): void;
  13497. /**
  13498. * Copy the properties of particle to another one.
  13499. * @param other the particle to copy the information to.
  13500. */
  13501. copyTo(other: Particle): void;
  13502. }
  13503. }
  13504. declare module "babylonjs/Particles/EmitterTypes/IParticleEmitterType" {
  13505. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13506. import { Effect } from "babylonjs/Materials/effect";
  13507. import { Particle } from "babylonjs/Particles/particle";
  13508. import { Nullable } from "babylonjs/types";
  13509. import { Scene } from "babylonjs/scene";
  13510. /**
  13511. * Particle emitter represents a volume emitting particles.
  13512. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  13513. */
  13514. export interface IParticleEmitterType {
  13515. /**
  13516. * Called by the particle System when the direction is computed for the created particle.
  13517. * @param worldMatrix is the world matrix of the particle system
  13518. * @param directionToUpdate is the direction vector to update with the result
  13519. * @param particle is the particle we are computed the direction for
  13520. * @param isLocal defines if the direction should be set in local space
  13521. */
  13522. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13523. /**
  13524. * Called by the particle System when the position is computed for the created particle.
  13525. * @param worldMatrix is the world matrix of the particle system
  13526. * @param positionToUpdate is the position vector to update with the result
  13527. * @param particle is the particle we are computed the position for
  13528. * @param isLocal defines if the position should be set in local space
  13529. */
  13530. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13531. /**
  13532. * Clones the current emitter and returns a copy of it
  13533. * @returns the new emitter
  13534. */
  13535. clone(): IParticleEmitterType;
  13536. /**
  13537. * Called by the GPUParticleSystem to setup the update shader
  13538. * @param effect defines the update shader
  13539. */
  13540. applyToShader(effect: Effect): void;
  13541. /**
  13542. * Returns a string to use to update the GPU particles update shader
  13543. * @returns the effect defines string
  13544. */
  13545. getEffectDefines(): string;
  13546. /**
  13547. * Returns a string representing the class name
  13548. * @returns a string containing the class name
  13549. */
  13550. getClassName(): string;
  13551. /**
  13552. * Serializes the particle system to a JSON object.
  13553. * @returns the JSON object
  13554. */
  13555. serialize(): any;
  13556. /**
  13557. * Parse properties from a JSON object
  13558. * @param serializationObject defines the JSON object
  13559. * @param scene defines the hosting scene
  13560. */
  13561. parse(serializationObject: any, scene: Nullable<Scene>): void;
  13562. }
  13563. }
  13564. declare module "babylonjs/Particles/EmitterTypes/boxParticleEmitter" {
  13565. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13566. import { Effect } from "babylonjs/Materials/effect";
  13567. import { Particle } from "babylonjs/Particles/particle";
  13568. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13569. /**
  13570. * Particle emitter emitting particles from the inside of a box.
  13571. * It emits the particles randomly between 2 given directions.
  13572. */
  13573. export class BoxParticleEmitter implements IParticleEmitterType {
  13574. /**
  13575. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13576. */
  13577. direction1: Vector3;
  13578. /**
  13579. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13580. */
  13581. direction2: Vector3;
  13582. /**
  13583. * 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.
  13584. */
  13585. minEmitBox: Vector3;
  13586. /**
  13587. * 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.
  13588. */
  13589. maxEmitBox: Vector3;
  13590. /**
  13591. * Creates a new instance BoxParticleEmitter
  13592. */
  13593. constructor();
  13594. /**
  13595. * Called by the particle System when the direction is computed for the created particle.
  13596. * @param worldMatrix is the world matrix of the particle system
  13597. * @param directionToUpdate is the direction vector to update with the result
  13598. * @param particle is the particle we are computed the direction for
  13599. * @param isLocal defines if the direction should be set in local space
  13600. */
  13601. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13602. /**
  13603. * Called by the particle System when the position is computed for the created particle.
  13604. * @param worldMatrix is the world matrix of the particle system
  13605. * @param positionToUpdate is the position vector to update with the result
  13606. * @param particle is the particle we are computed the position for
  13607. * @param isLocal defines if the position should be set in local space
  13608. */
  13609. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13610. /**
  13611. * Clones the current emitter and returns a copy of it
  13612. * @returns the new emitter
  13613. */
  13614. clone(): BoxParticleEmitter;
  13615. /**
  13616. * Called by the GPUParticleSystem to setup the update shader
  13617. * @param effect defines the update shader
  13618. */
  13619. applyToShader(effect: Effect): void;
  13620. /**
  13621. * Returns a string to use to update the GPU particles update shader
  13622. * @returns a string containng the defines string
  13623. */
  13624. getEffectDefines(): string;
  13625. /**
  13626. * Returns the string "BoxParticleEmitter"
  13627. * @returns a string containing the class name
  13628. */
  13629. getClassName(): string;
  13630. /**
  13631. * Serializes the particle system to a JSON object.
  13632. * @returns the JSON object
  13633. */
  13634. serialize(): any;
  13635. /**
  13636. * Parse properties from a JSON object
  13637. * @param serializationObject defines the JSON object
  13638. */
  13639. parse(serializationObject: any): void;
  13640. }
  13641. }
  13642. declare module "babylonjs/Particles/EmitterTypes/coneParticleEmitter" {
  13643. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13644. import { Effect } from "babylonjs/Materials/effect";
  13645. import { Particle } from "babylonjs/Particles/particle";
  13646. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13647. /**
  13648. * Particle emitter emitting particles from the inside of a cone.
  13649. * It emits the particles alongside the cone volume from the base to the particle.
  13650. * The emission direction might be randomized.
  13651. */
  13652. export class ConeParticleEmitter implements IParticleEmitterType {
  13653. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  13654. directionRandomizer: number;
  13655. private _radius;
  13656. private _angle;
  13657. private _height;
  13658. /**
  13659. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  13660. */
  13661. radiusRange: number;
  13662. /**
  13663. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  13664. */
  13665. heightRange: number;
  13666. /**
  13667. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  13668. */
  13669. emitFromSpawnPointOnly: boolean;
  13670. /**
  13671. * Gets or sets the radius of the emission cone
  13672. */
  13673. get radius(): number;
  13674. set radius(value: number);
  13675. /**
  13676. * Gets or sets the angle of the emission cone
  13677. */
  13678. get angle(): number;
  13679. set angle(value: number);
  13680. private _buildHeight;
  13681. /**
  13682. * Creates a new instance ConeParticleEmitter
  13683. * @param radius the radius of the emission cone (1 by default)
  13684. * @param angle the cone base angle (PI by default)
  13685. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  13686. */
  13687. constructor(radius?: number, angle?: number,
  13688. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  13689. directionRandomizer?: number);
  13690. /**
  13691. * Called by the particle System when the direction is computed for the created particle.
  13692. * @param worldMatrix is the world matrix of the particle system
  13693. * @param directionToUpdate is the direction vector to update with the result
  13694. * @param particle is the particle we are computed the direction for
  13695. * @param isLocal defines if the direction should be set in local space
  13696. */
  13697. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13698. /**
  13699. * Called by the particle System when the position is computed for the created particle.
  13700. * @param worldMatrix is the world matrix of the particle system
  13701. * @param positionToUpdate is the position vector to update with the result
  13702. * @param particle is the particle we are computed the position for
  13703. * @param isLocal defines if the position should be set in local space
  13704. */
  13705. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13706. /**
  13707. * Clones the current emitter and returns a copy of it
  13708. * @returns the new emitter
  13709. */
  13710. clone(): ConeParticleEmitter;
  13711. /**
  13712. * Called by the GPUParticleSystem to setup the update shader
  13713. * @param effect defines the update shader
  13714. */
  13715. applyToShader(effect: Effect): void;
  13716. /**
  13717. * Returns a string to use to update the GPU particles update shader
  13718. * @returns a string containng the defines string
  13719. */
  13720. getEffectDefines(): string;
  13721. /**
  13722. * Returns the string "ConeParticleEmitter"
  13723. * @returns a string containing the class name
  13724. */
  13725. getClassName(): string;
  13726. /**
  13727. * Serializes the particle system to a JSON object.
  13728. * @returns the JSON object
  13729. */
  13730. serialize(): any;
  13731. /**
  13732. * Parse properties from a JSON object
  13733. * @param serializationObject defines the JSON object
  13734. */
  13735. parse(serializationObject: any): void;
  13736. }
  13737. }
  13738. declare module "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter" {
  13739. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13740. import { Effect } from "babylonjs/Materials/effect";
  13741. import { Particle } from "babylonjs/Particles/particle";
  13742. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13743. /**
  13744. * Particle emitter emitting particles from the inside of a cylinder.
  13745. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  13746. */
  13747. export class CylinderParticleEmitter implements IParticleEmitterType {
  13748. /**
  13749. * The radius of the emission cylinder.
  13750. */
  13751. radius: number;
  13752. /**
  13753. * The height of the emission cylinder.
  13754. */
  13755. height: number;
  13756. /**
  13757. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13758. */
  13759. radiusRange: number;
  13760. /**
  13761. * How much to randomize the particle direction [0-1].
  13762. */
  13763. directionRandomizer: number;
  13764. /**
  13765. * Creates a new instance CylinderParticleEmitter
  13766. * @param radius the radius of the emission cylinder (1 by default)
  13767. * @param height the height of the emission cylinder (1 by default)
  13768. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13769. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13770. */
  13771. constructor(
  13772. /**
  13773. * The radius of the emission cylinder.
  13774. */
  13775. radius?: number,
  13776. /**
  13777. * The height of the emission cylinder.
  13778. */
  13779. height?: number,
  13780. /**
  13781. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13782. */
  13783. radiusRange?: number,
  13784. /**
  13785. * How much to randomize the particle direction [0-1].
  13786. */
  13787. directionRandomizer?: number);
  13788. /**
  13789. * Called by the particle System when the direction is computed for the created particle.
  13790. * @param worldMatrix is the world matrix of the particle system
  13791. * @param directionToUpdate is the direction vector to update with the result
  13792. * @param particle is the particle we are computed the direction for
  13793. * @param isLocal defines if the direction should be set in local space
  13794. */
  13795. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13796. /**
  13797. * Called by the particle System when the position is computed for the created particle.
  13798. * @param worldMatrix is the world matrix of the particle system
  13799. * @param positionToUpdate is the position vector to update with the result
  13800. * @param particle is the particle we are computed the position for
  13801. * @param isLocal defines if the position should be set in local space
  13802. */
  13803. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13804. /**
  13805. * Clones the current emitter and returns a copy of it
  13806. * @returns the new emitter
  13807. */
  13808. clone(): CylinderParticleEmitter;
  13809. /**
  13810. * Called by the GPUParticleSystem to setup the update shader
  13811. * @param effect defines the update shader
  13812. */
  13813. applyToShader(effect: Effect): void;
  13814. /**
  13815. * Returns a string to use to update the GPU particles update shader
  13816. * @returns a string containng the defines string
  13817. */
  13818. getEffectDefines(): string;
  13819. /**
  13820. * Returns the string "CylinderParticleEmitter"
  13821. * @returns a string containing the class name
  13822. */
  13823. getClassName(): string;
  13824. /**
  13825. * Serializes the particle system to a JSON object.
  13826. * @returns the JSON object
  13827. */
  13828. serialize(): any;
  13829. /**
  13830. * Parse properties from a JSON object
  13831. * @param serializationObject defines the JSON object
  13832. */
  13833. parse(serializationObject: any): void;
  13834. }
  13835. /**
  13836. * Particle emitter emitting particles from the inside of a cylinder.
  13837. * It emits the particles randomly between two vectors.
  13838. */
  13839. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  13840. /**
  13841. * The min limit of the emission direction.
  13842. */
  13843. direction1: Vector3;
  13844. /**
  13845. * The max limit of the emission direction.
  13846. */
  13847. direction2: Vector3;
  13848. /**
  13849. * Creates a new instance CylinderDirectedParticleEmitter
  13850. * @param radius the radius of the emission cylinder (1 by default)
  13851. * @param height the height of the emission cylinder (1 by default)
  13852. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13853. * @param direction1 the min limit of the emission direction (up vector by default)
  13854. * @param direction2 the max limit of the emission direction (up vector by default)
  13855. */
  13856. constructor(radius?: number, height?: number, radiusRange?: number,
  13857. /**
  13858. * The min limit of the emission direction.
  13859. */
  13860. direction1?: Vector3,
  13861. /**
  13862. * The max limit of the emission direction.
  13863. */
  13864. direction2?: Vector3);
  13865. /**
  13866. * Called by the particle System when the direction is computed for the created particle.
  13867. * @param worldMatrix is the world matrix of the particle system
  13868. * @param directionToUpdate is the direction vector to update with the result
  13869. * @param particle is the particle we are computed the direction for
  13870. */
  13871. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  13872. /**
  13873. * Clones the current emitter and returns a copy of it
  13874. * @returns the new emitter
  13875. */
  13876. clone(): CylinderDirectedParticleEmitter;
  13877. /**
  13878. * Called by the GPUParticleSystem to setup the update shader
  13879. * @param effect defines the update shader
  13880. */
  13881. applyToShader(effect: Effect): void;
  13882. /**
  13883. * Returns a string to use to update the GPU particles update shader
  13884. * @returns a string containng the defines string
  13885. */
  13886. getEffectDefines(): string;
  13887. /**
  13888. * Returns the string "CylinderDirectedParticleEmitter"
  13889. * @returns a string containing the class name
  13890. */
  13891. getClassName(): string;
  13892. /**
  13893. * Serializes the particle system to a JSON object.
  13894. * @returns the JSON object
  13895. */
  13896. serialize(): any;
  13897. /**
  13898. * Parse properties from a JSON object
  13899. * @param serializationObject defines the JSON object
  13900. */
  13901. parse(serializationObject: any): void;
  13902. }
  13903. }
  13904. declare module "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter" {
  13905. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13906. import { Effect } from "babylonjs/Materials/effect";
  13907. import { Particle } from "babylonjs/Particles/particle";
  13908. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13909. /**
  13910. * Particle emitter emitting particles from the inside of a hemisphere.
  13911. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  13912. */
  13913. export class HemisphericParticleEmitter implements IParticleEmitterType {
  13914. /**
  13915. * The radius of the emission hemisphere.
  13916. */
  13917. radius: number;
  13918. /**
  13919. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13920. */
  13921. radiusRange: number;
  13922. /**
  13923. * How much to randomize the particle direction [0-1].
  13924. */
  13925. directionRandomizer: number;
  13926. /**
  13927. * Creates a new instance HemisphericParticleEmitter
  13928. * @param radius the radius of the emission hemisphere (1 by default)
  13929. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13930. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13931. */
  13932. constructor(
  13933. /**
  13934. * The radius of the emission hemisphere.
  13935. */
  13936. radius?: number,
  13937. /**
  13938. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13939. */
  13940. radiusRange?: number,
  13941. /**
  13942. * How much to randomize the particle direction [0-1].
  13943. */
  13944. directionRandomizer?: number);
  13945. /**
  13946. * Called by the particle System when the direction is computed for the created particle.
  13947. * @param worldMatrix is the world matrix of the particle system
  13948. * @param directionToUpdate is the direction vector to update with the result
  13949. * @param particle is the particle we are computed the direction for
  13950. * @param isLocal defines if the direction should be set in local space
  13951. */
  13952. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13953. /**
  13954. * Called by the particle System when the position is computed for the created particle.
  13955. * @param worldMatrix is the world matrix of the particle system
  13956. * @param positionToUpdate is the position vector to update with the result
  13957. * @param particle is the particle we are computed the position for
  13958. * @param isLocal defines if the position should be set in local space
  13959. */
  13960. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13961. /**
  13962. * Clones the current emitter and returns a copy of it
  13963. * @returns the new emitter
  13964. */
  13965. clone(): HemisphericParticleEmitter;
  13966. /**
  13967. * Called by the GPUParticleSystem to setup the update shader
  13968. * @param effect defines the update shader
  13969. */
  13970. applyToShader(effect: Effect): void;
  13971. /**
  13972. * Returns a string to use to update the GPU particles update shader
  13973. * @returns a string containng the defines string
  13974. */
  13975. getEffectDefines(): string;
  13976. /**
  13977. * Returns the string "HemisphericParticleEmitter"
  13978. * @returns a string containing the class name
  13979. */
  13980. getClassName(): string;
  13981. /**
  13982. * Serializes the particle system to a JSON object.
  13983. * @returns the JSON object
  13984. */
  13985. serialize(): any;
  13986. /**
  13987. * Parse properties from a JSON object
  13988. * @param serializationObject defines the JSON object
  13989. */
  13990. parse(serializationObject: any): void;
  13991. }
  13992. }
  13993. declare module "babylonjs/Particles/EmitterTypes/pointParticleEmitter" {
  13994. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13995. import { Effect } from "babylonjs/Materials/effect";
  13996. import { Particle } from "babylonjs/Particles/particle";
  13997. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13998. /**
  13999. * Particle emitter emitting particles from a point.
  14000. * It emits the particles randomly between 2 given directions.
  14001. */
  14002. export class PointParticleEmitter implements IParticleEmitterType {
  14003. /**
  14004. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14005. */
  14006. direction1: Vector3;
  14007. /**
  14008. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14009. */
  14010. direction2: Vector3;
  14011. /**
  14012. * Creates a new instance PointParticleEmitter
  14013. */
  14014. constructor();
  14015. /**
  14016. * Called by the particle System when the direction is computed for the created particle.
  14017. * @param worldMatrix is the world matrix of the particle system
  14018. * @param directionToUpdate is the direction vector to update with the result
  14019. * @param particle is the particle we are computed the direction for
  14020. * @param isLocal defines if the direction should be set in local space
  14021. */
  14022. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14023. /**
  14024. * Called by the particle System when the position is computed for the created particle.
  14025. * @param worldMatrix is the world matrix of the particle system
  14026. * @param positionToUpdate is the position vector to update with the result
  14027. * @param particle is the particle we are computed the position for
  14028. * @param isLocal defines if the position should be set in local space
  14029. */
  14030. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14031. /**
  14032. * Clones the current emitter and returns a copy of it
  14033. * @returns the new emitter
  14034. */
  14035. clone(): PointParticleEmitter;
  14036. /**
  14037. * Called by the GPUParticleSystem to setup the update shader
  14038. * @param effect defines the update shader
  14039. */
  14040. applyToShader(effect: Effect): void;
  14041. /**
  14042. * Returns a string to use to update the GPU particles update shader
  14043. * @returns a string containng the defines string
  14044. */
  14045. getEffectDefines(): string;
  14046. /**
  14047. * Returns the string "PointParticleEmitter"
  14048. * @returns a string containing the class name
  14049. */
  14050. getClassName(): string;
  14051. /**
  14052. * Serializes the particle system to a JSON object.
  14053. * @returns the JSON object
  14054. */
  14055. serialize(): any;
  14056. /**
  14057. * Parse properties from a JSON object
  14058. * @param serializationObject defines the JSON object
  14059. */
  14060. parse(serializationObject: any): void;
  14061. }
  14062. }
  14063. declare module "babylonjs/Particles/EmitterTypes/sphereParticleEmitter" {
  14064. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  14065. import { Effect } from "babylonjs/Materials/effect";
  14066. import { Particle } from "babylonjs/Particles/particle";
  14067. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  14068. /**
  14069. * Particle emitter emitting particles from the inside of a sphere.
  14070. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  14071. */
  14072. export class SphereParticleEmitter implements IParticleEmitterType {
  14073. /**
  14074. * The radius of the emission sphere.
  14075. */
  14076. radius: number;
  14077. /**
  14078. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  14079. */
  14080. radiusRange: number;
  14081. /**
  14082. * How much to randomize the particle direction [0-1].
  14083. */
  14084. directionRandomizer: number;
  14085. /**
  14086. * Creates a new instance SphereParticleEmitter
  14087. * @param radius the radius of the emission sphere (1 by default)
  14088. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  14089. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  14090. */
  14091. constructor(
  14092. /**
  14093. * The radius of the emission sphere.
  14094. */
  14095. radius?: number,
  14096. /**
  14097. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  14098. */
  14099. radiusRange?: number,
  14100. /**
  14101. * How much to randomize the particle direction [0-1].
  14102. */
  14103. directionRandomizer?: number);
  14104. /**
  14105. * Called by the particle System when the direction is computed for the created particle.
  14106. * @param worldMatrix is the world matrix of the particle system
  14107. * @param directionToUpdate is the direction vector to update with the result
  14108. * @param particle is the particle we are computed the direction for
  14109. * @param isLocal defines if the direction should be set in local space
  14110. */
  14111. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14112. /**
  14113. * Called by the particle System when the position is computed for the created particle.
  14114. * @param worldMatrix is the world matrix of the particle system
  14115. * @param positionToUpdate is the position vector to update with the result
  14116. * @param particle is the particle we are computed the position for
  14117. * @param isLocal defines if the position should be set in local space
  14118. */
  14119. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14120. /**
  14121. * Clones the current emitter and returns a copy of it
  14122. * @returns the new emitter
  14123. */
  14124. clone(): SphereParticleEmitter;
  14125. /**
  14126. * Called by the GPUParticleSystem to setup the update shader
  14127. * @param effect defines the update shader
  14128. */
  14129. applyToShader(effect: Effect): void;
  14130. /**
  14131. * Returns a string to use to update the GPU particles update shader
  14132. * @returns a string containng the defines string
  14133. */
  14134. getEffectDefines(): string;
  14135. /**
  14136. * Returns the string "SphereParticleEmitter"
  14137. * @returns a string containing the class name
  14138. */
  14139. getClassName(): string;
  14140. /**
  14141. * Serializes the particle system to a JSON object.
  14142. * @returns the JSON object
  14143. */
  14144. serialize(): any;
  14145. /**
  14146. * Parse properties from a JSON object
  14147. * @param serializationObject defines the JSON object
  14148. */
  14149. parse(serializationObject: any): void;
  14150. }
  14151. /**
  14152. * Particle emitter emitting particles from the inside of a sphere.
  14153. * It emits the particles randomly between two vectors.
  14154. */
  14155. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  14156. /**
  14157. * The min limit of the emission direction.
  14158. */
  14159. direction1: Vector3;
  14160. /**
  14161. * The max limit of the emission direction.
  14162. */
  14163. direction2: Vector3;
  14164. /**
  14165. * Creates a new instance SphereDirectedParticleEmitter
  14166. * @param radius the radius of the emission sphere (1 by default)
  14167. * @param direction1 the min limit of the emission direction (up vector by default)
  14168. * @param direction2 the max limit of the emission direction (up vector by default)
  14169. */
  14170. constructor(radius?: number,
  14171. /**
  14172. * The min limit of the emission direction.
  14173. */
  14174. direction1?: Vector3,
  14175. /**
  14176. * The max limit of the emission direction.
  14177. */
  14178. direction2?: Vector3);
  14179. /**
  14180. * Called by the particle System when the direction is computed for the created particle.
  14181. * @param worldMatrix is the world matrix of the particle system
  14182. * @param directionToUpdate is the direction vector to update with the result
  14183. * @param particle is the particle we are computed the direction for
  14184. */
  14185. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  14186. /**
  14187. * Clones the current emitter and returns a copy of it
  14188. * @returns the new emitter
  14189. */
  14190. clone(): SphereDirectedParticleEmitter;
  14191. /**
  14192. * Called by the GPUParticleSystem to setup the update shader
  14193. * @param effect defines the update shader
  14194. */
  14195. applyToShader(effect: Effect): void;
  14196. /**
  14197. * Returns a string to use to update the GPU particles update shader
  14198. * @returns a string containng the defines string
  14199. */
  14200. getEffectDefines(): string;
  14201. /**
  14202. * Returns the string "SphereDirectedParticleEmitter"
  14203. * @returns a string containing the class name
  14204. */
  14205. getClassName(): string;
  14206. /**
  14207. * Serializes the particle system to a JSON object.
  14208. * @returns the JSON object
  14209. */
  14210. serialize(): any;
  14211. /**
  14212. * Parse properties from a JSON object
  14213. * @param serializationObject defines the JSON object
  14214. */
  14215. parse(serializationObject: any): void;
  14216. }
  14217. }
  14218. declare module "babylonjs/Particles/EmitterTypes/customParticleEmitter" {
  14219. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  14220. import { Effect } from "babylonjs/Materials/effect";
  14221. import { Particle } from "babylonjs/Particles/particle";
  14222. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  14223. import { Nullable } from "babylonjs/types";
  14224. /**
  14225. * Particle emitter emitting particles from a custom list of positions.
  14226. */
  14227. export class CustomParticleEmitter implements IParticleEmitterType {
  14228. /**
  14229. * Gets or sets the position generator that will create the inital position of each particle.
  14230. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  14231. */
  14232. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  14233. /**
  14234. * Gets or sets the destination generator that will create the final destination of each particle.
  14235. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  14236. */
  14237. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  14238. /**
  14239. * Creates a new instance CustomParticleEmitter
  14240. */
  14241. constructor();
  14242. /**
  14243. * Called by the particle System when the direction is computed for the created particle.
  14244. * @param worldMatrix is the world matrix of the particle system
  14245. * @param directionToUpdate is the direction vector to update with the result
  14246. * @param particle is the particle we are computed the direction for
  14247. * @param isLocal defines if the direction should be set in local space
  14248. */
  14249. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14250. /**
  14251. * Called by the particle System when the position is computed for the created particle.
  14252. * @param worldMatrix is the world matrix of the particle system
  14253. * @param positionToUpdate is the position vector to update with the result
  14254. * @param particle is the particle we are computed the position for
  14255. * @param isLocal defines if the position should be set in local space
  14256. */
  14257. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14258. /**
  14259. * Clones the current emitter and returns a copy of it
  14260. * @returns the new emitter
  14261. */
  14262. clone(): CustomParticleEmitter;
  14263. /**
  14264. * Called by the GPUParticleSystem to setup the update shader
  14265. * @param effect defines the update shader
  14266. */
  14267. applyToShader(effect: Effect): void;
  14268. /**
  14269. * Returns a string to use to update the GPU particles update shader
  14270. * @returns a string containng the defines string
  14271. */
  14272. getEffectDefines(): string;
  14273. /**
  14274. * Returns the string "PointParticleEmitter"
  14275. * @returns a string containing the class name
  14276. */
  14277. getClassName(): string;
  14278. /**
  14279. * Serializes the particle system to a JSON object.
  14280. * @returns the JSON object
  14281. */
  14282. serialize(): any;
  14283. /**
  14284. * Parse properties from a JSON object
  14285. * @param serializationObject defines the JSON object
  14286. */
  14287. parse(serializationObject: any): void;
  14288. }
  14289. }
  14290. declare module "babylonjs/Particles/EmitterTypes/meshParticleEmitter" {
  14291. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  14292. import { Effect } from "babylonjs/Materials/effect";
  14293. import { Particle } from "babylonjs/Particles/particle";
  14294. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  14295. import { Nullable } from "babylonjs/types";
  14296. import { Scene } from "babylonjs/scene";
  14297. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14298. /**
  14299. * Particle emitter emitting particles from the inside of a box.
  14300. * It emits the particles randomly between 2 given directions.
  14301. */
  14302. export class MeshParticleEmitter implements IParticleEmitterType {
  14303. private _indices;
  14304. private _positions;
  14305. private _normals;
  14306. private _storedNormal;
  14307. private _mesh;
  14308. /**
  14309. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14310. */
  14311. direction1: Vector3;
  14312. /**
  14313. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14314. */
  14315. direction2: Vector3;
  14316. /**
  14317. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  14318. */
  14319. useMeshNormalsForDirection: boolean;
  14320. /** Defines the mesh to use as source */
  14321. get mesh(): Nullable<AbstractMesh>;
  14322. set mesh(value: Nullable<AbstractMesh>);
  14323. /**
  14324. * Creates a new instance MeshParticleEmitter
  14325. * @param mesh defines the mesh to use as source
  14326. */
  14327. constructor(mesh?: Nullable<AbstractMesh>);
  14328. /**
  14329. * Called by the particle System when the direction is computed for the created particle.
  14330. * @param worldMatrix is the world matrix of the particle system
  14331. * @param directionToUpdate is the direction vector to update with the result
  14332. * @param particle is the particle we are computed the direction for
  14333. * @param isLocal defines if the direction should be set in local space
  14334. */
  14335. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14336. /**
  14337. * Called by the particle System when the position is computed for the created particle.
  14338. * @param worldMatrix is the world matrix of the particle system
  14339. * @param positionToUpdate is the position vector to update with the result
  14340. * @param particle is the particle we are computed the position for
  14341. * @param isLocal defines if the position should be set in local space
  14342. */
  14343. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14344. /**
  14345. * Clones the current emitter and returns a copy of it
  14346. * @returns the new emitter
  14347. */
  14348. clone(): MeshParticleEmitter;
  14349. /**
  14350. * Called by the GPUParticleSystem to setup the update shader
  14351. * @param effect defines the update shader
  14352. */
  14353. applyToShader(effect: Effect): void;
  14354. /**
  14355. * Returns a string to use to update the GPU particles update shader
  14356. * @returns a string containng the defines string
  14357. */
  14358. getEffectDefines(): string;
  14359. /**
  14360. * Returns the string "BoxParticleEmitter"
  14361. * @returns a string containing the class name
  14362. */
  14363. getClassName(): string;
  14364. /**
  14365. * Serializes the particle system to a JSON object.
  14366. * @returns the JSON object
  14367. */
  14368. serialize(): any;
  14369. /**
  14370. * Parse properties from a JSON object
  14371. * @param serializationObject defines the JSON object
  14372. * @param scene defines the hosting scene
  14373. */
  14374. parse(serializationObject: any, scene: Nullable<Scene>): void;
  14375. }
  14376. }
  14377. declare module "babylonjs/Particles/EmitterTypes/index" {
  14378. export * from "babylonjs/Particles/EmitterTypes/boxParticleEmitter";
  14379. export * from "babylonjs/Particles/EmitterTypes/coneParticleEmitter";
  14380. export * from "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter";
  14381. export * from "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter";
  14382. export * from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  14383. export * from "babylonjs/Particles/EmitterTypes/pointParticleEmitter";
  14384. export * from "babylonjs/Particles/EmitterTypes/sphereParticleEmitter";
  14385. export * from "babylonjs/Particles/EmitterTypes/customParticleEmitter";
  14386. export * from "babylonjs/Particles/EmitterTypes/meshParticleEmitter";
  14387. }
  14388. declare module "babylonjs/Particles/IParticleSystem" {
  14389. import { Nullable } from "babylonjs/types";
  14390. import { Vector2, Vector3, Matrix } from "babylonjs/Maths/math.vector";
  14391. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  14392. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  14393. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  14394. import { Scene } from "babylonjs/scene";
  14395. import { ColorGradient, FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  14396. import { Effect } from "babylonjs/Materials/effect";
  14397. import { Observable } from "babylonjs/Misc/observable";
  14398. import { Animation } from "babylonjs/Animations/animation";
  14399. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14400. /**
  14401. * Interface representing a particle system in Babylon.js.
  14402. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  14403. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  14404. */
  14405. export interface IParticleSystem {
  14406. /**
  14407. * List of animations used by the particle system.
  14408. */
  14409. animations: Animation[];
  14410. /**
  14411. * The id of the Particle system.
  14412. */
  14413. id: string;
  14414. /**
  14415. * The name of the Particle system.
  14416. */
  14417. name: string;
  14418. /**
  14419. * The emitter represents the Mesh or position we are attaching the particle system to.
  14420. */
  14421. emitter: Nullable<AbstractMesh | Vector3>;
  14422. /**
  14423. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  14424. */
  14425. isBillboardBased: boolean;
  14426. /**
  14427. * The rendering group used by the Particle system to chose when to render.
  14428. */
  14429. renderingGroupId: number;
  14430. /**
  14431. * The layer mask we are rendering the particles through.
  14432. */
  14433. layerMask: number;
  14434. /**
  14435. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  14436. */
  14437. updateSpeed: number;
  14438. /**
  14439. * The amount of time the particle system is running (depends of the overall update speed).
  14440. */
  14441. targetStopDuration: number;
  14442. /**
  14443. * The texture used to render each particle. (this can be a spritesheet)
  14444. */
  14445. particleTexture: Nullable<BaseTexture>;
  14446. /**
  14447. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  14448. */
  14449. blendMode: number;
  14450. /**
  14451. * Minimum life time of emitting particles.
  14452. */
  14453. minLifeTime: number;
  14454. /**
  14455. * Maximum life time of emitting particles.
  14456. */
  14457. maxLifeTime: number;
  14458. /**
  14459. * Minimum Size of emitting particles.
  14460. */
  14461. minSize: number;
  14462. /**
  14463. * Maximum Size of emitting particles.
  14464. */
  14465. maxSize: number;
  14466. /**
  14467. * Minimum scale of emitting particles on X axis.
  14468. */
  14469. minScaleX: number;
  14470. /**
  14471. * Maximum scale of emitting particles on X axis.
  14472. */
  14473. maxScaleX: number;
  14474. /**
  14475. * Minimum scale of emitting particles on Y axis.
  14476. */
  14477. minScaleY: number;
  14478. /**
  14479. * Maximum scale of emitting particles on Y axis.
  14480. */
  14481. maxScaleY: number;
  14482. /**
  14483. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  14484. */
  14485. color1: Color4;
  14486. /**
  14487. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  14488. */
  14489. color2: Color4;
  14490. /**
  14491. * Color the particle will have at the end of its lifetime.
  14492. */
  14493. colorDead: Color4;
  14494. /**
  14495. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  14496. */
  14497. emitRate: number;
  14498. /**
  14499. * You can use gravity if you want to give an orientation to your particles.
  14500. */
  14501. gravity: Vector3;
  14502. /**
  14503. * Minimum power of emitting particles.
  14504. */
  14505. minEmitPower: number;
  14506. /**
  14507. * Maximum power of emitting particles.
  14508. */
  14509. maxEmitPower: number;
  14510. /**
  14511. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  14512. */
  14513. minAngularSpeed: number;
  14514. /**
  14515. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  14516. */
  14517. maxAngularSpeed: number;
  14518. /**
  14519. * Gets or sets the minimal initial rotation in radians.
  14520. */
  14521. minInitialRotation: number;
  14522. /**
  14523. * Gets or sets the maximal initial rotation in radians.
  14524. */
  14525. maxInitialRotation: number;
  14526. /**
  14527. * The particle emitter type defines the emitter used by the particle system.
  14528. * It can be for example box, sphere, or cone...
  14529. */
  14530. particleEmitterType: Nullable<IParticleEmitterType>;
  14531. /**
  14532. * Defines the delay in milliseconds before starting the system (0 by default)
  14533. */
  14534. startDelay: number;
  14535. /**
  14536. * 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
  14537. */
  14538. preWarmCycles: number;
  14539. /**
  14540. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  14541. */
  14542. preWarmStepOffset: number;
  14543. /**
  14544. * 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)
  14545. */
  14546. spriteCellChangeSpeed: number;
  14547. /**
  14548. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  14549. */
  14550. startSpriteCellID: number;
  14551. /**
  14552. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  14553. */
  14554. endSpriteCellID: number;
  14555. /**
  14556. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  14557. */
  14558. spriteCellWidth: number;
  14559. /**
  14560. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  14561. */
  14562. spriteCellHeight: number;
  14563. /**
  14564. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  14565. */
  14566. spriteRandomStartCell: boolean;
  14567. /**
  14568. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  14569. */
  14570. isAnimationSheetEnabled: boolean;
  14571. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  14572. translationPivot: Vector2;
  14573. /**
  14574. * Gets or sets a texture used to add random noise to particle positions
  14575. */
  14576. noiseTexture: Nullable<BaseTexture>;
  14577. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  14578. noiseStrength: Vector3;
  14579. /**
  14580. * Gets or sets the billboard mode to use when isBillboardBased = true.
  14581. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  14582. */
  14583. billboardMode: number;
  14584. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  14585. limitVelocityDamping: number;
  14586. /**
  14587. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  14588. */
  14589. beginAnimationOnStart: boolean;
  14590. /**
  14591. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  14592. */
  14593. beginAnimationFrom: number;
  14594. /**
  14595. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  14596. */
  14597. beginAnimationTo: number;
  14598. /**
  14599. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  14600. */
  14601. beginAnimationLoop: boolean;
  14602. /**
  14603. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  14604. */
  14605. disposeOnStop: boolean;
  14606. /**
  14607. * Specifies if the particles are updated in emitter local space or world space
  14608. */
  14609. isLocal: boolean;
  14610. /** Snippet ID if the particle system was created from the snippet server */
  14611. snippetId: string;
  14612. /** Gets or sets a matrix to use to compute projection */
  14613. defaultProjectionMatrix: Matrix;
  14614. /**
  14615. * Gets the maximum number of particles active at the same time.
  14616. * @returns The max number of active particles.
  14617. */
  14618. getCapacity(): number;
  14619. /**
  14620. * Gets the number of particles active at the same time.
  14621. * @returns The number of active particles.
  14622. */
  14623. getActiveCount(): number;
  14624. /**
  14625. * Gets if the system has been started. (Note: this will still be true after stop is called)
  14626. * @returns True if it has been started, otherwise false.
  14627. */
  14628. isStarted(): boolean;
  14629. /**
  14630. * Animates the particle system for this frame.
  14631. */
  14632. animate(): void;
  14633. /**
  14634. * Renders the particle system in its current state.
  14635. * @returns the current number of particles
  14636. */
  14637. render(): number;
  14638. /**
  14639. * Dispose the particle system and frees its associated resources.
  14640. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  14641. */
  14642. dispose(disposeTexture?: boolean): void;
  14643. /**
  14644. * An event triggered when the system is disposed
  14645. */
  14646. onDisposeObservable: Observable<IParticleSystem>;
  14647. /**
  14648. * Clones the particle system.
  14649. * @param name The name of the cloned object
  14650. * @param newEmitter The new emitter to use
  14651. * @returns the cloned particle system
  14652. */
  14653. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  14654. /**
  14655. * Serializes the particle system to a JSON object
  14656. * @param serializeTexture defines if the texture must be serialized as well
  14657. * @returns the JSON object
  14658. */
  14659. serialize(serializeTexture: boolean): any;
  14660. /**
  14661. * Rebuild the particle system
  14662. */
  14663. rebuild(): void;
  14664. /** Force the system to rebuild all gradients that need to be resync */
  14665. forceRefreshGradients(): void;
  14666. /**
  14667. * Starts the particle system and begins to emit
  14668. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  14669. */
  14670. start(delay?: number): void;
  14671. /**
  14672. * Stops the particle system.
  14673. */
  14674. stop(): void;
  14675. /**
  14676. * Remove all active particles
  14677. */
  14678. reset(): void;
  14679. /**
  14680. * Gets a boolean indicating that the system is stopping
  14681. * @returns true if the system is currently stopping
  14682. */
  14683. isStopping(): boolean;
  14684. /**
  14685. * Is this system ready to be used/rendered
  14686. * @return true if the system is ready
  14687. */
  14688. isReady(): boolean;
  14689. /**
  14690. * Returns the string "ParticleSystem"
  14691. * @returns a string containing the class name
  14692. */
  14693. getClassName(): string;
  14694. /**
  14695. * Gets the custom effect used to render the particles
  14696. * @param blendMode Blend mode for which the effect should be retrieved
  14697. * @returns The effect
  14698. */
  14699. getCustomEffect(blendMode: number): Nullable<Effect>;
  14700. /**
  14701. * Sets the custom effect used to render the particles
  14702. * @param effect The effect to set
  14703. * @param blendMode Blend mode for which the effect should be set
  14704. */
  14705. setCustomEffect(effect: Nullable<Effect>, blendMode: number): void;
  14706. /**
  14707. * Fill the defines array according to the current settings of the particle system
  14708. * @param defines Array to be updated
  14709. * @param blendMode blend mode to take into account when updating the array
  14710. */
  14711. fillDefines(defines: Array<string>, blendMode: number): void;
  14712. /**
  14713. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  14714. * @param uniforms Uniforms array to fill
  14715. * @param attributes Attributes array to fill
  14716. * @param samplers Samplers array to fill
  14717. */
  14718. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  14719. /**
  14720. * Observable that will be called just before the particles are drawn
  14721. */
  14722. onBeforeDrawParticlesObservable: Observable<Nullable<Effect>>;
  14723. /**
  14724. * Gets the name of the particle vertex shader
  14725. */
  14726. vertexShaderName: string;
  14727. /**
  14728. * Adds a new color gradient
  14729. * @param gradient defines the gradient to use (between 0 and 1)
  14730. * @param color1 defines the color to affect to the specified gradient
  14731. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  14732. * @returns the current particle system
  14733. */
  14734. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  14735. /**
  14736. * Remove a specific color gradient
  14737. * @param gradient defines the gradient to remove
  14738. * @returns the current particle system
  14739. */
  14740. removeColorGradient(gradient: number): IParticleSystem;
  14741. /**
  14742. * Adds a new size gradient
  14743. * @param gradient defines the gradient to use (between 0 and 1)
  14744. * @param factor defines the size factor to affect to the specified gradient
  14745. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14746. * @returns the current particle system
  14747. */
  14748. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14749. /**
  14750. * Remove a specific size gradient
  14751. * @param gradient defines the gradient to remove
  14752. * @returns the current particle system
  14753. */
  14754. removeSizeGradient(gradient: number): IParticleSystem;
  14755. /**
  14756. * Gets the current list of color gradients.
  14757. * You must use addColorGradient and removeColorGradient to udpate this list
  14758. * @returns the list of color gradients
  14759. */
  14760. getColorGradients(): Nullable<Array<ColorGradient>>;
  14761. /**
  14762. * Gets the current list of size gradients.
  14763. * You must use addSizeGradient and removeSizeGradient to udpate this list
  14764. * @returns the list of size gradients
  14765. */
  14766. getSizeGradients(): Nullable<Array<FactorGradient>>;
  14767. /**
  14768. * Gets the current list of angular speed gradients.
  14769. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  14770. * @returns the list of angular speed gradients
  14771. */
  14772. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  14773. /**
  14774. * Adds a new angular speed gradient
  14775. * @param gradient defines the gradient to use (between 0 and 1)
  14776. * @param factor defines the angular speed to affect to the specified gradient
  14777. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14778. * @returns the current particle system
  14779. */
  14780. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14781. /**
  14782. * Remove a specific angular speed gradient
  14783. * @param gradient defines the gradient to remove
  14784. * @returns the current particle system
  14785. */
  14786. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  14787. /**
  14788. * Gets the current list of velocity gradients.
  14789. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  14790. * @returns the list of velocity gradients
  14791. */
  14792. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  14793. /**
  14794. * Adds a new velocity gradient
  14795. * @param gradient defines the gradient to use (between 0 and 1)
  14796. * @param factor defines the velocity to affect to the specified gradient
  14797. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14798. * @returns the current particle system
  14799. */
  14800. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14801. /**
  14802. * Remove a specific velocity gradient
  14803. * @param gradient defines the gradient to remove
  14804. * @returns the current particle system
  14805. */
  14806. removeVelocityGradient(gradient: number): IParticleSystem;
  14807. /**
  14808. * Gets the current list of limit velocity gradients.
  14809. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  14810. * @returns the list of limit velocity gradients
  14811. */
  14812. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  14813. /**
  14814. * Adds a new limit velocity gradient
  14815. * @param gradient defines the gradient to use (between 0 and 1)
  14816. * @param factor defines the limit velocity to affect to the specified gradient
  14817. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14818. * @returns the current particle system
  14819. */
  14820. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14821. /**
  14822. * Remove a specific limit velocity gradient
  14823. * @param gradient defines the gradient to remove
  14824. * @returns the current particle system
  14825. */
  14826. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  14827. /**
  14828. * Adds a new drag gradient
  14829. * @param gradient defines the gradient to use (between 0 and 1)
  14830. * @param factor defines the drag to affect to the specified gradient
  14831. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14832. * @returns the current particle system
  14833. */
  14834. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14835. /**
  14836. * Remove a specific drag gradient
  14837. * @param gradient defines the gradient to remove
  14838. * @returns the current particle system
  14839. */
  14840. removeDragGradient(gradient: number): IParticleSystem;
  14841. /**
  14842. * Gets the current list of drag gradients.
  14843. * You must use addDragGradient and removeDragGradient to udpate this list
  14844. * @returns the list of drag gradients
  14845. */
  14846. getDragGradients(): Nullable<Array<FactorGradient>>;
  14847. /**
  14848. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  14849. * @param gradient defines the gradient to use (between 0 and 1)
  14850. * @param factor defines the emit rate to affect to the specified gradient
  14851. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14852. * @returns the current particle system
  14853. */
  14854. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14855. /**
  14856. * Remove a specific emit rate gradient
  14857. * @param gradient defines the gradient to remove
  14858. * @returns the current particle system
  14859. */
  14860. removeEmitRateGradient(gradient: number): IParticleSystem;
  14861. /**
  14862. * Gets the current list of emit rate gradients.
  14863. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  14864. * @returns the list of emit rate gradients
  14865. */
  14866. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  14867. /**
  14868. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  14869. * @param gradient defines the gradient to use (between 0 and 1)
  14870. * @param factor defines the start size to affect to the specified gradient
  14871. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14872. * @returns the current particle system
  14873. */
  14874. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14875. /**
  14876. * Remove a specific start size gradient
  14877. * @param gradient defines the gradient to remove
  14878. * @returns the current particle system
  14879. */
  14880. removeStartSizeGradient(gradient: number): IParticleSystem;
  14881. /**
  14882. * Gets the current list of start size gradients.
  14883. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  14884. * @returns the list of start size gradients
  14885. */
  14886. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  14887. /**
  14888. * Adds a new life time gradient
  14889. * @param gradient defines the gradient to use (between 0 and 1)
  14890. * @param factor defines the life time factor to affect to the specified gradient
  14891. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14892. * @returns the current particle system
  14893. */
  14894. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14895. /**
  14896. * Remove a specific life time gradient
  14897. * @param gradient defines the gradient to remove
  14898. * @returns the current particle system
  14899. */
  14900. removeLifeTimeGradient(gradient: number): IParticleSystem;
  14901. /**
  14902. * Gets the current list of life time gradients.
  14903. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  14904. * @returns the list of life time gradients
  14905. */
  14906. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  14907. /**
  14908. * Gets the current list of color gradients.
  14909. * You must use addColorGradient and removeColorGradient to udpate this list
  14910. * @returns the list of color gradients
  14911. */
  14912. getColorGradients(): Nullable<Array<ColorGradient>>;
  14913. /**
  14914. * Adds a new ramp gradient used to remap particle colors
  14915. * @param gradient defines the gradient to use (between 0 and 1)
  14916. * @param color defines the color to affect to the specified gradient
  14917. * @returns the current particle system
  14918. */
  14919. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  14920. /**
  14921. * Gets the current list of ramp gradients.
  14922. * You must use addRampGradient and removeRampGradient to udpate this list
  14923. * @returns the list of ramp gradients
  14924. */
  14925. getRampGradients(): Nullable<Array<Color3Gradient>>;
  14926. /** Gets or sets a boolean indicating that ramp gradients must be used
  14927. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  14928. */
  14929. useRampGradients: boolean;
  14930. /**
  14931. * Adds a new color remap gradient
  14932. * @param gradient defines the gradient to use (between 0 and 1)
  14933. * @param min defines the color remap minimal range
  14934. * @param max defines the color remap maximal range
  14935. * @returns the current particle system
  14936. */
  14937. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14938. /**
  14939. * Gets the current list of color remap gradients.
  14940. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  14941. * @returns the list of color remap gradients
  14942. */
  14943. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  14944. /**
  14945. * Adds a new alpha remap gradient
  14946. * @param gradient defines the gradient to use (between 0 and 1)
  14947. * @param min defines the alpha remap minimal range
  14948. * @param max defines the alpha remap maximal range
  14949. * @returns the current particle system
  14950. */
  14951. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14952. /**
  14953. * Gets the current list of alpha remap gradients.
  14954. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  14955. * @returns the list of alpha remap gradients
  14956. */
  14957. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  14958. /**
  14959. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  14960. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14961. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14962. * @returns the emitter
  14963. */
  14964. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  14965. /**
  14966. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  14967. * @param radius The radius of the hemisphere to emit from
  14968. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14969. * @returns the emitter
  14970. */
  14971. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  14972. /**
  14973. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  14974. * @param radius The radius of the sphere to emit from
  14975. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14976. * @returns the emitter
  14977. */
  14978. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  14979. /**
  14980. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  14981. * @param radius The radius of the sphere to emit from
  14982. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  14983. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  14984. * @returns the emitter
  14985. */
  14986. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  14987. /**
  14988. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  14989. * @param radius The radius of the emission cylinder
  14990. * @param height The height of the emission cylinder
  14991. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  14992. * @param directionRandomizer How much to randomize the particle direction [0-1]
  14993. * @returns the emitter
  14994. */
  14995. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  14996. /**
  14997. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  14998. * @param radius The radius of the cylinder to emit from
  14999. * @param height The height of the emission cylinder
  15000. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15001. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  15002. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  15003. * @returns the emitter
  15004. */
  15005. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  15006. /**
  15007. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  15008. * @param radius The radius of the cone to emit from
  15009. * @param angle The base angle of the cone
  15010. * @returns the emitter
  15011. */
  15012. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  15013. /**
  15014. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  15015. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  15016. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  15017. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  15018. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  15019. * @returns the emitter
  15020. */
  15021. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  15022. /**
  15023. * Get hosting scene
  15024. * @returns the scene
  15025. */
  15026. getScene(): Nullable<Scene>;
  15027. }
  15028. }
  15029. declare module "babylonjs/Meshes/transformNode" {
  15030. import { DeepImmutable } from "babylonjs/types";
  15031. import { Observable } from "babylonjs/Misc/observable";
  15032. import { Nullable } from "babylonjs/types";
  15033. import { Camera } from "babylonjs/Cameras/camera";
  15034. import { Scene } from "babylonjs/scene";
  15035. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  15036. import { Node } from "babylonjs/node";
  15037. import { Bone } from "babylonjs/Bones/bone";
  15038. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  15039. import { Space } from "babylonjs/Maths/math.axis";
  15040. /**
  15041. * 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.
  15042. * @see https://doc.babylonjs.com/how_to/transformnode
  15043. */
  15044. export class TransformNode extends Node {
  15045. /**
  15046. * Object will not rotate to face the camera
  15047. */
  15048. static BILLBOARDMODE_NONE: number;
  15049. /**
  15050. * Object will rotate to face the camera but only on the x axis
  15051. */
  15052. static BILLBOARDMODE_X: number;
  15053. /**
  15054. * Object will rotate to face the camera but only on the y axis
  15055. */
  15056. static BILLBOARDMODE_Y: number;
  15057. /**
  15058. * Object will rotate to face the camera but only on the z axis
  15059. */
  15060. static BILLBOARDMODE_Z: number;
  15061. /**
  15062. * Object will rotate to face the camera
  15063. */
  15064. static BILLBOARDMODE_ALL: number;
  15065. /**
  15066. * Object will rotate to face the camera's position instead of orientation
  15067. */
  15068. static BILLBOARDMODE_USE_POSITION: number;
  15069. private static _TmpRotation;
  15070. private static _TmpScaling;
  15071. private static _TmpTranslation;
  15072. private _forward;
  15073. private _forwardInverted;
  15074. private _up;
  15075. private _right;
  15076. private _rightInverted;
  15077. private _position;
  15078. private _rotation;
  15079. private _rotationQuaternion;
  15080. protected _scaling: Vector3;
  15081. protected _isDirty: boolean;
  15082. private _transformToBoneReferal;
  15083. private _isAbsoluteSynced;
  15084. private _billboardMode;
  15085. /**
  15086. * Gets or sets the billboard mode. Default is 0.
  15087. *
  15088. * | Value | Type | Description |
  15089. * | --- | --- | --- |
  15090. * | 0 | BILLBOARDMODE_NONE | |
  15091. * | 1 | BILLBOARDMODE_X | |
  15092. * | 2 | BILLBOARDMODE_Y | |
  15093. * | 4 | BILLBOARDMODE_Z | |
  15094. * | 7 | BILLBOARDMODE_ALL | |
  15095. *
  15096. */
  15097. get billboardMode(): number;
  15098. set billboardMode(value: number);
  15099. private _preserveParentRotationForBillboard;
  15100. /**
  15101. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  15102. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  15103. */
  15104. get preserveParentRotationForBillboard(): boolean;
  15105. set preserveParentRotationForBillboard(value: boolean);
  15106. /**
  15107. * 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
  15108. */
  15109. scalingDeterminant: number;
  15110. private _infiniteDistance;
  15111. /**
  15112. * Gets or sets the distance of the object to max, often used by skybox
  15113. */
  15114. get infiniteDistance(): boolean;
  15115. set infiniteDistance(value: boolean);
  15116. /**
  15117. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  15118. * By default the system will update normals to compensate
  15119. */
  15120. ignoreNonUniformScaling: boolean;
  15121. /**
  15122. * 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
  15123. */
  15124. reIntegrateRotationIntoRotationQuaternion: boolean;
  15125. /** @hidden */
  15126. _poseMatrix: Nullable<Matrix>;
  15127. /** @hidden */
  15128. _localMatrix: Matrix;
  15129. private _usePivotMatrix;
  15130. private _absolutePosition;
  15131. private _absoluteScaling;
  15132. private _absoluteRotationQuaternion;
  15133. private _pivotMatrix;
  15134. private _pivotMatrixInverse;
  15135. /** @hidden */
  15136. _postMultiplyPivotMatrix: boolean;
  15137. protected _isWorldMatrixFrozen: boolean;
  15138. /** @hidden */
  15139. _indexInSceneTransformNodesArray: number;
  15140. /**
  15141. * An event triggered after the world matrix is updated
  15142. */
  15143. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  15144. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  15145. /**
  15146. * Gets a string identifying the name of the class
  15147. * @returns "TransformNode" string
  15148. */
  15149. getClassName(): string;
  15150. /**
  15151. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  15152. */
  15153. get position(): Vector3;
  15154. set position(newPosition: Vector3);
  15155. /**
  15156. * 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)).
  15157. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  15158. */
  15159. get rotation(): Vector3;
  15160. set rotation(newRotation: Vector3);
  15161. /**
  15162. * 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)).
  15163. */
  15164. get scaling(): Vector3;
  15165. set scaling(newScaling: Vector3);
  15166. /**
  15167. * 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).
  15168. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  15169. */
  15170. get rotationQuaternion(): Nullable<Quaternion>;
  15171. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  15172. /**
  15173. * The forward direction of that transform in world space.
  15174. */
  15175. get forward(): Vector3;
  15176. /**
  15177. * The up direction of that transform in world space.
  15178. */
  15179. get up(): Vector3;
  15180. /**
  15181. * The right direction of that transform in world space.
  15182. */
  15183. get right(): Vector3;
  15184. /**
  15185. * Copies the parameter passed Matrix into the mesh Pose matrix.
  15186. * @param matrix the matrix to copy the pose from
  15187. * @returns this TransformNode.
  15188. */
  15189. updatePoseMatrix(matrix: Matrix): TransformNode;
  15190. /**
  15191. * Returns the mesh Pose matrix.
  15192. * @returns the pose matrix
  15193. */
  15194. getPoseMatrix(): Matrix;
  15195. /** @hidden */
  15196. _isSynchronized(): boolean;
  15197. /** @hidden */
  15198. _initCache(): void;
  15199. /**
  15200. * Flag the transform node as dirty (Forcing it to update everything)
  15201. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  15202. * @returns this transform node
  15203. */
  15204. markAsDirty(property: string): TransformNode;
  15205. /**
  15206. * Returns the current mesh absolute position.
  15207. * Returns a Vector3.
  15208. */
  15209. get absolutePosition(): Vector3;
  15210. /**
  15211. * Returns the current mesh absolute scaling.
  15212. * Returns a Vector3.
  15213. */
  15214. get absoluteScaling(): Vector3;
  15215. /**
  15216. * Returns the current mesh absolute rotation.
  15217. * Returns a Quaternion.
  15218. */
  15219. get absoluteRotationQuaternion(): Quaternion;
  15220. /**
  15221. * Sets a new matrix to apply before all other transformation
  15222. * @param matrix defines the transform matrix
  15223. * @returns the current TransformNode
  15224. */
  15225. setPreTransformMatrix(matrix: Matrix): TransformNode;
  15226. /**
  15227. * Sets a new pivot matrix to the current node
  15228. * @param matrix defines the new pivot matrix to use
  15229. * @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
  15230. * @returns the current TransformNode
  15231. */
  15232. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  15233. /**
  15234. * Returns the mesh pivot matrix.
  15235. * Default : Identity.
  15236. * @returns the matrix
  15237. */
  15238. getPivotMatrix(): Matrix;
  15239. /**
  15240. * Instantiate (when possible) or clone that node with its hierarchy
  15241. * @param newParent defines the new parent to use for the instance (or clone)
  15242. * @param options defines options to configure how copy is done
  15243. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  15244. * @returns an instance (or a clone) of the current node with its hiearchy
  15245. */
  15246. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  15247. doNotInstantiate: boolean;
  15248. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  15249. /**
  15250. * Prevents the World matrix to be computed any longer
  15251. * @param newWorldMatrix defines an optional matrix to use as world matrix
  15252. * @returns the TransformNode.
  15253. */
  15254. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  15255. /**
  15256. * Allows back the World matrix computation.
  15257. * @returns the TransformNode.
  15258. */
  15259. unfreezeWorldMatrix(): this;
  15260. /**
  15261. * True if the World matrix has been frozen.
  15262. */
  15263. get isWorldMatrixFrozen(): boolean;
  15264. /**
  15265. * Retuns the mesh absolute position in the World.
  15266. * @returns a Vector3.
  15267. */
  15268. getAbsolutePosition(): Vector3;
  15269. /**
  15270. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  15271. * @param absolutePosition the absolute position to set
  15272. * @returns the TransformNode.
  15273. */
  15274. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  15275. /**
  15276. * Sets the mesh position in its local space.
  15277. * @param vector3 the position to set in localspace
  15278. * @returns the TransformNode.
  15279. */
  15280. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  15281. /**
  15282. * Returns the mesh position in the local space from the current World matrix values.
  15283. * @returns a new Vector3.
  15284. */
  15285. getPositionExpressedInLocalSpace(): Vector3;
  15286. /**
  15287. * Translates the mesh along the passed Vector3 in its local space.
  15288. * @param vector3 the distance to translate in localspace
  15289. * @returns the TransformNode.
  15290. */
  15291. locallyTranslate(vector3: Vector3): TransformNode;
  15292. private static _lookAtVectorCache;
  15293. /**
  15294. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  15295. * @param targetPoint the position (must be in same space as current mesh) to look at
  15296. * @param yawCor optional yaw (y-axis) correction in radians
  15297. * @param pitchCor optional pitch (x-axis) correction in radians
  15298. * @param rollCor optional roll (z-axis) correction in radians
  15299. * @param space the choosen space of the target
  15300. * @returns the TransformNode.
  15301. */
  15302. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  15303. /**
  15304. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  15305. * This Vector3 is expressed in the World space.
  15306. * @param localAxis axis to rotate
  15307. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  15308. */
  15309. getDirection(localAxis: Vector3): Vector3;
  15310. /**
  15311. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  15312. * localAxis is expressed in the mesh local space.
  15313. * result is computed in the Wordl space from the mesh World matrix.
  15314. * @param localAxis axis to rotate
  15315. * @param result the resulting transformnode
  15316. * @returns this TransformNode.
  15317. */
  15318. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  15319. /**
  15320. * Sets this transform node rotation to the given local axis.
  15321. * @param localAxis the axis in local space
  15322. * @param yawCor optional yaw (y-axis) correction in radians
  15323. * @param pitchCor optional pitch (x-axis) correction in radians
  15324. * @param rollCor optional roll (z-axis) correction in radians
  15325. * @returns this TransformNode
  15326. */
  15327. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  15328. /**
  15329. * Sets a new pivot point to the current node
  15330. * @param point defines the new pivot point to use
  15331. * @param space defines if the point is in world or local space (local by default)
  15332. * @returns the current TransformNode
  15333. */
  15334. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  15335. /**
  15336. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  15337. * @returns the pivot point
  15338. */
  15339. getPivotPoint(): Vector3;
  15340. /**
  15341. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  15342. * @param result the vector3 to store the result
  15343. * @returns this TransformNode.
  15344. */
  15345. getPivotPointToRef(result: Vector3): TransformNode;
  15346. /**
  15347. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  15348. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  15349. */
  15350. getAbsolutePivotPoint(): Vector3;
  15351. /**
  15352. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  15353. * @param result vector3 to store the result
  15354. * @returns this TransformNode.
  15355. */
  15356. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  15357. /**
  15358. * Defines the passed node as the parent of the current node.
  15359. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  15360. * @see https://doc.babylonjs.com/how_to/parenting
  15361. * @param node the node ot set as the parent
  15362. * @returns this TransformNode.
  15363. */
  15364. setParent(node: Nullable<Node>): TransformNode;
  15365. private _nonUniformScaling;
  15366. /**
  15367. * True if the scaling property of this object is non uniform eg. (1,2,1)
  15368. */
  15369. get nonUniformScaling(): boolean;
  15370. /** @hidden */
  15371. _updateNonUniformScalingState(value: boolean): boolean;
  15372. /**
  15373. * Attach the current TransformNode to another TransformNode associated with a bone
  15374. * @param bone Bone affecting the TransformNode
  15375. * @param affectedTransformNode TransformNode associated with the bone
  15376. * @returns this object
  15377. */
  15378. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  15379. /**
  15380. * Detach the transform node if its associated with a bone
  15381. * @returns this object
  15382. */
  15383. detachFromBone(): TransformNode;
  15384. private static _rotationAxisCache;
  15385. /**
  15386. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  15387. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  15388. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  15389. * The passed axis is also normalized.
  15390. * @param axis the axis to rotate around
  15391. * @param amount the amount to rotate in radians
  15392. * @param space Space to rotate in (Default: local)
  15393. * @returns the TransformNode.
  15394. */
  15395. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  15396. /**
  15397. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  15398. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  15399. * The passed axis is also normalized. .
  15400. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  15401. * @param point the point to rotate around
  15402. * @param axis the axis to rotate around
  15403. * @param amount the amount to rotate in radians
  15404. * @returns the TransformNode
  15405. */
  15406. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  15407. /**
  15408. * Translates the mesh along the axis vector for the passed distance in the given space.
  15409. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  15410. * @param axis the axis to translate in
  15411. * @param distance the distance to translate
  15412. * @param space Space to rotate in (Default: local)
  15413. * @returns the TransformNode.
  15414. */
  15415. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  15416. /**
  15417. * Adds a rotation step to the mesh current rotation.
  15418. * x, y, z are Euler angles expressed in radians.
  15419. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  15420. * This means this rotation is made in the mesh local space only.
  15421. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  15422. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  15423. * ```javascript
  15424. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  15425. * ```
  15426. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  15427. * 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.
  15428. * @param x Rotation to add
  15429. * @param y Rotation to add
  15430. * @param z Rotation to add
  15431. * @returns the TransformNode.
  15432. */
  15433. addRotation(x: number, y: number, z: number): TransformNode;
  15434. /**
  15435. * @hidden
  15436. */
  15437. protected _getEffectiveParent(): Nullable<Node>;
  15438. /**
  15439. * Computes the world matrix of the node
  15440. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  15441. * @returns the world matrix
  15442. */
  15443. computeWorldMatrix(force?: boolean): Matrix;
  15444. /**
  15445. * Resets this nodeTransform's local matrix to Matrix.Identity().
  15446. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  15447. */
  15448. resetLocalMatrix(independentOfChildren?: boolean): void;
  15449. protected _afterComputeWorldMatrix(): void;
  15450. /**
  15451. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  15452. * @param func callback function to add
  15453. *
  15454. * @returns the TransformNode.
  15455. */
  15456. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  15457. /**
  15458. * Removes a registered callback function.
  15459. * @param func callback function to remove
  15460. * @returns the TransformNode.
  15461. */
  15462. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  15463. /**
  15464. * Gets the position of the current mesh in camera space
  15465. * @param camera defines the camera to use
  15466. * @returns a position
  15467. */
  15468. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  15469. /**
  15470. * Returns the distance from the mesh to the active camera
  15471. * @param camera defines the camera to use
  15472. * @returns the distance
  15473. */
  15474. getDistanceToCamera(camera?: Nullable<Camera>): number;
  15475. /**
  15476. * Clone the current transform node
  15477. * @param name Name of the new clone
  15478. * @param newParent New parent for the clone
  15479. * @param doNotCloneChildren Do not clone children hierarchy
  15480. * @returns the new transform node
  15481. */
  15482. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  15483. /**
  15484. * Serializes the objects information.
  15485. * @param currentSerializationObject defines the object to serialize in
  15486. * @returns the serialized object
  15487. */
  15488. serialize(currentSerializationObject?: any): any;
  15489. /**
  15490. * Returns a new TransformNode object parsed from the source provided.
  15491. * @param parsedTransformNode is the source.
  15492. * @param scene the scne the object belongs to
  15493. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  15494. * @returns a new TransformNode object parsed from the source provided.
  15495. */
  15496. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  15497. /**
  15498. * Get all child-transformNodes of this node
  15499. * @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
  15500. * @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
  15501. * @returns an array of TransformNode
  15502. */
  15503. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  15504. /**
  15505. * Releases resources associated with this transform node.
  15506. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  15507. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  15508. */
  15509. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  15510. /**
  15511. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  15512. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  15513. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  15514. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  15515. * @returns the current mesh
  15516. */
  15517. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  15518. private _syncAbsoluteScalingAndRotation;
  15519. }
  15520. }
  15521. declare module "babylonjs/Animations/animationPropertiesOverride" {
  15522. /**
  15523. * Class used to override all child animations of a given target
  15524. */
  15525. export class AnimationPropertiesOverride {
  15526. /**
  15527. * Gets or sets a value indicating if animation blending must be used
  15528. */
  15529. enableBlending: boolean;
  15530. /**
  15531. * Gets or sets the blending speed to use when enableBlending is true
  15532. */
  15533. blendingSpeed: number;
  15534. /**
  15535. * Gets or sets the default loop mode to use
  15536. */
  15537. loopMode: number;
  15538. }
  15539. }
  15540. declare module "babylonjs/Bones/bone" {
  15541. import { Skeleton } from "babylonjs/Bones/skeleton";
  15542. import { Vector3, Quaternion, Matrix } from "babylonjs/Maths/math.vector";
  15543. import { Nullable } from "babylonjs/types";
  15544. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  15545. import { TransformNode } from "babylonjs/Meshes/transformNode";
  15546. import { Node } from "babylonjs/node";
  15547. import { Space } from "babylonjs/Maths/math.axis";
  15548. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  15549. /**
  15550. * Class used to store bone information
  15551. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  15552. */
  15553. export class Bone extends Node {
  15554. /**
  15555. * defines the bone name
  15556. */
  15557. name: string;
  15558. private static _tmpVecs;
  15559. private static _tmpQuat;
  15560. private static _tmpMats;
  15561. /**
  15562. * Gets the list of child bones
  15563. */
  15564. children: Bone[];
  15565. /** Gets the animations associated with this bone */
  15566. animations: import("babylonjs/Animations/animation").Animation[];
  15567. /**
  15568. * Gets or sets bone length
  15569. */
  15570. length: number;
  15571. /**
  15572. * @hidden Internal only
  15573. * Set this value to map this bone to a different index in the transform matrices
  15574. * Set this value to -1 to exclude the bone from the transform matrices
  15575. */
  15576. _index: Nullable<number>;
  15577. private _skeleton;
  15578. private _localMatrix;
  15579. private _restPose;
  15580. private _bindPose;
  15581. private _baseMatrix;
  15582. private _absoluteTransform;
  15583. private _invertedAbsoluteTransform;
  15584. private _parent;
  15585. private _scalingDeterminant;
  15586. private _worldTransform;
  15587. private _localScaling;
  15588. private _localRotation;
  15589. private _localPosition;
  15590. private _needToDecompose;
  15591. private _needToCompose;
  15592. /** @hidden */
  15593. _linkedTransformNode: Nullable<TransformNode>;
  15594. /** @hidden */
  15595. _waitingTransformNodeId: Nullable<string>;
  15596. /** @hidden */
  15597. get _matrix(): Matrix;
  15598. /** @hidden */
  15599. set _matrix(value: Matrix);
  15600. /**
  15601. * Create a new bone
  15602. * @param name defines the bone name
  15603. * @param skeleton defines the parent skeleton
  15604. * @param parentBone defines the parent (can be null if the bone is the root)
  15605. * @param localMatrix defines the local matrix
  15606. * @param restPose defines the rest pose matrix
  15607. * @param baseMatrix defines the base matrix
  15608. * @param index defines index of the bone in the hiearchy
  15609. */
  15610. constructor(
  15611. /**
  15612. * defines the bone name
  15613. */
  15614. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  15615. /**
  15616. * Gets the current object class name.
  15617. * @return the class name
  15618. */
  15619. getClassName(): string;
  15620. /**
  15621. * Gets the parent skeleton
  15622. * @returns a skeleton
  15623. */
  15624. getSkeleton(): Skeleton;
  15625. /**
  15626. * Gets parent bone
  15627. * @returns a bone or null if the bone is the root of the bone hierarchy
  15628. */
  15629. getParent(): Nullable<Bone>;
  15630. /**
  15631. * Returns an array containing the root bones
  15632. * @returns an array containing the root bones
  15633. */
  15634. getChildren(): Array<Bone>;
  15635. /**
  15636. * Gets the node index in matrix array generated for rendering
  15637. * @returns the node index
  15638. */
  15639. getIndex(): number;
  15640. /**
  15641. * Sets the parent bone
  15642. * @param parent defines the parent (can be null if the bone is the root)
  15643. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  15644. */
  15645. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  15646. /**
  15647. * Gets the local matrix
  15648. * @returns a matrix
  15649. */
  15650. getLocalMatrix(): Matrix;
  15651. /**
  15652. * Gets the base matrix (initial matrix which remains unchanged)
  15653. * @returns a matrix
  15654. */
  15655. getBaseMatrix(): Matrix;
  15656. /**
  15657. * Gets the rest pose matrix
  15658. * @returns a matrix
  15659. */
  15660. getRestPose(): Matrix;
  15661. /**
  15662. * Sets the rest pose matrix
  15663. * @param matrix the local-space rest pose to set for this bone
  15664. */
  15665. setRestPose(matrix: Matrix): void;
  15666. /**
  15667. * Gets the bind pose matrix
  15668. * @returns the bind pose matrix
  15669. */
  15670. getBindPose(): Matrix;
  15671. /**
  15672. * Sets the bind pose matrix
  15673. * @param matrix the local-space bind pose to set for this bone
  15674. */
  15675. setBindPose(matrix: Matrix): void;
  15676. /**
  15677. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  15678. */
  15679. getWorldMatrix(): Matrix;
  15680. /**
  15681. * Sets the local matrix to rest pose matrix
  15682. */
  15683. returnToRest(): void;
  15684. /**
  15685. * Gets the inverse of the absolute transform matrix.
  15686. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  15687. * @returns a matrix
  15688. */
  15689. getInvertedAbsoluteTransform(): Matrix;
  15690. /**
  15691. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  15692. * @returns a matrix
  15693. */
  15694. getAbsoluteTransform(): Matrix;
  15695. /**
  15696. * Links with the given transform node.
  15697. * The local matrix of this bone is copied from the transform node every frame.
  15698. * @param transformNode defines the transform node to link to
  15699. */
  15700. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  15701. /**
  15702. * Gets the node used to drive the bone's transformation
  15703. * @returns a transform node or null
  15704. */
  15705. getTransformNode(): Nullable<TransformNode>;
  15706. /** Gets or sets current position (in local space) */
  15707. get position(): Vector3;
  15708. set position(newPosition: Vector3);
  15709. /** Gets or sets current rotation (in local space) */
  15710. get rotation(): Vector3;
  15711. set rotation(newRotation: Vector3);
  15712. /** Gets or sets current rotation quaternion (in local space) */
  15713. get rotationQuaternion(): Quaternion;
  15714. set rotationQuaternion(newRotation: Quaternion);
  15715. /** Gets or sets current scaling (in local space) */
  15716. get scaling(): Vector3;
  15717. set scaling(newScaling: Vector3);
  15718. /**
  15719. * Gets the animation properties override
  15720. */
  15721. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  15722. private _decompose;
  15723. private _compose;
  15724. /**
  15725. * Update the base and local matrices
  15726. * @param matrix defines the new base or local matrix
  15727. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  15728. * @param updateLocalMatrix defines if the local matrix should be updated
  15729. */
  15730. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  15731. /** @hidden */
  15732. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  15733. /**
  15734. * Flag the bone as dirty (Forcing it to update everything)
  15735. */
  15736. markAsDirty(): void;
  15737. /** @hidden */
  15738. _markAsDirtyAndCompose(): void;
  15739. private _markAsDirtyAndDecompose;
  15740. /**
  15741. * Translate the bone in local or world space
  15742. * @param vec The amount to translate the bone
  15743. * @param space The space that the translation is in
  15744. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15745. */
  15746. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15747. /**
  15748. * Set the postion of the bone in local or world space
  15749. * @param position The position to set the bone
  15750. * @param space The space that the position is in
  15751. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15752. */
  15753. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15754. /**
  15755. * Set the absolute position of the bone (world space)
  15756. * @param position The position to set the bone
  15757. * @param mesh The mesh that this bone is attached to
  15758. */
  15759. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  15760. /**
  15761. * Scale the bone on the x, y and z axes (in local space)
  15762. * @param x The amount to scale the bone on the x axis
  15763. * @param y The amount to scale the bone on the y axis
  15764. * @param z The amount to scale the bone on the z axis
  15765. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  15766. */
  15767. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  15768. /**
  15769. * Set the bone scaling in local space
  15770. * @param scale defines the scaling vector
  15771. */
  15772. setScale(scale: Vector3): void;
  15773. /**
  15774. * Gets the current scaling in local space
  15775. * @returns the current scaling vector
  15776. */
  15777. getScale(): Vector3;
  15778. /**
  15779. * Gets the current scaling in local space and stores it in a target vector
  15780. * @param result defines the target vector
  15781. */
  15782. getScaleToRef(result: Vector3): void;
  15783. /**
  15784. * Set the yaw, pitch, and roll of the bone in local or world space
  15785. * @param yaw The rotation of the bone on the y axis
  15786. * @param pitch The rotation of the bone on the x axis
  15787. * @param roll The rotation of the bone on the z axis
  15788. * @param space The space that the axes of rotation are in
  15789. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15790. */
  15791. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  15792. /**
  15793. * Add a rotation to the bone on an axis in local or world space
  15794. * @param axis The axis to rotate the bone on
  15795. * @param amount The amount to rotate the bone
  15796. * @param space The space that the axis is in
  15797. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15798. */
  15799. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  15800. /**
  15801. * Set the rotation of the bone to a particular axis angle in local or world space
  15802. * @param axis The axis to rotate the bone on
  15803. * @param angle The angle that the bone should be rotated to
  15804. * @param space The space that the axis is in
  15805. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15806. */
  15807. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  15808. /**
  15809. * Set the euler rotation of the bone in local of world space
  15810. * @param rotation The euler rotation that the bone should be set to
  15811. * @param space The space that the rotation is in
  15812. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15813. */
  15814. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15815. /**
  15816. * Set the quaternion rotation of the bone in local of world space
  15817. * @param quat The quaternion rotation that the bone should be set to
  15818. * @param space The space that the rotation is in
  15819. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15820. */
  15821. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  15822. /**
  15823. * Set the rotation matrix of the bone in local of world space
  15824. * @param rotMat The rotation matrix that the bone should be set to
  15825. * @param space The space that the rotation is in
  15826. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15827. */
  15828. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  15829. private _rotateWithMatrix;
  15830. private _getNegativeRotationToRef;
  15831. /**
  15832. * Get the position of the bone in local or world space
  15833. * @param space The space that the returned position is in
  15834. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15835. * @returns The position of the bone
  15836. */
  15837. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  15838. /**
  15839. * Copy the position of the bone to a vector3 in local or world space
  15840. * @param space The space that the returned position is in
  15841. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15842. * @param result The vector3 to copy the position to
  15843. */
  15844. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  15845. /**
  15846. * Get the absolute position of the bone (world space)
  15847. * @param mesh The mesh that this bone is attached to
  15848. * @returns The absolute position of the bone
  15849. */
  15850. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  15851. /**
  15852. * Copy the absolute position of the bone (world space) to the result param
  15853. * @param mesh The mesh that this bone is attached to
  15854. * @param result The vector3 to copy the absolute position to
  15855. */
  15856. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  15857. /**
  15858. * Compute the absolute transforms of this bone and its children
  15859. */
  15860. computeAbsoluteTransforms(): void;
  15861. /**
  15862. * Get the world direction from an axis that is in the local space of the bone
  15863. * @param localAxis The local direction that is used to compute the world direction
  15864. * @param mesh The mesh that this bone is attached to
  15865. * @returns The world direction
  15866. */
  15867. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15868. /**
  15869. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  15870. * @param localAxis The local direction that is used to compute the world direction
  15871. * @param mesh The mesh that this bone is attached to
  15872. * @param result The vector3 that the world direction will be copied to
  15873. */
  15874. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15875. /**
  15876. * Get the euler rotation of the bone in local or world space
  15877. * @param space The space that the rotation should be in
  15878. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15879. * @returns The euler rotation
  15880. */
  15881. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  15882. /**
  15883. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  15884. * @param space The space that the rotation should be in
  15885. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15886. * @param result The vector3 that the rotation should be copied to
  15887. */
  15888. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15889. /**
  15890. * Get the quaternion rotation of the bone in either local or world space
  15891. * @param space The space that the rotation should be in
  15892. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15893. * @returns The quaternion rotation
  15894. */
  15895. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  15896. /**
  15897. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  15898. * @param space The space that the rotation should be in
  15899. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15900. * @param result The quaternion that the rotation should be copied to
  15901. */
  15902. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  15903. /**
  15904. * Get the rotation matrix of the bone in local or world space
  15905. * @param space The space that the rotation should be in
  15906. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15907. * @returns The rotation matrix
  15908. */
  15909. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  15910. /**
  15911. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  15912. * @param space The space that the rotation should be in
  15913. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15914. * @param result The quaternion that the rotation should be copied to
  15915. */
  15916. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  15917. /**
  15918. * Get the world position of a point that is in the local space of the bone
  15919. * @param position The local position
  15920. * @param mesh The mesh that this bone is attached to
  15921. * @returns The world position
  15922. */
  15923. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15924. /**
  15925. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  15926. * @param position The local position
  15927. * @param mesh The mesh that this bone is attached to
  15928. * @param result The vector3 that the world position should be copied to
  15929. */
  15930. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15931. /**
  15932. * Get the local position of a point that is in world space
  15933. * @param position The world position
  15934. * @param mesh The mesh that this bone is attached to
  15935. * @returns The local position
  15936. */
  15937. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15938. /**
  15939. * Get the local position of a point that is in world space and copy it to the result param
  15940. * @param position The world position
  15941. * @param mesh The mesh that this bone is attached to
  15942. * @param result The vector3 that the local position should be copied to
  15943. */
  15944. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15945. }
  15946. }
  15947. declare module "babylonjs/Animations/runtimeAnimation" {
  15948. import { Animation, _IAnimationState } from "babylonjs/Animations/animation";
  15949. import { Animatable } from "babylonjs/Animations/animatable";
  15950. import { Scene } from "babylonjs/scene";
  15951. /**
  15952. * Defines a runtime animation
  15953. */
  15954. export class RuntimeAnimation {
  15955. private _events;
  15956. /**
  15957. * The current frame of the runtime animation
  15958. */
  15959. private _currentFrame;
  15960. /**
  15961. * The animation used by the runtime animation
  15962. */
  15963. private _animation;
  15964. /**
  15965. * The target of the runtime animation
  15966. */
  15967. private _target;
  15968. /**
  15969. * The initiating animatable
  15970. */
  15971. private _host;
  15972. /**
  15973. * The original value of the runtime animation
  15974. */
  15975. private _originalValue;
  15976. /**
  15977. * The original blend value of the runtime animation
  15978. */
  15979. private _originalBlendValue;
  15980. /**
  15981. * The offsets cache of the runtime animation
  15982. */
  15983. private _offsetsCache;
  15984. /**
  15985. * The high limits cache of the runtime animation
  15986. */
  15987. private _highLimitsCache;
  15988. /**
  15989. * Specifies if the runtime animation has been stopped
  15990. */
  15991. private _stopped;
  15992. /**
  15993. * The blending factor of the runtime animation
  15994. */
  15995. private _blendingFactor;
  15996. /**
  15997. * The BabylonJS scene
  15998. */
  15999. private _scene;
  16000. /**
  16001. * The current value of the runtime animation
  16002. */
  16003. private _currentValue;
  16004. /** @hidden */
  16005. _animationState: _IAnimationState;
  16006. /**
  16007. * The active target of the runtime animation
  16008. */
  16009. private _activeTargets;
  16010. private _currentActiveTarget;
  16011. private _directTarget;
  16012. /**
  16013. * The target path of the runtime animation
  16014. */
  16015. private _targetPath;
  16016. /**
  16017. * The weight of the runtime animation
  16018. */
  16019. private _weight;
  16020. /**
  16021. * The ratio offset of the runtime animation
  16022. */
  16023. private _ratioOffset;
  16024. /**
  16025. * The previous delay of the runtime animation
  16026. */
  16027. private _previousDelay;
  16028. /**
  16029. * The previous ratio of the runtime animation
  16030. */
  16031. private _previousRatio;
  16032. private _enableBlending;
  16033. private _keys;
  16034. private _minFrame;
  16035. private _maxFrame;
  16036. private _minValue;
  16037. private _maxValue;
  16038. private _targetIsArray;
  16039. /**
  16040. * Gets the current frame of the runtime animation
  16041. */
  16042. get currentFrame(): number;
  16043. /**
  16044. * Gets the weight of the runtime animation
  16045. */
  16046. get weight(): number;
  16047. /**
  16048. * Gets the current value of the runtime animation
  16049. */
  16050. get currentValue(): any;
  16051. /**
  16052. * Gets the target path of the runtime animation
  16053. */
  16054. get targetPath(): string;
  16055. /**
  16056. * Gets the actual target of the runtime animation
  16057. */
  16058. get target(): any;
  16059. /**
  16060. * Gets the additive state of the runtime animation
  16061. */
  16062. get isAdditive(): boolean;
  16063. /** @hidden */
  16064. _onLoop: () => void;
  16065. /**
  16066. * Create a new RuntimeAnimation object
  16067. * @param target defines the target of the animation
  16068. * @param animation defines the source animation object
  16069. * @param scene defines the hosting scene
  16070. * @param host defines the initiating Animatable
  16071. */
  16072. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  16073. private _preparePath;
  16074. /**
  16075. * Gets the animation from the runtime animation
  16076. */
  16077. get animation(): Animation;
  16078. /**
  16079. * Resets the runtime animation to the beginning
  16080. * @param restoreOriginal defines whether to restore the target property to the original value
  16081. */
  16082. reset(restoreOriginal?: boolean): void;
  16083. /**
  16084. * Specifies if the runtime animation is stopped
  16085. * @returns Boolean specifying if the runtime animation is stopped
  16086. */
  16087. isStopped(): boolean;
  16088. /**
  16089. * Disposes of the runtime animation
  16090. */
  16091. dispose(): void;
  16092. /**
  16093. * Apply the interpolated value to the target
  16094. * @param currentValue defines the value computed by the animation
  16095. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  16096. */
  16097. setValue(currentValue: any, weight: number): void;
  16098. private _getOriginalValues;
  16099. private _setValue;
  16100. /**
  16101. * Gets the loop pmode of the runtime animation
  16102. * @returns Loop Mode
  16103. */
  16104. private _getCorrectLoopMode;
  16105. /**
  16106. * Move the current animation to a given frame
  16107. * @param frame defines the frame to move to
  16108. */
  16109. goToFrame(frame: number): void;
  16110. /**
  16111. * @hidden Internal use only
  16112. */
  16113. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  16114. /**
  16115. * Execute the current animation
  16116. * @param delay defines the delay to add to the current frame
  16117. * @param from defines the lower bound of the animation range
  16118. * @param to defines the upper bound of the animation range
  16119. * @param loop defines if the current animation must loop
  16120. * @param speedRatio defines the current speed ratio
  16121. * @param weight defines the weight of the animation (default is -1 so no weight)
  16122. * @param onLoop optional callback called when animation loops
  16123. * @returns a boolean indicating if the animation is running
  16124. */
  16125. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  16126. }
  16127. }
  16128. declare module "babylonjs/Animations/animatable" {
  16129. import { Animation } from "babylonjs/Animations/animation";
  16130. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  16131. import { Nullable } from "babylonjs/types";
  16132. import { Observable } from "babylonjs/Misc/observable";
  16133. import { Scene } from "babylonjs/scene";
  16134. import { Matrix, Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  16135. import { Node } from "babylonjs/node";
  16136. /**
  16137. * Class used to store an actual running animation
  16138. */
  16139. export class Animatable {
  16140. /** defines the target object */
  16141. target: any;
  16142. /** defines the starting frame number (default is 0) */
  16143. fromFrame: number;
  16144. /** defines the ending frame number (default is 100) */
  16145. toFrame: number;
  16146. /** defines if the animation must loop (default is false) */
  16147. loopAnimation: boolean;
  16148. /** defines a callback to call when animation ends if it is not looping */
  16149. onAnimationEnd?: (() => void) | null | undefined;
  16150. /** defines a callback to call when animation loops */
  16151. onAnimationLoop?: (() => void) | null | undefined;
  16152. /** defines whether the animation should be evaluated additively */
  16153. isAdditive: boolean;
  16154. private _localDelayOffset;
  16155. private _pausedDelay;
  16156. private _runtimeAnimations;
  16157. private _paused;
  16158. private _scene;
  16159. private _speedRatio;
  16160. private _weight;
  16161. private _syncRoot;
  16162. /**
  16163. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  16164. * This will only apply for non looping animation (default is true)
  16165. */
  16166. disposeOnEnd: boolean;
  16167. /**
  16168. * Gets a boolean indicating if the animation has started
  16169. */
  16170. animationStarted: boolean;
  16171. /**
  16172. * Observer raised when the animation ends
  16173. */
  16174. onAnimationEndObservable: Observable<Animatable>;
  16175. /**
  16176. * Observer raised when the animation loops
  16177. */
  16178. onAnimationLoopObservable: Observable<Animatable>;
  16179. /**
  16180. * Gets the root Animatable used to synchronize and normalize animations
  16181. */
  16182. get syncRoot(): Nullable<Animatable>;
  16183. /**
  16184. * Gets the current frame of the first RuntimeAnimation
  16185. * Used to synchronize Animatables
  16186. */
  16187. get masterFrame(): number;
  16188. /**
  16189. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  16190. */
  16191. get weight(): number;
  16192. set weight(value: number);
  16193. /**
  16194. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  16195. */
  16196. get speedRatio(): number;
  16197. set speedRatio(value: number);
  16198. /**
  16199. * Creates a new Animatable
  16200. * @param scene defines the hosting scene
  16201. * @param target defines the target object
  16202. * @param fromFrame defines the starting frame number (default is 0)
  16203. * @param toFrame defines the ending frame number (default is 100)
  16204. * @param loopAnimation defines if the animation must loop (default is false)
  16205. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  16206. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  16207. * @param animations defines a group of animation to add to the new Animatable
  16208. * @param onAnimationLoop defines a callback to call when animation loops
  16209. * @param isAdditive defines whether the animation should be evaluated additively
  16210. */
  16211. constructor(scene: Scene,
  16212. /** defines the target object */
  16213. target: any,
  16214. /** defines the starting frame number (default is 0) */
  16215. fromFrame?: number,
  16216. /** defines the ending frame number (default is 100) */
  16217. toFrame?: number,
  16218. /** defines if the animation must loop (default is false) */
  16219. loopAnimation?: boolean, speedRatio?: number,
  16220. /** defines a callback to call when animation ends if it is not looping */
  16221. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  16222. /** defines a callback to call when animation loops */
  16223. onAnimationLoop?: (() => void) | null | undefined,
  16224. /** defines whether the animation should be evaluated additively */
  16225. isAdditive?: boolean);
  16226. /**
  16227. * Synchronize and normalize current Animatable with a source Animatable
  16228. * This is useful when using animation weights and when animations are not of the same length
  16229. * @param root defines the root Animatable to synchronize with
  16230. * @returns the current Animatable
  16231. */
  16232. syncWith(root: Animatable): Animatable;
  16233. /**
  16234. * Gets the list of runtime animations
  16235. * @returns an array of RuntimeAnimation
  16236. */
  16237. getAnimations(): RuntimeAnimation[];
  16238. /**
  16239. * Adds more animations to the current animatable
  16240. * @param target defines the target of the animations
  16241. * @param animations defines the new animations to add
  16242. */
  16243. appendAnimations(target: any, animations: Animation[]): void;
  16244. /**
  16245. * Gets the source animation for a specific property
  16246. * @param property defines the propertyu to look for
  16247. * @returns null or the source animation for the given property
  16248. */
  16249. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  16250. /**
  16251. * Gets the runtime animation for a specific property
  16252. * @param property defines the propertyu to look for
  16253. * @returns null or the runtime animation for the given property
  16254. */
  16255. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  16256. /**
  16257. * Resets the animatable to its original state
  16258. */
  16259. reset(): void;
  16260. /**
  16261. * Allows the animatable to blend with current running animations
  16262. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  16263. * @param blendingSpeed defines the blending speed to use
  16264. */
  16265. enableBlending(blendingSpeed: number): void;
  16266. /**
  16267. * Disable animation blending
  16268. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  16269. */
  16270. disableBlending(): void;
  16271. /**
  16272. * Jump directly to a given frame
  16273. * @param frame defines the frame to jump to
  16274. */
  16275. goToFrame(frame: number): void;
  16276. /**
  16277. * Pause the animation
  16278. */
  16279. pause(): void;
  16280. /**
  16281. * Restart the animation
  16282. */
  16283. restart(): void;
  16284. private _raiseOnAnimationEnd;
  16285. /**
  16286. * Stop and delete the current animation
  16287. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  16288. * @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)
  16289. */
  16290. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  16291. /**
  16292. * Wait asynchronously for the animation to end
  16293. * @returns a promise which will be fullfilled when the animation ends
  16294. */
  16295. waitAsync(): Promise<Animatable>;
  16296. /** @hidden */
  16297. _animate(delay: number): boolean;
  16298. }
  16299. module "babylonjs/scene" {
  16300. interface Scene {
  16301. /** @hidden */
  16302. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  16303. /** @hidden */
  16304. _processLateAnimationBindingsForMatrices(holder: {
  16305. totalWeight: number;
  16306. totalAdditiveWeight: number;
  16307. animations: RuntimeAnimation[];
  16308. additiveAnimations: RuntimeAnimation[];
  16309. originalValue: Matrix;
  16310. }): any;
  16311. /** @hidden */
  16312. _processLateAnimationBindingsForQuaternions(holder: {
  16313. totalWeight: number;
  16314. totalAdditiveWeight: number;
  16315. animations: RuntimeAnimation[];
  16316. additiveAnimations: RuntimeAnimation[];
  16317. originalValue: Quaternion;
  16318. }, refQuaternion: Quaternion): Quaternion;
  16319. /** @hidden */
  16320. _processLateAnimationBindings(): void;
  16321. /**
  16322. * Will start the animation sequence of a given target
  16323. * @param target defines the target
  16324. * @param from defines from which frame should animation start
  16325. * @param to defines until which frame should animation run.
  16326. * @param weight defines the weight to apply to the animation (1.0 by default)
  16327. * @param loop defines if the animation loops
  16328. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  16329. * @param onAnimationEnd defines the function to be executed when the animation ends
  16330. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  16331. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  16332. * @param onAnimationLoop defines the callback to call when an animation loops
  16333. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16334. * @returns the animatable object created for this animation
  16335. */
  16336. 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;
  16337. /**
  16338. * Will start the animation sequence of a given target
  16339. * @param target defines the target
  16340. * @param from defines from which frame should animation start
  16341. * @param to defines until which frame should animation run.
  16342. * @param loop defines if the animation loops
  16343. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  16344. * @param onAnimationEnd defines the function to be executed when the animation ends
  16345. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  16346. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  16347. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  16348. * @param onAnimationLoop defines the callback to call when an animation loops
  16349. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16350. * @returns the animatable object created for this animation
  16351. */
  16352. 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;
  16353. /**
  16354. * Will start the animation sequence of a given target and its hierarchy
  16355. * @param target defines the target
  16356. * @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.
  16357. * @param from defines from which frame should animation start
  16358. * @param to defines until which frame should animation run.
  16359. * @param loop defines if the animation loops
  16360. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  16361. * @param onAnimationEnd defines the function to be executed when the animation ends
  16362. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  16363. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  16364. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  16365. * @param onAnimationLoop defines the callback to call when an animation loops
  16366. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16367. * @returns the list of created animatables
  16368. */
  16369. 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[];
  16370. /**
  16371. * Begin a new animation on a given node
  16372. * @param target defines the target where the animation will take place
  16373. * @param animations defines the list of animations to start
  16374. * @param from defines the initial value
  16375. * @param to defines the final value
  16376. * @param loop defines if you want animation to loop (off by default)
  16377. * @param speedRatio defines the speed ratio to apply to all animations
  16378. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  16379. * @param onAnimationLoop defines the callback to call when an animation loops
  16380. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16381. * @returns the list of created animatables
  16382. */
  16383. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  16384. /**
  16385. * Begin a new animation on a given node and its hierarchy
  16386. * @param target defines the root node where the animation will take place
  16387. * @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.
  16388. * @param animations defines the list of animations to start
  16389. * @param from defines the initial value
  16390. * @param to defines the final value
  16391. * @param loop defines if you want animation to loop (off by default)
  16392. * @param speedRatio defines the speed ratio to apply to all animations
  16393. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  16394. * @param onAnimationLoop defines the callback to call when an animation loops
  16395. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16396. * @returns the list of animatables created for all nodes
  16397. */
  16398. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  16399. /**
  16400. * Gets the animatable associated with a specific target
  16401. * @param target defines the target of the animatable
  16402. * @returns the required animatable if found
  16403. */
  16404. getAnimatableByTarget(target: any): Nullable<Animatable>;
  16405. /**
  16406. * Gets all animatables associated with a given target
  16407. * @param target defines the target to look animatables for
  16408. * @returns an array of Animatables
  16409. */
  16410. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  16411. /**
  16412. * Stops and removes all animations that have been applied to the scene
  16413. */
  16414. stopAllAnimations(): void;
  16415. /**
  16416. * Gets the current delta time used by animation engine
  16417. */
  16418. deltaTime: number;
  16419. }
  16420. }
  16421. module "babylonjs/Bones/bone" {
  16422. interface Bone {
  16423. /**
  16424. * Copy an animation range from another bone
  16425. * @param source defines the source bone
  16426. * @param rangeName defines the range name to copy
  16427. * @param frameOffset defines the frame offset
  16428. * @param rescaleAsRequired defines if rescaling must be applied if required
  16429. * @param skelDimensionsRatio defines the scaling ratio
  16430. * @returns true if operation was successful
  16431. */
  16432. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  16433. }
  16434. }
  16435. }
  16436. declare module "babylonjs/Bones/skeleton" {
  16437. import { Bone } from "babylonjs/Bones/bone";
  16438. import { Observable } from "babylonjs/Misc/observable";
  16439. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  16440. import { Scene } from "babylonjs/scene";
  16441. import { Nullable } from "babylonjs/types";
  16442. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16443. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  16444. import { Animatable } from "babylonjs/Animations/animatable";
  16445. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  16446. import { Animation } from "babylonjs/Animations/animation";
  16447. import { AnimationRange } from "babylonjs/Animations/animationRange";
  16448. import { IInspectable } from "babylonjs/Misc/iInspectable";
  16449. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  16450. /**
  16451. * Class used to handle skinning animations
  16452. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  16453. */
  16454. export class Skeleton implements IAnimatable {
  16455. /** defines the skeleton name */
  16456. name: string;
  16457. /** defines the skeleton Id */
  16458. id: string;
  16459. /**
  16460. * Defines the list of child bones
  16461. */
  16462. bones: Bone[];
  16463. /**
  16464. * Defines an estimate of the dimension of the skeleton at rest
  16465. */
  16466. dimensionsAtRest: Vector3;
  16467. /**
  16468. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  16469. */
  16470. needInitialSkinMatrix: boolean;
  16471. /**
  16472. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  16473. */
  16474. overrideMesh: Nullable<AbstractMesh>;
  16475. /**
  16476. * Gets the list of animations attached to this skeleton
  16477. */
  16478. animations: Array<Animation>;
  16479. private _scene;
  16480. private _isDirty;
  16481. private _transformMatrices;
  16482. private _transformMatrixTexture;
  16483. private _meshesWithPoseMatrix;
  16484. private _animatables;
  16485. private _identity;
  16486. private _synchronizedWithMesh;
  16487. private _ranges;
  16488. private _lastAbsoluteTransformsUpdateId;
  16489. private _canUseTextureForBones;
  16490. private _uniqueId;
  16491. /** @hidden */
  16492. _numBonesWithLinkedTransformNode: number;
  16493. /** @hidden */
  16494. _hasWaitingData: Nullable<boolean>;
  16495. /** @hidden */
  16496. _waitingOverrideMeshId: Nullable<string>;
  16497. /**
  16498. * Specifies if the skeleton should be serialized
  16499. */
  16500. doNotSerialize: boolean;
  16501. private _useTextureToStoreBoneMatrices;
  16502. /**
  16503. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  16504. * Please note that this option is not available if the hardware does not support it
  16505. */
  16506. get useTextureToStoreBoneMatrices(): boolean;
  16507. set useTextureToStoreBoneMatrices(value: boolean);
  16508. private _animationPropertiesOverride;
  16509. /**
  16510. * Gets or sets the animation properties override
  16511. */
  16512. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  16513. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  16514. /**
  16515. * List of inspectable custom properties (used by the Inspector)
  16516. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  16517. */
  16518. inspectableCustomProperties: IInspectable[];
  16519. /**
  16520. * An observable triggered before computing the skeleton's matrices
  16521. */
  16522. onBeforeComputeObservable: Observable<Skeleton>;
  16523. /**
  16524. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  16525. */
  16526. get isUsingTextureForMatrices(): boolean;
  16527. /**
  16528. * Gets the unique ID of this skeleton
  16529. */
  16530. get uniqueId(): number;
  16531. /**
  16532. * Creates a new skeleton
  16533. * @param name defines the skeleton name
  16534. * @param id defines the skeleton Id
  16535. * @param scene defines the hosting scene
  16536. */
  16537. constructor(
  16538. /** defines the skeleton name */
  16539. name: string,
  16540. /** defines the skeleton Id */
  16541. id: string, scene: Scene);
  16542. /**
  16543. * Gets the current object class name.
  16544. * @return the class name
  16545. */
  16546. getClassName(): string;
  16547. /**
  16548. * Returns an array containing the root bones
  16549. * @returns an array containing the root bones
  16550. */
  16551. getChildren(): Array<Bone>;
  16552. /**
  16553. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  16554. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  16555. * @returns a Float32Array containing matrices data
  16556. */
  16557. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  16558. /**
  16559. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  16560. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  16561. * @returns a raw texture containing the data
  16562. */
  16563. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  16564. /**
  16565. * Gets the current hosting scene
  16566. * @returns a scene object
  16567. */
  16568. getScene(): Scene;
  16569. /**
  16570. * Gets a string representing the current skeleton data
  16571. * @param fullDetails defines a boolean indicating if we want a verbose version
  16572. * @returns a string representing the current skeleton data
  16573. */
  16574. toString(fullDetails?: boolean): string;
  16575. /**
  16576. * Get bone's index searching by name
  16577. * @param name defines bone's name to search for
  16578. * @return the indice of the bone. Returns -1 if not found
  16579. */
  16580. getBoneIndexByName(name: string): number;
  16581. /**
  16582. * Creater a new animation range
  16583. * @param name defines the name of the range
  16584. * @param from defines the start key
  16585. * @param to defines the end key
  16586. */
  16587. createAnimationRange(name: string, from: number, to: number): void;
  16588. /**
  16589. * Delete a specific animation range
  16590. * @param name defines the name of the range
  16591. * @param deleteFrames defines if frames must be removed as well
  16592. */
  16593. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  16594. /**
  16595. * Gets a specific animation range
  16596. * @param name defines the name of the range to look for
  16597. * @returns the requested animation range or null if not found
  16598. */
  16599. getAnimationRange(name: string): Nullable<AnimationRange>;
  16600. /**
  16601. * Gets the list of all animation ranges defined on this skeleton
  16602. * @returns an array
  16603. */
  16604. getAnimationRanges(): Nullable<AnimationRange>[];
  16605. /**
  16606. * Copy animation range from a source skeleton.
  16607. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  16608. * @param source defines the source skeleton
  16609. * @param name defines the name of the range to copy
  16610. * @param rescaleAsRequired defines if rescaling must be applied if required
  16611. * @returns true if operation was successful
  16612. */
  16613. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  16614. /**
  16615. * Forces the skeleton to go to rest pose
  16616. */
  16617. returnToRest(): void;
  16618. private _getHighestAnimationFrame;
  16619. /**
  16620. * Begin a specific animation range
  16621. * @param name defines the name of the range to start
  16622. * @param loop defines if looping must be turned on (false by default)
  16623. * @param speedRatio defines the speed ratio to apply (1 by default)
  16624. * @param onAnimationEnd defines a callback which will be called when animation will end
  16625. * @returns a new animatable
  16626. */
  16627. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  16628. /**
  16629. * Convert the keyframes for a range of animation on a skeleton to be relative to a given reference frame.
  16630. * @param skeleton defines the Skeleton containing the animation range to convert
  16631. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  16632. * @param range defines the name of the AnimationRange belonging to the Skeleton to convert
  16633. * @returns the original skeleton
  16634. */
  16635. static MakeAnimationAdditive(skeleton: Skeleton, referenceFrame: number | undefined, range: string): Nullable<Skeleton>;
  16636. /** @hidden */
  16637. _markAsDirty(): void;
  16638. /** @hidden */
  16639. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  16640. /** @hidden */
  16641. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  16642. private _computeTransformMatrices;
  16643. /**
  16644. * Build all resources required to render a skeleton
  16645. */
  16646. prepare(): void;
  16647. /**
  16648. * Gets the list of animatables currently running for this skeleton
  16649. * @returns an array of animatables
  16650. */
  16651. getAnimatables(): IAnimatable[];
  16652. /**
  16653. * Clone the current skeleton
  16654. * @param name defines the name of the new skeleton
  16655. * @param id defines the id of the new skeleton
  16656. * @returns the new skeleton
  16657. */
  16658. clone(name: string, id?: string): Skeleton;
  16659. /**
  16660. * Enable animation blending for this skeleton
  16661. * @param blendingSpeed defines the blending speed to apply
  16662. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  16663. */
  16664. enableBlending(blendingSpeed?: number): void;
  16665. /**
  16666. * Releases all resources associated with the current skeleton
  16667. */
  16668. dispose(): void;
  16669. /**
  16670. * Serialize the skeleton in a JSON object
  16671. * @returns a JSON object
  16672. */
  16673. serialize(): any;
  16674. /**
  16675. * Creates a new skeleton from serialized data
  16676. * @param parsedSkeleton defines the serialized data
  16677. * @param scene defines the hosting scene
  16678. * @returns a new skeleton
  16679. */
  16680. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  16681. /**
  16682. * Compute all node absolute transforms
  16683. * @param forceUpdate defines if computation must be done even if cache is up to date
  16684. */
  16685. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  16686. /**
  16687. * Gets the root pose matrix
  16688. * @returns a matrix
  16689. */
  16690. getPoseMatrix(): Nullable<Matrix>;
  16691. /**
  16692. * Sorts bones per internal index
  16693. */
  16694. sortBones(): void;
  16695. private _sortBones;
  16696. }
  16697. }
  16698. declare module "babylonjs/Meshes/instancedMesh" {
  16699. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  16700. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  16701. import { Camera } from "babylonjs/Cameras/camera";
  16702. import { Node } from "babylonjs/node";
  16703. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16704. import { Mesh } from "babylonjs/Meshes/mesh";
  16705. import { Material } from "babylonjs/Materials/material";
  16706. import { Skeleton } from "babylonjs/Bones/skeleton";
  16707. import { Light } from "babylonjs/Lights/light";
  16708. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  16709. /**
  16710. * Creates an instance based on a source mesh.
  16711. */
  16712. export class InstancedMesh extends AbstractMesh {
  16713. private _sourceMesh;
  16714. private _currentLOD;
  16715. /** @hidden */
  16716. _indexInSourceMeshInstanceArray: number;
  16717. constructor(name: string, source: Mesh);
  16718. /**
  16719. * Returns the string "InstancedMesh".
  16720. */
  16721. getClassName(): string;
  16722. /** Gets the list of lights affecting that mesh */
  16723. get lightSources(): Light[];
  16724. _resyncLightSources(): void;
  16725. _resyncLightSource(light: Light): void;
  16726. _removeLightSource(light: Light, dispose: boolean): void;
  16727. /**
  16728. * If the source mesh receives shadows
  16729. */
  16730. get receiveShadows(): boolean;
  16731. /**
  16732. * The material of the source mesh
  16733. */
  16734. get material(): Nullable<Material>;
  16735. /**
  16736. * Visibility of the source mesh
  16737. */
  16738. get visibility(): number;
  16739. /**
  16740. * Skeleton of the source mesh
  16741. */
  16742. get skeleton(): Nullable<Skeleton>;
  16743. /**
  16744. * Rendering ground id of the source mesh
  16745. */
  16746. get renderingGroupId(): number;
  16747. set renderingGroupId(value: number);
  16748. /**
  16749. * Returns the total number of vertices (integer).
  16750. */
  16751. getTotalVertices(): number;
  16752. /**
  16753. * Returns a positive integer : the total number of indices in this mesh geometry.
  16754. * @returns the numner of indices or zero if the mesh has no geometry.
  16755. */
  16756. getTotalIndices(): number;
  16757. /**
  16758. * The source mesh of the instance
  16759. */
  16760. get sourceMesh(): Mesh;
  16761. /**
  16762. * Creates a new InstancedMesh object from the mesh model.
  16763. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  16764. * @param name defines the name of the new instance
  16765. * @returns a new InstancedMesh
  16766. */
  16767. createInstance(name: string): InstancedMesh;
  16768. /**
  16769. * Is this node ready to be used/rendered
  16770. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  16771. * @return {boolean} is it ready
  16772. */
  16773. isReady(completeCheck?: boolean): boolean;
  16774. /**
  16775. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  16776. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  16777. * @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.
  16778. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  16779. */
  16780. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  16781. /**
  16782. * Sets the vertex data of the mesh geometry for the requested `kind`.
  16783. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  16784. * The `data` are either a numeric array either a Float32Array.
  16785. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  16786. * 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).
  16787. * Note that a new underlying VertexBuffer object is created each call.
  16788. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  16789. *
  16790. * Possible `kind` values :
  16791. * - VertexBuffer.PositionKind
  16792. * - VertexBuffer.UVKind
  16793. * - VertexBuffer.UV2Kind
  16794. * - VertexBuffer.UV3Kind
  16795. * - VertexBuffer.UV4Kind
  16796. * - VertexBuffer.UV5Kind
  16797. * - VertexBuffer.UV6Kind
  16798. * - VertexBuffer.ColorKind
  16799. * - VertexBuffer.MatricesIndicesKind
  16800. * - VertexBuffer.MatricesIndicesExtraKind
  16801. * - VertexBuffer.MatricesWeightsKind
  16802. * - VertexBuffer.MatricesWeightsExtraKind
  16803. *
  16804. * Returns the Mesh.
  16805. */
  16806. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  16807. /**
  16808. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  16809. * If the mesh has no geometry, it is simply returned as it is.
  16810. * The `data` are either a numeric array either a Float32Array.
  16811. * No new underlying VertexBuffer object is created.
  16812. * 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.
  16813. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  16814. *
  16815. * Possible `kind` values :
  16816. * - VertexBuffer.PositionKind
  16817. * - VertexBuffer.UVKind
  16818. * - VertexBuffer.UV2Kind
  16819. * - VertexBuffer.UV3Kind
  16820. * - VertexBuffer.UV4Kind
  16821. * - VertexBuffer.UV5Kind
  16822. * - VertexBuffer.UV6Kind
  16823. * - VertexBuffer.ColorKind
  16824. * - VertexBuffer.MatricesIndicesKind
  16825. * - VertexBuffer.MatricesIndicesExtraKind
  16826. * - VertexBuffer.MatricesWeightsKind
  16827. * - VertexBuffer.MatricesWeightsExtraKind
  16828. *
  16829. * Returns the Mesh.
  16830. */
  16831. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  16832. /**
  16833. * Sets the mesh indices.
  16834. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  16835. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  16836. * This method creates a new index buffer each call.
  16837. * Returns the Mesh.
  16838. */
  16839. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  16840. /**
  16841. * Boolean : True if the mesh owns the requested kind of data.
  16842. */
  16843. isVerticesDataPresent(kind: string): boolean;
  16844. /**
  16845. * Returns an array of indices (IndicesArray).
  16846. */
  16847. getIndices(): Nullable<IndicesArray>;
  16848. get _positions(): Nullable<Vector3[]>;
  16849. /**
  16850. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  16851. * This means the mesh underlying bounding box and sphere are recomputed.
  16852. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  16853. * @returns the current mesh
  16854. */
  16855. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  16856. /** @hidden */
  16857. _preActivate(): InstancedMesh;
  16858. /** @hidden */
  16859. _activate(renderId: number, intermediateRendering: boolean): boolean;
  16860. /** @hidden */
  16861. _postActivate(): void;
  16862. getWorldMatrix(): Matrix;
  16863. get isAnInstance(): boolean;
  16864. /**
  16865. * Returns the current associated LOD AbstractMesh.
  16866. */
  16867. getLOD(camera: Camera): AbstractMesh;
  16868. /** @hidden */
  16869. _preActivateForIntermediateRendering(renderId: number): Mesh;
  16870. /** @hidden */
  16871. _syncSubMeshes(): InstancedMesh;
  16872. /** @hidden */
  16873. _generatePointsArray(): boolean;
  16874. /** @hidden */
  16875. _updateBoundingInfo(): AbstractMesh;
  16876. /**
  16877. * Creates a new InstancedMesh from the current mesh.
  16878. * - name (string) : the cloned mesh name
  16879. * - newParent (optional Node) : the optional Node to parent the clone to.
  16880. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  16881. *
  16882. * Returns the clone.
  16883. */
  16884. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  16885. /**
  16886. * Disposes the InstancedMesh.
  16887. * Returns nothing.
  16888. */
  16889. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  16890. }
  16891. module "babylonjs/Meshes/mesh" {
  16892. interface Mesh {
  16893. /**
  16894. * Register a custom buffer that will be instanced
  16895. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  16896. * @param kind defines the buffer kind
  16897. * @param stride defines the stride in floats
  16898. */
  16899. registerInstancedBuffer(kind: string, stride: number): void;
  16900. /**
  16901. * true to use the edge renderer for all instances of this mesh
  16902. */
  16903. edgesShareWithInstances: boolean;
  16904. /** @hidden */
  16905. _userInstancedBuffersStorage: {
  16906. data: {
  16907. [key: string]: Float32Array;
  16908. };
  16909. sizes: {
  16910. [key: string]: number;
  16911. };
  16912. vertexBuffers: {
  16913. [key: string]: Nullable<VertexBuffer>;
  16914. };
  16915. strides: {
  16916. [key: string]: number;
  16917. };
  16918. };
  16919. }
  16920. }
  16921. module "babylonjs/Meshes/abstractMesh" {
  16922. interface AbstractMesh {
  16923. /**
  16924. * Object used to store instanced buffers defined by user
  16925. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  16926. */
  16927. instancedBuffers: {
  16928. [key: string]: any;
  16929. };
  16930. }
  16931. }
  16932. }
  16933. declare module "babylonjs/Materials/shaderMaterial" {
  16934. import { Nullable } from "babylonjs/types";
  16935. import { Scene } from "babylonjs/scene";
  16936. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  16937. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16938. import { Mesh } from "babylonjs/Meshes/mesh";
  16939. import { SubMesh } from "babylonjs/Meshes/subMesh";
  16940. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  16941. import { Effect } from "babylonjs/Materials/effect";
  16942. import { Material } from "babylonjs/Materials/material";
  16943. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  16944. /**
  16945. * Defines the options associated with the creation of a shader material.
  16946. */
  16947. export interface IShaderMaterialOptions {
  16948. /**
  16949. * Does the material work in alpha blend mode
  16950. */
  16951. needAlphaBlending: boolean;
  16952. /**
  16953. * Does the material work in alpha test mode
  16954. */
  16955. needAlphaTesting: boolean;
  16956. /**
  16957. * The list of attribute names used in the shader
  16958. */
  16959. attributes: string[];
  16960. /**
  16961. * The list of unifrom names used in the shader
  16962. */
  16963. uniforms: string[];
  16964. /**
  16965. * The list of UBO names used in the shader
  16966. */
  16967. uniformBuffers: string[];
  16968. /**
  16969. * The list of sampler names used in the shader
  16970. */
  16971. samplers: string[];
  16972. /**
  16973. * The list of defines used in the shader
  16974. */
  16975. defines: string[];
  16976. }
  16977. /**
  16978. * 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.
  16979. *
  16980. * This returned material effects how the mesh will look based on the code in the shaders.
  16981. *
  16982. * @see https://doc.babylonjs.com/how_to/shader_material
  16983. */
  16984. export class ShaderMaterial extends Material {
  16985. private _shaderPath;
  16986. private _options;
  16987. private _textures;
  16988. private _textureArrays;
  16989. private _floats;
  16990. private _ints;
  16991. private _floatsArrays;
  16992. private _colors3;
  16993. private _colors3Arrays;
  16994. private _colors4;
  16995. private _colors4Arrays;
  16996. private _vectors2;
  16997. private _vectors3;
  16998. private _vectors4;
  16999. private _matrices;
  17000. private _matrixArrays;
  17001. private _matrices3x3;
  17002. private _matrices2x2;
  17003. private _vectors2Arrays;
  17004. private _vectors3Arrays;
  17005. private _vectors4Arrays;
  17006. private _cachedWorldViewMatrix;
  17007. private _cachedWorldViewProjectionMatrix;
  17008. private _renderId;
  17009. private _multiview;
  17010. private _cachedDefines;
  17011. /** Define the Url to load snippets */
  17012. static SnippetUrl: string;
  17013. /** Snippet ID if the material was created from the snippet server */
  17014. snippetId: string;
  17015. /**
  17016. * Instantiate a new shader material.
  17017. * 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.
  17018. * This returned material effects how the mesh will look based on the code in the shaders.
  17019. * @see https://doc.babylonjs.com/how_to/shader_material
  17020. * @param name Define the name of the material in the scene
  17021. * @param scene Define the scene the material belongs to
  17022. * @param shaderPath Defines the route to the shader code in one of three ways:
  17023. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  17024. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  17025. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  17026. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  17027. * @param options Define the options used to create the shader
  17028. */
  17029. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  17030. /**
  17031. * Gets the shader path used to define the shader code
  17032. * It can be modified to trigger a new compilation
  17033. */
  17034. get shaderPath(): any;
  17035. /**
  17036. * Sets the shader path used to define the shader code
  17037. * It can be modified to trigger a new compilation
  17038. */
  17039. set shaderPath(shaderPath: any);
  17040. /**
  17041. * Gets the options used to compile the shader.
  17042. * They can be modified to trigger a new compilation
  17043. */
  17044. get options(): IShaderMaterialOptions;
  17045. /**
  17046. * Gets the current class name of the material e.g. "ShaderMaterial"
  17047. * Mainly use in serialization.
  17048. * @returns the class name
  17049. */
  17050. getClassName(): string;
  17051. /**
  17052. * Specifies if the material will require alpha blending
  17053. * @returns a boolean specifying if alpha blending is needed
  17054. */
  17055. needAlphaBlending(): boolean;
  17056. /**
  17057. * Specifies if this material should be rendered in alpha test mode
  17058. * @returns a boolean specifying if an alpha test is needed.
  17059. */
  17060. needAlphaTesting(): boolean;
  17061. private _checkUniform;
  17062. /**
  17063. * Set a texture in the shader.
  17064. * @param name Define the name of the uniform samplers as defined in the shader
  17065. * @param texture Define the texture to bind to this sampler
  17066. * @return the material itself allowing "fluent" like uniform updates
  17067. */
  17068. setTexture(name: string, texture: BaseTexture): ShaderMaterial;
  17069. /**
  17070. * Set a texture array in the shader.
  17071. * @param name Define the name of the uniform sampler array as defined in the shader
  17072. * @param textures Define the list of textures to bind to this sampler
  17073. * @return the material itself allowing "fluent" like uniform updates
  17074. */
  17075. setTextureArray(name: string, textures: BaseTexture[]): ShaderMaterial;
  17076. /**
  17077. * Set a float in the shader.
  17078. * @param name Define the name of the uniform as defined in the shader
  17079. * @param value Define the value to give to the uniform
  17080. * @return the material itself allowing "fluent" like uniform updates
  17081. */
  17082. setFloat(name: string, value: number): ShaderMaterial;
  17083. /**
  17084. * Set a int in the shader.
  17085. * @param name Define the name of the uniform as defined in the shader
  17086. * @param value Define the value to give to the uniform
  17087. * @return the material itself allowing "fluent" like uniform updates
  17088. */
  17089. setInt(name: string, value: number): ShaderMaterial;
  17090. /**
  17091. * Set an array of floats in the shader.
  17092. * @param name Define the name of the uniform as defined in the shader
  17093. * @param value Define the value to give to the uniform
  17094. * @return the material itself allowing "fluent" like uniform updates
  17095. */
  17096. setFloats(name: string, value: number[]): ShaderMaterial;
  17097. /**
  17098. * Set a vec3 in the shader from a Color3.
  17099. * @param name Define the name of the uniform as defined in the shader
  17100. * @param value Define the value to give to the uniform
  17101. * @return the material itself allowing "fluent" like uniform updates
  17102. */
  17103. setColor3(name: string, value: Color3): ShaderMaterial;
  17104. /**
  17105. * Set a vec3 array in the shader from a Color3 array.
  17106. * @param name Define the name of the uniform as defined in the shader
  17107. * @param value Define the value to give to the uniform
  17108. * @return the material itself allowing "fluent" like uniform updates
  17109. */
  17110. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  17111. /**
  17112. * Set a vec4 in the shader from a Color4.
  17113. * @param name Define the name of the uniform as defined in the shader
  17114. * @param value Define the value to give to the uniform
  17115. * @return the material itself allowing "fluent" like uniform updates
  17116. */
  17117. setColor4(name: string, value: Color4): ShaderMaterial;
  17118. /**
  17119. * Set a vec4 array in the shader from a Color4 array.
  17120. * @param name Define the name of the uniform as defined in the shader
  17121. * @param value Define the value to give to the uniform
  17122. * @return the material itself allowing "fluent" like uniform updates
  17123. */
  17124. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  17125. /**
  17126. * Set a vec2 in the shader from a Vector2.
  17127. * @param name Define the name of the uniform as defined in the shader
  17128. * @param value Define the value to give to the uniform
  17129. * @return the material itself allowing "fluent" like uniform updates
  17130. */
  17131. setVector2(name: string, value: Vector2): ShaderMaterial;
  17132. /**
  17133. * Set a vec3 in the shader from a Vector3.
  17134. * @param name Define the name of the uniform as defined in the shader
  17135. * @param value Define the value to give to the uniform
  17136. * @return the material itself allowing "fluent" like uniform updates
  17137. */
  17138. setVector3(name: string, value: Vector3): ShaderMaterial;
  17139. /**
  17140. * Set a vec4 in the shader from a Vector4.
  17141. * @param name Define the name of the uniform as defined in the shader
  17142. * @param value Define the value to give to the uniform
  17143. * @return the material itself allowing "fluent" like uniform updates
  17144. */
  17145. setVector4(name: string, value: Vector4): ShaderMaterial;
  17146. /**
  17147. * Set a mat4 in the shader from a Matrix.
  17148. * @param name Define the name of the uniform as defined in the shader
  17149. * @param value Define the value to give to the uniform
  17150. * @return the material itself allowing "fluent" like uniform updates
  17151. */
  17152. setMatrix(name: string, value: Matrix): ShaderMaterial;
  17153. /**
  17154. * Set a float32Array in the shader from a matrix array.
  17155. * @param name Define the name of the uniform as defined in the shader
  17156. * @param value Define the value to give to the uniform
  17157. * @return the material itself allowing "fluent" like uniform updates
  17158. */
  17159. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  17160. /**
  17161. * Set a mat3 in the shader from a Float32Array.
  17162. * @param name Define the name of the uniform as defined in the shader
  17163. * @param value Define the value to give to the uniform
  17164. * @return the material itself allowing "fluent" like uniform updates
  17165. */
  17166. setMatrix3x3(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  17167. /**
  17168. * Set a mat2 in the shader from a Float32Array.
  17169. * @param name Define the name of the uniform as defined in the shader
  17170. * @param value Define the value to give to the uniform
  17171. * @return the material itself allowing "fluent" like uniform updates
  17172. */
  17173. setMatrix2x2(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  17174. /**
  17175. * Set a vec2 array in the shader from a number array.
  17176. * @param name Define the name of the uniform as defined in the shader
  17177. * @param value Define the value to give to the uniform
  17178. * @return the material itself allowing "fluent" like uniform updates
  17179. */
  17180. setArray2(name: string, value: number[]): ShaderMaterial;
  17181. /**
  17182. * Set a vec3 array in the shader from a number array.
  17183. * @param name Define the name of the uniform as defined in the shader
  17184. * @param value Define the value to give to the uniform
  17185. * @return the material itself allowing "fluent" like uniform updates
  17186. */
  17187. setArray3(name: string, value: number[]): ShaderMaterial;
  17188. /**
  17189. * Set a vec4 array in the shader from a number array.
  17190. * @param name Define the name of the uniform as defined in the shader
  17191. * @param value Define the value to give to the uniform
  17192. * @return the material itself allowing "fluent" like uniform updates
  17193. */
  17194. setArray4(name: string, value: number[]): ShaderMaterial;
  17195. private _checkCache;
  17196. /**
  17197. * Specifies that the submesh is ready to be used
  17198. * @param mesh defines the mesh to check
  17199. * @param subMesh defines which submesh to check
  17200. * @param useInstances specifies that instances should be used
  17201. * @returns a boolean indicating that the submesh is ready or not
  17202. */
  17203. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  17204. /**
  17205. * Checks if the material is ready to render the requested mesh
  17206. * @param mesh Define the mesh to render
  17207. * @param useInstances Define whether or not the material is used with instances
  17208. * @returns true if ready, otherwise false
  17209. */
  17210. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  17211. /**
  17212. * Binds the world matrix to the material
  17213. * @param world defines the world transformation matrix
  17214. * @param effectOverride - If provided, use this effect instead of internal effect
  17215. */
  17216. bindOnlyWorldMatrix(world: Matrix, effectOverride?: Nullable<Effect>): void;
  17217. /**
  17218. * Binds the submesh to this material by preparing the effect and shader to draw
  17219. * @param world defines the world transformation matrix
  17220. * @param mesh defines the mesh containing the submesh
  17221. * @param subMesh defines the submesh to bind the material to
  17222. */
  17223. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  17224. /**
  17225. * Binds the material to the mesh
  17226. * @param world defines the world transformation matrix
  17227. * @param mesh defines the mesh to bind the material to
  17228. * @param effectOverride - If provided, use this effect instead of internal effect
  17229. */
  17230. bind(world: Matrix, mesh?: Mesh, effectOverride?: Nullable<Effect>): void;
  17231. protected _afterBind(mesh?: Mesh): void;
  17232. /**
  17233. * Gets the active textures from the material
  17234. * @returns an array of textures
  17235. */
  17236. getActiveTextures(): BaseTexture[];
  17237. /**
  17238. * Specifies if the material uses a texture
  17239. * @param texture defines the texture to check against the material
  17240. * @returns a boolean specifying if the material uses the texture
  17241. */
  17242. hasTexture(texture: BaseTexture): boolean;
  17243. /**
  17244. * Makes a duplicate of the material, and gives it a new name
  17245. * @param name defines the new name for the duplicated material
  17246. * @returns the cloned material
  17247. */
  17248. clone(name: string): ShaderMaterial;
  17249. /**
  17250. * Disposes the material
  17251. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  17252. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  17253. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  17254. */
  17255. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  17256. /**
  17257. * Serializes this material in a JSON representation
  17258. * @returns the serialized material object
  17259. */
  17260. serialize(): any;
  17261. /**
  17262. * Creates a shader material from parsed shader material data
  17263. * @param source defines the JSON represnetation of the material
  17264. * @param scene defines the hosting scene
  17265. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  17266. * @returns a new material
  17267. */
  17268. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  17269. /**
  17270. * Creates a new ShaderMaterial from a snippet saved in a remote file
  17271. * @param name defines the name of the ShaderMaterial to create (can be null or empty to use the one from the json data)
  17272. * @param url defines the url to load from
  17273. * @param scene defines the hosting scene
  17274. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  17275. * @returns a promise that will resolve to the new ShaderMaterial
  17276. */
  17277. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  17278. /**
  17279. * Creates a ShaderMaterial from a snippet saved by the Inspector
  17280. * @param snippetId defines the snippet to load
  17281. * @param scene defines the hosting scene
  17282. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  17283. * @returns a promise that will resolve to the new ShaderMaterial
  17284. */
  17285. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  17286. }
  17287. }
  17288. declare module "babylonjs/Shaders/color.fragment" {
  17289. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  17290. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  17291. /** @hidden */
  17292. export var colorPixelShader: {
  17293. name: string;
  17294. shader: string;
  17295. };
  17296. }
  17297. declare module "babylonjs/Shaders/color.vertex" {
  17298. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  17299. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  17300. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  17301. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  17302. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  17303. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  17304. /** @hidden */
  17305. export var colorVertexShader: {
  17306. name: string;
  17307. shader: string;
  17308. };
  17309. }
  17310. declare module "babylonjs/Meshes/linesMesh" {
  17311. import { Nullable } from "babylonjs/types";
  17312. import { Scene } from "babylonjs/scene";
  17313. import { Color3 } from "babylonjs/Maths/math.color";
  17314. import { Node } from "babylonjs/node";
  17315. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17316. import { Mesh } from "babylonjs/Meshes/mesh";
  17317. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  17318. import { Effect } from "babylonjs/Materials/effect";
  17319. import { Material } from "babylonjs/Materials/material";
  17320. import "babylonjs/Shaders/color.fragment";
  17321. import "babylonjs/Shaders/color.vertex";
  17322. /**
  17323. * Line mesh
  17324. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  17325. */
  17326. export class LinesMesh extends Mesh {
  17327. /**
  17328. * If vertex color should be applied to the mesh
  17329. */
  17330. readonly useVertexColor?: boolean | undefined;
  17331. /**
  17332. * If vertex alpha should be applied to the mesh
  17333. */
  17334. readonly useVertexAlpha?: boolean | undefined;
  17335. /**
  17336. * Color of the line (Default: White)
  17337. */
  17338. color: Color3;
  17339. /**
  17340. * Alpha of the line (Default: 1)
  17341. */
  17342. alpha: number;
  17343. /**
  17344. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  17345. * This margin is expressed in world space coordinates, so its value may vary.
  17346. * Default value is 0.1
  17347. */
  17348. intersectionThreshold: number;
  17349. private _colorShader;
  17350. private color4;
  17351. /**
  17352. * Creates a new LinesMesh
  17353. * @param name defines the name
  17354. * @param scene defines the hosting scene
  17355. * @param parent defines the parent mesh if any
  17356. * @param source defines the optional source LinesMesh used to clone data from
  17357. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  17358. * When false, achieved by calling a clone(), also passing False.
  17359. * This will make creation of children, recursive.
  17360. * @param useVertexColor defines if this LinesMesh supports vertex color
  17361. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  17362. */
  17363. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  17364. /**
  17365. * If vertex color should be applied to the mesh
  17366. */
  17367. useVertexColor?: boolean | undefined,
  17368. /**
  17369. * If vertex alpha should be applied to the mesh
  17370. */
  17371. useVertexAlpha?: boolean | undefined);
  17372. private _addClipPlaneDefine;
  17373. private _removeClipPlaneDefine;
  17374. isReady(): boolean;
  17375. /**
  17376. * Returns the string "LineMesh"
  17377. */
  17378. getClassName(): string;
  17379. /**
  17380. * @hidden
  17381. */
  17382. get material(): Material;
  17383. /**
  17384. * @hidden
  17385. */
  17386. set material(value: Material);
  17387. /**
  17388. * @hidden
  17389. */
  17390. get checkCollisions(): boolean;
  17391. /** @hidden */
  17392. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  17393. /** @hidden */
  17394. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  17395. /**
  17396. * Disposes of the line mesh
  17397. * @param doNotRecurse If children should be disposed
  17398. */
  17399. dispose(doNotRecurse?: boolean): void;
  17400. /**
  17401. * Returns a new LineMesh object cloned from the current one.
  17402. */
  17403. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  17404. /**
  17405. * Creates a new InstancedLinesMesh object from the mesh model.
  17406. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  17407. * @param name defines the name of the new instance
  17408. * @returns a new InstancedLinesMesh
  17409. */
  17410. createInstance(name: string): InstancedLinesMesh;
  17411. }
  17412. /**
  17413. * Creates an instance based on a source LinesMesh
  17414. */
  17415. export class InstancedLinesMesh extends InstancedMesh {
  17416. /**
  17417. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  17418. * This margin is expressed in world space coordinates, so its value may vary.
  17419. * Initilized with the intersectionThreshold value of the source LinesMesh
  17420. */
  17421. intersectionThreshold: number;
  17422. constructor(name: string, source: LinesMesh);
  17423. /**
  17424. * Returns the string "InstancedLinesMesh".
  17425. */
  17426. getClassName(): string;
  17427. }
  17428. }
  17429. declare module "babylonjs/Shaders/line.fragment" {
  17430. /** @hidden */
  17431. export var linePixelShader: {
  17432. name: string;
  17433. shader: string;
  17434. };
  17435. }
  17436. declare module "babylonjs/Shaders/line.vertex" {
  17437. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  17438. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  17439. /** @hidden */
  17440. export var lineVertexShader: {
  17441. name: string;
  17442. shader: string;
  17443. };
  17444. }
  17445. declare module "babylonjs/Rendering/edgesRenderer" {
  17446. import { Nullable } from "babylonjs/types";
  17447. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  17448. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17449. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  17450. import { IDisposable } from "babylonjs/scene";
  17451. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  17452. import "babylonjs/Shaders/line.fragment";
  17453. import "babylonjs/Shaders/line.vertex";
  17454. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  17455. import { SmartArray } from "babylonjs/Misc/smartArray";
  17456. module "babylonjs/scene" {
  17457. interface Scene {
  17458. /** @hidden */
  17459. _edgeRenderLineShader: Nullable<ShaderMaterial>;
  17460. }
  17461. }
  17462. module "babylonjs/Meshes/abstractMesh" {
  17463. interface AbstractMesh {
  17464. /**
  17465. * Gets the edgesRenderer associated with the mesh
  17466. */
  17467. edgesRenderer: Nullable<EdgesRenderer>;
  17468. }
  17469. }
  17470. module "babylonjs/Meshes/linesMesh" {
  17471. interface LinesMesh {
  17472. /**
  17473. * Enables the edge rendering mode on the mesh.
  17474. * This mode makes the mesh edges visible
  17475. * @param epsilon defines the maximal distance between two angles to detect a face
  17476. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17477. * @returns the currentAbstractMesh
  17478. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17479. */
  17480. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  17481. }
  17482. }
  17483. module "babylonjs/Meshes/linesMesh" {
  17484. interface InstancedLinesMesh {
  17485. /**
  17486. * Enables the edge rendering mode on the mesh.
  17487. * This mode makes the mesh edges visible
  17488. * @param epsilon defines the maximal distance between two angles to detect a face
  17489. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17490. * @returns the current InstancedLinesMesh
  17491. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17492. */
  17493. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  17494. }
  17495. }
  17496. /**
  17497. * Defines the minimum contract an Edges renderer should follow.
  17498. */
  17499. export interface IEdgesRenderer extends IDisposable {
  17500. /**
  17501. * Gets or sets a boolean indicating if the edgesRenderer is active
  17502. */
  17503. isEnabled: boolean;
  17504. /**
  17505. * Renders the edges of the attached mesh,
  17506. */
  17507. render(): void;
  17508. /**
  17509. * Checks wether or not the edges renderer is ready to render.
  17510. * @return true if ready, otherwise false.
  17511. */
  17512. isReady(): boolean;
  17513. /**
  17514. * List of instances to render in case the source mesh has instances
  17515. */
  17516. customInstances: SmartArray<Matrix>;
  17517. }
  17518. /**
  17519. * Defines the additional options of the edges renderer
  17520. */
  17521. export interface IEdgesRendererOptions {
  17522. /**
  17523. * Gets or sets a boolean indicating that the alternate edge finder algorithm must be used
  17524. * If not defined, the default value is true
  17525. */
  17526. useAlternateEdgeFinder?: boolean;
  17527. /**
  17528. * Gets or sets a boolean indicating that the vertex merger fast processing must be used.
  17529. * If not defined, the default value is true.
  17530. * 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)
  17531. * This option is used only if useAlternateEdgeFinder = true
  17532. */
  17533. useFastVertexMerger?: boolean;
  17534. /**
  17535. * During edges processing, the vertices are merged if they are close enough: epsilonVertexMerge is the limit whithin which vertices are considered to be equal.
  17536. * The default value is 1e-6
  17537. * This option is used only if useAlternateEdgeFinder = true
  17538. */
  17539. epsilonVertexMerge?: number;
  17540. /**
  17541. * 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
  17542. * 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.
  17543. * This option is used only if useAlternateEdgeFinder = true
  17544. */
  17545. applyTessellation?: boolean;
  17546. /**
  17547. * 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
  17548. * The default value is 1e-6
  17549. * This option is used only if useAlternateEdgeFinder = true
  17550. */
  17551. epsilonVertexAligned?: number;
  17552. }
  17553. /**
  17554. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  17555. */
  17556. export class EdgesRenderer implements IEdgesRenderer {
  17557. /**
  17558. * Define the size of the edges with an orthographic camera
  17559. */
  17560. edgesWidthScalerForOrthographic: number;
  17561. /**
  17562. * Define the size of the edges with a perspective camera
  17563. */
  17564. edgesWidthScalerForPerspective: number;
  17565. protected _source: AbstractMesh;
  17566. protected _linesPositions: number[];
  17567. protected _linesNormals: number[];
  17568. protected _linesIndices: number[];
  17569. protected _epsilon: number;
  17570. protected _indicesCount: number;
  17571. protected _lineShader: ShaderMaterial;
  17572. protected _ib: DataBuffer;
  17573. protected _buffers: {
  17574. [key: string]: Nullable<VertexBuffer>;
  17575. };
  17576. protected _buffersForInstances: {
  17577. [key: string]: Nullable<VertexBuffer>;
  17578. };
  17579. protected _checkVerticesInsteadOfIndices: boolean;
  17580. protected _options: Nullable<IEdgesRendererOptions>;
  17581. private _meshRebuildObserver;
  17582. private _meshDisposeObserver;
  17583. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  17584. isEnabled: boolean;
  17585. /**
  17586. * List of instances to render in case the source mesh has instances
  17587. */
  17588. customInstances: SmartArray<Matrix>;
  17589. private static GetShader;
  17590. /**
  17591. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  17592. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  17593. * @param source Mesh used to create edges
  17594. * @param epsilon sum of angles in adjacency to check for edge
  17595. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices. Note that this parameter is not used if options.useAlternateEdgeFinder = true
  17596. * @param generateEdgesLines - should generate Lines or only prepare resources.
  17597. * @param options The options to apply when generating the edges
  17598. */
  17599. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean, options?: IEdgesRendererOptions);
  17600. protected _prepareRessources(): void;
  17601. /** @hidden */
  17602. _rebuild(): void;
  17603. /**
  17604. * Releases the required resources for the edges renderer
  17605. */
  17606. dispose(): void;
  17607. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  17608. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  17609. /**
  17610. * Checks if the pair of p0 and p1 is en edge
  17611. * @param faceIndex
  17612. * @param edge
  17613. * @param faceNormals
  17614. * @param p0
  17615. * @param p1
  17616. * @private
  17617. */
  17618. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  17619. /**
  17620. * push line into the position, normal and index buffer
  17621. * @protected
  17622. */
  17623. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  17624. /**
  17625. * See https://playground.babylonjs.com/#R3JR6V#1 for a visual display of the algorithm
  17626. */
  17627. private _tessellateTriangle;
  17628. private _generateEdgesLinesAlternate;
  17629. /**
  17630. * Generates lines edges from adjacencjes
  17631. * @private
  17632. */
  17633. _generateEdgesLines(): void;
  17634. /**
  17635. * Checks wether or not the edges renderer is ready to render.
  17636. * @return true if ready, otherwise false.
  17637. */
  17638. isReady(): boolean;
  17639. /**
  17640. * Renders the edges of the attached mesh,
  17641. */
  17642. render(): void;
  17643. }
  17644. /**
  17645. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  17646. */
  17647. export class LineEdgesRenderer extends EdgesRenderer {
  17648. /**
  17649. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  17650. * @param source LineMesh used to generate edges
  17651. * @param epsilon not important (specified angle for edge detection)
  17652. * @param checkVerticesInsteadOfIndices not important for LineMesh
  17653. */
  17654. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  17655. /**
  17656. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  17657. */
  17658. _generateEdgesLines(): void;
  17659. }
  17660. }
  17661. declare module "babylonjs/Rendering/renderingGroup" {
  17662. import { SmartArray, SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  17663. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17664. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17665. import { Nullable } from "babylonjs/types";
  17666. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17667. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  17668. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  17669. import { Material } from "babylonjs/Materials/material";
  17670. import { Scene } from "babylonjs/scene";
  17671. /**
  17672. * This represents the object necessary to create a rendering group.
  17673. * This is exclusively used and created by the rendering manager.
  17674. * To modify the behavior, you use the available helpers in your scene or meshes.
  17675. * @hidden
  17676. */
  17677. export class RenderingGroup {
  17678. index: number;
  17679. private static _zeroVector;
  17680. private _scene;
  17681. private _opaqueSubMeshes;
  17682. private _transparentSubMeshes;
  17683. private _alphaTestSubMeshes;
  17684. private _depthOnlySubMeshes;
  17685. private _particleSystems;
  17686. private _spriteManagers;
  17687. private _opaqueSortCompareFn;
  17688. private _alphaTestSortCompareFn;
  17689. private _transparentSortCompareFn;
  17690. private _renderOpaque;
  17691. private _renderAlphaTest;
  17692. private _renderTransparent;
  17693. /** @hidden */
  17694. _edgesRenderers: SmartArrayNoDuplicate<IEdgesRenderer>;
  17695. onBeforeTransparentRendering: () => void;
  17696. /**
  17697. * Set the opaque sort comparison function.
  17698. * If null the sub meshes will be render in the order they were created
  17699. */
  17700. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17701. /**
  17702. * Set the alpha test sort comparison function.
  17703. * If null the sub meshes will be render in the order they were created
  17704. */
  17705. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17706. /**
  17707. * Set the transparent sort comparison function.
  17708. * If null the sub meshes will be render in the order they were created
  17709. */
  17710. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17711. /**
  17712. * Creates a new rendering group.
  17713. * @param index The rendering group index
  17714. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  17715. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  17716. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  17717. */
  17718. 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>);
  17719. /**
  17720. * Render all the sub meshes contained in the group.
  17721. * @param customRenderFunction Used to override the default render behaviour of the group.
  17722. * @returns true if rendered some submeshes.
  17723. */
  17724. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  17725. /**
  17726. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  17727. * @param subMeshes The submeshes to render
  17728. */
  17729. private renderOpaqueSorted;
  17730. /**
  17731. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  17732. * @param subMeshes The submeshes to render
  17733. */
  17734. private renderAlphaTestSorted;
  17735. /**
  17736. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  17737. * @param subMeshes The submeshes to render
  17738. */
  17739. private renderTransparentSorted;
  17740. /**
  17741. * Renders the submeshes in a specified order.
  17742. * @param subMeshes The submeshes to sort before render
  17743. * @param sortCompareFn The comparison function use to sort
  17744. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  17745. * @param transparent Specifies to activate blending if true
  17746. */
  17747. private static renderSorted;
  17748. /**
  17749. * Renders the submeshes in the order they were dispatched (no sort applied).
  17750. * @param subMeshes The submeshes to render
  17751. */
  17752. private static renderUnsorted;
  17753. /**
  17754. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17755. * are rendered back to front if in the same alpha index.
  17756. *
  17757. * @param a The first submesh
  17758. * @param b The second submesh
  17759. * @returns The result of the comparison
  17760. */
  17761. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  17762. /**
  17763. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17764. * are rendered back to front.
  17765. *
  17766. * @param a The first submesh
  17767. * @param b The second submesh
  17768. * @returns The result of the comparison
  17769. */
  17770. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  17771. /**
  17772. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17773. * are rendered front to back (prevent overdraw).
  17774. *
  17775. * @param a The first submesh
  17776. * @param b The second submesh
  17777. * @returns The result of the comparison
  17778. */
  17779. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  17780. /**
  17781. * Resets the different lists of submeshes to prepare a new frame.
  17782. */
  17783. prepare(): void;
  17784. dispose(): void;
  17785. /**
  17786. * Inserts the submesh in its correct queue depending on its material.
  17787. * @param subMesh The submesh to dispatch
  17788. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17789. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17790. */
  17791. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17792. dispatchSprites(spriteManager: ISpriteManager): void;
  17793. dispatchParticles(particleSystem: IParticleSystem): void;
  17794. private _renderParticles;
  17795. private _renderSprites;
  17796. }
  17797. }
  17798. declare module "babylonjs/Rendering/renderingManager" {
  17799. import { Nullable } from "babylonjs/types";
  17800. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17801. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17802. import { SmartArray } from "babylonjs/Misc/smartArray";
  17803. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  17804. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17805. import { Material } from "babylonjs/Materials/material";
  17806. import { Scene } from "babylonjs/scene";
  17807. import { Camera } from "babylonjs/Cameras/camera";
  17808. /**
  17809. * Interface describing the different options available in the rendering manager
  17810. * regarding Auto Clear between groups.
  17811. */
  17812. export interface IRenderingManagerAutoClearSetup {
  17813. /**
  17814. * Defines whether or not autoclear is enable.
  17815. */
  17816. autoClear: boolean;
  17817. /**
  17818. * Defines whether or not to autoclear the depth buffer.
  17819. */
  17820. depth: boolean;
  17821. /**
  17822. * Defines whether or not to autoclear the stencil buffer.
  17823. */
  17824. stencil: boolean;
  17825. }
  17826. /**
  17827. * This class is used by the onRenderingGroupObservable
  17828. */
  17829. export class RenderingGroupInfo {
  17830. /**
  17831. * The Scene that being rendered
  17832. */
  17833. scene: Scene;
  17834. /**
  17835. * The camera currently used for the rendering pass
  17836. */
  17837. camera: Nullable<Camera>;
  17838. /**
  17839. * The ID of the renderingGroup being processed
  17840. */
  17841. renderingGroupId: number;
  17842. }
  17843. /**
  17844. * This is the manager responsible of all the rendering for meshes sprites and particles.
  17845. * It is enable to manage the different groups as well as the different necessary sort functions.
  17846. * This should not be used directly aside of the few static configurations
  17847. */
  17848. export class RenderingManager {
  17849. /**
  17850. * The max id used for rendering groups (not included)
  17851. */
  17852. static MAX_RENDERINGGROUPS: number;
  17853. /**
  17854. * The min id used for rendering groups (included)
  17855. */
  17856. static MIN_RENDERINGGROUPS: number;
  17857. /**
  17858. * Used to globally prevent autoclearing scenes.
  17859. */
  17860. static AUTOCLEAR: boolean;
  17861. /**
  17862. * @hidden
  17863. */
  17864. _useSceneAutoClearSetup: boolean;
  17865. private _scene;
  17866. private _renderingGroups;
  17867. private _depthStencilBufferAlreadyCleaned;
  17868. private _autoClearDepthStencil;
  17869. private _customOpaqueSortCompareFn;
  17870. private _customAlphaTestSortCompareFn;
  17871. private _customTransparentSortCompareFn;
  17872. private _renderingGroupInfo;
  17873. /**
  17874. * Instantiates a new rendering group for a particular scene
  17875. * @param scene Defines the scene the groups belongs to
  17876. */
  17877. constructor(scene: Scene);
  17878. private _clearDepthStencilBuffer;
  17879. /**
  17880. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  17881. * @hidden
  17882. */
  17883. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  17884. /**
  17885. * Resets the different information of the group to prepare a new frame
  17886. * @hidden
  17887. */
  17888. reset(): void;
  17889. /**
  17890. * Dispose and release the group and its associated resources.
  17891. * @hidden
  17892. */
  17893. dispose(): void;
  17894. /**
  17895. * Clear the info related to rendering groups preventing retention points during dispose.
  17896. */
  17897. freeRenderingGroups(): void;
  17898. private _prepareRenderingGroup;
  17899. /**
  17900. * Add a sprite manager to the rendering manager in order to render it this frame.
  17901. * @param spriteManager Define the sprite manager to render
  17902. */
  17903. dispatchSprites(spriteManager: ISpriteManager): void;
  17904. /**
  17905. * Add a particle system to the rendering manager in order to render it this frame.
  17906. * @param particleSystem Define the particle system to render
  17907. */
  17908. dispatchParticles(particleSystem: IParticleSystem): void;
  17909. /**
  17910. * Add a submesh to the manager in order to render it this frame
  17911. * @param subMesh The submesh to dispatch
  17912. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17913. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17914. */
  17915. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17916. /**
  17917. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  17918. * This allowed control for front to back rendering or reversly depending of the special needs.
  17919. *
  17920. * @param renderingGroupId The rendering group id corresponding to its index
  17921. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  17922. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  17923. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  17924. */
  17925. 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;
  17926. /**
  17927. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  17928. *
  17929. * @param renderingGroupId The rendering group id corresponding to its index
  17930. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  17931. * @param depth Automatically clears depth between groups if true and autoClear is true.
  17932. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  17933. */
  17934. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  17935. /**
  17936. * Gets the current auto clear configuration for one rendering group of the rendering
  17937. * manager.
  17938. * @param index the rendering group index to get the information for
  17939. * @returns The auto clear setup for the requested rendering group
  17940. */
  17941. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  17942. }
  17943. }
  17944. declare module "babylonjs/Lights/Shadows/shadowGenerator" {
  17945. import { SmartArray } from "babylonjs/Misc/smartArray";
  17946. import { Nullable } from "babylonjs/types";
  17947. import { Scene } from "babylonjs/scene";
  17948. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  17949. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17950. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17951. import { Mesh } from "babylonjs/Meshes/mesh";
  17952. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  17953. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  17954. import { Effect } from "babylonjs/Materials/effect";
  17955. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  17956. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  17957. import "babylonjs/Shaders/shadowMap.fragment";
  17958. import "babylonjs/Shaders/shadowMap.vertex";
  17959. import "babylonjs/Shaders/depthBoxBlur.fragment";
  17960. import "babylonjs/Shaders/ShadersInclude/shadowMapFragmentSoftTransparentShadow";
  17961. import { Observable } from "babylonjs/Misc/observable";
  17962. /**
  17963. * Defines the options associated with the creation of a custom shader for a shadow generator.
  17964. */
  17965. export interface ICustomShaderOptions {
  17966. /**
  17967. * Gets or sets the custom shader name to use
  17968. */
  17969. shaderName: string;
  17970. /**
  17971. * The list of attribute names used in the shader
  17972. */
  17973. attributes?: string[];
  17974. /**
  17975. * The list of unifrom names used in the shader
  17976. */
  17977. uniforms?: string[];
  17978. /**
  17979. * The list of sampler names used in the shader
  17980. */
  17981. samplers?: string[];
  17982. /**
  17983. * The list of defines used in the shader
  17984. */
  17985. defines?: string[];
  17986. }
  17987. /**
  17988. * Interface to implement to create a shadow generator compatible with BJS.
  17989. */
  17990. export interface IShadowGenerator {
  17991. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  17992. id: string;
  17993. /**
  17994. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  17995. * @returns The render target texture if present otherwise, null
  17996. */
  17997. getShadowMap(): Nullable<RenderTargetTexture>;
  17998. /**
  17999. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  18000. * @param subMesh The submesh we want to render in the shadow map
  18001. * @param useInstances Defines wether will draw in the map using instances
  18002. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  18003. * @returns true if ready otherwise, false
  18004. */
  18005. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  18006. /**
  18007. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  18008. * @param defines Defines of the material we want to update
  18009. * @param lightIndex Index of the light in the enabled light list of the material
  18010. */
  18011. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  18012. /**
  18013. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  18014. * defined in the generator but impacting the effect).
  18015. * It implies the unifroms available on the materials are the standard BJS ones.
  18016. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  18017. * @param effect The effect we are binfing the information for
  18018. */
  18019. bindShadowLight(lightIndex: string, effect: Effect): void;
  18020. /**
  18021. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  18022. * (eq to shadow prjection matrix * light transform matrix)
  18023. * @returns The transform matrix used to create the shadow map
  18024. */
  18025. getTransformMatrix(): Matrix;
  18026. /**
  18027. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  18028. * Cube and 2D textures for instance.
  18029. */
  18030. recreateShadowMap(): void;
  18031. /**
  18032. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  18033. * @param onCompiled Callback triggered at the and of the effects compilation
  18034. * @param options Sets of optional options forcing the compilation with different modes
  18035. */
  18036. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  18037. useInstances: boolean;
  18038. }>): void;
  18039. /**
  18040. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  18041. * @param options Sets of optional options forcing the compilation with different modes
  18042. * @returns A promise that resolves when the compilation completes
  18043. */
  18044. forceCompilationAsync(options?: Partial<{
  18045. useInstances: boolean;
  18046. }>): Promise<void>;
  18047. /**
  18048. * Serializes the shadow generator setup to a json object.
  18049. * @returns The serialized JSON object
  18050. */
  18051. serialize(): any;
  18052. /**
  18053. * Disposes the Shadow map and related Textures and effects.
  18054. */
  18055. dispose(): void;
  18056. }
  18057. /**
  18058. * Default implementation IShadowGenerator.
  18059. * This is the main object responsible of generating shadows in the framework.
  18060. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  18061. */
  18062. export class ShadowGenerator implements IShadowGenerator {
  18063. /**
  18064. * Name of the shadow generator class
  18065. */
  18066. static CLASSNAME: string;
  18067. /**
  18068. * Shadow generator mode None: no filtering applied.
  18069. */
  18070. static readonly FILTER_NONE: number;
  18071. /**
  18072. * Shadow generator mode ESM: Exponential Shadow Mapping.
  18073. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  18074. */
  18075. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  18076. /**
  18077. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  18078. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  18079. */
  18080. static readonly FILTER_POISSONSAMPLING: number;
  18081. /**
  18082. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  18083. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  18084. */
  18085. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  18086. /**
  18087. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  18088. * edge artifacts on steep falloff.
  18089. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  18090. */
  18091. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  18092. /**
  18093. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  18094. * edge artifacts on steep falloff.
  18095. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  18096. */
  18097. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  18098. /**
  18099. * Shadow generator mode PCF: Percentage Closer Filtering
  18100. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  18101. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  18102. */
  18103. static readonly FILTER_PCF: number;
  18104. /**
  18105. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  18106. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  18107. * Contact Hardening
  18108. */
  18109. static readonly FILTER_PCSS: number;
  18110. /**
  18111. * Reserved for PCF and PCSS
  18112. * Highest Quality.
  18113. *
  18114. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  18115. *
  18116. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  18117. */
  18118. static readonly QUALITY_HIGH: number;
  18119. /**
  18120. * Reserved for PCF and PCSS
  18121. * Good tradeoff for quality/perf cross devices
  18122. *
  18123. * Execute PCF on a 3*3 kernel.
  18124. *
  18125. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  18126. */
  18127. static readonly QUALITY_MEDIUM: number;
  18128. /**
  18129. * Reserved for PCF and PCSS
  18130. * The lowest quality but the fastest.
  18131. *
  18132. * Execute PCF on a 1*1 kernel.
  18133. *
  18134. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  18135. */
  18136. static readonly QUALITY_LOW: number;
  18137. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  18138. id: string;
  18139. /** Gets or sets the custom shader name to use */
  18140. customShaderOptions: ICustomShaderOptions;
  18141. /**
  18142. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  18143. */
  18144. onBeforeShadowMapRenderObservable: Observable<Effect>;
  18145. /**
  18146. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  18147. */
  18148. onAfterShadowMapRenderObservable: Observable<Effect>;
  18149. /**
  18150. * Observable triggered before a mesh is rendered in the shadow map.
  18151. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  18152. */
  18153. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  18154. /**
  18155. * Observable triggered after a mesh is rendered in the shadow map.
  18156. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  18157. */
  18158. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  18159. protected _bias: number;
  18160. /**
  18161. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  18162. */
  18163. get bias(): number;
  18164. /**
  18165. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  18166. */
  18167. set bias(bias: number);
  18168. protected _normalBias: number;
  18169. /**
  18170. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  18171. */
  18172. get normalBias(): number;
  18173. /**
  18174. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  18175. */
  18176. set normalBias(normalBias: number);
  18177. protected _blurBoxOffset: number;
  18178. /**
  18179. * Gets the blur box offset: offset applied during the blur pass.
  18180. * Only useful if useKernelBlur = false
  18181. */
  18182. get blurBoxOffset(): number;
  18183. /**
  18184. * Sets the blur box offset: offset applied during the blur pass.
  18185. * Only useful if useKernelBlur = false
  18186. */
  18187. set blurBoxOffset(value: number);
  18188. protected _blurScale: number;
  18189. /**
  18190. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  18191. * 2 means half of the size.
  18192. */
  18193. get blurScale(): number;
  18194. /**
  18195. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  18196. * 2 means half of the size.
  18197. */
  18198. set blurScale(value: number);
  18199. protected _blurKernel: number;
  18200. /**
  18201. * Gets the blur kernel: kernel size of the blur pass.
  18202. * Only useful if useKernelBlur = true
  18203. */
  18204. get blurKernel(): number;
  18205. /**
  18206. * Sets the blur kernel: kernel size of the blur pass.
  18207. * Only useful if useKernelBlur = true
  18208. */
  18209. set blurKernel(value: number);
  18210. protected _useKernelBlur: boolean;
  18211. /**
  18212. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  18213. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  18214. */
  18215. get useKernelBlur(): boolean;
  18216. /**
  18217. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  18218. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  18219. */
  18220. set useKernelBlur(value: boolean);
  18221. protected _depthScale: number;
  18222. /**
  18223. * Gets the depth scale used in ESM mode.
  18224. */
  18225. get depthScale(): number;
  18226. /**
  18227. * Sets the depth scale used in ESM mode.
  18228. * This can override the scale stored on the light.
  18229. */
  18230. set depthScale(value: number);
  18231. protected _validateFilter(filter: number): number;
  18232. protected _filter: number;
  18233. /**
  18234. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  18235. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  18236. */
  18237. get filter(): number;
  18238. /**
  18239. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  18240. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  18241. */
  18242. set filter(value: number);
  18243. /**
  18244. * Gets if the current filter is set to Poisson Sampling.
  18245. */
  18246. get usePoissonSampling(): boolean;
  18247. /**
  18248. * Sets the current filter to Poisson Sampling.
  18249. */
  18250. set usePoissonSampling(value: boolean);
  18251. /**
  18252. * Gets if the current filter is set to ESM.
  18253. */
  18254. get useExponentialShadowMap(): boolean;
  18255. /**
  18256. * Sets the current filter is to ESM.
  18257. */
  18258. set useExponentialShadowMap(value: boolean);
  18259. /**
  18260. * Gets if the current filter is set to filtered ESM.
  18261. */
  18262. get useBlurExponentialShadowMap(): boolean;
  18263. /**
  18264. * Gets if the current filter is set to filtered ESM.
  18265. */
  18266. set useBlurExponentialShadowMap(value: boolean);
  18267. /**
  18268. * Gets if the current filter is set to "close ESM" (using the inverse of the
  18269. * exponential to prevent steep falloff artifacts).
  18270. */
  18271. get useCloseExponentialShadowMap(): boolean;
  18272. /**
  18273. * Sets the current filter to "close ESM" (using the inverse of the
  18274. * exponential to prevent steep falloff artifacts).
  18275. */
  18276. set useCloseExponentialShadowMap(value: boolean);
  18277. /**
  18278. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  18279. * exponential to prevent steep falloff artifacts).
  18280. */
  18281. get useBlurCloseExponentialShadowMap(): boolean;
  18282. /**
  18283. * Sets the current filter to filtered "close ESM" (using the inverse of the
  18284. * exponential to prevent steep falloff artifacts).
  18285. */
  18286. set useBlurCloseExponentialShadowMap(value: boolean);
  18287. /**
  18288. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  18289. */
  18290. get usePercentageCloserFiltering(): boolean;
  18291. /**
  18292. * Sets the current filter to "PCF" (percentage closer filtering).
  18293. */
  18294. set usePercentageCloserFiltering(value: boolean);
  18295. protected _filteringQuality: number;
  18296. /**
  18297. * Gets the PCF or PCSS Quality.
  18298. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  18299. */
  18300. get filteringQuality(): number;
  18301. /**
  18302. * Sets the PCF or PCSS Quality.
  18303. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  18304. */
  18305. set filteringQuality(filteringQuality: number);
  18306. /**
  18307. * Gets if the current filter is set to "PCSS" (contact hardening).
  18308. */
  18309. get useContactHardeningShadow(): boolean;
  18310. /**
  18311. * Sets the current filter to "PCSS" (contact hardening).
  18312. */
  18313. set useContactHardeningShadow(value: boolean);
  18314. protected _contactHardeningLightSizeUVRatio: number;
  18315. /**
  18316. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  18317. * Using a ratio helps keeping shape stability independently of the map size.
  18318. *
  18319. * It does not account for the light projection as it was having too much
  18320. * instability during the light setup or during light position changes.
  18321. *
  18322. * Only valid if useContactHardeningShadow is true.
  18323. */
  18324. get contactHardeningLightSizeUVRatio(): number;
  18325. /**
  18326. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  18327. * Using a ratio helps keeping shape stability independently of the map size.
  18328. *
  18329. * It does not account for the light projection as it was having too much
  18330. * instability during the light setup or during light position changes.
  18331. *
  18332. * Only valid if useContactHardeningShadow is true.
  18333. */
  18334. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  18335. protected _darkness: number;
  18336. /** Gets or sets the actual darkness of a shadow */
  18337. get darkness(): number;
  18338. set darkness(value: number);
  18339. /**
  18340. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  18341. * 0 means strongest and 1 would means no shadow.
  18342. * @returns the darkness.
  18343. */
  18344. getDarkness(): number;
  18345. /**
  18346. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  18347. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  18348. * @returns the shadow generator allowing fluent coding.
  18349. */
  18350. setDarkness(darkness: number): ShadowGenerator;
  18351. protected _transparencyShadow: boolean;
  18352. /** Gets or sets the ability to have transparent shadow */
  18353. get transparencyShadow(): boolean;
  18354. set transparencyShadow(value: boolean);
  18355. /**
  18356. * Sets the ability to have transparent shadow (boolean).
  18357. * @param transparent True if transparent else False
  18358. * @returns the shadow generator allowing fluent coding
  18359. */
  18360. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  18361. /**
  18362. * Enables or disables shadows with varying strength based on the transparency
  18363. * When it is enabled, the strength of the shadow is taken equal to mesh.visibility
  18364. * If you enabled an alpha texture on your material, the alpha value red from the texture is also combined to compute the strength:
  18365. * mesh.visibility * alphaTexture.a
  18366. * Note that by definition transparencyShadow must be set to true for enableSoftTransparentShadow to work!
  18367. */
  18368. enableSoftTransparentShadow: boolean;
  18369. protected _shadowMap: Nullable<RenderTargetTexture>;
  18370. protected _shadowMap2: Nullable<RenderTargetTexture>;
  18371. /**
  18372. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  18373. * @returns The render target texture if present otherwise, null
  18374. */
  18375. getShadowMap(): Nullable<RenderTargetTexture>;
  18376. /**
  18377. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  18378. * @returns The render target texture if the shadow map is present otherwise, null
  18379. */
  18380. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  18381. /**
  18382. * Gets the class name of that object
  18383. * @returns "ShadowGenerator"
  18384. */
  18385. getClassName(): string;
  18386. /**
  18387. * Helper function to add a mesh and its descendants to the list of shadow casters.
  18388. * @param mesh Mesh to add
  18389. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  18390. * @returns the Shadow Generator itself
  18391. */
  18392. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  18393. /**
  18394. * Helper function to remove a mesh and its descendants from the list of shadow casters
  18395. * @param mesh Mesh to remove
  18396. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  18397. * @returns the Shadow Generator itself
  18398. */
  18399. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  18400. /**
  18401. * Controls the extent to which the shadows fade out at the edge of the frustum
  18402. */
  18403. frustumEdgeFalloff: number;
  18404. protected _light: IShadowLight;
  18405. /**
  18406. * Returns the associated light object.
  18407. * @returns the light generating the shadow
  18408. */
  18409. getLight(): IShadowLight;
  18410. /**
  18411. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  18412. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  18413. * It might on the other hand introduce peter panning.
  18414. */
  18415. forceBackFacesOnly: boolean;
  18416. protected _scene: Scene;
  18417. protected _lightDirection: Vector3;
  18418. protected _effect: Effect;
  18419. protected _viewMatrix: Matrix;
  18420. protected _projectionMatrix: Matrix;
  18421. protected _transformMatrix: Matrix;
  18422. protected _cachedPosition: Vector3;
  18423. protected _cachedDirection: Vector3;
  18424. protected _cachedDefines: string;
  18425. protected _currentRenderID: number;
  18426. protected _boxBlurPostprocess: Nullable<PostProcess>;
  18427. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  18428. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  18429. protected _blurPostProcesses: PostProcess[];
  18430. protected _mapSize: number;
  18431. protected _currentFaceIndex: number;
  18432. protected _currentFaceIndexCache: number;
  18433. protected _textureType: number;
  18434. protected _defaultTextureMatrix: Matrix;
  18435. protected _storedUniqueId: Nullable<number>;
  18436. /** @hidden */
  18437. static _SceneComponentInitialization: (scene: Scene) => void;
  18438. /**
  18439. * Creates a ShadowGenerator object.
  18440. * A ShadowGenerator is the required tool to use the shadows.
  18441. * Each light casting shadows needs to use its own ShadowGenerator.
  18442. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  18443. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  18444. * @param light The light object generating the shadows.
  18445. * @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.
  18446. */
  18447. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  18448. protected _initializeGenerator(): void;
  18449. protected _createTargetRenderTexture(): void;
  18450. protected _initializeShadowMap(): void;
  18451. protected _initializeBlurRTTAndPostProcesses(): void;
  18452. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  18453. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  18454. protected _renderSubMeshForShadowMap(subMesh: SubMesh, isTransparent?: boolean): void;
  18455. protected _applyFilterValues(): void;
  18456. /**
  18457. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  18458. * @param onCompiled Callback triggered at the and of the effects compilation
  18459. * @param options Sets of optional options forcing the compilation with different modes
  18460. */
  18461. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  18462. useInstances: boolean;
  18463. }>): void;
  18464. /**
  18465. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  18466. * @param options Sets of optional options forcing the compilation with different modes
  18467. * @returns A promise that resolves when the compilation completes
  18468. */
  18469. forceCompilationAsync(options?: Partial<{
  18470. useInstances: boolean;
  18471. }>): Promise<void>;
  18472. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  18473. private _prepareShadowDefines;
  18474. /**
  18475. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  18476. * @param subMesh The submesh we want to render in the shadow map
  18477. * @param useInstances Defines wether will draw in the map using instances
  18478. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  18479. * @returns true if ready otherwise, false
  18480. */
  18481. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  18482. /**
  18483. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  18484. * @param defines Defines of the material we want to update
  18485. * @param lightIndex Index of the light in the enabled light list of the material
  18486. */
  18487. prepareDefines(defines: any, lightIndex: number): void;
  18488. /**
  18489. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  18490. * defined in the generator but impacting the effect).
  18491. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  18492. * @param effect The effect we are binfing the information for
  18493. */
  18494. bindShadowLight(lightIndex: string, effect: Effect): void;
  18495. /**
  18496. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  18497. * (eq to shadow prjection matrix * light transform matrix)
  18498. * @returns The transform matrix used to create the shadow map
  18499. */
  18500. getTransformMatrix(): Matrix;
  18501. /**
  18502. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  18503. * Cube and 2D textures for instance.
  18504. */
  18505. recreateShadowMap(): void;
  18506. protected _disposeBlurPostProcesses(): void;
  18507. protected _disposeRTTandPostProcesses(): void;
  18508. /**
  18509. * Disposes the ShadowGenerator.
  18510. * Returns nothing.
  18511. */
  18512. dispose(): void;
  18513. /**
  18514. * Serializes the shadow generator setup to a json object.
  18515. * @returns The serialized JSON object
  18516. */
  18517. serialize(): any;
  18518. /**
  18519. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  18520. * @param parsedShadowGenerator The JSON object to parse
  18521. * @param scene The scene to create the shadow map for
  18522. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  18523. * @returns The parsed shadow generator
  18524. */
  18525. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  18526. }
  18527. }
  18528. declare module "babylonjs/Lights/light" {
  18529. import { Nullable } from "babylonjs/types";
  18530. import { Scene } from "babylonjs/scene";
  18531. import { Vector3 } from "babylonjs/Maths/math.vector";
  18532. import { Color3 } from "babylonjs/Maths/math.color";
  18533. import { Node } from "babylonjs/node";
  18534. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18535. import { Effect } from "babylonjs/Materials/effect";
  18536. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  18537. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  18538. /**
  18539. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  18540. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  18541. * 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.
  18542. */
  18543. export abstract class Light extends Node {
  18544. /**
  18545. * Falloff Default: light is falling off following the material specification:
  18546. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  18547. */
  18548. static readonly FALLOFF_DEFAULT: number;
  18549. /**
  18550. * Falloff Physical: light is falling off following the inverse squared distance law.
  18551. */
  18552. static readonly FALLOFF_PHYSICAL: number;
  18553. /**
  18554. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  18555. * to enhance interoperability with other engines.
  18556. */
  18557. static readonly FALLOFF_GLTF: number;
  18558. /**
  18559. * Falloff Standard: light is falling off like in the standard material
  18560. * to enhance interoperability with other materials.
  18561. */
  18562. static readonly FALLOFF_STANDARD: number;
  18563. /**
  18564. * If every light affecting the material is in this lightmapMode,
  18565. * material.lightmapTexture adds or multiplies
  18566. * (depends on material.useLightmapAsShadowmap)
  18567. * after every other light calculations.
  18568. */
  18569. static readonly LIGHTMAP_DEFAULT: number;
  18570. /**
  18571. * material.lightmapTexture as only diffuse lighting from this light
  18572. * adds only specular lighting from this light
  18573. * adds dynamic shadows
  18574. */
  18575. static readonly LIGHTMAP_SPECULAR: number;
  18576. /**
  18577. * material.lightmapTexture as only lighting
  18578. * no light calculation from this light
  18579. * only adds dynamic shadows from this light
  18580. */
  18581. static readonly LIGHTMAP_SHADOWSONLY: number;
  18582. /**
  18583. * Each light type uses the default quantity according to its type:
  18584. * point/spot lights use luminous intensity
  18585. * directional lights use illuminance
  18586. */
  18587. static readonly INTENSITYMODE_AUTOMATIC: number;
  18588. /**
  18589. * lumen (lm)
  18590. */
  18591. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  18592. /**
  18593. * candela (lm/sr)
  18594. */
  18595. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  18596. /**
  18597. * lux (lm/m^2)
  18598. */
  18599. static readonly INTENSITYMODE_ILLUMINANCE: number;
  18600. /**
  18601. * nit (cd/m^2)
  18602. */
  18603. static readonly INTENSITYMODE_LUMINANCE: number;
  18604. /**
  18605. * Light type const id of the point light.
  18606. */
  18607. static readonly LIGHTTYPEID_POINTLIGHT: number;
  18608. /**
  18609. * Light type const id of the directional light.
  18610. */
  18611. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  18612. /**
  18613. * Light type const id of the spot light.
  18614. */
  18615. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  18616. /**
  18617. * Light type const id of the hemispheric light.
  18618. */
  18619. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  18620. /**
  18621. * Diffuse gives the basic color to an object.
  18622. */
  18623. diffuse: Color3;
  18624. /**
  18625. * Specular produces a highlight color on an object.
  18626. * Note: This is note affecting PBR materials.
  18627. */
  18628. specular: Color3;
  18629. /**
  18630. * Defines the falloff type for this light. This lets overrriding how punctual light are
  18631. * falling off base on range or angle.
  18632. * This can be set to any values in Light.FALLOFF_x.
  18633. *
  18634. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  18635. * other types of materials.
  18636. */
  18637. falloffType: number;
  18638. /**
  18639. * Strength of the light.
  18640. * Note: By default it is define in the framework own unit.
  18641. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  18642. */
  18643. intensity: number;
  18644. private _range;
  18645. protected _inverseSquaredRange: number;
  18646. /**
  18647. * Defines how far from the source the light is impacting in scene units.
  18648. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  18649. */
  18650. get range(): number;
  18651. /**
  18652. * Defines how far from the source the light is impacting in scene units.
  18653. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  18654. */
  18655. set range(value: number);
  18656. /**
  18657. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  18658. * of light.
  18659. */
  18660. private _photometricScale;
  18661. private _intensityMode;
  18662. /**
  18663. * Gets the photometric scale used to interpret the intensity.
  18664. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  18665. */
  18666. get intensityMode(): number;
  18667. /**
  18668. * Sets the photometric scale used to interpret the intensity.
  18669. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  18670. */
  18671. set intensityMode(value: number);
  18672. private _radius;
  18673. /**
  18674. * Gets the light radius used by PBR Materials to simulate soft area lights.
  18675. */
  18676. get radius(): number;
  18677. /**
  18678. * sets the light radius used by PBR Materials to simulate soft area lights.
  18679. */
  18680. set radius(value: number);
  18681. private _renderPriority;
  18682. /**
  18683. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  18684. * exceeding the number allowed of the materials.
  18685. */
  18686. renderPriority: number;
  18687. private _shadowEnabled;
  18688. /**
  18689. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  18690. * the current shadow generator.
  18691. */
  18692. get shadowEnabled(): boolean;
  18693. /**
  18694. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  18695. * the current shadow generator.
  18696. */
  18697. set shadowEnabled(value: boolean);
  18698. private _includedOnlyMeshes;
  18699. /**
  18700. * Gets the only meshes impacted by this light.
  18701. */
  18702. get includedOnlyMeshes(): AbstractMesh[];
  18703. /**
  18704. * Sets the only meshes impacted by this light.
  18705. */
  18706. set includedOnlyMeshes(value: AbstractMesh[]);
  18707. private _excludedMeshes;
  18708. /**
  18709. * Gets the meshes not impacted by this light.
  18710. */
  18711. get excludedMeshes(): AbstractMesh[];
  18712. /**
  18713. * Sets the meshes not impacted by this light.
  18714. */
  18715. set excludedMeshes(value: AbstractMesh[]);
  18716. private _excludeWithLayerMask;
  18717. /**
  18718. * Gets the layer id use to find what meshes are not impacted by the light.
  18719. * Inactive if 0
  18720. */
  18721. get excludeWithLayerMask(): number;
  18722. /**
  18723. * Sets the layer id use to find what meshes are not impacted by the light.
  18724. * Inactive if 0
  18725. */
  18726. set excludeWithLayerMask(value: number);
  18727. private _includeOnlyWithLayerMask;
  18728. /**
  18729. * Gets the layer id use to find what meshes are impacted by the light.
  18730. * Inactive if 0
  18731. */
  18732. get includeOnlyWithLayerMask(): number;
  18733. /**
  18734. * Sets the layer id use to find what meshes are impacted by the light.
  18735. * Inactive if 0
  18736. */
  18737. set includeOnlyWithLayerMask(value: number);
  18738. private _lightmapMode;
  18739. /**
  18740. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  18741. */
  18742. get lightmapMode(): number;
  18743. /**
  18744. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  18745. */
  18746. set lightmapMode(value: number);
  18747. /**
  18748. * Shadow generator associted to the light.
  18749. * @hidden Internal use only.
  18750. */
  18751. _shadowGenerator: Nullable<IShadowGenerator>;
  18752. /**
  18753. * @hidden Internal use only.
  18754. */
  18755. _excludedMeshesIds: string[];
  18756. /**
  18757. * @hidden Internal use only.
  18758. */
  18759. _includedOnlyMeshesIds: string[];
  18760. /**
  18761. * The current light unifom buffer.
  18762. * @hidden Internal use only.
  18763. */
  18764. _uniformBuffer: UniformBuffer;
  18765. /** @hidden */
  18766. _renderId: number;
  18767. /**
  18768. * Creates a Light object in the scene.
  18769. * Documentation : https://doc.babylonjs.com/babylon101/lights
  18770. * @param name The firendly name of the light
  18771. * @param scene The scene the light belongs too
  18772. */
  18773. constructor(name: string, scene: Scene);
  18774. protected abstract _buildUniformLayout(): void;
  18775. /**
  18776. * Sets the passed Effect "effect" with the Light information.
  18777. * @param effect The effect to update
  18778. * @param lightIndex The index of the light in the effect to update
  18779. * @returns The light
  18780. */
  18781. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  18782. /**
  18783. * Sets the passed Effect "effect" with the Light textures.
  18784. * @param effect The effect to update
  18785. * @param lightIndex The index of the light in the effect to update
  18786. * @returns The light
  18787. */
  18788. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  18789. /**
  18790. * Binds the lights information from the scene to the effect for the given mesh.
  18791. * @param lightIndex Light index
  18792. * @param scene The scene where the light belongs to
  18793. * @param effect The effect we are binding the data to
  18794. * @param useSpecular Defines if specular is supported
  18795. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  18796. */
  18797. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  18798. /**
  18799. * Sets the passed Effect "effect" with the Light information.
  18800. * @param effect The effect to update
  18801. * @param lightDataUniformName The uniform used to store light data (position or direction)
  18802. * @returns The light
  18803. */
  18804. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  18805. /**
  18806. * Returns the string "Light".
  18807. * @returns the class name
  18808. */
  18809. getClassName(): string;
  18810. /** @hidden */
  18811. readonly _isLight: boolean;
  18812. /**
  18813. * Converts the light information to a readable string for debug purpose.
  18814. * @param fullDetails Supports for multiple levels of logging within scene loading
  18815. * @returns the human readable light info
  18816. */
  18817. toString(fullDetails?: boolean): string;
  18818. /** @hidden */
  18819. protected _syncParentEnabledState(): void;
  18820. /**
  18821. * Set the enabled state of this node.
  18822. * @param value - the new enabled state
  18823. */
  18824. setEnabled(value: boolean): void;
  18825. /**
  18826. * Returns the Light associated shadow generator if any.
  18827. * @return the associated shadow generator.
  18828. */
  18829. getShadowGenerator(): Nullable<IShadowGenerator>;
  18830. /**
  18831. * Returns a Vector3, the absolute light position in the World.
  18832. * @returns the world space position of the light
  18833. */
  18834. getAbsolutePosition(): Vector3;
  18835. /**
  18836. * Specifies if the light will affect the passed mesh.
  18837. * @param mesh The mesh to test against the light
  18838. * @return true the mesh is affected otherwise, false.
  18839. */
  18840. canAffectMesh(mesh: AbstractMesh): boolean;
  18841. /**
  18842. * Sort function to order lights for rendering.
  18843. * @param a First Light object to compare to second.
  18844. * @param b Second Light object to compare first.
  18845. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  18846. */
  18847. static CompareLightsPriority(a: Light, b: Light): number;
  18848. /**
  18849. * Releases resources associated with this node.
  18850. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  18851. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  18852. */
  18853. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  18854. /**
  18855. * Returns the light type ID (integer).
  18856. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  18857. */
  18858. getTypeID(): number;
  18859. /**
  18860. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  18861. * @returns the scaled intensity in intensity mode unit
  18862. */
  18863. getScaledIntensity(): number;
  18864. /**
  18865. * Returns a new Light object, named "name", from the current one.
  18866. * @param name The name of the cloned light
  18867. * @param newParent The parent of this light, if it has one
  18868. * @returns the new created light
  18869. */
  18870. clone(name: string, newParent?: Nullable<Node>): Nullable<Light>;
  18871. /**
  18872. * Serializes the current light into a Serialization object.
  18873. * @returns the serialized object.
  18874. */
  18875. serialize(): any;
  18876. /**
  18877. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  18878. * This new light is named "name" and added to the passed scene.
  18879. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  18880. * @param name The friendly name of the light
  18881. * @param scene The scene the new light will belong to
  18882. * @returns the constructor function
  18883. */
  18884. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  18885. /**
  18886. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  18887. * @param parsedLight The JSON representation of the light
  18888. * @param scene The scene to create the parsed light in
  18889. * @returns the created light after parsing
  18890. */
  18891. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  18892. private _hookArrayForExcluded;
  18893. private _hookArrayForIncludedOnly;
  18894. private _resyncMeshes;
  18895. /**
  18896. * Forces the meshes to update their light related information in their rendering used effects
  18897. * @hidden Internal Use Only
  18898. */
  18899. _markMeshesAsLightDirty(): void;
  18900. /**
  18901. * Recomputes the cached photometric scale if needed.
  18902. */
  18903. private _computePhotometricScale;
  18904. /**
  18905. * Returns the Photometric Scale according to the light type and intensity mode.
  18906. */
  18907. private _getPhotometricScale;
  18908. /**
  18909. * Reorder the light in the scene according to their defined priority.
  18910. * @hidden Internal Use Only
  18911. */
  18912. _reorderLightsInScene(): void;
  18913. /**
  18914. * Prepares the list of defines specific to the light type.
  18915. * @param defines the list of defines
  18916. * @param lightIndex defines the index of the light for the effect
  18917. */
  18918. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  18919. }
  18920. }
  18921. declare module "babylonjs/Cameras/targetCamera" {
  18922. import { Nullable } from "babylonjs/types";
  18923. import { Camera } from "babylonjs/Cameras/camera";
  18924. import { Scene } from "babylonjs/scene";
  18925. import { Quaternion, Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  18926. /**
  18927. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  18928. * This is the base of the follow, arc rotate cameras and Free camera
  18929. * @see https://doc.babylonjs.com/features/cameras
  18930. */
  18931. export class TargetCamera extends Camera {
  18932. private static _RigCamTransformMatrix;
  18933. private static _TargetTransformMatrix;
  18934. private static _TargetFocalPoint;
  18935. private _tmpUpVector;
  18936. private _tmpTargetVector;
  18937. /**
  18938. * Define the current direction the camera is moving to
  18939. */
  18940. cameraDirection: Vector3;
  18941. /**
  18942. * Define the current rotation the camera is rotating to
  18943. */
  18944. cameraRotation: Vector2;
  18945. /** Gets or sets a boolean indicating that the scaling of the parent hierarchy will not be taken in account by the camera */
  18946. ignoreParentScaling: boolean;
  18947. /**
  18948. * When set, the up vector of the camera will be updated by the rotation of the camera
  18949. */
  18950. updateUpVectorFromRotation: boolean;
  18951. private _tmpQuaternion;
  18952. /**
  18953. * Define the current rotation of the camera
  18954. */
  18955. rotation: Vector3;
  18956. /**
  18957. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  18958. */
  18959. rotationQuaternion: Quaternion;
  18960. /**
  18961. * Define the current speed of the camera
  18962. */
  18963. speed: number;
  18964. /**
  18965. * Add constraint to the camera to prevent it to move freely in all directions and
  18966. * around all axis.
  18967. */
  18968. noRotationConstraint: boolean;
  18969. /**
  18970. * Reverses mouselook direction to 'natural' panning as opposed to traditional direct
  18971. * panning
  18972. */
  18973. invertRotation: boolean;
  18974. /**
  18975. * Speed multiplier for inverse camera panning
  18976. */
  18977. inverseRotationSpeed: number;
  18978. /**
  18979. * Define the current target of the camera as an object or a position.
  18980. */
  18981. lockedTarget: any;
  18982. /** @hidden */
  18983. _currentTarget: Vector3;
  18984. /** @hidden */
  18985. _initialFocalDistance: number;
  18986. /** @hidden */
  18987. _viewMatrix: Matrix;
  18988. /** @hidden */
  18989. _camMatrix: Matrix;
  18990. /** @hidden */
  18991. _cameraTransformMatrix: Matrix;
  18992. /** @hidden */
  18993. _cameraRotationMatrix: Matrix;
  18994. /** @hidden */
  18995. _referencePoint: Vector3;
  18996. /** @hidden */
  18997. _transformedReferencePoint: Vector3;
  18998. /** @hidden */
  18999. _reset: () => void;
  19000. private _defaultUp;
  19001. /**
  19002. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  19003. * This is the base of the follow, arc rotate cameras and Free camera
  19004. * @see https://doc.babylonjs.com/features/cameras
  19005. * @param name Defines the name of the camera in the scene
  19006. * @param position Defines the start position of the camera in the scene
  19007. * @param scene Defines the scene the camera belongs to
  19008. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  19009. */
  19010. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  19011. /**
  19012. * Gets the position in front of the camera at a given distance.
  19013. * @param distance The distance from the camera we want the position to be
  19014. * @returns the position
  19015. */
  19016. getFrontPosition(distance: number): Vector3;
  19017. /** @hidden */
  19018. _getLockedTargetPosition(): Nullable<Vector3>;
  19019. private _storedPosition;
  19020. private _storedRotation;
  19021. private _storedRotationQuaternion;
  19022. /**
  19023. * Store current camera state of the camera (fov, position, rotation, etc..)
  19024. * @returns the camera
  19025. */
  19026. storeState(): Camera;
  19027. /**
  19028. * Restored camera state. You must call storeState() first
  19029. * @returns whether it was successful or not
  19030. * @hidden
  19031. */
  19032. _restoreStateValues(): boolean;
  19033. /** @hidden */
  19034. _initCache(): void;
  19035. /** @hidden */
  19036. _updateCache(ignoreParentClass?: boolean): void;
  19037. /** @hidden */
  19038. _isSynchronizedViewMatrix(): boolean;
  19039. /** @hidden */
  19040. _computeLocalCameraSpeed(): number;
  19041. /**
  19042. * Defines the target the camera should look at.
  19043. * @param target Defines the new target as a Vector or a mesh
  19044. */
  19045. setTarget(target: Vector3): void;
  19046. /**
  19047. * Defines the target point of the camera.
  19048. * The camera looks towards it form the radius distance.
  19049. */
  19050. get target(): Vector3;
  19051. set target(value: Vector3);
  19052. /**
  19053. * Return the current target position of the camera. This value is expressed in local space.
  19054. * @returns the target position
  19055. */
  19056. getTarget(): Vector3;
  19057. /** @hidden */
  19058. _decideIfNeedsToMove(): boolean;
  19059. /** @hidden */
  19060. _updatePosition(): void;
  19061. /** @hidden */
  19062. _checkInputs(): void;
  19063. protected _updateCameraRotationMatrix(): void;
  19064. /**
  19065. * 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)
  19066. * @returns the current camera
  19067. */
  19068. private _rotateUpVectorWithCameraRotationMatrix;
  19069. private _cachedRotationZ;
  19070. private _cachedQuaternionRotationZ;
  19071. /** @hidden */
  19072. _getViewMatrix(): Matrix;
  19073. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  19074. /**
  19075. * @hidden
  19076. */
  19077. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  19078. /**
  19079. * @hidden
  19080. */
  19081. _updateRigCameras(): void;
  19082. private _getRigCamPositionAndTarget;
  19083. /**
  19084. * Gets the current object class name.
  19085. * @return the class name
  19086. */
  19087. getClassName(): string;
  19088. }
  19089. }
  19090. declare module "babylonjs/Events/keyboardEvents" {
  19091. /**
  19092. * Gather the list of keyboard event types as constants.
  19093. */
  19094. export class KeyboardEventTypes {
  19095. /**
  19096. * The keydown event is fired when a key becomes active (pressed).
  19097. */
  19098. static readonly KEYDOWN: number;
  19099. /**
  19100. * The keyup event is fired when a key has been released.
  19101. */
  19102. static readonly KEYUP: number;
  19103. }
  19104. /**
  19105. * This class is used to store keyboard related info for the onKeyboardObservable event.
  19106. */
  19107. export class KeyboardInfo {
  19108. /**
  19109. * Defines the type of event (KeyboardEventTypes)
  19110. */
  19111. type: number;
  19112. /**
  19113. * Defines the related dom event
  19114. */
  19115. event: KeyboardEvent;
  19116. /**
  19117. * Instantiates a new keyboard info.
  19118. * This class is used to store keyboard related info for the onKeyboardObservable event.
  19119. * @param type Defines the type of event (KeyboardEventTypes)
  19120. * @param event Defines the related dom event
  19121. */
  19122. constructor(
  19123. /**
  19124. * Defines the type of event (KeyboardEventTypes)
  19125. */
  19126. type: number,
  19127. /**
  19128. * Defines the related dom event
  19129. */
  19130. event: KeyboardEvent);
  19131. }
  19132. /**
  19133. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  19134. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  19135. */
  19136. export class KeyboardInfoPre extends KeyboardInfo {
  19137. /**
  19138. * Defines the type of event (KeyboardEventTypes)
  19139. */
  19140. type: number;
  19141. /**
  19142. * Defines the related dom event
  19143. */
  19144. event: KeyboardEvent;
  19145. /**
  19146. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  19147. */
  19148. skipOnPointerObservable: boolean;
  19149. /**
  19150. * Instantiates a new keyboard pre info.
  19151. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  19152. * @param type Defines the type of event (KeyboardEventTypes)
  19153. * @param event Defines the related dom event
  19154. */
  19155. constructor(
  19156. /**
  19157. * Defines the type of event (KeyboardEventTypes)
  19158. */
  19159. type: number,
  19160. /**
  19161. * Defines the related dom event
  19162. */
  19163. event: KeyboardEvent);
  19164. }
  19165. }
  19166. declare module "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput" {
  19167. import { Nullable } from "babylonjs/types";
  19168. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  19169. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  19170. /**
  19171. * Manage the keyboard inputs to control the movement of a free camera.
  19172. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19173. */
  19174. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  19175. /**
  19176. * Defines the camera the input is attached to.
  19177. */
  19178. camera: FreeCamera;
  19179. /**
  19180. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  19181. */
  19182. keysUp: number[];
  19183. /**
  19184. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  19185. */
  19186. keysUpward: number[];
  19187. /**
  19188. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  19189. */
  19190. keysDown: number[];
  19191. /**
  19192. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  19193. */
  19194. keysDownward: number[];
  19195. /**
  19196. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  19197. */
  19198. keysLeft: number[];
  19199. /**
  19200. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  19201. */
  19202. keysRight: number[];
  19203. private _keys;
  19204. private _onCanvasBlurObserver;
  19205. private _onKeyboardObserver;
  19206. private _engine;
  19207. private _scene;
  19208. /**
  19209. * Attach the input controls to a specific dom element to get the input from.
  19210. * @param element Defines the element the controls should be listened from
  19211. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19212. */
  19213. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19214. /**
  19215. * Detach the current controls from the specified dom element.
  19216. * @param element Defines the element to stop listening the inputs from
  19217. */
  19218. detachControl(element: Nullable<HTMLElement>): void;
  19219. /**
  19220. * Update the current camera state depending on the inputs that have been used this frame.
  19221. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  19222. */
  19223. checkInputs(): void;
  19224. /**
  19225. * Gets the class name of the current intput.
  19226. * @returns the class name
  19227. */
  19228. getClassName(): string;
  19229. /** @hidden */
  19230. _onLostFocus(): void;
  19231. /**
  19232. * Get the friendly name associated with the input class.
  19233. * @returns the input friendly name
  19234. */
  19235. getSimpleName(): string;
  19236. }
  19237. }
  19238. declare module "babylonjs/Events/pointerEvents" {
  19239. import { Nullable } from "babylonjs/types";
  19240. import { Vector2 } from "babylonjs/Maths/math.vector";
  19241. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  19242. import { Ray } from "babylonjs/Culling/ray";
  19243. /**
  19244. * Gather the list of pointer event types as constants.
  19245. */
  19246. export class PointerEventTypes {
  19247. /**
  19248. * 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.
  19249. */
  19250. static readonly POINTERDOWN: number;
  19251. /**
  19252. * The pointerup event is fired when a pointer is no longer active.
  19253. */
  19254. static readonly POINTERUP: number;
  19255. /**
  19256. * The pointermove event is fired when a pointer changes coordinates.
  19257. */
  19258. static readonly POINTERMOVE: number;
  19259. /**
  19260. * The pointerwheel event is fired when a mouse wheel has been rotated.
  19261. */
  19262. static readonly POINTERWHEEL: number;
  19263. /**
  19264. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  19265. */
  19266. static readonly POINTERPICK: number;
  19267. /**
  19268. * The pointertap event is fired when a the object has been touched and released without drag.
  19269. */
  19270. static readonly POINTERTAP: number;
  19271. /**
  19272. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  19273. */
  19274. static readonly POINTERDOUBLETAP: number;
  19275. }
  19276. /**
  19277. * Base class of pointer info types.
  19278. */
  19279. export class PointerInfoBase {
  19280. /**
  19281. * Defines the type of event (PointerEventTypes)
  19282. */
  19283. type: number;
  19284. /**
  19285. * Defines the related dom event
  19286. */
  19287. event: PointerEvent | MouseWheelEvent;
  19288. /**
  19289. * Instantiates the base class of pointers info.
  19290. * @param type Defines the type of event (PointerEventTypes)
  19291. * @param event Defines the related dom event
  19292. */
  19293. constructor(
  19294. /**
  19295. * Defines the type of event (PointerEventTypes)
  19296. */
  19297. type: number,
  19298. /**
  19299. * Defines the related dom event
  19300. */
  19301. event: PointerEvent | MouseWheelEvent);
  19302. }
  19303. /**
  19304. * This class is used to store pointer related info for the onPrePointerObservable event.
  19305. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  19306. */
  19307. export class PointerInfoPre extends PointerInfoBase {
  19308. /**
  19309. * Ray from a pointer if availible (eg. 6dof controller)
  19310. */
  19311. ray: Nullable<Ray>;
  19312. /**
  19313. * Defines the local position of the pointer on the canvas.
  19314. */
  19315. localPosition: Vector2;
  19316. /**
  19317. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  19318. */
  19319. skipOnPointerObservable: boolean;
  19320. /**
  19321. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  19322. * @param type Defines the type of event (PointerEventTypes)
  19323. * @param event Defines the related dom event
  19324. * @param localX Defines the local x coordinates of the pointer when the event occured
  19325. * @param localY Defines the local y coordinates of the pointer when the event occured
  19326. */
  19327. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  19328. }
  19329. /**
  19330. * This type contains all the data related to a pointer event in Babylon.js.
  19331. * 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.
  19332. */
  19333. export class PointerInfo extends PointerInfoBase {
  19334. /**
  19335. * Defines the picking info associated to the info (if any)\
  19336. */
  19337. pickInfo: Nullable<PickingInfo>;
  19338. /**
  19339. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  19340. * @param type Defines the type of event (PointerEventTypes)
  19341. * @param event Defines the related dom event
  19342. * @param pickInfo Defines the picking info associated to the info (if any)\
  19343. */
  19344. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  19345. /**
  19346. * Defines the picking info associated to the info (if any)\
  19347. */
  19348. pickInfo: Nullable<PickingInfo>);
  19349. }
  19350. /**
  19351. * Data relating to a touch event on the screen.
  19352. */
  19353. export interface PointerTouch {
  19354. /**
  19355. * X coordinate of touch.
  19356. */
  19357. x: number;
  19358. /**
  19359. * Y coordinate of touch.
  19360. */
  19361. y: number;
  19362. /**
  19363. * Id of touch. Unique for each finger.
  19364. */
  19365. pointerId: number;
  19366. /**
  19367. * Event type passed from DOM.
  19368. */
  19369. type: any;
  19370. }
  19371. }
  19372. declare module "babylonjs/Cameras/Inputs/freeCameraMouseInput" {
  19373. import { Observable } from "babylonjs/Misc/observable";
  19374. import { Nullable } from "babylonjs/types";
  19375. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  19376. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  19377. /**
  19378. * Manage the mouse inputs to control the movement of a free camera.
  19379. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19380. */
  19381. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  19382. /**
  19383. * Define if touch is enabled in the mouse input
  19384. */
  19385. touchEnabled: boolean;
  19386. /**
  19387. * Defines the camera the input is attached to.
  19388. */
  19389. camera: FreeCamera;
  19390. /**
  19391. * Defines the buttons associated with the input to handle camera move.
  19392. */
  19393. buttons: number[];
  19394. /**
  19395. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  19396. */
  19397. angularSensibility: number;
  19398. private _pointerInput;
  19399. private _onMouseMove;
  19400. private _observer;
  19401. private previousPosition;
  19402. /**
  19403. * Observable for when a pointer move event occurs containing the move offset
  19404. */
  19405. onPointerMovedObservable: Observable<{
  19406. offsetX: number;
  19407. offsetY: number;
  19408. }>;
  19409. /**
  19410. * @hidden
  19411. * If the camera should be rotated automatically based on pointer movement
  19412. */
  19413. _allowCameraRotation: boolean;
  19414. /**
  19415. * Manage the mouse inputs to control the movement of a free camera.
  19416. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19417. * @param touchEnabled Defines if touch is enabled or not
  19418. */
  19419. constructor(
  19420. /**
  19421. * Define if touch is enabled in the mouse input
  19422. */
  19423. touchEnabled?: boolean);
  19424. /**
  19425. * Attach the input controls to a specific dom element to get the input from.
  19426. * @param element Defines the element the controls should be listened from
  19427. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19428. */
  19429. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19430. /**
  19431. * Called on JS contextmenu event.
  19432. * Override this method to provide functionality.
  19433. */
  19434. protected onContextMenu(evt: PointerEvent): void;
  19435. /**
  19436. * Detach the current controls from the specified dom element.
  19437. * @param element Defines the element to stop listening the inputs from
  19438. */
  19439. detachControl(element: Nullable<HTMLElement>): void;
  19440. /**
  19441. * Gets the class name of the current intput.
  19442. * @returns the class name
  19443. */
  19444. getClassName(): string;
  19445. /**
  19446. * Get the friendly name associated with the input class.
  19447. * @returns the input friendly name
  19448. */
  19449. getSimpleName(): string;
  19450. }
  19451. }
  19452. declare module "babylonjs/Cameras/Inputs/freeCameraTouchInput" {
  19453. import { Nullable } from "babylonjs/types";
  19454. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  19455. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  19456. /**
  19457. * Manage the touch inputs to control the movement of a free camera.
  19458. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19459. */
  19460. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  19461. /**
  19462. * Define if mouse events can be treated as touch events
  19463. */
  19464. allowMouse: boolean;
  19465. /**
  19466. * Defines the camera the input is attached to.
  19467. */
  19468. camera: FreeCamera;
  19469. /**
  19470. * Defines the touch sensibility for rotation.
  19471. * The higher the faster.
  19472. */
  19473. touchAngularSensibility: number;
  19474. /**
  19475. * Defines the touch sensibility for move.
  19476. * The higher the faster.
  19477. */
  19478. touchMoveSensibility: number;
  19479. private _offsetX;
  19480. private _offsetY;
  19481. private _pointerPressed;
  19482. private _pointerInput;
  19483. private _observer;
  19484. private _onLostFocus;
  19485. /**
  19486. * Manage the touch inputs to control the movement of a free camera.
  19487. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19488. * @param allowMouse Defines if mouse events can be treated as touch events
  19489. */
  19490. constructor(
  19491. /**
  19492. * Define if mouse events can be treated as touch events
  19493. */
  19494. allowMouse?: boolean);
  19495. /**
  19496. * Attach the input controls to a specific dom element to get the input from.
  19497. * @param element Defines the element the controls should be listened from
  19498. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19499. */
  19500. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19501. /**
  19502. * Detach the current controls from the specified dom element.
  19503. * @param element Defines the element to stop listening the inputs from
  19504. */
  19505. detachControl(element: Nullable<HTMLElement>): void;
  19506. /**
  19507. * Update the current camera state depending on the inputs that have been used this frame.
  19508. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  19509. */
  19510. checkInputs(): void;
  19511. /**
  19512. * Gets the class name of the current intput.
  19513. * @returns the class name
  19514. */
  19515. getClassName(): string;
  19516. /**
  19517. * Get the friendly name associated with the input class.
  19518. * @returns the input friendly name
  19519. */
  19520. getSimpleName(): string;
  19521. }
  19522. }
  19523. declare module "babylonjs/Cameras/freeCameraInputsManager" {
  19524. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  19525. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  19526. import { FreeCameraMouseInput } from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  19527. import { Nullable } from "babylonjs/types";
  19528. /**
  19529. * Default Inputs manager for the FreeCamera.
  19530. * It groups all the default supported inputs for ease of use.
  19531. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19532. */
  19533. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  19534. /**
  19535. * @hidden
  19536. */
  19537. _mouseInput: Nullable<FreeCameraMouseInput>;
  19538. /**
  19539. * Instantiates a new FreeCameraInputsManager.
  19540. * @param camera Defines the camera the inputs belong to
  19541. */
  19542. constructor(camera: FreeCamera);
  19543. /**
  19544. * Add keyboard input support to the input manager.
  19545. * @returns the current input manager
  19546. */
  19547. addKeyboard(): FreeCameraInputsManager;
  19548. /**
  19549. * Add mouse input support to the input manager.
  19550. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  19551. * @returns the current input manager
  19552. */
  19553. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  19554. /**
  19555. * Removes the mouse input support from the manager
  19556. * @returns the current input manager
  19557. */
  19558. removeMouse(): FreeCameraInputsManager;
  19559. /**
  19560. * Add touch input support to the input manager.
  19561. * @returns the current input manager
  19562. */
  19563. addTouch(): FreeCameraInputsManager;
  19564. /**
  19565. * Remove all attached input methods from a camera
  19566. */
  19567. clear(): void;
  19568. }
  19569. }
  19570. declare module "babylonjs/Cameras/freeCamera" {
  19571. import { Vector3 } from "babylonjs/Maths/math.vector";
  19572. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19573. import { Scene } from "babylonjs/scene";
  19574. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  19575. import { FreeCameraInputsManager } from "babylonjs/Cameras/freeCameraInputsManager";
  19576. /**
  19577. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  19578. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  19579. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  19580. */
  19581. export class FreeCamera extends TargetCamera {
  19582. /**
  19583. * Define the collision ellipsoid of the camera.
  19584. * This is helpful to simulate a camera body like the player body around the camera
  19585. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  19586. */
  19587. ellipsoid: Vector3;
  19588. /**
  19589. * Define an offset for the position of the ellipsoid around the camera.
  19590. * This can be helpful to determine the center of the body near the gravity center of the body
  19591. * instead of its head.
  19592. */
  19593. ellipsoidOffset: Vector3;
  19594. /**
  19595. * Enable or disable collisions of the camera with the rest of the scene objects.
  19596. */
  19597. checkCollisions: boolean;
  19598. /**
  19599. * Enable or disable gravity on the camera.
  19600. */
  19601. applyGravity: boolean;
  19602. /**
  19603. * Define the input manager associated to the camera.
  19604. */
  19605. inputs: FreeCameraInputsManager;
  19606. /**
  19607. * Gets the input sensibility for a mouse input. (default is 2000.0)
  19608. * Higher values reduce sensitivity.
  19609. */
  19610. get angularSensibility(): number;
  19611. /**
  19612. * Sets the input sensibility for a mouse input. (default is 2000.0)
  19613. * Higher values reduce sensitivity.
  19614. */
  19615. set angularSensibility(value: number);
  19616. /**
  19617. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  19618. */
  19619. get keysUp(): number[];
  19620. set keysUp(value: number[]);
  19621. /**
  19622. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  19623. */
  19624. get keysUpward(): number[];
  19625. set keysUpward(value: number[]);
  19626. /**
  19627. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  19628. */
  19629. get keysDown(): number[];
  19630. set keysDown(value: number[]);
  19631. /**
  19632. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  19633. */
  19634. get keysDownward(): number[];
  19635. set keysDownward(value: number[]);
  19636. /**
  19637. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  19638. */
  19639. get keysLeft(): number[];
  19640. set keysLeft(value: number[]);
  19641. /**
  19642. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  19643. */
  19644. get keysRight(): number[];
  19645. set keysRight(value: number[]);
  19646. /**
  19647. * Event raised when the camera collide with a mesh in the scene.
  19648. */
  19649. onCollide: (collidedMesh: AbstractMesh) => void;
  19650. private _collider;
  19651. private _needMoveForGravity;
  19652. private _oldPosition;
  19653. private _diffPosition;
  19654. private _newPosition;
  19655. /** @hidden */
  19656. _localDirection: Vector3;
  19657. /** @hidden */
  19658. _transformedDirection: Vector3;
  19659. /**
  19660. * Instantiates a Free Camera.
  19661. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  19662. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  19663. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  19664. * @param name Define the name of the camera in the scene
  19665. * @param position Define the start position of the camera in the scene
  19666. * @param scene Define the scene the camera belongs to
  19667. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  19668. */
  19669. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  19670. /**
  19671. * Attached controls to the current camera.
  19672. * @param element Defines the element the controls should be listened from
  19673. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19674. */
  19675. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19676. /**
  19677. * Detach the current controls from the camera.
  19678. * The camera will stop reacting to inputs.
  19679. * @param element Defines the element to stop listening the inputs from
  19680. */
  19681. detachControl(element: HTMLElement): void;
  19682. private _collisionMask;
  19683. /**
  19684. * Define a collision mask to limit the list of object the camera can collide with
  19685. */
  19686. get collisionMask(): number;
  19687. set collisionMask(mask: number);
  19688. /** @hidden */
  19689. _collideWithWorld(displacement: Vector3): void;
  19690. private _onCollisionPositionChange;
  19691. /** @hidden */
  19692. _checkInputs(): void;
  19693. /** @hidden */
  19694. _decideIfNeedsToMove(): boolean;
  19695. /** @hidden */
  19696. _updatePosition(): void;
  19697. /**
  19698. * Destroy the camera and release the current resources hold by it.
  19699. */
  19700. dispose(): void;
  19701. /**
  19702. * Gets the current object class name.
  19703. * @return the class name
  19704. */
  19705. getClassName(): string;
  19706. }
  19707. }
  19708. declare module "babylonjs/Gamepads/gamepad" {
  19709. import { Observable } from "babylonjs/Misc/observable";
  19710. /**
  19711. * Represents a gamepad control stick position
  19712. */
  19713. export class StickValues {
  19714. /**
  19715. * The x component of the control stick
  19716. */
  19717. x: number;
  19718. /**
  19719. * The y component of the control stick
  19720. */
  19721. y: number;
  19722. /**
  19723. * Initializes the gamepad x and y control stick values
  19724. * @param x The x component of the gamepad control stick value
  19725. * @param y The y component of the gamepad control stick value
  19726. */
  19727. constructor(
  19728. /**
  19729. * The x component of the control stick
  19730. */
  19731. x: number,
  19732. /**
  19733. * The y component of the control stick
  19734. */
  19735. y: number);
  19736. }
  19737. /**
  19738. * An interface which manages callbacks for gamepad button changes
  19739. */
  19740. export interface GamepadButtonChanges {
  19741. /**
  19742. * Called when a gamepad has been changed
  19743. */
  19744. changed: boolean;
  19745. /**
  19746. * Called when a gamepad press event has been triggered
  19747. */
  19748. pressChanged: boolean;
  19749. /**
  19750. * Called when a touch event has been triggered
  19751. */
  19752. touchChanged: boolean;
  19753. /**
  19754. * Called when a value has changed
  19755. */
  19756. valueChanged: boolean;
  19757. }
  19758. /**
  19759. * Represents a gamepad
  19760. */
  19761. export class Gamepad {
  19762. /**
  19763. * The id of the gamepad
  19764. */
  19765. id: string;
  19766. /**
  19767. * The index of the gamepad
  19768. */
  19769. index: number;
  19770. /**
  19771. * The browser gamepad
  19772. */
  19773. browserGamepad: any;
  19774. /**
  19775. * Specifies what type of gamepad this represents
  19776. */
  19777. type: number;
  19778. private _leftStick;
  19779. private _rightStick;
  19780. /** @hidden */
  19781. _isConnected: boolean;
  19782. private _leftStickAxisX;
  19783. private _leftStickAxisY;
  19784. private _rightStickAxisX;
  19785. private _rightStickAxisY;
  19786. /**
  19787. * Triggered when the left control stick has been changed
  19788. */
  19789. private _onleftstickchanged;
  19790. /**
  19791. * Triggered when the right control stick has been changed
  19792. */
  19793. private _onrightstickchanged;
  19794. /**
  19795. * Represents a gamepad controller
  19796. */
  19797. static GAMEPAD: number;
  19798. /**
  19799. * Represents a generic controller
  19800. */
  19801. static GENERIC: number;
  19802. /**
  19803. * Represents an XBox controller
  19804. */
  19805. static XBOX: number;
  19806. /**
  19807. * Represents a pose-enabled controller
  19808. */
  19809. static POSE_ENABLED: number;
  19810. /**
  19811. * Represents an Dual Shock controller
  19812. */
  19813. static DUALSHOCK: number;
  19814. /**
  19815. * Specifies whether the left control stick should be Y-inverted
  19816. */
  19817. protected _invertLeftStickY: boolean;
  19818. /**
  19819. * Specifies if the gamepad has been connected
  19820. */
  19821. get isConnected(): boolean;
  19822. /**
  19823. * Initializes the gamepad
  19824. * @param id The id of the gamepad
  19825. * @param index The index of the gamepad
  19826. * @param browserGamepad The browser gamepad
  19827. * @param leftStickX The x component of the left joystick
  19828. * @param leftStickY The y component of the left joystick
  19829. * @param rightStickX The x component of the right joystick
  19830. * @param rightStickY The y component of the right joystick
  19831. */
  19832. constructor(
  19833. /**
  19834. * The id of the gamepad
  19835. */
  19836. id: string,
  19837. /**
  19838. * The index of the gamepad
  19839. */
  19840. index: number,
  19841. /**
  19842. * The browser gamepad
  19843. */
  19844. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  19845. /**
  19846. * Callback triggered when the left joystick has changed
  19847. * @param callback
  19848. */
  19849. onleftstickchanged(callback: (values: StickValues) => void): void;
  19850. /**
  19851. * Callback triggered when the right joystick has changed
  19852. * @param callback
  19853. */
  19854. onrightstickchanged(callback: (values: StickValues) => void): void;
  19855. /**
  19856. * Gets the left joystick
  19857. */
  19858. get leftStick(): StickValues;
  19859. /**
  19860. * Sets the left joystick values
  19861. */
  19862. set leftStick(newValues: StickValues);
  19863. /**
  19864. * Gets the right joystick
  19865. */
  19866. get rightStick(): StickValues;
  19867. /**
  19868. * Sets the right joystick value
  19869. */
  19870. set rightStick(newValues: StickValues);
  19871. /**
  19872. * Updates the gamepad joystick positions
  19873. */
  19874. update(): void;
  19875. /**
  19876. * Disposes the gamepad
  19877. */
  19878. dispose(): void;
  19879. }
  19880. /**
  19881. * Represents a generic gamepad
  19882. */
  19883. export class GenericPad extends Gamepad {
  19884. private _buttons;
  19885. private _onbuttondown;
  19886. private _onbuttonup;
  19887. /**
  19888. * Observable triggered when a button has been pressed
  19889. */
  19890. onButtonDownObservable: Observable<number>;
  19891. /**
  19892. * Observable triggered when a button has been released
  19893. */
  19894. onButtonUpObservable: Observable<number>;
  19895. /**
  19896. * Callback triggered when a button has been pressed
  19897. * @param callback Called when a button has been pressed
  19898. */
  19899. onbuttondown(callback: (buttonPressed: number) => void): void;
  19900. /**
  19901. * Callback triggered when a button has been released
  19902. * @param callback Called when a button has been released
  19903. */
  19904. onbuttonup(callback: (buttonReleased: number) => void): void;
  19905. /**
  19906. * Initializes the generic gamepad
  19907. * @param id The id of the generic gamepad
  19908. * @param index The index of the generic gamepad
  19909. * @param browserGamepad The browser gamepad
  19910. */
  19911. constructor(id: string, index: number, browserGamepad: any);
  19912. private _setButtonValue;
  19913. /**
  19914. * Updates the generic gamepad
  19915. */
  19916. update(): void;
  19917. /**
  19918. * Disposes the generic gamepad
  19919. */
  19920. dispose(): void;
  19921. }
  19922. }
  19923. declare module "babylonjs/Gamepads/Controllers/poseEnabledController" {
  19924. import { Observable } from "babylonjs/Misc/observable";
  19925. import { Nullable } from "babylonjs/types";
  19926. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  19927. import { TransformNode } from "babylonjs/Meshes/transformNode";
  19928. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19929. import { Ray } from "babylonjs/Culling/ray";
  19930. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  19931. import { PoseControlled, DevicePose } from "babylonjs/Cameras/VR/webVRCamera";
  19932. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  19933. /**
  19934. * Defines the types of pose enabled controllers that are supported
  19935. */
  19936. export enum PoseEnabledControllerType {
  19937. /**
  19938. * HTC Vive
  19939. */
  19940. VIVE = 0,
  19941. /**
  19942. * Oculus Rift
  19943. */
  19944. OCULUS = 1,
  19945. /**
  19946. * Windows mixed reality
  19947. */
  19948. WINDOWS = 2,
  19949. /**
  19950. * Samsung gear VR
  19951. */
  19952. GEAR_VR = 3,
  19953. /**
  19954. * Google Daydream
  19955. */
  19956. DAYDREAM = 4,
  19957. /**
  19958. * Generic
  19959. */
  19960. GENERIC = 5
  19961. }
  19962. /**
  19963. * Defines the MutableGamepadButton interface for the state of a gamepad button
  19964. */
  19965. export interface MutableGamepadButton {
  19966. /**
  19967. * Value of the button/trigger
  19968. */
  19969. value: number;
  19970. /**
  19971. * If the button/trigger is currently touched
  19972. */
  19973. touched: boolean;
  19974. /**
  19975. * If the button/trigger is currently pressed
  19976. */
  19977. pressed: boolean;
  19978. }
  19979. /**
  19980. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  19981. * @hidden
  19982. */
  19983. export interface ExtendedGamepadButton extends GamepadButton {
  19984. /**
  19985. * If the button/trigger is currently pressed
  19986. */
  19987. readonly pressed: boolean;
  19988. /**
  19989. * If the button/trigger is currently touched
  19990. */
  19991. readonly touched: boolean;
  19992. /**
  19993. * Value of the button/trigger
  19994. */
  19995. readonly value: number;
  19996. }
  19997. /** @hidden */
  19998. export interface _GamePadFactory {
  19999. /**
  20000. * Returns whether or not the current gamepad can be created for this type of controller.
  20001. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  20002. * @returns true if it can be created, otherwise false
  20003. */
  20004. canCreate(gamepadInfo: any): boolean;
  20005. /**
  20006. * Creates a new instance of the Gamepad.
  20007. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  20008. * @returns the new gamepad instance
  20009. */
  20010. create(gamepadInfo: any): Gamepad;
  20011. }
  20012. /**
  20013. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  20014. */
  20015. export class PoseEnabledControllerHelper {
  20016. /** @hidden */
  20017. static _ControllerFactories: _GamePadFactory[];
  20018. /** @hidden */
  20019. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  20020. /**
  20021. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  20022. * @param vrGamepad the gamepad to initialized
  20023. * @returns a vr controller of the type the gamepad identified as
  20024. */
  20025. static InitiateController(vrGamepad: any): Gamepad;
  20026. }
  20027. /**
  20028. * Defines the PoseEnabledController object that contains state of a vr capable controller
  20029. */
  20030. export class PoseEnabledController extends Gamepad implements PoseControlled {
  20031. /**
  20032. * If the controller is used in a webXR session
  20033. */
  20034. isXR: boolean;
  20035. private _deviceRoomPosition;
  20036. private _deviceRoomRotationQuaternion;
  20037. /**
  20038. * The device position in babylon space
  20039. */
  20040. devicePosition: Vector3;
  20041. /**
  20042. * The device rotation in babylon space
  20043. */
  20044. deviceRotationQuaternion: Quaternion;
  20045. /**
  20046. * The scale factor of the device in babylon space
  20047. */
  20048. deviceScaleFactor: number;
  20049. /**
  20050. * (Likely devicePosition should be used instead) The device position in its room space
  20051. */
  20052. position: Vector3;
  20053. /**
  20054. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  20055. */
  20056. rotationQuaternion: Quaternion;
  20057. /**
  20058. * The type of controller (Eg. Windows mixed reality)
  20059. */
  20060. controllerType: PoseEnabledControllerType;
  20061. protected _calculatedPosition: Vector3;
  20062. private _calculatedRotation;
  20063. /**
  20064. * The raw pose from the device
  20065. */
  20066. rawPose: DevicePose;
  20067. private _trackPosition;
  20068. private _maxRotationDistFromHeadset;
  20069. private _draggedRoomRotation;
  20070. /**
  20071. * @hidden
  20072. */
  20073. _disableTrackPosition(fixedPosition: Vector3): void;
  20074. /**
  20075. * Internal, the mesh attached to the controller
  20076. * @hidden
  20077. */
  20078. _mesh: Nullable<AbstractMesh>;
  20079. private _poseControlledCamera;
  20080. private _leftHandSystemQuaternion;
  20081. /**
  20082. * Internal, matrix used to convert room space to babylon space
  20083. * @hidden
  20084. */
  20085. _deviceToWorld: Matrix;
  20086. /**
  20087. * Node to be used when casting a ray from the controller
  20088. * @hidden
  20089. */
  20090. _pointingPoseNode: Nullable<TransformNode>;
  20091. /**
  20092. * Name of the child mesh that can be used to cast a ray from the controller
  20093. */
  20094. static readonly POINTING_POSE: string;
  20095. /**
  20096. * Creates a new PoseEnabledController from a gamepad
  20097. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  20098. */
  20099. constructor(browserGamepad: any);
  20100. private _workingMatrix;
  20101. /**
  20102. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  20103. */
  20104. update(): void;
  20105. /**
  20106. * Updates only the pose device and mesh without doing any button event checking
  20107. */
  20108. protected _updatePoseAndMesh(): void;
  20109. /**
  20110. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  20111. * @param poseData raw pose fromthe device
  20112. */
  20113. updateFromDevice(poseData: DevicePose): void;
  20114. /**
  20115. * @hidden
  20116. */
  20117. _meshAttachedObservable: Observable<AbstractMesh>;
  20118. /**
  20119. * Attaches a mesh to the controller
  20120. * @param mesh the mesh to be attached
  20121. */
  20122. attachToMesh(mesh: AbstractMesh): void;
  20123. /**
  20124. * Attaches the controllers mesh to a camera
  20125. * @param camera the camera the mesh should be attached to
  20126. */
  20127. attachToPoseControlledCamera(camera: TargetCamera): void;
  20128. /**
  20129. * Disposes of the controller
  20130. */
  20131. dispose(): void;
  20132. /**
  20133. * The mesh that is attached to the controller
  20134. */
  20135. get mesh(): Nullable<AbstractMesh>;
  20136. /**
  20137. * Gets the ray of the controller in the direction the controller is pointing
  20138. * @param length the length the resulting ray should be
  20139. * @returns a ray in the direction the controller is pointing
  20140. */
  20141. getForwardRay(length?: number): Ray;
  20142. }
  20143. }
  20144. declare module "babylonjs/Gamepads/Controllers/webVRController" {
  20145. import { Observable } from "babylonjs/Misc/observable";
  20146. import { Scene } from "babylonjs/scene";
  20147. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20148. import { PoseEnabledController, ExtendedGamepadButton, MutableGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  20149. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  20150. import { Nullable } from "babylonjs/types";
  20151. /**
  20152. * Defines the WebVRController object that represents controllers tracked in 3D space
  20153. */
  20154. export abstract class WebVRController extends PoseEnabledController {
  20155. /**
  20156. * Internal, the default controller model for the controller
  20157. */
  20158. protected _defaultModel: Nullable<AbstractMesh>;
  20159. /**
  20160. * Fired when the trigger state has changed
  20161. */
  20162. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  20163. /**
  20164. * Fired when the main button state has changed
  20165. */
  20166. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  20167. /**
  20168. * Fired when the secondary button state has changed
  20169. */
  20170. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  20171. /**
  20172. * Fired when the pad state has changed
  20173. */
  20174. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  20175. /**
  20176. * Fired when controllers stick values have changed
  20177. */
  20178. onPadValuesChangedObservable: Observable<StickValues>;
  20179. /**
  20180. * Array of button availible on the controller
  20181. */
  20182. protected _buttons: Array<MutableGamepadButton>;
  20183. private _onButtonStateChange;
  20184. /**
  20185. * Fired when a controller button's state has changed
  20186. * @param callback the callback containing the button that was modified
  20187. */
  20188. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  20189. /**
  20190. * X and Y axis corresponding to the controllers joystick
  20191. */
  20192. pad: StickValues;
  20193. /**
  20194. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  20195. */
  20196. hand: string;
  20197. /**
  20198. * The default controller model for the controller
  20199. */
  20200. get defaultModel(): Nullable<AbstractMesh>;
  20201. /**
  20202. * Creates a new WebVRController from a gamepad
  20203. * @param vrGamepad the gamepad that the WebVRController should be created from
  20204. */
  20205. constructor(vrGamepad: any);
  20206. /**
  20207. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  20208. */
  20209. update(): void;
  20210. /**
  20211. * Function to be called when a button is modified
  20212. */
  20213. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  20214. /**
  20215. * Loads a mesh and attaches it to the controller
  20216. * @param scene the scene the mesh should be added to
  20217. * @param meshLoaded callback for when the mesh has been loaded
  20218. */
  20219. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  20220. private _setButtonValue;
  20221. private _changes;
  20222. private _checkChanges;
  20223. /**
  20224. * Disposes of th webVRCOntroller
  20225. */
  20226. dispose(): void;
  20227. }
  20228. }
  20229. declare module "babylonjs/Lights/hemisphericLight" {
  20230. import { Nullable } from "babylonjs/types";
  20231. import { Scene } from "babylonjs/scene";
  20232. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  20233. import { Color3 } from "babylonjs/Maths/math.color";
  20234. import { Effect } from "babylonjs/Materials/effect";
  20235. import { Light } from "babylonjs/Lights/light";
  20236. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  20237. /**
  20238. * The HemisphericLight simulates the ambient environment light,
  20239. * so the passed direction is the light reflection direction, not the incoming direction.
  20240. */
  20241. export class HemisphericLight extends Light {
  20242. /**
  20243. * The groundColor is the light in the opposite direction to the one specified during creation.
  20244. * 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.
  20245. */
  20246. groundColor: Color3;
  20247. /**
  20248. * The light reflection direction, not the incoming direction.
  20249. */
  20250. direction: Vector3;
  20251. /**
  20252. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  20253. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  20254. * The HemisphericLight can't cast shadows.
  20255. * Documentation : https://doc.babylonjs.com/babylon101/lights
  20256. * @param name The friendly name of the light
  20257. * @param direction The direction of the light reflection
  20258. * @param scene The scene the light belongs to
  20259. */
  20260. constructor(name: string, direction: Vector3, scene: Scene);
  20261. protected _buildUniformLayout(): void;
  20262. /**
  20263. * Returns the string "HemisphericLight".
  20264. * @return The class name
  20265. */
  20266. getClassName(): string;
  20267. /**
  20268. * Sets the HemisphericLight direction towards the passed target (Vector3).
  20269. * Returns the updated direction.
  20270. * @param target The target the direction should point to
  20271. * @return The computed direction
  20272. */
  20273. setDirectionToTarget(target: Vector3): Vector3;
  20274. /**
  20275. * Returns the shadow generator associated to the light.
  20276. * @returns Always null for hemispheric lights because it does not support shadows.
  20277. */
  20278. getShadowGenerator(): Nullable<IShadowGenerator>;
  20279. /**
  20280. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  20281. * @param effect The effect to update
  20282. * @param lightIndex The index of the light in the effect to update
  20283. * @returns The hemispheric light
  20284. */
  20285. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  20286. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  20287. /**
  20288. * Computes the world matrix of the node
  20289. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  20290. * @param useWasUpdatedFlag defines a reserved property
  20291. * @returns the world matrix
  20292. */
  20293. computeWorldMatrix(): Matrix;
  20294. /**
  20295. * Returns the integer 3.
  20296. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  20297. */
  20298. getTypeID(): number;
  20299. /**
  20300. * Prepares the list of defines specific to the light type.
  20301. * @param defines the list of defines
  20302. * @param lightIndex defines the index of the light for the effect
  20303. */
  20304. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  20305. }
  20306. }
  20307. declare module "babylonjs/Shaders/vrMultiviewToSingleview.fragment" {
  20308. /** @hidden */
  20309. export var vrMultiviewToSingleviewPixelShader: {
  20310. name: string;
  20311. shader: string;
  20312. };
  20313. }
  20314. declare module "babylonjs/Materials/Textures/MultiviewRenderTarget" {
  20315. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  20316. import { Scene } from "babylonjs/scene";
  20317. /**
  20318. * Renders to multiple views with a single draw call
  20319. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  20320. */
  20321. export class MultiviewRenderTarget extends RenderTargetTexture {
  20322. /**
  20323. * Creates a multiview render target
  20324. * @param scene scene used with the render target
  20325. * @param size the size of the render target (used for each view)
  20326. */
  20327. constructor(scene: Scene, size?: number | {
  20328. width: number;
  20329. height: number;
  20330. } | {
  20331. ratio: number;
  20332. });
  20333. /**
  20334. * @hidden
  20335. * @param faceIndex the face index, if its a cube texture
  20336. */
  20337. _bindFrameBuffer(faceIndex?: number): void;
  20338. /**
  20339. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  20340. * @returns the view count
  20341. */
  20342. getViewCount(): number;
  20343. }
  20344. }
  20345. declare module "babylonjs/Engines/Extensions/engine.multiview" {
  20346. import { Camera } from "babylonjs/Cameras/camera";
  20347. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  20348. import { Nullable } from "babylonjs/types";
  20349. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  20350. import { Matrix } from "babylonjs/Maths/math.vector";
  20351. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  20352. module "babylonjs/Engines/engine" {
  20353. interface Engine {
  20354. /**
  20355. * Creates a new multiview render target
  20356. * @param width defines the width of the texture
  20357. * @param height defines the height of the texture
  20358. * @returns the created multiview texture
  20359. */
  20360. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  20361. /**
  20362. * Binds a multiview framebuffer to be drawn to
  20363. * @param multiviewTexture texture to bind
  20364. */
  20365. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  20366. }
  20367. }
  20368. module "babylonjs/Cameras/camera" {
  20369. interface Camera {
  20370. /**
  20371. * @hidden
  20372. * 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)
  20373. */
  20374. _useMultiviewToSingleView: boolean;
  20375. /**
  20376. * @hidden
  20377. * 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)
  20378. */
  20379. _multiviewTexture: Nullable<RenderTargetTexture>;
  20380. /**
  20381. * @hidden
  20382. * ensures the multiview texture of the camera exists and has the specified width/height
  20383. * @param width height to set on the multiview texture
  20384. * @param height width to set on the multiview texture
  20385. */
  20386. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  20387. }
  20388. }
  20389. module "babylonjs/scene" {
  20390. interface Scene {
  20391. /** @hidden */
  20392. _transformMatrixR: Matrix;
  20393. /** @hidden */
  20394. _multiviewSceneUbo: Nullable<UniformBuffer>;
  20395. /** @hidden */
  20396. _createMultiviewUbo(): void;
  20397. /** @hidden */
  20398. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  20399. /** @hidden */
  20400. _renderMultiviewToSingleView(camera: Camera): void;
  20401. }
  20402. }
  20403. }
  20404. declare module "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess" {
  20405. import { Camera } from "babylonjs/Cameras/camera";
  20406. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  20407. import "babylonjs/Shaders/vrMultiviewToSingleview.fragment";
  20408. import "babylonjs/Engines/Extensions/engine.multiview";
  20409. /**
  20410. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  20411. * This will not be used for webXR as it supports displaying texture arrays directly
  20412. */
  20413. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  20414. /**
  20415. * Gets a string identifying the name of the class
  20416. * @returns "VRMultiviewToSingleviewPostProcess" string
  20417. */
  20418. getClassName(): string;
  20419. /**
  20420. * Initializes a VRMultiviewToSingleview
  20421. * @param name name of the post process
  20422. * @param camera camera to be applied to
  20423. * @param scaleFactor scaling factor to the size of the output texture
  20424. */
  20425. constructor(name: string, camera: Camera, scaleFactor: number);
  20426. }
  20427. }
  20428. declare module "babylonjs/Cameras/RigModes/webVRRigMode" { }
  20429. declare module "babylonjs/Engines/Extensions/engine.webVR" {
  20430. import { Nullable } from "babylonjs/types";
  20431. import { Size } from "babylonjs/Maths/math.size";
  20432. import { Observable } from "babylonjs/Misc/observable";
  20433. import { WebVROptions } from "babylonjs/Cameras/VR/webVRCamera";
  20434. /**
  20435. * Interface used to define additional presentation attributes
  20436. */
  20437. export interface IVRPresentationAttributes {
  20438. /**
  20439. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  20440. */
  20441. highRefreshRate: boolean;
  20442. /**
  20443. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  20444. */
  20445. foveationLevel: number;
  20446. }
  20447. module "babylonjs/Engines/engine" {
  20448. interface Engine {
  20449. /** @hidden */
  20450. _vrDisplay: any;
  20451. /** @hidden */
  20452. _vrSupported: boolean;
  20453. /** @hidden */
  20454. _oldSize: Size;
  20455. /** @hidden */
  20456. _oldHardwareScaleFactor: number;
  20457. /** @hidden */
  20458. _vrExclusivePointerMode: boolean;
  20459. /** @hidden */
  20460. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  20461. /** @hidden */
  20462. _onVRDisplayPointerRestricted: () => void;
  20463. /** @hidden */
  20464. _onVRDisplayPointerUnrestricted: () => void;
  20465. /** @hidden */
  20466. _onVrDisplayConnect: Nullable<(display: any) => void>;
  20467. /** @hidden */
  20468. _onVrDisplayDisconnect: Nullable<() => void>;
  20469. /** @hidden */
  20470. _onVrDisplayPresentChange: Nullable<() => void>;
  20471. /**
  20472. * Observable signaled when VR display mode changes
  20473. */
  20474. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  20475. /**
  20476. * Observable signaled when VR request present is complete
  20477. */
  20478. onVRRequestPresentComplete: Observable<boolean>;
  20479. /**
  20480. * Observable signaled when VR request present starts
  20481. */
  20482. onVRRequestPresentStart: Observable<Engine>;
  20483. /**
  20484. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  20485. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  20486. */
  20487. isInVRExclusivePointerMode: boolean;
  20488. /**
  20489. * Gets a boolean indicating if a webVR device was detected
  20490. * @returns true if a webVR device was detected
  20491. */
  20492. isVRDevicePresent(): boolean;
  20493. /**
  20494. * Gets the current webVR device
  20495. * @returns the current webVR device (or null)
  20496. */
  20497. getVRDevice(): any;
  20498. /**
  20499. * Initializes a webVR display and starts listening to display change events
  20500. * The onVRDisplayChangedObservable will be notified upon these changes
  20501. * @returns A promise containing a VRDisplay and if vr is supported
  20502. */
  20503. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  20504. /** @hidden */
  20505. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  20506. /**
  20507. * Gets or sets the presentation attributes used to configure VR rendering
  20508. */
  20509. vrPresentationAttributes?: IVRPresentationAttributes;
  20510. /**
  20511. * Call this function to switch to webVR mode
  20512. * Will do nothing if webVR is not supported or if there is no webVR device
  20513. * @param options the webvr options provided to the camera. mainly used for multiview
  20514. * @see https://doc.babylonjs.com/how_to/webvr_camera
  20515. */
  20516. enableVR(options: WebVROptions): void;
  20517. /** @hidden */
  20518. _onVRFullScreenTriggered(): void;
  20519. }
  20520. }
  20521. }
  20522. declare module "babylonjs/Cameras/VR/webVRCamera" {
  20523. import { Nullable } from "babylonjs/types";
  20524. import { Observable } from "babylonjs/Misc/observable";
  20525. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  20526. import { Scene } from "babylonjs/scene";
  20527. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  20528. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  20529. import { Node } from "babylonjs/node";
  20530. import { Ray } from "babylonjs/Culling/ray";
  20531. import "babylonjs/Cameras/RigModes/webVRRigMode";
  20532. import "babylonjs/Engines/Extensions/engine.webVR";
  20533. /**
  20534. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  20535. * IMPORTANT!! The data is right-hand data.
  20536. * @export
  20537. * @interface DevicePose
  20538. */
  20539. export interface DevicePose {
  20540. /**
  20541. * The position of the device, values in array are [x,y,z].
  20542. */
  20543. readonly position: Nullable<Float32Array>;
  20544. /**
  20545. * The linearVelocity of the device, values in array are [x,y,z].
  20546. */
  20547. readonly linearVelocity: Nullable<Float32Array>;
  20548. /**
  20549. * The linearAcceleration of the device, values in array are [x,y,z].
  20550. */
  20551. readonly linearAcceleration: Nullable<Float32Array>;
  20552. /**
  20553. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  20554. */
  20555. readonly orientation: Nullable<Float32Array>;
  20556. /**
  20557. * The angularVelocity of the device, values in array are [x,y,z].
  20558. */
  20559. readonly angularVelocity: Nullable<Float32Array>;
  20560. /**
  20561. * The angularAcceleration of the device, values in array are [x,y,z].
  20562. */
  20563. readonly angularAcceleration: Nullable<Float32Array>;
  20564. }
  20565. /**
  20566. * Interface representing a pose controlled object in Babylon.
  20567. * A pose controlled object has both regular pose values as well as pose values
  20568. * from an external device such as a VR head mounted display
  20569. */
  20570. export interface PoseControlled {
  20571. /**
  20572. * The position of the object in babylon space.
  20573. */
  20574. position: Vector3;
  20575. /**
  20576. * The rotation quaternion of the object in babylon space.
  20577. */
  20578. rotationQuaternion: Quaternion;
  20579. /**
  20580. * The position of the device in babylon space.
  20581. */
  20582. devicePosition?: Vector3;
  20583. /**
  20584. * The rotation quaternion of the device in babylon space.
  20585. */
  20586. deviceRotationQuaternion: Quaternion;
  20587. /**
  20588. * The raw pose coming from the device.
  20589. */
  20590. rawPose: Nullable<DevicePose>;
  20591. /**
  20592. * The scale of the device to be used when translating from device space to babylon space.
  20593. */
  20594. deviceScaleFactor: number;
  20595. /**
  20596. * Updates the poseControlled values based on the input device pose.
  20597. * @param poseData the pose data to update the object with
  20598. */
  20599. updateFromDevice(poseData: DevicePose): void;
  20600. }
  20601. /**
  20602. * Set of options to customize the webVRCamera
  20603. */
  20604. export interface WebVROptions {
  20605. /**
  20606. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  20607. */
  20608. trackPosition?: boolean;
  20609. /**
  20610. * Sets the scale of the vrDevice in babylon space. (default: 1)
  20611. */
  20612. positionScale?: number;
  20613. /**
  20614. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  20615. */
  20616. displayName?: string;
  20617. /**
  20618. * Should the native controller meshes be initialized. (default: true)
  20619. */
  20620. controllerMeshes?: boolean;
  20621. /**
  20622. * Creating a default HemiLight only on controllers. (default: true)
  20623. */
  20624. defaultLightingOnControllers?: boolean;
  20625. /**
  20626. * If you don't want to use the default VR button of the helper. (default: false)
  20627. */
  20628. useCustomVRButton?: boolean;
  20629. /**
  20630. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  20631. */
  20632. customVRButton?: HTMLButtonElement;
  20633. /**
  20634. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  20635. */
  20636. rayLength?: number;
  20637. /**
  20638. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  20639. */
  20640. defaultHeight?: number;
  20641. /**
  20642. * If multiview should be used if availible (default: false)
  20643. */
  20644. useMultiview?: boolean;
  20645. }
  20646. /**
  20647. * This represents a WebVR camera.
  20648. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  20649. * @example https://doc.babylonjs.com/how_to/webvr_camera
  20650. */
  20651. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  20652. private webVROptions;
  20653. /**
  20654. * @hidden
  20655. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  20656. */
  20657. _vrDevice: any;
  20658. /**
  20659. * The rawPose of the vrDevice.
  20660. */
  20661. rawPose: Nullable<DevicePose>;
  20662. private _onVREnabled;
  20663. private _specsVersion;
  20664. private _attached;
  20665. private _frameData;
  20666. protected _descendants: Array<Node>;
  20667. private _deviceRoomPosition;
  20668. /** @hidden */
  20669. _deviceRoomRotationQuaternion: Quaternion;
  20670. private _standingMatrix;
  20671. /**
  20672. * Represents device position in babylon space.
  20673. */
  20674. devicePosition: Vector3;
  20675. /**
  20676. * Represents device rotation in babylon space.
  20677. */
  20678. deviceRotationQuaternion: Quaternion;
  20679. /**
  20680. * The scale of the device to be used when translating from device space to babylon space.
  20681. */
  20682. deviceScaleFactor: number;
  20683. private _deviceToWorld;
  20684. private _worldToDevice;
  20685. /**
  20686. * References to the webVR controllers for the vrDevice.
  20687. */
  20688. controllers: Array<WebVRController>;
  20689. /**
  20690. * Emits an event when a controller is attached.
  20691. */
  20692. onControllersAttachedObservable: Observable<WebVRController[]>;
  20693. /**
  20694. * Emits an event when a controller's mesh has been loaded;
  20695. */
  20696. onControllerMeshLoadedObservable: Observable<WebVRController>;
  20697. /**
  20698. * Emits an event when the HMD's pose has been updated.
  20699. */
  20700. onPoseUpdatedFromDeviceObservable: Observable<any>;
  20701. private _poseSet;
  20702. /**
  20703. * If the rig cameras be used as parent instead of this camera.
  20704. */
  20705. rigParenting: boolean;
  20706. private _lightOnControllers;
  20707. private _defaultHeight?;
  20708. /**
  20709. * Instantiates a WebVRFreeCamera.
  20710. * @param name The name of the WebVRFreeCamera
  20711. * @param position The starting anchor position for the camera
  20712. * @param scene The scene the camera belongs to
  20713. * @param webVROptions a set of customizable options for the webVRCamera
  20714. */
  20715. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  20716. /**
  20717. * Gets the device distance from the ground in meters.
  20718. * @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.
  20719. */
  20720. deviceDistanceToRoomGround(): number;
  20721. /**
  20722. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  20723. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  20724. */
  20725. useStandingMatrix(callback?: (bool: boolean) => void): void;
  20726. /**
  20727. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  20728. * @returns A promise with a boolean set to if the standing matrix is supported.
  20729. */
  20730. useStandingMatrixAsync(): Promise<boolean>;
  20731. /**
  20732. * Disposes the camera
  20733. */
  20734. dispose(): void;
  20735. /**
  20736. * Gets a vrController by name.
  20737. * @param name The name of the controller to retreive
  20738. * @returns the controller matching the name specified or null if not found
  20739. */
  20740. getControllerByName(name: string): Nullable<WebVRController>;
  20741. private _leftController;
  20742. /**
  20743. * The controller corresponding to the users left hand.
  20744. */
  20745. get leftController(): Nullable<WebVRController>;
  20746. private _rightController;
  20747. /**
  20748. * The controller corresponding to the users right hand.
  20749. */
  20750. get rightController(): Nullable<WebVRController>;
  20751. /**
  20752. * Casts a ray forward from the vrCamera's gaze.
  20753. * @param length Length of the ray (default: 100)
  20754. * @returns the ray corresponding to the gaze
  20755. */
  20756. getForwardRay(length?: number): Ray;
  20757. /**
  20758. * @hidden
  20759. * Updates the camera based on device's frame data
  20760. */
  20761. _checkInputs(): void;
  20762. /**
  20763. * Updates the poseControlled values based on the input device pose.
  20764. * @param poseData Pose coming from the device
  20765. */
  20766. updateFromDevice(poseData: DevicePose): void;
  20767. private _htmlElementAttached;
  20768. private _detachIfAttached;
  20769. /**
  20770. * WebVR's attach control will start broadcasting frames to the device.
  20771. * Note that in certain browsers (chrome for example) this function must be called
  20772. * within a user-interaction callback. Example:
  20773. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  20774. *
  20775. * @param element html element to attach the vrDevice to
  20776. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  20777. */
  20778. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  20779. /**
  20780. * Detaches the camera from the html element and disables VR
  20781. *
  20782. * @param element html element to detach from
  20783. */
  20784. detachControl(element: HTMLElement): void;
  20785. /**
  20786. * @returns the name of this class
  20787. */
  20788. getClassName(): string;
  20789. /**
  20790. * Calls resetPose on the vrDisplay
  20791. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  20792. */
  20793. resetToCurrentRotation(): void;
  20794. /**
  20795. * @hidden
  20796. * Updates the rig cameras (left and right eye)
  20797. */
  20798. _updateRigCameras(): void;
  20799. private _workingVector;
  20800. private _oneVector;
  20801. private _workingMatrix;
  20802. private updateCacheCalled;
  20803. private _correctPositionIfNotTrackPosition;
  20804. /**
  20805. * @hidden
  20806. * Updates the cached values of the camera
  20807. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  20808. */
  20809. _updateCache(ignoreParentClass?: boolean): void;
  20810. /**
  20811. * @hidden
  20812. * Get current device position in babylon world
  20813. */
  20814. _computeDevicePosition(): void;
  20815. /**
  20816. * Updates the current device position and rotation in the babylon world
  20817. */
  20818. update(): void;
  20819. /**
  20820. * @hidden
  20821. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  20822. * @returns an identity matrix
  20823. */
  20824. _getViewMatrix(): Matrix;
  20825. private _tmpMatrix;
  20826. /**
  20827. * This function is called by the two RIG cameras.
  20828. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  20829. * @hidden
  20830. */
  20831. _getWebVRViewMatrix(): Matrix;
  20832. /** @hidden */
  20833. _getWebVRProjectionMatrix(): Matrix;
  20834. private _onGamepadConnectedObserver;
  20835. private _onGamepadDisconnectedObserver;
  20836. private _updateCacheWhenTrackingDisabledObserver;
  20837. /**
  20838. * Initializes the controllers and their meshes
  20839. */
  20840. initControllers(): void;
  20841. }
  20842. }
  20843. declare module "babylonjs/Materials/materialHelper" {
  20844. import { Nullable } from "babylonjs/types";
  20845. import { Scene } from "babylonjs/scene";
  20846. import { Engine } from "babylonjs/Engines/engine";
  20847. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20848. import { Light } from "babylonjs/Lights/light";
  20849. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  20850. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  20851. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  20852. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  20853. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  20854. /**
  20855. * "Static Class" containing the most commonly used helper while dealing with material for rendering purpose.
  20856. *
  20857. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  20858. *
  20859. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  20860. */
  20861. export class MaterialHelper {
  20862. /**
  20863. * Bind the current view position to an effect.
  20864. * @param effect The effect to be bound
  20865. * @param scene The scene the eyes position is used from
  20866. * @param variableName name of the shader variable that will hold the eye position
  20867. */
  20868. static BindEyePosition(effect: Effect, scene: Scene, variableName?: string): void;
  20869. /**
  20870. * Helps preparing the defines values about the UVs in used in the effect.
  20871. * UVs are shared as much as we can accross channels in the shaders.
  20872. * @param texture The texture we are preparing the UVs for
  20873. * @param defines The defines to update
  20874. * @param key The channel key "diffuse", "specular"... used in the shader
  20875. */
  20876. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  20877. /**
  20878. * Binds a texture matrix value to its corrsponding uniform
  20879. * @param texture The texture to bind the matrix for
  20880. * @param uniformBuffer The uniform buffer receivin the data
  20881. * @param key The channel key "diffuse", "specular"... used in the shader
  20882. */
  20883. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  20884. /**
  20885. * Gets the current status of the fog (should it be enabled?)
  20886. * @param mesh defines the mesh to evaluate for fog support
  20887. * @param scene defines the hosting scene
  20888. * @returns true if fog must be enabled
  20889. */
  20890. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  20891. /**
  20892. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  20893. * @param mesh defines the current mesh
  20894. * @param scene defines the current scene
  20895. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  20896. * @param pointsCloud defines if point cloud rendering has to be turned on
  20897. * @param fogEnabled defines if fog has to be turned on
  20898. * @param alphaTest defines if alpha testing has to be turned on
  20899. * @param defines defines the current list of defines
  20900. */
  20901. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  20902. /**
  20903. * Helper used to prepare the list of defines associated with frame values for shader compilation
  20904. * @param scene defines the current scene
  20905. * @param engine defines the current engine
  20906. * @param defines specifies the list of active defines
  20907. * @param useInstances defines if instances have to be turned on
  20908. * @param useClipPlane defines if clip plane have to be turned on
  20909. * @param useInstances defines if instances have to be turned on
  20910. * @param useThinInstances defines if thin instances have to be turned on
  20911. */
  20912. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>, useThinInstances?: boolean): void;
  20913. /**
  20914. * Prepares the defines for bones
  20915. * @param mesh The mesh containing the geometry data we will draw
  20916. * @param defines The defines to update
  20917. */
  20918. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  20919. /**
  20920. * Prepares the defines for morph targets
  20921. * @param mesh The mesh containing the geometry data we will draw
  20922. * @param defines The defines to update
  20923. */
  20924. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  20925. /**
  20926. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  20927. * @param mesh The mesh containing the geometry data we will draw
  20928. * @param defines The defines to update
  20929. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  20930. * @param useBones Precise whether bones should be used or not (override mesh info)
  20931. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  20932. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  20933. * @returns false if defines are considered not dirty and have not been checked
  20934. */
  20935. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  20936. /**
  20937. * Prepares the defines related to multiview
  20938. * @param scene The scene we are intending to draw
  20939. * @param defines The defines to update
  20940. */
  20941. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  20942. /**
  20943. * Prepares the defines related to the prepass
  20944. * @param scene The scene we are intending to draw
  20945. * @param defines The defines to update
  20946. * @param canRenderToMRT Indicates if this material renders to several textures in the prepass
  20947. */
  20948. static PrepareDefinesForPrePass(scene: Scene, defines: any, canRenderToMRT: boolean): void;
  20949. /**
  20950. * Prepares the defines related to the light information passed in parameter
  20951. * @param scene The scene we are intending to draw
  20952. * @param mesh The mesh the effect is compiling for
  20953. * @param light The light the effect is compiling for
  20954. * @param lightIndex The index of the light
  20955. * @param defines The defines to update
  20956. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  20957. * @param state Defines the current state regarding what is needed (normals, etc...)
  20958. */
  20959. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  20960. needNormals: boolean;
  20961. needRebuild: boolean;
  20962. shadowEnabled: boolean;
  20963. specularEnabled: boolean;
  20964. lightmapMode: boolean;
  20965. }): void;
  20966. /**
  20967. * Prepares the defines related to the light information passed in parameter
  20968. * @param scene The scene we are intending to draw
  20969. * @param mesh The mesh the effect is compiling for
  20970. * @param defines The defines to update
  20971. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  20972. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  20973. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  20974. * @returns true if normals will be required for the rest of the effect
  20975. */
  20976. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  20977. /**
  20978. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  20979. * @param lightIndex defines the light index
  20980. * @param uniformsList The uniform list
  20981. * @param samplersList The sampler list
  20982. * @param projectedLightTexture defines if projected texture must be used
  20983. * @param uniformBuffersList defines an optional list of uniform buffers
  20984. */
  20985. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  20986. /**
  20987. * Prepares the uniforms and samplers list to be used in the effect
  20988. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  20989. * @param samplersList The sampler list
  20990. * @param defines The defines helping in the list generation
  20991. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  20992. */
  20993. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  20994. /**
  20995. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  20996. * @param defines The defines to update while falling back
  20997. * @param fallbacks The authorized effect fallbacks
  20998. * @param maxSimultaneousLights The maximum number of lights allowed
  20999. * @param rank the current rank of the Effect
  21000. * @returns The newly affected rank
  21001. */
  21002. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  21003. private static _TmpMorphInfluencers;
  21004. /**
  21005. * Prepares the list of attributes required for morph targets according to the effect defines.
  21006. * @param attribs The current list of supported attribs
  21007. * @param mesh The mesh to prepare the morph targets attributes for
  21008. * @param influencers The number of influencers
  21009. */
  21010. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  21011. /**
  21012. * Prepares the list of attributes required for morph targets according to the effect defines.
  21013. * @param attribs The current list of supported attribs
  21014. * @param mesh The mesh to prepare the morph targets attributes for
  21015. * @param defines The current Defines of the effect
  21016. */
  21017. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  21018. /**
  21019. * Prepares the list of attributes required for bones according to the effect defines.
  21020. * @param attribs The current list of supported attribs
  21021. * @param mesh The mesh to prepare the bones attributes for
  21022. * @param defines The current Defines of the effect
  21023. * @param fallbacks The current efffect fallback strategy
  21024. */
  21025. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  21026. /**
  21027. * Check and prepare the list of attributes required for instances according to the effect defines.
  21028. * @param attribs The current list of supported attribs
  21029. * @param defines The current MaterialDefines of the effect
  21030. */
  21031. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  21032. /**
  21033. * Add the list of attributes required for instances to the attribs array.
  21034. * @param attribs The current list of supported attribs
  21035. */
  21036. static PushAttributesForInstances(attribs: string[]): void;
  21037. /**
  21038. * Binds the light information to the effect.
  21039. * @param light The light containing the generator
  21040. * @param effect The effect we are binding the data to
  21041. * @param lightIndex The light index in the effect used to render
  21042. */
  21043. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  21044. /**
  21045. * Binds the lights information from the scene to the effect for the given mesh.
  21046. * @param light Light to bind
  21047. * @param lightIndex Light index
  21048. * @param scene The scene where the light belongs to
  21049. * @param effect The effect we are binding the data to
  21050. * @param useSpecular Defines if specular is supported
  21051. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  21052. */
  21053. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  21054. /**
  21055. * Binds the lights information from the scene to the effect for the given mesh.
  21056. * @param scene The scene the lights belongs to
  21057. * @param mesh The mesh we are binding the information to render
  21058. * @param effect The effect we are binding the data to
  21059. * @param defines The generated defines for the effect
  21060. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  21061. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  21062. */
  21063. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  21064. private static _tempFogColor;
  21065. /**
  21066. * Binds the fog information from the scene to the effect for the given mesh.
  21067. * @param scene The scene the lights belongs to
  21068. * @param mesh The mesh we are binding the information to render
  21069. * @param effect The effect we are binding the data to
  21070. * @param linearSpace Defines if the fog effect is applied in linear space
  21071. */
  21072. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  21073. /**
  21074. * Binds the bones information from the mesh to the effect.
  21075. * @param mesh The mesh we are binding the information to render
  21076. * @param effect The effect we are binding the data to
  21077. */
  21078. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  21079. /**
  21080. * Binds the morph targets information from the mesh to the effect.
  21081. * @param abstractMesh The mesh we are binding the information to render
  21082. * @param effect The effect we are binding the data to
  21083. */
  21084. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  21085. /**
  21086. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  21087. * @param defines The generated defines used in the effect
  21088. * @param effect The effect we are binding the data to
  21089. * @param scene The scene we are willing to render with logarithmic scale for
  21090. */
  21091. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  21092. /**
  21093. * Binds the clip plane information from the scene to the effect.
  21094. * @param scene The scene the clip plane information are extracted from
  21095. * @param effect The effect we are binding the data to
  21096. */
  21097. static BindClipPlane(effect: Effect, scene: Scene): void;
  21098. }
  21099. }
  21100. declare module "babylonjs/Materials/Node/Blocks/Input/inputBlock" {
  21101. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21102. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  21103. import { NodeMaterialSystemValues } from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  21104. import { Nullable } from "babylonjs/types";
  21105. import { Effect } from "babylonjs/Materials/effect";
  21106. import { Matrix } from "babylonjs/Maths/math.vector";
  21107. import { Scene } from "babylonjs/scene";
  21108. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21109. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21110. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  21111. import { AnimatedInputBlockTypes } from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  21112. import { Observable } from "babylonjs/Misc/observable";
  21113. /**
  21114. * Block used to expose an input value
  21115. */
  21116. export class InputBlock extends NodeMaterialBlock {
  21117. private _mode;
  21118. private _associatedVariableName;
  21119. private _storedValue;
  21120. private _valueCallback;
  21121. private _type;
  21122. private _animationType;
  21123. /** Gets or set a value used to limit the range of float values */
  21124. min: number;
  21125. /** Gets or set a value used to limit the range of float values */
  21126. max: number;
  21127. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  21128. isBoolean: boolean;
  21129. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  21130. matrixMode: number;
  21131. /** @hidden */
  21132. _systemValue: Nullable<NodeMaterialSystemValues>;
  21133. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  21134. isConstant: boolean;
  21135. /** Gets or sets the group to use to display this block in the Inspector */
  21136. groupInInspector: string;
  21137. /** Gets an observable raised when the value is changed */
  21138. onValueChangedObservable: Observable<InputBlock>;
  21139. /**
  21140. * Gets or sets the connection point type (default is float)
  21141. */
  21142. get type(): NodeMaterialBlockConnectionPointTypes;
  21143. /**
  21144. * Creates a new InputBlock
  21145. * @param name defines the block name
  21146. * @param target defines the target of that block (Vertex by default)
  21147. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  21148. */
  21149. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  21150. /**
  21151. * Validates if a name is a reserve word.
  21152. * @param newName the new name to be given to the node.
  21153. * @returns false if the name is a reserve word, else true.
  21154. */
  21155. validateBlockName(newName: string): boolean;
  21156. /**
  21157. * Gets the output component
  21158. */
  21159. get output(): NodeMaterialConnectionPoint;
  21160. /**
  21161. * Set the source of this connection point to a vertex attribute
  21162. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  21163. * @returns the current connection point
  21164. */
  21165. setAsAttribute(attributeName?: string): InputBlock;
  21166. /**
  21167. * Set the source of this connection point to a system value
  21168. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  21169. * @returns the current connection point
  21170. */
  21171. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  21172. /**
  21173. * Gets or sets the value of that point.
  21174. * Please note that this value will be ignored if valueCallback is defined
  21175. */
  21176. get value(): any;
  21177. set value(value: any);
  21178. /**
  21179. * Gets or sets a callback used to get the value of that point.
  21180. * Please note that setting this value will force the connection point to ignore the value property
  21181. */
  21182. get valueCallback(): () => any;
  21183. set valueCallback(value: () => any);
  21184. /**
  21185. * Gets or sets the associated variable name in the shader
  21186. */
  21187. get associatedVariableName(): string;
  21188. set associatedVariableName(value: string);
  21189. /** Gets or sets the type of animation applied to the input */
  21190. get animationType(): AnimatedInputBlockTypes;
  21191. set animationType(value: AnimatedInputBlockTypes);
  21192. /**
  21193. * Gets a boolean indicating that this connection point not defined yet
  21194. */
  21195. get isUndefined(): boolean;
  21196. /**
  21197. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  21198. * In this case the connection point name must be the name of the uniform to use.
  21199. * Can only be set on inputs
  21200. */
  21201. get isUniform(): boolean;
  21202. set isUniform(value: boolean);
  21203. /**
  21204. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  21205. * In this case the connection point name must be the name of the attribute to use
  21206. * Can only be set on inputs
  21207. */
  21208. get isAttribute(): boolean;
  21209. set isAttribute(value: boolean);
  21210. /**
  21211. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  21212. * Can only be set on exit points
  21213. */
  21214. get isVarying(): boolean;
  21215. set isVarying(value: boolean);
  21216. /**
  21217. * Gets a boolean indicating that the current connection point is a system value
  21218. */
  21219. get isSystemValue(): boolean;
  21220. /**
  21221. * Gets or sets the current well known value or null if not defined as a system value
  21222. */
  21223. get systemValue(): Nullable<NodeMaterialSystemValues>;
  21224. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  21225. /**
  21226. * Gets the current class name
  21227. * @returns the class name
  21228. */
  21229. getClassName(): string;
  21230. /**
  21231. * Animate the input if animationType !== None
  21232. * @param scene defines the rendering scene
  21233. */
  21234. animate(scene: Scene): void;
  21235. private _emitDefine;
  21236. initialize(state: NodeMaterialBuildState): void;
  21237. /**
  21238. * Set the input block to its default value (based on its type)
  21239. */
  21240. setDefaultValue(): void;
  21241. private _emitConstant;
  21242. /** @hidden */
  21243. get _noContextSwitch(): boolean;
  21244. private _emit;
  21245. /** @hidden */
  21246. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  21247. /** @hidden */
  21248. _transmit(effect: Effect, scene: Scene): void;
  21249. protected _buildBlock(state: NodeMaterialBuildState): void;
  21250. protected _dumpPropertiesCode(): string;
  21251. dispose(): void;
  21252. serialize(): any;
  21253. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21254. }
  21255. }
  21256. declare module "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint" {
  21257. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  21258. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  21259. import { Nullable } from "babylonjs/types";
  21260. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  21261. import { Observable } from "babylonjs/Misc/observable";
  21262. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21263. /**
  21264. * Enum used to define the compatibility state between two connection points
  21265. */
  21266. export enum NodeMaterialConnectionPointCompatibilityStates {
  21267. /** Points are compatibles */
  21268. Compatible = 0,
  21269. /** Points are incompatible because of their types */
  21270. TypeIncompatible = 1,
  21271. /** Points are incompatible because of their targets (vertex vs fragment) */
  21272. TargetIncompatible = 2
  21273. }
  21274. /**
  21275. * Defines the direction of a connection point
  21276. */
  21277. export enum NodeMaterialConnectionPointDirection {
  21278. /** Input */
  21279. Input = 0,
  21280. /** Output */
  21281. Output = 1
  21282. }
  21283. /**
  21284. * Defines a connection point for a block
  21285. */
  21286. export class NodeMaterialConnectionPoint {
  21287. /** @hidden */
  21288. _ownerBlock: NodeMaterialBlock;
  21289. /** @hidden */
  21290. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  21291. private _endpoints;
  21292. private _associatedVariableName;
  21293. private _direction;
  21294. /** @hidden */
  21295. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  21296. /** @hidden */
  21297. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  21298. private _type;
  21299. /** @hidden */
  21300. _enforceAssociatedVariableName: boolean;
  21301. /** Gets the direction of the point */
  21302. get direction(): NodeMaterialConnectionPointDirection;
  21303. /** Indicates that this connection point needs dual validation before being connected to another point */
  21304. needDualDirectionValidation: boolean;
  21305. /**
  21306. * Gets or sets the additional types supported by this connection point
  21307. */
  21308. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  21309. /**
  21310. * Gets or sets the additional types excluded by this connection point
  21311. */
  21312. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  21313. /**
  21314. * Observable triggered when this point is connected
  21315. */
  21316. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  21317. /**
  21318. * Gets or sets the associated variable name in the shader
  21319. */
  21320. get associatedVariableName(): string;
  21321. set associatedVariableName(value: string);
  21322. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  21323. get innerType(): NodeMaterialBlockConnectionPointTypes;
  21324. /**
  21325. * Gets or sets the connection point type (default is float)
  21326. */
  21327. get type(): NodeMaterialBlockConnectionPointTypes;
  21328. set type(value: NodeMaterialBlockConnectionPointTypes);
  21329. /**
  21330. * Gets or sets the connection point name
  21331. */
  21332. name: string;
  21333. /**
  21334. * Gets or sets the connection point name
  21335. */
  21336. displayName: string;
  21337. /**
  21338. * Gets or sets a boolean indicating that this connection point can be omitted
  21339. */
  21340. isOptional: boolean;
  21341. /**
  21342. * Gets or sets a boolean indicating that this connection point is exposed on a frame
  21343. */
  21344. isExposedOnFrame: boolean;
  21345. /**
  21346. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  21347. */
  21348. define: string;
  21349. /** @hidden */
  21350. _prioritizeVertex: boolean;
  21351. private _target;
  21352. /** Gets or sets the target of that connection point */
  21353. get target(): NodeMaterialBlockTargets;
  21354. set target(value: NodeMaterialBlockTargets);
  21355. /**
  21356. * Gets a boolean indicating that the current point is connected to another NodeMaterialBlock
  21357. */
  21358. get isConnected(): boolean;
  21359. /**
  21360. * Gets a boolean indicating that the current point is connected to an input block
  21361. */
  21362. get isConnectedToInputBlock(): boolean;
  21363. /**
  21364. * Gets a the connected input block (if any)
  21365. */
  21366. get connectInputBlock(): Nullable<InputBlock>;
  21367. /** Get the other side of the connection (if any) */
  21368. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  21369. /** Get the block that owns this connection point */
  21370. get ownerBlock(): NodeMaterialBlock;
  21371. /** Get the block connected on the other side of this connection (if any) */
  21372. get sourceBlock(): Nullable<NodeMaterialBlock>;
  21373. /** Get the block connected on the endpoints of this connection (if any) */
  21374. get connectedBlocks(): Array<NodeMaterialBlock>;
  21375. /** Gets the list of connected endpoints */
  21376. get endpoints(): NodeMaterialConnectionPoint[];
  21377. /** Gets a boolean indicating if that output point is connected to at least one input */
  21378. get hasEndpoints(): boolean;
  21379. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  21380. get isConnectedInVertexShader(): boolean;
  21381. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  21382. get isConnectedInFragmentShader(): boolean;
  21383. /**
  21384. * Creates a block suitable to be used as an input for this input point.
  21385. * If null is returned, a block based on the point type will be created.
  21386. * @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
  21387. */
  21388. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  21389. /**
  21390. * Creates a new connection point
  21391. * @param name defines the connection point name
  21392. * @param ownerBlock defines the block hosting this connection point
  21393. * @param direction defines the direction of the connection point
  21394. */
  21395. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  21396. /**
  21397. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  21398. * @returns the class name
  21399. */
  21400. getClassName(): string;
  21401. /**
  21402. * Gets a boolean indicating if the current point can be connected to another point
  21403. * @param connectionPoint defines the other connection point
  21404. * @returns a boolean
  21405. */
  21406. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  21407. /**
  21408. * Gets a number indicating if the current point can be connected to another point
  21409. * @param connectionPoint defines the other connection point
  21410. * @returns a number defining the compatibility state
  21411. */
  21412. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  21413. /**
  21414. * Connect this point to another connection point
  21415. * @param connectionPoint defines the other connection point
  21416. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  21417. * @returns the current connection point
  21418. */
  21419. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  21420. /**
  21421. * Disconnect this point from one of his endpoint
  21422. * @param endpoint defines the other connection point
  21423. * @returns the current connection point
  21424. */
  21425. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  21426. /**
  21427. * Serializes this point in a JSON representation
  21428. * @param isInput defines if the connection point is an input (default is true)
  21429. * @returns the serialized point object
  21430. */
  21431. serialize(isInput?: boolean): any;
  21432. /**
  21433. * Release resources
  21434. */
  21435. dispose(): void;
  21436. }
  21437. }
  21438. declare module "babylonjs/Materials/Node/Enums/nodeMaterialModes" {
  21439. /**
  21440. * Enum used to define the material modes
  21441. */
  21442. export enum NodeMaterialModes {
  21443. /** Regular material */
  21444. Material = 0,
  21445. /** For post process */
  21446. PostProcess = 1,
  21447. /** For particle system */
  21448. Particle = 2,
  21449. /** For procedural texture */
  21450. ProceduralTexture = 3
  21451. }
  21452. }
  21453. declare module "babylonjs/Materials/Node/Blocks/Dual/textureBlock" {
  21454. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21455. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21456. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  21457. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21458. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21459. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  21460. import { Effect } from "babylonjs/Materials/effect";
  21461. import { Mesh } from "babylonjs/Meshes/mesh";
  21462. import { Nullable } from "babylonjs/types";
  21463. import { Texture } from "babylonjs/Materials/Textures/texture";
  21464. import { Scene } from "babylonjs/scene";
  21465. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  21466. /**
  21467. * Block used to read a texture from a sampler
  21468. */
  21469. export class TextureBlock extends NodeMaterialBlock {
  21470. private _defineName;
  21471. private _linearDefineName;
  21472. private _gammaDefineName;
  21473. private _tempTextureRead;
  21474. private _samplerName;
  21475. private _transformedUVName;
  21476. private _textureTransformName;
  21477. private _textureInfoName;
  21478. private _mainUVName;
  21479. private _mainUVDefineName;
  21480. private _fragmentOnly;
  21481. /**
  21482. * Gets or sets the texture associated with the node
  21483. */
  21484. texture: Nullable<Texture>;
  21485. /**
  21486. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  21487. */
  21488. convertToGammaSpace: boolean;
  21489. /**
  21490. * Gets or sets a boolean indicating if content needs to be converted to linear space
  21491. */
  21492. convertToLinearSpace: boolean;
  21493. /**
  21494. * Create a new TextureBlock
  21495. * @param name defines the block name
  21496. */
  21497. constructor(name: string, fragmentOnly?: boolean);
  21498. /**
  21499. * Gets the current class name
  21500. * @returns the class name
  21501. */
  21502. getClassName(): string;
  21503. /**
  21504. * Gets the uv input component
  21505. */
  21506. get uv(): NodeMaterialConnectionPoint;
  21507. /**
  21508. * Gets the rgba output component
  21509. */
  21510. get rgba(): NodeMaterialConnectionPoint;
  21511. /**
  21512. * Gets the rgb output component
  21513. */
  21514. get rgb(): NodeMaterialConnectionPoint;
  21515. /**
  21516. * Gets the r output component
  21517. */
  21518. get r(): NodeMaterialConnectionPoint;
  21519. /**
  21520. * Gets the g output component
  21521. */
  21522. get g(): NodeMaterialConnectionPoint;
  21523. /**
  21524. * Gets the b output component
  21525. */
  21526. get b(): NodeMaterialConnectionPoint;
  21527. /**
  21528. * Gets the a output component
  21529. */
  21530. get a(): NodeMaterialConnectionPoint;
  21531. get target(): NodeMaterialBlockTargets;
  21532. autoConfigure(material: NodeMaterial): void;
  21533. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  21534. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21535. isReady(): boolean;
  21536. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  21537. private get _isMixed();
  21538. private _injectVertexCode;
  21539. private _writeTextureRead;
  21540. private _writeOutput;
  21541. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21542. protected _dumpPropertiesCode(): string;
  21543. serialize(): any;
  21544. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21545. }
  21546. }
  21547. declare module "babylonjs/Shaders/ShadersInclude/reflectionFunction" {
  21548. /** @hidden */
  21549. export var reflectionFunction: {
  21550. name: string;
  21551. shader: string;
  21552. };
  21553. }
  21554. declare module "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock" {
  21555. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21556. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21557. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21558. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21559. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21560. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  21561. import { Effect } from "babylonjs/Materials/effect";
  21562. import { Mesh } from "babylonjs/Meshes/mesh";
  21563. import { Nullable } from "babylonjs/types";
  21564. import { Scene } from "babylonjs/scene";
  21565. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  21566. /**
  21567. * Base block used to read a reflection texture from a sampler
  21568. */
  21569. export abstract class ReflectionTextureBaseBlock extends NodeMaterialBlock {
  21570. /** @hidden */
  21571. _define3DName: string;
  21572. /** @hidden */
  21573. _defineCubicName: string;
  21574. /** @hidden */
  21575. _defineExplicitName: string;
  21576. /** @hidden */
  21577. _defineProjectionName: string;
  21578. /** @hidden */
  21579. _defineLocalCubicName: string;
  21580. /** @hidden */
  21581. _defineSphericalName: string;
  21582. /** @hidden */
  21583. _definePlanarName: string;
  21584. /** @hidden */
  21585. _defineEquirectangularName: string;
  21586. /** @hidden */
  21587. _defineMirroredEquirectangularFixedName: string;
  21588. /** @hidden */
  21589. _defineEquirectangularFixedName: string;
  21590. /** @hidden */
  21591. _defineSkyboxName: string;
  21592. /** @hidden */
  21593. _defineOppositeZ: string;
  21594. /** @hidden */
  21595. _cubeSamplerName: string;
  21596. /** @hidden */
  21597. _2DSamplerName: string;
  21598. protected _positionUVWName: string;
  21599. protected _directionWName: string;
  21600. protected _reflectionVectorName: string;
  21601. /** @hidden */
  21602. _reflectionCoordsName: string;
  21603. /** @hidden */
  21604. _reflectionMatrixName: string;
  21605. protected _reflectionColorName: string;
  21606. /**
  21607. * Gets or sets the texture associated with the node
  21608. */
  21609. texture: Nullable<BaseTexture>;
  21610. /**
  21611. * Create a new ReflectionTextureBaseBlock
  21612. * @param name defines the block name
  21613. */
  21614. constructor(name: string);
  21615. /**
  21616. * Gets the current class name
  21617. * @returns the class name
  21618. */
  21619. getClassName(): string;
  21620. /**
  21621. * Gets the world position input component
  21622. */
  21623. abstract get position(): NodeMaterialConnectionPoint;
  21624. /**
  21625. * Gets the world position input component
  21626. */
  21627. abstract get worldPosition(): NodeMaterialConnectionPoint;
  21628. /**
  21629. * Gets the world normal input component
  21630. */
  21631. abstract get worldNormal(): NodeMaterialConnectionPoint;
  21632. /**
  21633. * Gets the world input component
  21634. */
  21635. abstract get world(): NodeMaterialConnectionPoint;
  21636. /**
  21637. * Gets the camera (or eye) position component
  21638. */
  21639. abstract get cameraPosition(): NodeMaterialConnectionPoint;
  21640. /**
  21641. * Gets the view input component
  21642. */
  21643. abstract get view(): NodeMaterialConnectionPoint;
  21644. protected _getTexture(): Nullable<BaseTexture>;
  21645. autoConfigure(material: NodeMaterial): void;
  21646. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21647. isReady(): boolean;
  21648. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  21649. /**
  21650. * Gets the code to inject in the vertex shader
  21651. * @param state current state of the node material building
  21652. * @returns the shader code
  21653. */
  21654. handleVertexSide(state: NodeMaterialBuildState): string;
  21655. /**
  21656. * Handles the inits for the fragment code path
  21657. * @param state node material build state
  21658. */
  21659. handleFragmentSideInits(state: NodeMaterialBuildState): void;
  21660. /**
  21661. * Generates the reflection coords code for the fragment code path
  21662. * @param worldNormalVarName name of the world normal variable
  21663. * @param worldPos name of the world position variable. If not provided, will use the world position connected to this block
  21664. * @param onlyReflectionVector if true, generates code only for the reflection vector computation, not for the reflection coordinates
  21665. * @returns the shader code
  21666. */
  21667. handleFragmentSideCodeReflectionCoords(worldNormalVarName: string, worldPos?: string, onlyReflectionVector?: boolean): string;
  21668. /**
  21669. * Generates the reflection color code for the fragment code path
  21670. * @param lodVarName name of the lod variable
  21671. * @param swizzleLookupTexture swizzle to use for the final color variable
  21672. * @returns the shader code
  21673. */
  21674. handleFragmentSideCodeReflectionColor(lodVarName?: string, swizzleLookupTexture?: string): string;
  21675. /**
  21676. * Generates the code corresponding to the connected output points
  21677. * @param state node material build state
  21678. * @param varName name of the variable to output
  21679. * @returns the shader code
  21680. */
  21681. writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  21682. protected _buildBlock(state: NodeMaterialBuildState): this;
  21683. protected _dumpPropertiesCode(): string;
  21684. serialize(): any;
  21685. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21686. }
  21687. }
  21688. declare module "babylonjs/Materials/Node/nodeMaterialConnectionPointCustomObject" {
  21689. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21690. import { NodeMaterialConnectionPoint, NodeMaterialConnectionPointDirection, NodeMaterialConnectionPointCompatibilityStates } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21691. import { Nullable } from "babylonjs/types";
  21692. /**
  21693. * Defines a connection point to be used for points with a custom object type
  21694. */
  21695. export class NodeMaterialConnectionPointCustomObject<T extends NodeMaterialBlock> extends NodeMaterialConnectionPoint {
  21696. private _blockType;
  21697. private _blockName;
  21698. private _nameForCheking?;
  21699. /**
  21700. * Creates a new connection point
  21701. * @param name defines the connection point name
  21702. * @param ownerBlock defines the block hosting this connection point
  21703. * @param direction defines the direction of the connection point
  21704. */
  21705. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection, _blockType: new (...args: any[]) => T, _blockName: string, _nameForCheking?: string | undefined);
  21706. /**
  21707. * Gets a number indicating if the current point can be connected to another point
  21708. * @param connectionPoint defines the other connection point
  21709. * @returns a number defining the compatibility state
  21710. */
  21711. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  21712. /**
  21713. * Creates a block suitable to be used as an input for this input point.
  21714. * If null is returned, a block based on the point type will be created.
  21715. * @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
  21716. */
  21717. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  21718. }
  21719. }
  21720. declare module "babylonjs/Materials/Node/nodeMaterialDecorator" {
  21721. /**
  21722. * Enum defining the type of properties that can be edited in the property pages in the NME
  21723. */
  21724. export enum PropertyTypeForEdition {
  21725. /** property is a boolean */
  21726. Boolean = 0,
  21727. /** property is a float */
  21728. Float = 1,
  21729. /** property is a Vector2 */
  21730. Vector2 = 2,
  21731. /** property is a list of values */
  21732. List = 3
  21733. }
  21734. /**
  21735. * Interface that defines an option in a variable of type list
  21736. */
  21737. export interface IEditablePropertyListOption {
  21738. /** label of the option */
  21739. "label": string;
  21740. /** value of the option */
  21741. "value": number;
  21742. }
  21743. /**
  21744. * Interface that defines the options available for an editable property
  21745. */
  21746. export interface IEditablePropertyOption {
  21747. /** min value */
  21748. "min"?: number;
  21749. /** max value */
  21750. "max"?: number;
  21751. /** notifiers: indicates which actions to take when the property is changed */
  21752. "notifiers"?: {
  21753. /** the material should be rebuilt */
  21754. "rebuild"?: boolean;
  21755. /** the preview should be updated */
  21756. "update"?: boolean;
  21757. };
  21758. /** list of the options for a variable of type list */
  21759. "options"?: IEditablePropertyListOption[];
  21760. }
  21761. /**
  21762. * Interface that describes an editable property
  21763. */
  21764. export interface IPropertyDescriptionForEdition {
  21765. /** name of the property */
  21766. "propertyName": string;
  21767. /** display name of the property */
  21768. "displayName": string;
  21769. /** type of the property */
  21770. "type": PropertyTypeForEdition;
  21771. /** group of the property - all properties with the same group value will be displayed in a specific section */
  21772. "groupName": string;
  21773. /** options for the property */
  21774. "options": IEditablePropertyOption;
  21775. }
  21776. /**
  21777. * Decorator that flags a property in a node material block as being editable
  21778. */
  21779. export function editableInPropertyPage(displayName: string, propertyType?: PropertyTypeForEdition, groupName?: string, options?: IEditablePropertyOption): (target: any, propertyKey: string) => void;
  21780. }
  21781. declare module "babylonjs/Materials/Node/Blocks/PBR/refractionBlock" {
  21782. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21783. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21784. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  21785. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21786. import { Nullable } from "babylonjs/types";
  21787. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21788. import { Mesh } from "babylonjs/Meshes/mesh";
  21789. import { SubMesh } from "babylonjs/Meshes/subMesh";
  21790. import { Effect } from "babylonjs/Materials/effect";
  21791. import { Scene } from "babylonjs/scene";
  21792. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21793. /**
  21794. * Block used to implement the refraction part of the sub surface module of the PBR material
  21795. */
  21796. export class RefractionBlock extends NodeMaterialBlock {
  21797. /** @hidden */
  21798. _define3DName: string;
  21799. /** @hidden */
  21800. _refractionMatrixName: string;
  21801. /** @hidden */
  21802. _defineLODRefractionAlpha: string;
  21803. /** @hidden */
  21804. _defineLinearSpecularRefraction: string;
  21805. /** @hidden */
  21806. _defineOppositeZ: string;
  21807. /** @hidden */
  21808. _cubeSamplerName: string;
  21809. /** @hidden */
  21810. _2DSamplerName: string;
  21811. /** @hidden */
  21812. _vRefractionMicrosurfaceInfosName: string;
  21813. /** @hidden */
  21814. _vRefractionInfosName: string;
  21815. private _scene;
  21816. /**
  21817. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  21818. * Materials half opaque for instance using refraction could benefit from this control.
  21819. */
  21820. linkRefractionWithTransparency: boolean;
  21821. /**
  21822. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  21823. */
  21824. invertRefractionY: boolean;
  21825. /**
  21826. * Gets or sets the texture associated with the node
  21827. */
  21828. texture: Nullable<BaseTexture>;
  21829. /**
  21830. * Create a new RefractionBlock
  21831. * @param name defines the block name
  21832. */
  21833. constructor(name: string);
  21834. /**
  21835. * Gets the current class name
  21836. * @returns the class name
  21837. */
  21838. getClassName(): string;
  21839. /**
  21840. * Gets the intensity input component
  21841. */
  21842. get intensity(): NodeMaterialConnectionPoint;
  21843. /**
  21844. * Gets the index of refraction input component
  21845. */
  21846. get indexOfRefraction(): NodeMaterialConnectionPoint;
  21847. /**
  21848. * Gets the tint at distance input component
  21849. */
  21850. get tintAtDistance(): NodeMaterialConnectionPoint;
  21851. /**
  21852. * Gets the view input component
  21853. */
  21854. get view(): NodeMaterialConnectionPoint;
  21855. /**
  21856. * Gets the refraction object output component
  21857. */
  21858. get refraction(): NodeMaterialConnectionPoint;
  21859. /**
  21860. * Returns true if the block has a texture
  21861. */
  21862. get hasTexture(): boolean;
  21863. protected _getTexture(): Nullable<BaseTexture>;
  21864. autoConfigure(material: NodeMaterial): void;
  21865. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21866. isReady(): boolean;
  21867. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  21868. /**
  21869. * Gets the main code of the block (fragment side)
  21870. * @param state current state of the node material building
  21871. * @returns the shader code
  21872. */
  21873. getCode(state: NodeMaterialBuildState): string;
  21874. protected _buildBlock(state: NodeMaterialBuildState): this;
  21875. protected _dumpPropertiesCode(): string;
  21876. serialize(): any;
  21877. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21878. }
  21879. }
  21880. declare module "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock" {
  21881. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21882. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21883. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  21884. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21885. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21886. import { NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  21887. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21888. import { Nullable } from "babylonjs/types";
  21889. import { Scene } from "babylonjs/scene";
  21890. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  21891. /**
  21892. * Base block used as input for post process
  21893. */
  21894. export class CurrentScreenBlock extends NodeMaterialBlock {
  21895. private _samplerName;
  21896. private _linearDefineName;
  21897. private _gammaDefineName;
  21898. private _mainUVName;
  21899. private _tempTextureRead;
  21900. /**
  21901. * Gets or sets the texture associated with the node
  21902. */
  21903. texture: Nullable<BaseTexture>;
  21904. /**
  21905. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  21906. */
  21907. convertToGammaSpace: boolean;
  21908. /**
  21909. * Gets or sets a boolean indicating if content needs to be converted to linear space
  21910. */
  21911. convertToLinearSpace: boolean;
  21912. /**
  21913. * Create a new CurrentScreenBlock
  21914. * @param name defines the block name
  21915. */
  21916. constructor(name: string);
  21917. /**
  21918. * Gets the current class name
  21919. * @returns the class name
  21920. */
  21921. getClassName(): string;
  21922. /**
  21923. * Gets the uv input component
  21924. */
  21925. get uv(): NodeMaterialConnectionPoint;
  21926. /**
  21927. * Gets the rgba output component
  21928. */
  21929. get rgba(): NodeMaterialConnectionPoint;
  21930. /**
  21931. * Gets the rgb output component
  21932. */
  21933. get rgb(): NodeMaterialConnectionPoint;
  21934. /**
  21935. * Gets the r output component
  21936. */
  21937. get r(): NodeMaterialConnectionPoint;
  21938. /**
  21939. * Gets the g output component
  21940. */
  21941. get g(): NodeMaterialConnectionPoint;
  21942. /**
  21943. * Gets the b output component
  21944. */
  21945. get b(): NodeMaterialConnectionPoint;
  21946. /**
  21947. * Gets the a output component
  21948. */
  21949. get a(): NodeMaterialConnectionPoint;
  21950. /**
  21951. * Initialize the block and prepare the context for build
  21952. * @param state defines the state that will be used for the build
  21953. */
  21954. initialize(state: NodeMaterialBuildState): void;
  21955. get target(): NodeMaterialBlockTargets;
  21956. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21957. isReady(): boolean;
  21958. private _injectVertexCode;
  21959. private _writeTextureRead;
  21960. private _writeOutput;
  21961. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21962. serialize(): any;
  21963. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21964. }
  21965. }
  21966. declare module "babylonjs/Materials/Node/Blocks/Particle/particleTextureBlock" {
  21967. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21968. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21969. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21970. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21971. import { NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  21972. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21973. import { Nullable } from "babylonjs/types";
  21974. import { Scene } from "babylonjs/scene";
  21975. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  21976. /**
  21977. * Base block used for the particle texture
  21978. */
  21979. export class ParticleTextureBlock extends NodeMaterialBlock {
  21980. private _samplerName;
  21981. private _linearDefineName;
  21982. private _gammaDefineName;
  21983. private _tempTextureRead;
  21984. /**
  21985. * Gets or sets the texture associated with the node
  21986. */
  21987. texture: Nullable<BaseTexture>;
  21988. /**
  21989. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  21990. */
  21991. convertToGammaSpace: boolean;
  21992. /**
  21993. * Gets or sets a boolean indicating if content needs to be converted to linear space
  21994. */
  21995. convertToLinearSpace: boolean;
  21996. /**
  21997. * Create a new ParticleTextureBlock
  21998. * @param name defines the block name
  21999. */
  22000. constructor(name: string);
  22001. /**
  22002. * Gets the current class name
  22003. * @returns the class name
  22004. */
  22005. getClassName(): string;
  22006. /**
  22007. * Gets the uv input component
  22008. */
  22009. get uv(): NodeMaterialConnectionPoint;
  22010. /**
  22011. * Gets the rgba output component
  22012. */
  22013. get rgba(): NodeMaterialConnectionPoint;
  22014. /**
  22015. * Gets the rgb output component
  22016. */
  22017. get rgb(): NodeMaterialConnectionPoint;
  22018. /**
  22019. * Gets the r output component
  22020. */
  22021. get r(): NodeMaterialConnectionPoint;
  22022. /**
  22023. * Gets the g output component
  22024. */
  22025. get g(): NodeMaterialConnectionPoint;
  22026. /**
  22027. * Gets the b output component
  22028. */
  22029. get b(): NodeMaterialConnectionPoint;
  22030. /**
  22031. * Gets the a output component
  22032. */
  22033. get a(): NodeMaterialConnectionPoint;
  22034. /**
  22035. * Initialize the block and prepare the context for build
  22036. * @param state defines the state that will be used for the build
  22037. */
  22038. initialize(state: NodeMaterialBuildState): void;
  22039. autoConfigure(material: NodeMaterial): void;
  22040. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  22041. isReady(): boolean;
  22042. private _writeOutput;
  22043. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  22044. serialize(): any;
  22045. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  22046. }
  22047. }
  22048. declare module "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData" {
  22049. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22050. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22051. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  22052. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  22053. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  22054. import { RefractionBlock } from "babylonjs/Materials/Node/Blocks/PBR/refractionBlock";
  22055. import { CurrentScreenBlock } from "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock";
  22056. import { ParticleTextureBlock } from "babylonjs/Materials/Node/Blocks/Particle/particleTextureBlock";
  22057. import { Scene } from "babylonjs/scene";
  22058. /**
  22059. * Class used to store shared data between 2 NodeMaterialBuildState
  22060. */
  22061. export class NodeMaterialBuildStateSharedData {
  22062. /**
  22063. * Gets the list of emitted varyings
  22064. */
  22065. temps: string[];
  22066. /**
  22067. * Gets the list of emitted varyings
  22068. */
  22069. varyings: string[];
  22070. /**
  22071. * Gets the varying declaration string
  22072. */
  22073. varyingDeclaration: string;
  22074. /**
  22075. * Input blocks
  22076. */
  22077. inputBlocks: InputBlock[];
  22078. /**
  22079. * Input blocks
  22080. */
  22081. textureBlocks: (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  22082. /**
  22083. * Bindable blocks (Blocks that need to set data to the effect)
  22084. */
  22085. bindableBlocks: NodeMaterialBlock[];
  22086. /**
  22087. * List of blocks that can provide a compilation fallback
  22088. */
  22089. blocksWithFallbacks: NodeMaterialBlock[];
  22090. /**
  22091. * List of blocks that can provide a define update
  22092. */
  22093. blocksWithDefines: NodeMaterialBlock[];
  22094. /**
  22095. * List of blocks that can provide a repeatable content
  22096. */
  22097. repeatableContentBlocks: NodeMaterialBlock[];
  22098. /**
  22099. * List of blocks that can provide a dynamic list of uniforms
  22100. */
  22101. dynamicUniformBlocks: NodeMaterialBlock[];
  22102. /**
  22103. * List of blocks that can block the isReady function for the material
  22104. */
  22105. blockingBlocks: NodeMaterialBlock[];
  22106. /**
  22107. * Gets the list of animated inputs
  22108. */
  22109. animatedInputs: InputBlock[];
  22110. /**
  22111. * Build Id used to avoid multiple recompilations
  22112. */
  22113. buildId: number;
  22114. /** List of emitted variables */
  22115. variableNames: {
  22116. [key: string]: number;
  22117. };
  22118. /** List of emitted defines */
  22119. defineNames: {
  22120. [key: string]: number;
  22121. };
  22122. /** Should emit comments? */
  22123. emitComments: boolean;
  22124. /** Emit build activity */
  22125. verbose: boolean;
  22126. /** Gets or sets the hosting scene */
  22127. scene: Scene;
  22128. /**
  22129. * Gets the compilation hints emitted at compilation time
  22130. */
  22131. hints: {
  22132. needWorldViewMatrix: boolean;
  22133. needWorldViewProjectionMatrix: boolean;
  22134. needAlphaBlending: boolean;
  22135. needAlphaTesting: boolean;
  22136. };
  22137. /**
  22138. * List of compilation checks
  22139. */
  22140. checks: {
  22141. emitVertex: boolean;
  22142. emitFragment: boolean;
  22143. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  22144. };
  22145. /**
  22146. * Is vertex program allowed to be empty?
  22147. */
  22148. allowEmptyVertexProgram: boolean;
  22149. /** Creates a new shared data */
  22150. constructor();
  22151. /**
  22152. * Emits console errors and exceptions if there is a failing check
  22153. */
  22154. emitErrors(): void;
  22155. }
  22156. }
  22157. declare module "babylonjs/Materials/Node/nodeMaterialBuildState" {
  22158. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  22159. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  22160. import { NodeMaterialBuildStateSharedData } from "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData";
  22161. /**
  22162. * Class used to store node based material build state
  22163. */
  22164. export class NodeMaterialBuildState {
  22165. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  22166. supportUniformBuffers: boolean;
  22167. /**
  22168. * Gets the list of emitted attributes
  22169. */
  22170. attributes: string[];
  22171. /**
  22172. * Gets the list of emitted uniforms
  22173. */
  22174. uniforms: string[];
  22175. /**
  22176. * Gets the list of emitted constants
  22177. */
  22178. constants: string[];
  22179. /**
  22180. * Gets the list of emitted samplers
  22181. */
  22182. samplers: string[];
  22183. /**
  22184. * Gets the list of emitted functions
  22185. */
  22186. functions: {
  22187. [key: string]: string;
  22188. };
  22189. /**
  22190. * Gets the list of emitted extensions
  22191. */
  22192. extensions: {
  22193. [key: string]: string;
  22194. };
  22195. /**
  22196. * Gets the target of the compilation state
  22197. */
  22198. target: NodeMaterialBlockTargets;
  22199. /**
  22200. * Gets the list of emitted counters
  22201. */
  22202. counters: {
  22203. [key: string]: number;
  22204. };
  22205. /**
  22206. * Shared data between multiple NodeMaterialBuildState instances
  22207. */
  22208. sharedData: NodeMaterialBuildStateSharedData;
  22209. /** @hidden */
  22210. _vertexState: NodeMaterialBuildState;
  22211. /** @hidden */
  22212. _attributeDeclaration: string;
  22213. /** @hidden */
  22214. _uniformDeclaration: string;
  22215. /** @hidden */
  22216. _constantDeclaration: string;
  22217. /** @hidden */
  22218. _samplerDeclaration: string;
  22219. /** @hidden */
  22220. _varyingTransfer: string;
  22221. /** @hidden */
  22222. _injectAtEnd: string;
  22223. private _repeatableContentAnchorIndex;
  22224. /** @hidden */
  22225. _builtCompilationString: string;
  22226. /**
  22227. * Gets the emitted compilation strings
  22228. */
  22229. compilationString: string;
  22230. /**
  22231. * Finalize the compilation strings
  22232. * @param state defines the current compilation state
  22233. */
  22234. finalize(state: NodeMaterialBuildState): void;
  22235. /** @hidden */
  22236. get _repeatableContentAnchor(): string;
  22237. /** @hidden */
  22238. _getFreeVariableName(prefix: string): string;
  22239. /** @hidden */
  22240. _getFreeDefineName(prefix: string): string;
  22241. /** @hidden */
  22242. _excludeVariableName(name: string): void;
  22243. /** @hidden */
  22244. _emit2DSampler(name: string): void;
  22245. /** @hidden */
  22246. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  22247. /** @hidden */
  22248. _emitExtension(name: string, extension: string, define?: string): void;
  22249. /** @hidden */
  22250. _emitFunction(name: string, code: string, comments: string): void;
  22251. /** @hidden */
  22252. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  22253. replaceStrings?: {
  22254. search: RegExp;
  22255. replace: string;
  22256. }[];
  22257. repeatKey?: string;
  22258. }): string;
  22259. /** @hidden */
  22260. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  22261. repeatKey?: string;
  22262. removeAttributes?: boolean;
  22263. removeUniforms?: boolean;
  22264. removeVaryings?: boolean;
  22265. removeIfDef?: boolean;
  22266. replaceStrings?: {
  22267. search: RegExp;
  22268. replace: string;
  22269. }[];
  22270. }, storeKey?: string): void;
  22271. /** @hidden */
  22272. _registerTempVariable(name: string): boolean;
  22273. /** @hidden */
  22274. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  22275. /** @hidden */
  22276. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  22277. /** @hidden */
  22278. _emitFloat(value: number): string;
  22279. }
  22280. }
  22281. declare module "babylonjs/Misc/uniqueIdGenerator" {
  22282. /**
  22283. * Helper class used to generate session unique ID
  22284. */
  22285. export class UniqueIdGenerator {
  22286. private static _UniqueIdCounter;
  22287. /**
  22288. * Gets an unique (relatively to the current scene) Id
  22289. */
  22290. static get UniqueId(): number;
  22291. }
  22292. }
  22293. declare module "babylonjs/Materials/Node/nodeMaterialBlock" {
  22294. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  22295. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22296. import { Nullable } from "babylonjs/types";
  22297. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22298. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  22299. import { Effect } from "babylonjs/Materials/effect";
  22300. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22301. import { Mesh } from "babylonjs/Meshes/mesh";
  22302. import { SubMesh } from "babylonjs/Meshes/subMesh";
  22303. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  22304. import { Scene } from "babylonjs/scene";
  22305. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  22306. /**
  22307. * Defines a block that can be used inside a node based material
  22308. */
  22309. export class NodeMaterialBlock {
  22310. private _buildId;
  22311. private _buildTarget;
  22312. private _target;
  22313. private _isFinalMerger;
  22314. private _isInput;
  22315. private _name;
  22316. protected _isUnique: boolean;
  22317. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  22318. inputsAreExclusive: boolean;
  22319. /** @hidden */
  22320. _codeVariableName: string;
  22321. /** @hidden */
  22322. _inputs: NodeMaterialConnectionPoint[];
  22323. /** @hidden */
  22324. _outputs: NodeMaterialConnectionPoint[];
  22325. /** @hidden */
  22326. _preparationId: number;
  22327. /**
  22328. * Gets the name of the block
  22329. */
  22330. get name(): string;
  22331. /**
  22332. * Sets the name of the block. Will check if the name is valid.
  22333. */
  22334. set name(newName: string);
  22335. /**
  22336. * Gets or sets the unique id of the node
  22337. */
  22338. uniqueId: number;
  22339. /**
  22340. * Gets or sets the comments associated with this block
  22341. */
  22342. comments: string;
  22343. /**
  22344. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  22345. */
  22346. get isUnique(): boolean;
  22347. /**
  22348. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  22349. */
  22350. get isFinalMerger(): boolean;
  22351. /**
  22352. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  22353. */
  22354. get isInput(): boolean;
  22355. /**
  22356. * Gets or sets the build Id
  22357. */
  22358. get buildId(): number;
  22359. set buildId(value: number);
  22360. /**
  22361. * Gets or sets the target of the block
  22362. */
  22363. get target(): NodeMaterialBlockTargets;
  22364. set target(value: NodeMaterialBlockTargets);
  22365. /**
  22366. * Gets the list of input points
  22367. */
  22368. get inputs(): NodeMaterialConnectionPoint[];
  22369. /** Gets the list of output points */
  22370. get outputs(): NodeMaterialConnectionPoint[];
  22371. /**
  22372. * Find an input by its name
  22373. * @param name defines the name of the input to look for
  22374. * @returns the input or null if not found
  22375. */
  22376. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  22377. /**
  22378. * Find an output by its name
  22379. * @param name defines the name of the outputto look for
  22380. * @returns the output or null if not found
  22381. */
  22382. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  22383. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  22384. visibleInInspector: boolean;
  22385. /**
  22386. * Creates a new NodeMaterialBlock
  22387. * @param name defines the block name
  22388. * @param target defines the target of that block (Vertex by default)
  22389. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  22390. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  22391. */
  22392. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  22393. /**
  22394. * Initialize the block and prepare the context for build
  22395. * @param state defines the state that will be used for the build
  22396. */
  22397. initialize(state: NodeMaterialBuildState): void;
  22398. /**
  22399. * Bind data to effect. Will only be called for blocks with isBindable === true
  22400. * @param effect defines the effect to bind data to
  22401. * @param nodeMaterial defines the hosting NodeMaterial
  22402. * @param mesh defines the mesh that will be rendered
  22403. * @param subMesh defines the submesh that will be rendered
  22404. */
  22405. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  22406. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  22407. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  22408. protected _writeFloat(value: number): string;
  22409. /**
  22410. * Gets the current class name e.g. "NodeMaterialBlock"
  22411. * @returns the class name
  22412. */
  22413. getClassName(): string;
  22414. /**
  22415. * Register a new input. Must be called inside a block constructor
  22416. * @param name defines the connection point name
  22417. * @param type defines the connection point type
  22418. * @param isOptional defines a boolean indicating that this input can be omitted
  22419. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  22420. * @param point an already created connection point. If not provided, create a new one
  22421. * @returns the current block
  22422. */
  22423. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  22424. /**
  22425. * Register a new output. Must be called inside a block constructor
  22426. * @param name defines the connection point name
  22427. * @param type defines the connection point type
  22428. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  22429. * @param point an already created connection point. If not provided, create a new one
  22430. * @returns the current block
  22431. */
  22432. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  22433. /**
  22434. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  22435. * @param forOutput defines an optional connection point to check compatibility with
  22436. * @returns the first available input or null
  22437. */
  22438. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  22439. /**
  22440. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  22441. * @param forBlock defines an optional block to check compatibility with
  22442. * @returns the first available input or null
  22443. */
  22444. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  22445. /**
  22446. * Gets the sibling of the given output
  22447. * @param current defines the current output
  22448. * @returns the next output in the list or null
  22449. */
  22450. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  22451. /**
  22452. * Connect current block with another block
  22453. * @param other defines the block to connect with
  22454. * @param options define the various options to help pick the right connections
  22455. * @returns the current block
  22456. */
  22457. connectTo(other: NodeMaterialBlock, options?: {
  22458. input?: string;
  22459. output?: string;
  22460. outputSwizzle?: string;
  22461. }): this | undefined;
  22462. protected _buildBlock(state: NodeMaterialBuildState): void;
  22463. /**
  22464. * Add uniforms, samplers and uniform buffers at compilation time
  22465. * @param state defines the state to update
  22466. * @param nodeMaterial defines the node material requesting the update
  22467. * @param defines defines the material defines to update
  22468. * @param uniformBuffers defines the list of uniform buffer names
  22469. */
  22470. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  22471. /**
  22472. * Add potential fallbacks if shader compilation fails
  22473. * @param mesh defines the mesh to be rendered
  22474. * @param fallbacks defines the current prioritized list of fallbacks
  22475. */
  22476. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  22477. /**
  22478. * Initialize defines for shader compilation
  22479. * @param mesh defines the mesh to be rendered
  22480. * @param nodeMaterial defines the node material requesting the update
  22481. * @param defines defines the material defines to update
  22482. * @param useInstances specifies that instances should be used
  22483. */
  22484. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  22485. /**
  22486. * Update defines for shader compilation
  22487. * @param mesh defines the mesh to be rendered
  22488. * @param nodeMaterial defines the node material requesting the update
  22489. * @param defines defines the material defines to update
  22490. * @param useInstances specifies that instances should be used
  22491. * @param subMesh defines which submesh to render
  22492. */
  22493. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  22494. /**
  22495. * Lets the block try to connect some inputs automatically
  22496. * @param material defines the hosting NodeMaterial
  22497. */
  22498. autoConfigure(material: NodeMaterial): void;
  22499. /**
  22500. * Function called when a block is declared as repeatable content generator
  22501. * @param vertexShaderState defines the current compilation state for the vertex shader
  22502. * @param fragmentShaderState defines the current compilation state for the fragment shader
  22503. * @param mesh defines the mesh to be rendered
  22504. * @param defines defines the material defines to update
  22505. */
  22506. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  22507. /**
  22508. * Checks if the block is ready
  22509. * @param mesh defines the mesh to be rendered
  22510. * @param nodeMaterial defines the node material requesting the update
  22511. * @param defines defines the material defines to update
  22512. * @param useInstances specifies that instances should be used
  22513. * @returns true if the block is ready
  22514. */
  22515. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  22516. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  22517. private _processBuild;
  22518. /**
  22519. * Validates the new name for the block node.
  22520. * @param newName the new name to be given to the node.
  22521. * @returns false if the name is a reserve word, else true.
  22522. */
  22523. validateBlockName(newName: string): boolean;
  22524. /**
  22525. * Compile the current node and generate the shader code
  22526. * @param state defines the current compilation state (uniforms, samplers, current string)
  22527. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  22528. * @returns true if already built
  22529. */
  22530. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  22531. protected _inputRename(name: string): string;
  22532. protected _outputRename(name: string): string;
  22533. protected _dumpPropertiesCode(): string;
  22534. /** @hidden */
  22535. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  22536. /** @hidden */
  22537. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  22538. /**
  22539. * Clone the current block to a new identical block
  22540. * @param scene defines the hosting scene
  22541. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  22542. * @returns a copy of the current block
  22543. */
  22544. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  22545. /**
  22546. * Serializes this block in a JSON representation
  22547. * @returns the serialized block object
  22548. */
  22549. serialize(): any;
  22550. /** @hidden */
  22551. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  22552. private _deserializePortDisplayNamesAndExposedOnFrame;
  22553. /**
  22554. * Release resources
  22555. */
  22556. dispose(): void;
  22557. }
  22558. }
  22559. declare module "babylonjs/Materials/pushMaterial" {
  22560. import { Nullable } from "babylonjs/types";
  22561. import { Scene } from "babylonjs/scene";
  22562. import { Matrix } from "babylonjs/Maths/math.vector";
  22563. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22564. import { Mesh } from "babylonjs/Meshes/mesh";
  22565. import { Material } from "babylonjs/Materials/material";
  22566. import { Effect } from "babylonjs/Materials/effect";
  22567. import { SubMesh } from "babylonjs/Meshes/subMesh";
  22568. /**
  22569. * Base class of materials working in push mode in babylon JS
  22570. * @hidden
  22571. */
  22572. export class PushMaterial extends Material {
  22573. protected _activeEffect: Effect;
  22574. protected _normalMatrix: Matrix;
  22575. constructor(name: string, scene: Scene);
  22576. getEffect(): Effect;
  22577. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  22578. protected _isReadyForSubMesh(subMesh: SubMesh): boolean;
  22579. /**
  22580. * Binds the given world matrix to the active effect
  22581. *
  22582. * @param world the matrix to bind
  22583. */
  22584. bindOnlyWorldMatrix(world: Matrix): void;
  22585. /**
  22586. * Binds the given normal matrix to the active effect
  22587. *
  22588. * @param normalMatrix the matrix to bind
  22589. */
  22590. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  22591. bind(world: Matrix, mesh?: Mesh): void;
  22592. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  22593. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  22594. }
  22595. }
  22596. declare module "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer" {
  22597. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22598. /**
  22599. * Root class for all node material optimizers
  22600. */
  22601. export class NodeMaterialOptimizer {
  22602. /**
  22603. * Function used to optimize a NodeMaterial graph
  22604. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  22605. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  22606. */
  22607. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  22608. }
  22609. }
  22610. declare module "babylonjs/Materials/Node/Blocks/transformBlock" {
  22611. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22612. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22613. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22614. import { Scene } from "babylonjs/scene";
  22615. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22616. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  22617. import { SubMesh } from "babylonjs/Meshes/subMesh";
  22618. /**
  22619. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  22620. */
  22621. export class TransformBlock extends NodeMaterialBlock {
  22622. /**
  22623. * Defines the value to use to complement W value to transform it to a Vector4
  22624. */
  22625. complementW: number;
  22626. /**
  22627. * Defines the value to use to complement z value to transform it to a Vector4
  22628. */
  22629. complementZ: number;
  22630. /**
  22631. * Creates a new TransformBlock
  22632. * @param name defines the block name
  22633. */
  22634. constructor(name: string);
  22635. /**
  22636. * Gets the current class name
  22637. * @returns the class name
  22638. */
  22639. getClassName(): string;
  22640. /**
  22641. * Gets the vector input
  22642. */
  22643. get vector(): NodeMaterialConnectionPoint;
  22644. /**
  22645. * Gets the output component
  22646. */
  22647. get output(): NodeMaterialConnectionPoint;
  22648. /**
  22649. * Gets the xyz output component
  22650. */
  22651. get xyz(): NodeMaterialConnectionPoint;
  22652. /**
  22653. * Gets the matrix transform input
  22654. */
  22655. get transform(): NodeMaterialConnectionPoint;
  22656. protected _buildBlock(state: NodeMaterialBuildState): this;
  22657. /**
  22658. * Update defines for shader compilation
  22659. * @param mesh defines the mesh to be rendered
  22660. * @param nodeMaterial defines the node material requesting the update
  22661. * @param defines defines the material defines to update
  22662. * @param useInstances specifies that instances should be used
  22663. * @param subMesh defines which submesh to render
  22664. */
  22665. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  22666. serialize(): any;
  22667. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  22668. protected _dumpPropertiesCode(): string;
  22669. }
  22670. }
  22671. declare module "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock" {
  22672. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22673. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22674. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22675. /**
  22676. * Block used to output the vertex position
  22677. */
  22678. export class VertexOutputBlock extends NodeMaterialBlock {
  22679. /**
  22680. * Creates a new VertexOutputBlock
  22681. * @param name defines the block name
  22682. */
  22683. constructor(name: string);
  22684. /**
  22685. * Gets the current class name
  22686. * @returns the class name
  22687. */
  22688. getClassName(): string;
  22689. /**
  22690. * Gets the vector input component
  22691. */
  22692. get vector(): NodeMaterialConnectionPoint;
  22693. protected _buildBlock(state: NodeMaterialBuildState): this;
  22694. }
  22695. }
  22696. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock" {
  22697. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22698. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22699. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22700. /**
  22701. * Block used to output the final color
  22702. */
  22703. export class FragmentOutputBlock extends NodeMaterialBlock {
  22704. /**
  22705. * Create a new FragmentOutputBlock
  22706. * @param name defines the block name
  22707. */
  22708. constructor(name: string);
  22709. /**
  22710. * Gets the current class name
  22711. * @returns the class name
  22712. */
  22713. getClassName(): string;
  22714. /**
  22715. * Gets the rgba input component
  22716. */
  22717. get rgba(): NodeMaterialConnectionPoint;
  22718. /**
  22719. * Gets the rgb input component
  22720. */
  22721. get rgb(): NodeMaterialConnectionPoint;
  22722. /**
  22723. * Gets the a input component
  22724. */
  22725. get a(): NodeMaterialConnectionPoint;
  22726. protected _buildBlock(state: NodeMaterialBuildState): this;
  22727. }
  22728. }
  22729. declare module "babylonjs/Materials/Node/Blocks/Particle/particleRampGradientBlock" {
  22730. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22731. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22732. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22733. /**
  22734. * Block used for the particle ramp gradient section
  22735. */
  22736. export class ParticleRampGradientBlock extends NodeMaterialBlock {
  22737. /**
  22738. * Create a new ParticleRampGradientBlock
  22739. * @param name defines the block name
  22740. */
  22741. constructor(name: string);
  22742. /**
  22743. * Gets the current class name
  22744. * @returns the class name
  22745. */
  22746. getClassName(): string;
  22747. /**
  22748. * Gets the color input component
  22749. */
  22750. get color(): NodeMaterialConnectionPoint;
  22751. /**
  22752. * Gets the rampColor output component
  22753. */
  22754. get rampColor(): NodeMaterialConnectionPoint;
  22755. /**
  22756. * Initialize the block and prepare the context for build
  22757. * @param state defines the state that will be used for the build
  22758. */
  22759. initialize(state: NodeMaterialBuildState): void;
  22760. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  22761. }
  22762. }
  22763. declare module "babylonjs/Materials/Node/Blocks/Particle/particleBlendMultiplyBlock" {
  22764. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22765. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22766. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22767. /**
  22768. * Block used for the particle blend multiply section
  22769. */
  22770. export class ParticleBlendMultiplyBlock extends NodeMaterialBlock {
  22771. /**
  22772. * Create a new ParticleBlendMultiplyBlock
  22773. * @param name defines the block name
  22774. */
  22775. constructor(name: string);
  22776. /**
  22777. * Gets the current class name
  22778. * @returns the class name
  22779. */
  22780. getClassName(): string;
  22781. /**
  22782. * Gets the color input component
  22783. */
  22784. get color(): NodeMaterialConnectionPoint;
  22785. /**
  22786. * Gets the alphaTexture input component
  22787. */
  22788. get alphaTexture(): NodeMaterialConnectionPoint;
  22789. /**
  22790. * Gets the alphaColor input component
  22791. */
  22792. get alphaColor(): NodeMaterialConnectionPoint;
  22793. /**
  22794. * Gets the blendColor output component
  22795. */
  22796. get blendColor(): NodeMaterialConnectionPoint;
  22797. /**
  22798. * Initialize the block and prepare the context for build
  22799. * @param state defines the state that will be used for the build
  22800. */
  22801. initialize(state: NodeMaterialBuildState): void;
  22802. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  22803. }
  22804. }
  22805. declare module "babylonjs/Materials/Node/Blocks/vectorMergerBlock" {
  22806. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22807. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22808. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22809. /**
  22810. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  22811. */
  22812. export class VectorMergerBlock extends NodeMaterialBlock {
  22813. /**
  22814. * Create a new VectorMergerBlock
  22815. * @param name defines the block name
  22816. */
  22817. constructor(name: string);
  22818. /**
  22819. * Gets the current class name
  22820. * @returns the class name
  22821. */
  22822. getClassName(): string;
  22823. /**
  22824. * Gets the xyz component (input)
  22825. */
  22826. get xyzIn(): NodeMaterialConnectionPoint;
  22827. /**
  22828. * Gets the xy component (input)
  22829. */
  22830. get xyIn(): NodeMaterialConnectionPoint;
  22831. /**
  22832. * Gets the x component (input)
  22833. */
  22834. get x(): NodeMaterialConnectionPoint;
  22835. /**
  22836. * Gets the y component (input)
  22837. */
  22838. get y(): NodeMaterialConnectionPoint;
  22839. /**
  22840. * Gets the z component (input)
  22841. */
  22842. get z(): NodeMaterialConnectionPoint;
  22843. /**
  22844. * Gets the w component (input)
  22845. */
  22846. get w(): NodeMaterialConnectionPoint;
  22847. /**
  22848. * Gets the xyzw component (output)
  22849. */
  22850. get xyzw(): NodeMaterialConnectionPoint;
  22851. /**
  22852. * Gets the xyz component (output)
  22853. */
  22854. get xyzOut(): NodeMaterialConnectionPoint;
  22855. /**
  22856. * Gets the xy component (output)
  22857. */
  22858. get xyOut(): NodeMaterialConnectionPoint;
  22859. /**
  22860. * Gets the xy component (output)
  22861. * @deprecated Please use xyOut instead.
  22862. */
  22863. get xy(): NodeMaterialConnectionPoint;
  22864. /**
  22865. * Gets the xyz component (output)
  22866. * @deprecated Please use xyzOut instead.
  22867. */
  22868. get xyz(): NodeMaterialConnectionPoint;
  22869. protected _buildBlock(state: NodeMaterialBuildState): this;
  22870. }
  22871. }
  22872. declare module "babylonjs/Materials/Node/Blocks/remapBlock" {
  22873. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22874. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22875. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22876. import { Vector2 } from "babylonjs/Maths/math.vector";
  22877. import { Scene } from "babylonjs/scene";
  22878. /**
  22879. * Block used to remap a float from a range to a new one
  22880. */
  22881. export class RemapBlock extends NodeMaterialBlock {
  22882. /**
  22883. * Gets or sets the source range
  22884. */
  22885. sourceRange: Vector2;
  22886. /**
  22887. * Gets or sets the target range
  22888. */
  22889. targetRange: Vector2;
  22890. /**
  22891. * Creates a new RemapBlock
  22892. * @param name defines the block name
  22893. */
  22894. constructor(name: string);
  22895. /**
  22896. * Gets the current class name
  22897. * @returns the class name
  22898. */
  22899. getClassName(): string;
  22900. /**
  22901. * Gets the input component
  22902. */
  22903. get input(): NodeMaterialConnectionPoint;
  22904. /**
  22905. * Gets the source min input component
  22906. */
  22907. get sourceMin(): NodeMaterialConnectionPoint;
  22908. /**
  22909. * Gets the source max input component
  22910. */
  22911. get sourceMax(): NodeMaterialConnectionPoint;
  22912. /**
  22913. * Gets the target min input component
  22914. */
  22915. get targetMin(): NodeMaterialConnectionPoint;
  22916. /**
  22917. * Gets the target max input component
  22918. */
  22919. get targetMax(): NodeMaterialConnectionPoint;
  22920. /**
  22921. * Gets the output component
  22922. */
  22923. get output(): NodeMaterialConnectionPoint;
  22924. protected _buildBlock(state: NodeMaterialBuildState): this;
  22925. protected _dumpPropertiesCode(): string;
  22926. serialize(): any;
  22927. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  22928. }
  22929. }
  22930. declare module "babylonjs/Materials/Node/Blocks/multiplyBlock" {
  22931. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22932. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22933. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22934. /**
  22935. * Block used to multiply 2 values
  22936. */
  22937. export class MultiplyBlock extends NodeMaterialBlock {
  22938. /**
  22939. * Creates a new MultiplyBlock
  22940. * @param name defines the block name
  22941. */
  22942. constructor(name: string);
  22943. /**
  22944. * Gets the current class name
  22945. * @returns the class name
  22946. */
  22947. getClassName(): string;
  22948. /**
  22949. * Gets the left operand input component
  22950. */
  22951. get left(): NodeMaterialConnectionPoint;
  22952. /**
  22953. * Gets the right operand input component
  22954. */
  22955. get right(): NodeMaterialConnectionPoint;
  22956. /**
  22957. * Gets the output component
  22958. */
  22959. get output(): NodeMaterialConnectionPoint;
  22960. protected _buildBlock(state: NodeMaterialBuildState): this;
  22961. }
  22962. }
  22963. declare module "babylonjs/Materials/Node/Blocks/colorSplitterBlock" {
  22964. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22965. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22966. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22967. /**
  22968. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  22969. */
  22970. export class ColorSplitterBlock extends NodeMaterialBlock {
  22971. /**
  22972. * Create a new ColorSplitterBlock
  22973. * @param name defines the block name
  22974. */
  22975. constructor(name: string);
  22976. /**
  22977. * Gets the current class name
  22978. * @returns the class name
  22979. */
  22980. getClassName(): string;
  22981. /**
  22982. * Gets the rgba component (input)
  22983. */
  22984. get rgba(): NodeMaterialConnectionPoint;
  22985. /**
  22986. * Gets the rgb component (input)
  22987. */
  22988. get rgbIn(): NodeMaterialConnectionPoint;
  22989. /**
  22990. * Gets the rgb component (output)
  22991. */
  22992. get rgbOut(): NodeMaterialConnectionPoint;
  22993. /**
  22994. * Gets the r component (output)
  22995. */
  22996. get r(): NodeMaterialConnectionPoint;
  22997. /**
  22998. * Gets the g component (output)
  22999. */
  23000. get g(): NodeMaterialConnectionPoint;
  23001. /**
  23002. * Gets the b component (output)
  23003. */
  23004. get b(): NodeMaterialConnectionPoint;
  23005. /**
  23006. * Gets the a component (output)
  23007. */
  23008. get a(): NodeMaterialConnectionPoint;
  23009. protected _inputRename(name: string): string;
  23010. protected _outputRename(name: string): string;
  23011. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  23012. }
  23013. }
  23014. declare module "babylonjs/Materials/Node/Blocks/trigonometryBlock" {
  23015. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  23016. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  23017. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  23018. import { Scene } from "babylonjs/scene";
  23019. /**
  23020. * Operations supported by the Trigonometry block
  23021. */
  23022. export enum TrigonometryBlockOperations {
  23023. /** Cos */
  23024. Cos = 0,
  23025. /** Sin */
  23026. Sin = 1,
  23027. /** Abs */
  23028. Abs = 2,
  23029. /** Exp */
  23030. Exp = 3,
  23031. /** Exp2 */
  23032. Exp2 = 4,
  23033. /** Round */
  23034. Round = 5,
  23035. /** Floor */
  23036. Floor = 6,
  23037. /** Ceiling */
  23038. Ceiling = 7,
  23039. /** Square root */
  23040. Sqrt = 8,
  23041. /** Log */
  23042. Log = 9,
  23043. /** Tangent */
  23044. Tan = 10,
  23045. /** Arc tangent */
  23046. ArcTan = 11,
  23047. /** Arc cosinus */
  23048. ArcCos = 12,
  23049. /** Arc sinus */
  23050. ArcSin = 13,
  23051. /** Fraction */
  23052. Fract = 14,
  23053. /** Sign */
  23054. Sign = 15,
  23055. /** To radians (from degrees) */
  23056. Radians = 16,
  23057. /** To degrees (from radians) */
  23058. Degrees = 17
  23059. }
  23060. /**
  23061. * Block used to apply trigonometry operation to floats
  23062. */
  23063. export class TrigonometryBlock extends NodeMaterialBlock {
  23064. /**
  23065. * Gets or sets the operation applied by the block
  23066. */
  23067. operation: TrigonometryBlockOperations;
  23068. /**
  23069. * Creates a new TrigonometryBlock
  23070. * @param name defines the block name
  23071. */
  23072. constructor(name: string);
  23073. /**
  23074. * Gets the current class name
  23075. * @returns the class name
  23076. */
  23077. getClassName(): string;
  23078. /**
  23079. * Gets the input component
  23080. */
  23081. get input(): NodeMaterialConnectionPoint;
  23082. /**
  23083. * Gets the output component
  23084. */
  23085. get output(): NodeMaterialConnectionPoint;
  23086. protected _buildBlock(state: NodeMaterialBuildState): this;
  23087. serialize(): any;
  23088. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  23089. protected _dumpPropertiesCode(): string;
  23090. }
  23091. }
  23092. declare module "babylonjs/Materials/Node/nodeMaterial" {
  23093. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  23094. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  23095. import { Scene } from "babylonjs/scene";
  23096. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23097. import { Matrix } from "babylonjs/Maths/math.vector";
  23098. import { Mesh } from "babylonjs/Meshes/mesh";
  23099. import { Engine } from "babylonjs/Engines/engine";
  23100. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  23101. import { Observable } from "babylonjs/Misc/observable";
  23102. import { SubMesh } from "babylonjs/Meshes/subMesh";
  23103. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  23104. import { NodeMaterialOptimizer } from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  23105. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  23106. import { Nullable } from "babylonjs/types";
  23107. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  23108. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  23109. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  23110. import { RefractionBlock } from "babylonjs/Materials/Node/Blocks/PBR/refractionBlock";
  23111. import { CurrentScreenBlock } from "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock";
  23112. import { ParticleTextureBlock } from "babylonjs/Materials/Node/Blocks/Particle/particleTextureBlock";
  23113. import { Effect } from "babylonjs/Materials/effect";
  23114. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  23115. import { Camera } from "babylonjs/Cameras/camera";
  23116. import { NodeMaterialModes } from "babylonjs/Materials/Node/Enums/nodeMaterialModes";
  23117. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  23118. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  23119. /**
  23120. * Interface used to configure the node material editor
  23121. */
  23122. export interface INodeMaterialEditorOptions {
  23123. /** Define the URl to load node editor script */
  23124. editorURL?: string;
  23125. }
  23126. /** @hidden */
  23127. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  23128. NORMAL: boolean;
  23129. TANGENT: boolean;
  23130. UV1: boolean;
  23131. /** BONES */
  23132. NUM_BONE_INFLUENCERS: number;
  23133. BonesPerMesh: number;
  23134. BONETEXTURE: boolean;
  23135. /** MORPH TARGETS */
  23136. MORPHTARGETS: boolean;
  23137. MORPHTARGETS_NORMAL: boolean;
  23138. MORPHTARGETS_TANGENT: boolean;
  23139. MORPHTARGETS_UV: boolean;
  23140. NUM_MORPH_INFLUENCERS: number;
  23141. /** IMAGE PROCESSING */
  23142. IMAGEPROCESSING: boolean;
  23143. VIGNETTE: boolean;
  23144. VIGNETTEBLENDMODEMULTIPLY: boolean;
  23145. VIGNETTEBLENDMODEOPAQUE: boolean;
  23146. TONEMAPPING: boolean;
  23147. TONEMAPPING_ACES: boolean;
  23148. CONTRAST: boolean;
  23149. EXPOSURE: boolean;
  23150. COLORCURVES: boolean;
  23151. COLORGRADING: boolean;
  23152. COLORGRADING3D: boolean;
  23153. SAMPLER3DGREENDEPTH: boolean;
  23154. SAMPLER3DBGRMAP: boolean;
  23155. IMAGEPROCESSINGPOSTPROCESS: boolean;
  23156. /** MISC. */
  23157. BUMPDIRECTUV: number;
  23158. constructor();
  23159. setValue(name: string, value: any, markAsUnprocessedIfDirty?: boolean): void;
  23160. }
  23161. /**
  23162. * Class used to configure NodeMaterial
  23163. */
  23164. export interface INodeMaterialOptions {
  23165. /**
  23166. * Defines if blocks should emit comments
  23167. */
  23168. emitComments: boolean;
  23169. }
  23170. /**
  23171. * Class used to create a node based material built by assembling shader blocks
  23172. */
  23173. export class NodeMaterial extends PushMaterial {
  23174. private static _BuildIdGenerator;
  23175. private _options;
  23176. private _vertexCompilationState;
  23177. private _fragmentCompilationState;
  23178. private _sharedData;
  23179. private _buildId;
  23180. private _buildWasSuccessful;
  23181. private _cachedWorldViewMatrix;
  23182. private _cachedWorldViewProjectionMatrix;
  23183. private _optimizers;
  23184. private _animationFrame;
  23185. /** Define the Url to load node editor script */
  23186. static EditorURL: string;
  23187. /** Define the Url to load snippets */
  23188. static SnippetUrl: string;
  23189. /** Gets or sets a boolean indicating that node materials should not deserialize textures from json / snippet content */
  23190. static IgnoreTexturesAtLoadTime: boolean;
  23191. private BJSNODEMATERIALEDITOR;
  23192. /** Get the inspector from bundle or global */
  23193. private _getGlobalNodeMaterialEditor;
  23194. /**
  23195. * Snippet ID if the material was created from the snippet server
  23196. */
  23197. snippetId: string;
  23198. /**
  23199. * Gets or sets data used by visual editor
  23200. * @see https://nme.babylonjs.com
  23201. */
  23202. editorData: any;
  23203. /**
  23204. * 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)
  23205. */
  23206. ignoreAlpha: boolean;
  23207. /**
  23208. * Defines the maximum number of lights that can be used in the material
  23209. */
  23210. maxSimultaneousLights: number;
  23211. /**
  23212. * Observable raised when the material is built
  23213. */
  23214. onBuildObservable: Observable<NodeMaterial>;
  23215. /**
  23216. * Gets or sets the root nodes of the material vertex shader
  23217. */
  23218. _vertexOutputNodes: NodeMaterialBlock[];
  23219. /**
  23220. * Gets or sets the root nodes of the material fragment (pixel) shader
  23221. */
  23222. _fragmentOutputNodes: NodeMaterialBlock[];
  23223. /** Gets or sets options to control the node material overall behavior */
  23224. get options(): INodeMaterialOptions;
  23225. set options(options: INodeMaterialOptions);
  23226. /**
  23227. * Default configuration related to image processing available in the standard Material.
  23228. */
  23229. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  23230. /**
  23231. * Gets the image processing configuration used either in this material.
  23232. */
  23233. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  23234. /**
  23235. * Sets the Default image processing configuration used either in the this material.
  23236. *
  23237. * If sets to null, the scene one is in use.
  23238. */
  23239. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  23240. /**
  23241. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  23242. */
  23243. attachedBlocks: NodeMaterialBlock[];
  23244. /**
  23245. * Specifies the mode of the node material
  23246. * @hidden
  23247. */
  23248. _mode: NodeMaterialModes;
  23249. /**
  23250. * Gets the mode property
  23251. */
  23252. get mode(): NodeMaterialModes;
  23253. /**
  23254. * Create a new node based material
  23255. * @param name defines the material name
  23256. * @param scene defines the hosting scene
  23257. * @param options defines creation option
  23258. */
  23259. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  23260. /**
  23261. * Gets the current class name of the material e.g. "NodeMaterial"
  23262. * @returns the class name
  23263. */
  23264. getClassName(): string;
  23265. /**
  23266. * Keep track of the image processing observer to allow dispose and replace.
  23267. */
  23268. private _imageProcessingObserver;
  23269. /**
  23270. * Attaches a new image processing configuration to the Standard Material.
  23271. * @param configuration
  23272. */
  23273. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  23274. /**
  23275. * Get a block by its name
  23276. * @param name defines the name of the block to retrieve
  23277. * @returns the required block or null if not found
  23278. */
  23279. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  23280. /**
  23281. * Get a block by its name
  23282. * @param predicate defines the predicate used to find the good candidate
  23283. * @returns the required block or null if not found
  23284. */
  23285. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  23286. /**
  23287. * Get an input block by its name
  23288. * @param predicate defines the predicate used to find the good candidate
  23289. * @returns the required input block or null if not found
  23290. */
  23291. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  23292. /**
  23293. * Gets the list of input blocks attached to this material
  23294. * @returns an array of InputBlocks
  23295. */
  23296. getInputBlocks(): InputBlock[];
  23297. /**
  23298. * Adds a new optimizer to the list of optimizers
  23299. * @param optimizer defines the optimizers to add
  23300. * @returns the current material
  23301. */
  23302. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  23303. /**
  23304. * Remove an optimizer from the list of optimizers
  23305. * @param optimizer defines the optimizers to remove
  23306. * @returns the current material
  23307. */
  23308. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  23309. /**
  23310. * Add a new block to the list of output nodes
  23311. * @param node defines the node to add
  23312. * @returns the current material
  23313. */
  23314. addOutputNode(node: NodeMaterialBlock): this;
  23315. /**
  23316. * Remove a block from the list of root nodes
  23317. * @param node defines the node to remove
  23318. * @returns the current material
  23319. */
  23320. removeOutputNode(node: NodeMaterialBlock): this;
  23321. private _addVertexOutputNode;
  23322. private _removeVertexOutputNode;
  23323. private _addFragmentOutputNode;
  23324. private _removeFragmentOutputNode;
  23325. /**
  23326. * Specifies if the material will require alpha blending
  23327. * @returns a boolean specifying if alpha blending is needed
  23328. */
  23329. needAlphaBlending(): boolean;
  23330. /**
  23331. * Specifies if this material should be rendered in alpha test mode
  23332. * @returns a boolean specifying if an alpha test is needed.
  23333. */
  23334. needAlphaTesting(): boolean;
  23335. private _initializeBlock;
  23336. private _resetDualBlocks;
  23337. /**
  23338. * Remove a block from the current node material
  23339. * @param block defines the block to remove
  23340. */
  23341. removeBlock(block: NodeMaterialBlock): void;
  23342. /**
  23343. * Build the material and generates the inner effect
  23344. * @param verbose defines if the build should log activity
  23345. */
  23346. build(verbose?: boolean): void;
  23347. /**
  23348. * Runs an otpimization phase to try to improve the shader code
  23349. */
  23350. optimize(): void;
  23351. private _prepareDefinesForAttributes;
  23352. /**
  23353. * Create a post process from the material
  23354. * @param camera The camera to apply the render pass to.
  23355. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  23356. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  23357. * @param engine The engine which the post process will be applied. (default: current engine)
  23358. * @param reusable If the post process can be reused on the same frame. (default: false)
  23359. * @param textureType Type of textures used when performing the post process. (default: 0)
  23360. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  23361. * @returns the post process created
  23362. */
  23363. createPostProcess(camera: Nullable<Camera>, options?: number | PostProcessOptions, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, textureFormat?: number): PostProcess;
  23364. /**
  23365. * Create the post process effect from the material
  23366. * @param postProcess The post process to create the effect for
  23367. */
  23368. createEffectForPostProcess(postProcess: PostProcess): void;
  23369. private _createEffectForPostProcess;
  23370. /**
  23371. * Create a new procedural texture based on this node material
  23372. * @param size defines the size of the texture
  23373. * @param scene defines the hosting scene
  23374. * @returns the new procedural texture attached to this node material
  23375. */
  23376. createProceduralTexture(size: number | {
  23377. width: number;
  23378. height: number;
  23379. layers?: number;
  23380. }, scene: Scene): ProceduralTexture;
  23381. private _createEffectForParticles;
  23382. private _checkInternals;
  23383. /**
  23384. * Create the effect to be used as the custom effect for a particle system
  23385. * @param particleSystem Particle system to create the effect for
  23386. * @param onCompiled defines a function to call when the effect creation is successful
  23387. * @param onError defines a function to call when the effect creation has failed
  23388. */
  23389. createEffectForParticles(particleSystem: IParticleSystem, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  23390. private _processDefines;
  23391. /**
  23392. * Get if the submesh is ready to be used and all its information available.
  23393. * Child classes can use it to update shaders
  23394. * @param mesh defines the mesh to check
  23395. * @param subMesh defines which submesh to check
  23396. * @param useInstances specifies that instances should be used
  23397. * @returns a boolean indicating that the submesh is ready or not
  23398. */
  23399. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  23400. /**
  23401. * Get a string representing the shaders built by the current node graph
  23402. */
  23403. get compiledShaders(): string;
  23404. /**
  23405. * Binds the world matrix to the material
  23406. * @param world defines the world transformation matrix
  23407. */
  23408. bindOnlyWorldMatrix(world: Matrix): void;
  23409. /**
  23410. * Binds the submesh to this material by preparing the effect and shader to draw
  23411. * @param world defines the world transformation matrix
  23412. * @param mesh defines the mesh containing the submesh
  23413. * @param subMesh defines the submesh to bind the material to
  23414. */
  23415. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  23416. /**
  23417. * Gets the active textures from the material
  23418. * @returns an array of textures
  23419. */
  23420. getActiveTextures(): BaseTexture[];
  23421. /**
  23422. * Gets the list of texture blocks
  23423. * @returns an array of texture blocks
  23424. */
  23425. getTextureBlocks(): (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  23426. /**
  23427. * Specifies if the material uses a texture
  23428. * @param texture defines the texture to check against the material
  23429. * @returns a boolean specifying if the material uses the texture
  23430. */
  23431. hasTexture(texture: BaseTexture): boolean;
  23432. /**
  23433. * Disposes the material
  23434. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  23435. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  23436. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  23437. */
  23438. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  23439. /** Creates the node editor window. */
  23440. private _createNodeEditor;
  23441. /**
  23442. * Launch the node material editor
  23443. * @param config Define the configuration of the editor
  23444. * @return a promise fulfilled when the node editor is visible
  23445. */
  23446. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  23447. /**
  23448. * Clear the current material
  23449. */
  23450. clear(): void;
  23451. /**
  23452. * Clear the current material and set it to a default state
  23453. */
  23454. setToDefault(): void;
  23455. /**
  23456. * Clear the current material and set it to a default state for post process
  23457. */
  23458. setToDefaultPostProcess(): void;
  23459. /**
  23460. * Clear the current material and set it to a default state for procedural texture
  23461. */
  23462. setToDefaultProceduralTexture(): void;
  23463. /**
  23464. * Clear the current material and set it to a default state for particle
  23465. */
  23466. setToDefaultParticle(): void;
  23467. /**
  23468. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  23469. * @param url defines the url to load from
  23470. * @returns a promise that will fullfil when the material is fully loaded
  23471. */
  23472. loadAsync(url: string): Promise<void>;
  23473. private _gatherBlocks;
  23474. /**
  23475. * Generate a string containing the code declaration required to create an equivalent of this material
  23476. * @returns a string
  23477. */
  23478. generateCode(): string;
  23479. /**
  23480. * Serializes this material in a JSON representation
  23481. * @returns the serialized material object
  23482. */
  23483. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  23484. private _restoreConnections;
  23485. /**
  23486. * Clear the current graph and load a new one from a serialization object
  23487. * @param source defines the JSON representation of the material
  23488. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  23489. * @param merge defines whether or not the source must be merged or replace the current content
  23490. */
  23491. loadFromSerialization(source: any, rootUrl?: string, merge?: boolean): void;
  23492. /**
  23493. * Makes a duplicate of the current material.
  23494. * @param name - name to use for the new material.
  23495. */
  23496. clone(name: string): NodeMaterial;
  23497. /**
  23498. * Creates a node material from parsed material data
  23499. * @param source defines the JSON representation of the material
  23500. * @param scene defines the hosting scene
  23501. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  23502. * @returns a new node material
  23503. */
  23504. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  23505. /**
  23506. * Creates a node material from a snippet saved in a remote file
  23507. * @param name defines the name of the material to create
  23508. * @param url defines the url to load from
  23509. * @param scene defines the hosting scene
  23510. * @returns a promise that will resolve to the new node material
  23511. */
  23512. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  23513. /**
  23514. * Creates a node material from a snippet saved by the node material editor
  23515. * @param snippetId defines the snippet to load
  23516. * @param scene defines the hosting scene
  23517. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  23518. * @param nodeMaterial defines a node material to update (instead of creating a new one)
  23519. * @returns a promise that will resolve to the new node material
  23520. */
  23521. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string, nodeMaterial?: NodeMaterial): Promise<NodeMaterial>;
  23522. /**
  23523. * Creates a new node material set to default basic configuration
  23524. * @param name defines the name of the material
  23525. * @param scene defines the hosting scene
  23526. * @returns a new NodeMaterial
  23527. */
  23528. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  23529. }
  23530. }
  23531. declare module "babylonjs/PostProcesses/postProcess" {
  23532. import { Nullable } from "babylonjs/types";
  23533. import { SmartArray } from "babylonjs/Misc/smartArray";
  23534. import { Observable } from "babylonjs/Misc/observable";
  23535. import { Vector2 } from "babylonjs/Maths/math.vector";
  23536. import { Camera } from "babylonjs/Cameras/camera";
  23537. import { Effect } from "babylonjs/Materials/effect";
  23538. import "babylonjs/Shaders/postprocess.vertex";
  23539. import { IInspectable } from "babylonjs/Misc/iInspectable";
  23540. import { Engine } from "babylonjs/Engines/engine";
  23541. import { Color4 } from "babylonjs/Maths/math.color";
  23542. import "babylonjs/Engines/Extensions/engine.renderTarget";
  23543. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  23544. import { Scene } from "babylonjs/scene";
  23545. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  23546. /**
  23547. * Size options for a post process
  23548. */
  23549. export type PostProcessOptions = {
  23550. width: number;
  23551. height: number;
  23552. };
  23553. /**
  23554. * PostProcess can be used to apply a shader to a texture after it has been rendered
  23555. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  23556. */
  23557. export class PostProcess {
  23558. /**
  23559. * Gets or sets the unique id of the post process
  23560. */
  23561. uniqueId: number;
  23562. /** Name of the PostProcess. */
  23563. name: string;
  23564. /**
  23565. * Width of the texture to apply the post process on
  23566. */
  23567. width: number;
  23568. /**
  23569. * Height of the texture to apply the post process on
  23570. */
  23571. height: number;
  23572. /**
  23573. * Gets the node material used to create this postprocess (null if the postprocess was manually created)
  23574. */
  23575. nodeMaterialSource: Nullable<NodeMaterial>;
  23576. /**
  23577. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  23578. * @hidden
  23579. */
  23580. _outputTexture: Nullable<InternalTexture>;
  23581. /**
  23582. * Sampling mode used by the shader
  23583. * See https://doc.babylonjs.com/classes/3.1/texture
  23584. */
  23585. renderTargetSamplingMode: number;
  23586. /**
  23587. * Clear color to use when screen clearing
  23588. */
  23589. clearColor: Color4;
  23590. /**
  23591. * If the buffer needs to be cleared before applying the post process. (default: true)
  23592. * Should be set to false if shader will overwrite all previous pixels.
  23593. */
  23594. autoClear: boolean;
  23595. /**
  23596. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  23597. */
  23598. alphaMode: number;
  23599. /**
  23600. * Sets the setAlphaBlendConstants of the babylon engine
  23601. */
  23602. alphaConstants: Color4;
  23603. /**
  23604. * Animations to be used for the post processing
  23605. */
  23606. animations: import("babylonjs/Animations/animation").Animation[];
  23607. /**
  23608. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  23609. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  23610. */
  23611. enablePixelPerfectMode: boolean;
  23612. /**
  23613. * Force the postprocess to be applied without taking in account viewport
  23614. */
  23615. forceFullscreenViewport: boolean;
  23616. /**
  23617. * List of inspectable custom properties (used by the Inspector)
  23618. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  23619. */
  23620. inspectableCustomProperties: IInspectable[];
  23621. /**
  23622. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  23623. *
  23624. * | Value | Type | Description |
  23625. * | ----- | ----------------------------------- | ----------- |
  23626. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  23627. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  23628. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  23629. *
  23630. */
  23631. scaleMode: number;
  23632. /**
  23633. * Force textures to be a power of two (default: false)
  23634. */
  23635. alwaysForcePOT: boolean;
  23636. private _samples;
  23637. /**
  23638. * Number of sample textures (default: 1)
  23639. */
  23640. get samples(): number;
  23641. set samples(n: number);
  23642. /**
  23643. * Modify the scale of the post process to be the same as the viewport (default: false)
  23644. */
  23645. adaptScaleToCurrentViewport: boolean;
  23646. private _camera;
  23647. protected _scene: Scene;
  23648. private _engine;
  23649. private _options;
  23650. private _reusable;
  23651. private _textureType;
  23652. private _textureFormat;
  23653. /**
  23654. * Smart array of input and output textures for the post process.
  23655. * @hidden
  23656. */
  23657. _textures: SmartArray<import("babylonjs/Materials/Textures/internalTexture").InternalTexture>;
  23658. /**
  23659. * The index in _textures that corresponds to the output texture.
  23660. * @hidden
  23661. */
  23662. _currentRenderTextureInd: number;
  23663. private _effect;
  23664. private _samplers;
  23665. private _fragmentUrl;
  23666. private _vertexUrl;
  23667. private _parameters;
  23668. private _scaleRatio;
  23669. protected _indexParameters: any;
  23670. private _shareOutputWithPostProcess;
  23671. private _texelSize;
  23672. private _forcedOutputTexture;
  23673. /**
  23674. * Returns the fragment url or shader name used in the post process.
  23675. * @returns the fragment url or name in the shader store.
  23676. */
  23677. getEffectName(): string;
  23678. /**
  23679. * An event triggered when the postprocess is activated.
  23680. */
  23681. onActivateObservable: Observable<Camera>;
  23682. private _onActivateObserver;
  23683. /**
  23684. * A function that is added to the onActivateObservable
  23685. */
  23686. set onActivate(callback: Nullable<(camera: Camera) => void>);
  23687. /**
  23688. * An event triggered when the postprocess changes its size.
  23689. */
  23690. onSizeChangedObservable: Observable<PostProcess>;
  23691. private _onSizeChangedObserver;
  23692. /**
  23693. * A function that is added to the onSizeChangedObservable
  23694. */
  23695. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  23696. /**
  23697. * An event triggered when the postprocess applies its effect.
  23698. */
  23699. onApplyObservable: Observable<Effect>;
  23700. private _onApplyObserver;
  23701. /**
  23702. * A function that is added to the onApplyObservable
  23703. */
  23704. set onApply(callback: (effect: Effect) => void);
  23705. /**
  23706. * An event triggered before rendering the postprocess
  23707. */
  23708. onBeforeRenderObservable: Observable<Effect>;
  23709. private _onBeforeRenderObserver;
  23710. /**
  23711. * A function that is added to the onBeforeRenderObservable
  23712. */
  23713. set onBeforeRender(callback: (effect: Effect) => void);
  23714. /**
  23715. * An event triggered after rendering the postprocess
  23716. */
  23717. onAfterRenderObservable: Observable<Effect>;
  23718. private _onAfterRenderObserver;
  23719. /**
  23720. * A function that is added to the onAfterRenderObservable
  23721. */
  23722. set onAfterRender(callback: (efect: Effect) => void);
  23723. /**
  23724. * 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
  23725. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  23726. */
  23727. get inputTexture(): InternalTexture;
  23728. set inputTexture(value: InternalTexture);
  23729. /**
  23730. * Since inputTexture should always be defined, if we previously manually set `inputTexture`,
  23731. * the only way to unset it is to use this function to restore its internal state
  23732. */
  23733. restoreDefaultInputTexture(): void;
  23734. /**
  23735. * Gets the camera which post process is applied to.
  23736. * @returns The camera the post process is applied to.
  23737. */
  23738. getCamera(): Camera;
  23739. /**
  23740. * Gets the texel size of the postprocess.
  23741. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  23742. */
  23743. get texelSize(): Vector2;
  23744. /**
  23745. * Creates a new instance PostProcess
  23746. * @param name The name of the PostProcess.
  23747. * @param fragmentUrl The url of the fragment shader to be used.
  23748. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  23749. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  23750. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  23751. * @param camera The camera to apply the render pass to.
  23752. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  23753. * @param engine The engine which the post process will be applied. (default: current engine)
  23754. * @param reusable If the post process can be reused on the same frame. (default: false)
  23755. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  23756. * @param textureType Type of textures used when performing the post process. (default: 0)
  23757. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  23758. * @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
  23759. * @param blockCompilation If the shader should not be compiled immediatly. (default: false)
  23760. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  23761. */
  23762. constructor(name: string, fragmentUrl: string, parameters: Nullable<string[]>, samplers: Nullable<string[]>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, defines?: Nullable<string>, textureType?: number, vertexUrl?: string, indexParameters?: any, blockCompilation?: boolean, textureFormat?: number);
  23763. /**
  23764. * Gets a string identifying the name of the class
  23765. * @returns "PostProcess" string
  23766. */
  23767. getClassName(): string;
  23768. /**
  23769. * Gets the engine which this post process belongs to.
  23770. * @returns The engine the post process was enabled with.
  23771. */
  23772. getEngine(): Engine;
  23773. /**
  23774. * The effect that is created when initializing the post process.
  23775. * @returns The created effect corresponding the the postprocess.
  23776. */
  23777. getEffect(): Effect;
  23778. /**
  23779. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  23780. * @param postProcess The post process to share the output with.
  23781. * @returns This post process.
  23782. */
  23783. shareOutputWith(postProcess: PostProcess): PostProcess;
  23784. /**
  23785. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  23786. * This should be called if the post process that shares output with this post process is disabled/disposed.
  23787. */
  23788. useOwnOutput(): void;
  23789. /**
  23790. * Updates the effect with the current post process compile time values and recompiles the shader.
  23791. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  23792. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  23793. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  23794. * @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
  23795. * @param onCompiled Called when the shader has been compiled.
  23796. * @param onError Called if there is an error when compiling a shader.
  23797. * @param vertexUrl The url of the vertex shader to be used (default: the one given at construction time)
  23798. * @param fragmentUrl The url of the fragment shader to be used (default: the one given at construction time)
  23799. */
  23800. 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;
  23801. /**
  23802. * The post process is reusable if it can be used multiple times within one frame.
  23803. * @returns If the post process is reusable
  23804. */
  23805. isReusable(): boolean;
  23806. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  23807. markTextureDirty(): void;
  23808. /**
  23809. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  23810. * 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.
  23811. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  23812. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  23813. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  23814. * @returns The target texture that was bound to be written to.
  23815. */
  23816. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  23817. /**
  23818. * If the post process is supported.
  23819. */
  23820. get isSupported(): boolean;
  23821. /**
  23822. * The aspect ratio of the output texture.
  23823. */
  23824. get aspectRatio(): number;
  23825. /**
  23826. * Get a value indicating if the post-process is ready to be used
  23827. * @returns true if the post-process is ready (shader is compiled)
  23828. */
  23829. isReady(): boolean;
  23830. /**
  23831. * Binds all textures and uniforms to the shader, this will be run on every pass.
  23832. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  23833. */
  23834. apply(): Nullable<Effect>;
  23835. private _disposeTextures;
  23836. /**
  23837. * Disposes the post process.
  23838. * @param camera The camera to dispose the post process on.
  23839. */
  23840. dispose(camera?: Camera): void;
  23841. /**
  23842. * Serializes the particle system to a JSON object
  23843. * @returns the JSON object
  23844. */
  23845. serialize(): any;
  23846. /**
  23847. * Creates a material from parsed material data
  23848. * @param parsedPostProcess defines parsed post process data
  23849. * @param scene defines the hosting scene
  23850. * @param rootUrl defines the root URL to use to load textures
  23851. * @returns a new post process
  23852. */
  23853. static Parse(parsedPostProcess: any, scene: Scene, rootUrl: string): Nullable<PostProcess>;
  23854. }
  23855. }
  23856. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration" {
  23857. /** @hidden */
  23858. export var kernelBlurVaryingDeclaration: {
  23859. name: string;
  23860. shader: string;
  23861. };
  23862. }
  23863. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment" {
  23864. /** @hidden */
  23865. export var kernelBlurFragment: {
  23866. name: string;
  23867. shader: string;
  23868. };
  23869. }
  23870. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2" {
  23871. /** @hidden */
  23872. export var kernelBlurFragment2: {
  23873. name: string;
  23874. shader: string;
  23875. };
  23876. }
  23877. declare module "babylonjs/Shaders/kernelBlur.fragment" {
  23878. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  23879. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  23880. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment";
  23881. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2";
  23882. /** @hidden */
  23883. export var kernelBlurPixelShader: {
  23884. name: string;
  23885. shader: string;
  23886. };
  23887. }
  23888. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVertex" {
  23889. /** @hidden */
  23890. export var kernelBlurVertex: {
  23891. name: string;
  23892. shader: string;
  23893. };
  23894. }
  23895. declare module "babylonjs/Shaders/kernelBlur.vertex" {
  23896. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  23897. import "babylonjs/Shaders/ShadersInclude/kernelBlurVertex";
  23898. /** @hidden */
  23899. export var kernelBlurVertexShader: {
  23900. name: string;
  23901. shader: string;
  23902. };
  23903. }
  23904. declare module "babylonjs/PostProcesses/blurPostProcess" {
  23905. import { Vector2 } from "babylonjs/Maths/math.vector";
  23906. import { Nullable } from "babylonjs/types";
  23907. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  23908. import { Camera } from "babylonjs/Cameras/camera";
  23909. import { Effect } from "babylonjs/Materials/effect";
  23910. import { Engine } from "babylonjs/Engines/engine";
  23911. import "babylonjs/Shaders/kernelBlur.fragment";
  23912. import "babylonjs/Shaders/kernelBlur.vertex";
  23913. import { Scene } from "babylonjs/scene";
  23914. /**
  23915. * The Blur Post Process which blurs an image based on a kernel and direction.
  23916. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  23917. */
  23918. export class BlurPostProcess extends PostProcess {
  23919. private blockCompilation;
  23920. protected _kernel: number;
  23921. protected _idealKernel: number;
  23922. protected _packedFloat: boolean;
  23923. private _staticDefines;
  23924. /** The direction in which to blur the image. */
  23925. direction: Vector2;
  23926. /**
  23927. * Sets the length in pixels of the blur sample region
  23928. */
  23929. set kernel(v: number);
  23930. /**
  23931. * Gets the length in pixels of the blur sample region
  23932. */
  23933. get kernel(): number;
  23934. /**
  23935. * Sets wether or not the blur needs to unpack/repack floats
  23936. */
  23937. set packedFloat(v: boolean);
  23938. /**
  23939. * Gets wether or not the blur is unpacking/repacking floats
  23940. */
  23941. get packedFloat(): boolean;
  23942. /**
  23943. * Gets a string identifying the name of the class
  23944. * @returns "BlurPostProcess" string
  23945. */
  23946. getClassName(): string;
  23947. /**
  23948. * Creates a new instance BlurPostProcess
  23949. * @param name The name of the effect.
  23950. * @param direction The direction in which to blur the image.
  23951. * @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.
  23952. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  23953. * @param camera The camera to apply the render pass to.
  23954. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  23955. * @param engine The engine which the post process will be applied. (default: current engine)
  23956. * @param reusable If the post process can be reused on the same frame. (default: false)
  23957. * @param textureType Type of textures used when performing the post process. (default: 0)
  23958. * @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)
  23959. */
  23960. constructor(name: string, direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  23961. /**
  23962. * Updates the effect with the current post process compile time values and recompiles the shader.
  23963. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  23964. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  23965. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  23966. * @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
  23967. * @param onCompiled Called when the shader has been compiled.
  23968. * @param onError Called if there is an error when compiling a shader.
  23969. */
  23970. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  23971. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  23972. /**
  23973. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  23974. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  23975. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  23976. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  23977. * The gaps between physical kernels are compensated for in the weighting of the samples
  23978. * @param idealKernel Ideal blur kernel.
  23979. * @return Nearest best kernel.
  23980. */
  23981. protected _nearestBestKernel(idealKernel: number): number;
  23982. /**
  23983. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  23984. * @param x The point on the Gaussian distribution to sample.
  23985. * @return the value of the Gaussian function at x.
  23986. */
  23987. protected _gaussianWeight(x: number): number;
  23988. /**
  23989. * Generates a string that can be used as a floating point number in GLSL.
  23990. * @param x Value to print.
  23991. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  23992. * @return GLSL float string.
  23993. */
  23994. protected _glslFloat(x: number, decimalFigures?: number): string;
  23995. /** @hidden */
  23996. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlurPostProcess>;
  23997. }
  23998. }
  23999. declare module "babylonjs/Materials/Textures/mirrorTexture" {
  24000. import { Scene } from "babylonjs/scene";
  24001. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  24002. import { Plane } from "babylonjs/Maths/math.plane";
  24003. /**
  24004. * Mirror texture can be used to simulate the view from a mirror in a scene.
  24005. * It will dynamically be rendered every frame to adapt to the camera point of view.
  24006. * You can then easily use it as a reflectionTexture on a flat surface.
  24007. * In case the surface is not a plane, please consider relying on reflection probes.
  24008. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  24009. */
  24010. export class MirrorTexture extends RenderTargetTexture {
  24011. private scene;
  24012. /**
  24013. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  24014. * 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.
  24015. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  24016. */
  24017. mirrorPlane: Plane;
  24018. /**
  24019. * Define the blur ratio used to blur the reflection if needed.
  24020. */
  24021. set blurRatio(value: number);
  24022. get blurRatio(): number;
  24023. /**
  24024. * Define the adaptive blur kernel used to blur the reflection if needed.
  24025. * This will autocompute the closest best match for the `blurKernel`
  24026. */
  24027. set adaptiveBlurKernel(value: number);
  24028. /**
  24029. * Define the blur kernel used to blur the reflection if needed.
  24030. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  24031. */
  24032. set blurKernel(value: number);
  24033. /**
  24034. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  24035. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  24036. */
  24037. set blurKernelX(value: number);
  24038. get blurKernelX(): number;
  24039. /**
  24040. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  24041. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  24042. */
  24043. set blurKernelY(value: number);
  24044. get blurKernelY(): number;
  24045. private _autoComputeBlurKernel;
  24046. protected _onRatioRescale(): void;
  24047. private _updateGammaSpace;
  24048. private _imageProcessingConfigChangeObserver;
  24049. private _transformMatrix;
  24050. private _mirrorMatrix;
  24051. private _savedViewMatrix;
  24052. private _blurX;
  24053. private _blurY;
  24054. private _adaptiveBlurKernel;
  24055. private _blurKernelX;
  24056. private _blurKernelY;
  24057. private _blurRatio;
  24058. /**
  24059. * Instantiates a Mirror Texture.
  24060. * Mirror texture can be used to simulate the view from a mirror in a scene.
  24061. * It will dynamically be rendered every frame to adapt to the camera point of view.
  24062. * You can then easily use it as a reflectionTexture on a flat surface.
  24063. * In case the surface is not a plane, please consider relying on reflection probes.
  24064. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  24065. * @param name
  24066. * @param size
  24067. * @param scene
  24068. * @param generateMipMaps
  24069. * @param type
  24070. * @param samplingMode
  24071. * @param generateDepthBuffer
  24072. */
  24073. constructor(name: string, size: number | {
  24074. width: number;
  24075. height: number;
  24076. } | {
  24077. ratio: number;
  24078. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  24079. private _preparePostProcesses;
  24080. /**
  24081. * Clone the mirror texture.
  24082. * @returns the cloned texture
  24083. */
  24084. clone(): MirrorTexture;
  24085. /**
  24086. * Serialize the texture to a JSON representation you could use in Parse later on
  24087. * @returns the serialized JSON representation
  24088. */
  24089. serialize(): any;
  24090. /**
  24091. * Dispose the texture and release its associated resources.
  24092. */
  24093. dispose(): void;
  24094. }
  24095. }
  24096. declare module "babylonjs/Materials/Textures/texture" {
  24097. import { Observable } from "babylonjs/Misc/observable";
  24098. import { Nullable } from "babylonjs/types";
  24099. import { Matrix } from "babylonjs/Maths/math.vector";
  24100. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  24101. import { IInspectable } from "babylonjs/Misc/iInspectable";
  24102. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  24103. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  24104. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  24105. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  24106. import { Scene } from "babylonjs/scene";
  24107. /**
  24108. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  24109. * @see https://doc.babylonjs.com/babylon101/materials#texture
  24110. */
  24111. export class Texture extends BaseTexture {
  24112. /**
  24113. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  24114. */
  24115. static SerializeBuffers: boolean;
  24116. /** @hidden */
  24117. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  24118. /** @hidden */
  24119. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  24120. /** @hidden */
  24121. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  24122. /** nearest is mag = nearest and min = nearest and mip = linear */
  24123. static readonly NEAREST_SAMPLINGMODE: number;
  24124. /** nearest is mag = nearest and min = nearest and mip = linear */
  24125. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  24126. /** Bilinear is mag = linear and min = linear and mip = nearest */
  24127. static readonly BILINEAR_SAMPLINGMODE: number;
  24128. /** Bilinear is mag = linear and min = linear and mip = nearest */
  24129. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  24130. /** Trilinear is mag = linear and min = linear and mip = linear */
  24131. static readonly TRILINEAR_SAMPLINGMODE: number;
  24132. /** Trilinear is mag = linear and min = linear and mip = linear */
  24133. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  24134. /** mag = nearest and min = nearest and mip = nearest */
  24135. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  24136. /** mag = nearest and min = linear and mip = nearest */
  24137. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  24138. /** mag = nearest and min = linear and mip = linear */
  24139. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  24140. /** mag = nearest and min = linear and mip = none */
  24141. static readonly NEAREST_LINEAR: number;
  24142. /** mag = nearest and min = nearest and mip = none */
  24143. static readonly NEAREST_NEAREST: number;
  24144. /** mag = linear and min = nearest and mip = nearest */
  24145. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  24146. /** mag = linear and min = nearest and mip = linear */
  24147. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  24148. /** mag = linear and min = linear and mip = none */
  24149. static readonly LINEAR_LINEAR: number;
  24150. /** mag = linear and min = nearest and mip = none */
  24151. static readonly LINEAR_NEAREST: number;
  24152. /** Explicit coordinates mode */
  24153. static readonly EXPLICIT_MODE: number;
  24154. /** Spherical coordinates mode */
  24155. static readonly SPHERICAL_MODE: number;
  24156. /** Planar coordinates mode */
  24157. static readonly PLANAR_MODE: number;
  24158. /** Cubic coordinates mode */
  24159. static readonly CUBIC_MODE: number;
  24160. /** Projection coordinates mode */
  24161. static readonly PROJECTION_MODE: number;
  24162. /** Inverse Cubic coordinates mode */
  24163. static readonly SKYBOX_MODE: number;
  24164. /** Inverse Cubic coordinates mode */
  24165. static readonly INVCUBIC_MODE: number;
  24166. /** Equirectangular coordinates mode */
  24167. static readonly EQUIRECTANGULAR_MODE: number;
  24168. /** Equirectangular Fixed coordinates mode */
  24169. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  24170. /** Equirectangular Fixed Mirrored coordinates mode */
  24171. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  24172. /** Texture is not repeating outside of 0..1 UVs */
  24173. static readonly CLAMP_ADDRESSMODE: number;
  24174. /** Texture is repeating outside of 0..1 UVs */
  24175. static readonly WRAP_ADDRESSMODE: number;
  24176. /** Texture is repeating and mirrored */
  24177. static readonly MIRROR_ADDRESSMODE: number;
  24178. /**
  24179. * 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
  24180. */
  24181. static UseSerializedUrlIfAny: boolean;
  24182. /**
  24183. * Define the url of the texture.
  24184. */
  24185. url: Nullable<string>;
  24186. /**
  24187. * Define an offset on the texture to offset the u coordinates of the UVs
  24188. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  24189. */
  24190. uOffset: number;
  24191. /**
  24192. * Define an offset on the texture to offset the v coordinates of the UVs
  24193. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  24194. */
  24195. vOffset: number;
  24196. /**
  24197. * Define an offset on the texture to scale the u coordinates of the UVs
  24198. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  24199. */
  24200. uScale: number;
  24201. /**
  24202. * Define an offset on the texture to scale the v coordinates of the UVs
  24203. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  24204. */
  24205. vScale: number;
  24206. /**
  24207. * Define an offset on the texture to rotate around the u coordinates of the UVs
  24208. * @see https://doc.babylonjs.com/how_to/more_materials
  24209. */
  24210. uAng: number;
  24211. /**
  24212. * Define an offset on the texture to rotate around the v coordinates of the UVs
  24213. * @see https://doc.babylonjs.com/how_to/more_materials
  24214. */
  24215. vAng: number;
  24216. /**
  24217. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  24218. * @see https://doc.babylonjs.com/how_to/more_materials
  24219. */
  24220. wAng: number;
  24221. /**
  24222. * Defines the center of rotation (U)
  24223. */
  24224. uRotationCenter: number;
  24225. /**
  24226. * Defines the center of rotation (V)
  24227. */
  24228. vRotationCenter: number;
  24229. /**
  24230. * Defines the center of rotation (W)
  24231. */
  24232. wRotationCenter: number;
  24233. /**
  24234. * Are mip maps generated for this texture or not.
  24235. */
  24236. get noMipmap(): boolean;
  24237. /**
  24238. * List of inspectable custom properties (used by the Inspector)
  24239. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  24240. */
  24241. inspectableCustomProperties: Nullable<IInspectable[]>;
  24242. private _noMipmap;
  24243. /** @hidden */
  24244. _invertY: boolean;
  24245. private _rowGenerationMatrix;
  24246. private _cachedTextureMatrix;
  24247. private _projectionModeMatrix;
  24248. private _t0;
  24249. private _t1;
  24250. private _t2;
  24251. private _cachedUOffset;
  24252. private _cachedVOffset;
  24253. private _cachedUScale;
  24254. private _cachedVScale;
  24255. private _cachedUAng;
  24256. private _cachedVAng;
  24257. private _cachedWAng;
  24258. private _cachedProjectionMatrixId;
  24259. private _cachedCoordinatesMode;
  24260. /** @hidden */
  24261. protected _initialSamplingMode: number;
  24262. /** @hidden */
  24263. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  24264. private _deleteBuffer;
  24265. protected _format: Nullable<number>;
  24266. private _delayedOnLoad;
  24267. private _delayedOnError;
  24268. private _mimeType?;
  24269. /** Returns the texture mime type if it was defined by a loader (undefined else) */
  24270. get mimeType(): string | undefined;
  24271. /**
  24272. * Observable triggered once the texture has been loaded.
  24273. */
  24274. onLoadObservable: Observable<Texture>;
  24275. protected _isBlocking: boolean;
  24276. /**
  24277. * Is the texture preventing material to render while loading.
  24278. * If false, a default texture will be used instead of the loading one during the preparation step.
  24279. */
  24280. set isBlocking(value: boolean);
  24281. get isBlocking(): boolean;
  24282. /**
  24283. * Get the current sampling mode associated with the texture.
  24284. */
  24285. get samplingMode(): number;
  24286. /**
  24287. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  24288. */
  24289. get invertY(): boolean;
  24290. /**
  24291. * Instantiates a new texture.
  24292. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  24293. * @see https://doc.babylonjs.com/babylon101/materials#texture
  24294. * @param url defines the url of the picture to load as a texture
  24295. * @param sceneOrEngine defines the scene or engine the texture will belong to
  24296. * @param noMipmap defines if the texture will require mip maps or not
  24297. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  24298. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  24299. * @param onLoad defines a callback triggered when the texture has been loaded
  24300. * @param onError defines a callback triggered when an error occurred during the loading session
  24301. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  24302. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  24303. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  24304. * @param mimeType defines an optional mime type information
  24305. */
  24306. 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);
  24307. /**
  24308. * Update the url (and optional buffer) of this texture if url was null during construction.
  24309. * @param url the url of the texture
  24310. * @param buffer the buffer of the texture (defaults to null)
  24311. * @param onLoad callback called when the texture is loaded (defaults to null)
  24312. */
  24313. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  24314. /**
  24315. * Finish the loading sequence of a texture flagged as delayed load.
  24316. * @hidden
  24317. */
  24318. delayLoad(): void;
  24319. private _prepareRowForTextureGeneration;
  24320. /**
  24321. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  24322. * @returns the transform matrix of the texture.
  24323. */
  24324. getTextureMatrix(uBase?: number): Matrix;
  24325. /**
  24326. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  24327. * @returns The reflection texture transform
  24328. */
  24329. getReflectionTextureMatrix(): Matrix;
  24330. /**
  24331. * Clones the texture.
  24332. * @returns the cloned texture
  24333. */
  24334. clone(): Texture;
  24335. /**
  24336. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  24337. * @returns The JSON representation of the texture
  24338. */
  24339. serialize(): any;
  24340. /**
  24341. * Get the current class name of the texture useful for serialization or dynamic coding.
  24342. * @returns "Texture"
  24343. */
  24344. getClassName(): string;
  24345. /**
  24346. * Dispose the texture and release its associated resources.
  24347. */
  24348. dispose(): void;
  24349. /**
  24350. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  24351. * @param parsedTexture Define the JSON representation of the texture
  24352. * @param scene Define the scene the parsed texture should be instantiated in
  24353. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  24354. * @returns The parsed texture if successful
  24355. */
  24356. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  24357. /**
  24358. * Creates a texture from its base 64 representation.
  24359. * @param data Define the base64 payload without the data: prefix
  24360. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  24361. * @param scene Define the scene the texture should belong to
  24362. * @param noMipmap Forces the texture to not create mip map information if true
  24363. * @param invertY define if the texture needs to be inverted on the y axis during loading
  24364. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  24365. * @param onLoad define a callback triggered when the texture has been loaded
  24366. * @param onError define a callback triggered when an error occurred during the loading session
  24367. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  24368. * @returns the created texture
  24369. */
  24370. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  24371. /**
  24372. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  24373. * @param data Define the base64 payload without the data: prefix
  24374. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  24375. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  24376. * @param scene Define the scene the texture should belong to
  24377. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  24378. * @param noMipmap Forces the texture to not create mip map information if true
  24379. * @param invertY define if the texture needs to be inverted on the y axis during loading
  24380. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  24381. * @param onLoad define a callback triggered when the texture has been loaded
  24382. * @param onError define a callback triggered when an error occurred during the loading session
  24383. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  24384. * @returns the created texture
  24385. */
  24386. 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;
  24387. }
  24388. }
  24389. declare module "babylonjs/PostProcesses/postProcessManager" {
  24390. import { Nullable } from "babylonjs/types";
  24391. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  24392. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  24393. import { Scene } from "babylonjs/scene";
  24394. /**
  24395. * PostProcessManager is used to manage one or more post processes or post process pipelines
  24396. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  24397. */
  24398. export class PostProcessManager {
  24399. private _scene;
  24400. private _indexBuffer;
  24401. private _vertexBuffers;
  24402. /**
  24403. * Creates a new instance PostProcess
  24404. * @param scene The scene that the post process is associated with.
  24405. */
  24406. constructor(scene: Scene);
  24407. private _prepareBuffers;
  24408. private _buildIndexBuffer;
  24409. /**
  24410. * Rebuilds the vertex buffers of the manager.
  24411. * @hidden
  24412. */
  24413. _rebuild(): void;
  24414. /**
  24415. * Prepares a frame to be run through a post process.
  24416. * @param sourceTexture The input texture to the post procesess. (default: null)
  24417. * @param postProcesses An array of post processes to be run. (default: null)
  24418. * @returns True if the post processes were able to be run.
  24419. * @hidden
  24420. */
  24421. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  24422. /**
  24423. * Manually render a set of post processes to a texture.
  24424. * Please note, the frame buffer won't be unbound after the call in case you have more render to do.
  24425. * @param postProcesses An array of post processes to be run.
  24426. * @param targetTexture The target texture to render to.
  24427. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  24428. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  24429. * @param lodLevel defines which lod of the texture to render to
  24430. * @param doNotBindFrambuffer If set to true, assumes that the framebuffer has been bound previously
  24431. */
  24432. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number, doNotBindFrambuffer?: boolean): void;
  24433. /**
  24434. * Finalize the result of the output of the postprocesses.
  24435. * @param doNotPresent If true the result will not be displayed to the screen.
  24436. * @param targetTexture The target texture to render to.
  24437. * @param faceIndex The index of the face to bind the target texture to.
  24438. * @param postProcesses The array of post processes to render.
  24439. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  24440. * @hidden
  24441. */
  24442. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  24443. /**
  24444. * Disposes of the post process manager.
  24445. */
  24446. dispose(): void;
  24447. }
  24448. }
  24449. declare module "babylonjs/Materials/Textures/renderTargetTexture" {
  24450. import { Observable } from "babylonjs/Misc/observable";
  24451. import { SmartArray } from "babylonjs/Misc/smartArray";
  24452. import { Nullable, Immutable } from "babylonjs/types";
  24453. import { Camera } from "babylonjs/Cameras/camera";
  24454. import { Scene } from "babylonjs/scene";
  24455. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  24456. import { Color4 } from "babylonjs/Maths/math.color";
  24457. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  24458. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24459. import { SubMesh } from "babylonjs/Meshes/subMesh";
  24460. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  24461. import { Texture } from "babylonjs/Materials/Textures/texture";
  24462. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  24463. import { RenderingManager } from "babylonjs/Rendering/renderingManager";
  24464. import "babylonjs/Engines/Extensions/engine.renderTarget";
  24465. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  24466. import { Engine } from "babylonjs/Engines/engine";
  24467. /**
  24468. * This Helps creating a texture that will be created from a camera in your scene.
  24469. * It is basically a dynamic texture that could be used to create special effects for instance.
  24470. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  24471. */
  24472. export class RenderTargetTexture extends Texture {
  24473. /**
  24474. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  24475. */
  24476. static readonly REFRESHRATE_RENDER_ONCE: number;
  24477. /**
  24478. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  24479. */
  24480. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  24481. /**
  24482. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  24483. * the central point of your effect and can save a lot of performances.
  24484. */
  24485. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  24486. /**
  24487. * Use this predicate to dynamically define the list of mesh you want to render.
  24488. * If set, the renderList property will be overwritten.
  24489. */
  24490. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  24491. private _renderList;
  24492. /**
  24493. * Use this list to define the list of mesh you want to render.
  24494. */
  24495. get renderList(): Nullable<Array<AbstractMesh>>;
  24496. set renderList(value: Nullable<Array<AbstractMesh>>);
  24497. /**
  24498. * Use this function to overload the renderList array at rendering time.
  24499. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  24500. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  24501. * the cube (if the RTT is a cube, else layerOrFace=0).
  24502. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  24503. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  24504. * hold dummy elements!
  24505. */
  24506. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  24507. private _hookArray;
  24508. /**
  24509. * Define if particles should be rendered in your texture.
  24510. */
  24511. renderParticles: boolean;
  24512. /**
  24513. * Define if sprites should be rendered in your texture.
  24514. */
  24515. renderSprites: boolean;
  24516. /**
  24517. * Define the camera used to render the texture.
  24518. */
  24519. activeCamera: Nullable<Camera>;
  24520. /**
  24521. * Override the mesh isReady function with your own one.
  24522. */
  24523. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  24524. /**
  24525. * Override the render function of the texture with your own one.
  24526. */
  24527. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  24528. /**
  24529. * Define if camera post processes should be use while rendering the texture.
  24530. */
  24531. useCameraPostProcesses: boolean;
  24532. /**
  24533. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  24534. */
  24535. ignoreCameraViewport: boolean;
  24536. private _postProcessManager;
  24537. private _postProcesses;
  24538. private _resizeObserver;
  24539. /**
  24540. * An event triggered when the texture is unbind.
  24541. */
  24542. onBeforeBindObservable: Observable<RenderTargetTexture>;
  24543. /**
  24544. * An event triggered when the texture is unbind.
  24545. */
  24546. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  24547. private _onAfterUnbindObserver;
  24548. /**
  24549. * Set a after unbind callback in the texture.
  24550. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  24551. */
  24552. set onAfterUnbind(callback: () => void);
  24553. /**
  24554. * An event triggered before rendering the texture
  24555. */
  24556. onBeforeRenderObservable: Observable<number>;
  24557. private _onBeforeRenderObserver;
  24558. /**
  24559. * Set a before render callback in the texture.
  24560. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  24561. */
  24562. set onBeforeRender(callback: (faceIndex: number) => void);
  24563. /**
  24564. * An event triggered after rendering the texture
  24565. */
  24566. onAfterRenderObservable: Observable<number>;
  24567. private _onAfterRenderObserver;
  24568. /**
  24569. * Set a after render callback in the texture.
  24570. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  24571. */
  24572. set onAfterRender(callback: (faceIndex: number) => void);
  24573. /**
  24574. * An event triggered after the texture clear
  24575. */
  24576. onClearObservable: Observable<Engine>;
  24577. private _onClearObserver;
  24578. /**
  24579. * Set a clear callback in the texture.
  24580. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  24581. */
  24582. set onClear(callback: (Engine: Engine) => void);
  24583. /**
  24584. * An event triggered when the texture is resized.
  24585. */
  24586. onResizeObservable: Observable<RenderTargetTexture>;
  24587. /**
  24588. * Define the clear color of the Render Target if it should be different from the scene.
  24589. */
  24590. clearColor: Color4;
  24591. protected _size: number | {
  24592. width: number;
  24593. height: number;
  24594. layers?: number;
  24595. };
  24596. protected _initialSizeParameter: number | {
  24597. width: number;
  24598. height: number;
  24599. } | {
  24600. ratio: number;
  24601. };
  24602. protected _sizeRatio: Nullable<number>;
  24603. /** @hidden */
  24604. _generateMipMaps: boolean;
  24605. protected _renderingManager: RenderingManager;
  24606. /** @hidden */
  24607. _waitingRenderList?: string[];
  24608. protected _doNotChangeAspectRatio: boolean;
  24609. protected _currentRefreshId: number;
  24610. protected _refreshRate: number;
  24611. protected _textureMatrix: Matrix;
  24612. protected _samples: number;
  24613. protected _renderTargetOptions: RenderTargetCreationOptions;
  24614. /**
  24615. * Gets render target creation options that were used.
  24616. */
  24617. get renderTargetOptions(): RenderTargetCreationOptions;
  24618. protected _onRatioRescale(): void;
  24619. /**
  24620. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  24621. * It must define where the camera used to render the texture is set
  24622. */
  24623. boundingBoxPosition: Vector3;
  24624. private _boundingBoxSize;
  24625. /**
  24626. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  24627. * When defined, the cubemap will switch to local mode
  24628. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  24629. * @example https://www.babylonjs-playground.com/#RNASML
  24630. */
  24631. set boundingBoxSize(value: Vector3);
  24632. get boundingBoxSize(): Vector3;
  24633. /**
  24634. * In case the RTT has been created with a depth texture, get the associated
  24635. * depth texture.
  24636. * Otherwise, return null.
  24637. */
  24638. get depthStencilTexture(): Nullable<InternalTexture>;
  24639. /**
  24640. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  24641. * or used a shadow, depth texture...
  24642. * @param name The friendly name of the texture
  24643. * @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)
  24644. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  24645. * @param generateMipMaps True if mip maps need to be generated after render.
  24646. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  24647. * @param type The type of the buffer in the RTT (int, half float, float...)
  24648. * @param isCube True if a cube texture needs to be created
  24649. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  24650. * @param generateDepthBuffer True to generate a depth buffer
  24651. * @param generateStencilBuffer True to generate a stencil buffer
  24652. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  24653. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  24654. * @param delayAllocation if the texture allocation should be delayed (default: false)
  24655. */
  24656. constructor(name: string, size: number | {
  24657. width: number;
  24658. height: number;
  24659. layers?: number;
  24660. } | {
  24661. ratio: number;
  24662. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  24663. /**
  24664. * Creates a depth stencil texture.
  24665. * This is only available in WebGL 2 or with the depth texture extension available.
  24666. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  24667. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  24668. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  24669. */
  24670. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  24671. private _processSizeParameter;
  24672. /**
  24673. * Define the number of samples to use in case of MSAA.
  24674. * It defaults to one meaning no MSAA has been enabled.
  24675. */
  24676. get samples(): number;
  24677. set samples(value: number);
  24678. /**
  24679. * Resets the refresh counter of the texture and start bak from scratch.
  24680. * Could be useful to regenerate the texture if it is setup to render only once.
  24681. */
  24682. resetRefreshCounter(): void;
  24683. /**
  24684. * Define the refresh rate of the texture or the rendering frequency.
  24685. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  24686. */
  24687. get refreshRate(): number;
  24688. set refreshRate(value: number);
  24689. /**
  24690. * Adds a post process to the render target rendering passes.
  24691. * @param postProcess define the post process to add
  24692. */
  24693. addPostProcess(postProcess: PostProcess): void;
  24694. /**
  24695. * Clear all the post processes attached to the render target
  24696. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  24697. */
  24698. clearPostProcesses(dispose?: boolean): void;
  24699. /**
  24700. * Remove one of the post process from the list of attached post processes to the texture
  24701. * @param postProcess define the post process to remove from the list
  24702. */
  24703. removePostProcess(postProcess: PostProcess): void;
  24704. /** @hidden */
  24705. _shouldRender(): boolean;
  24706. /**
  24707. * Gets the actual render size of the texture.
  24708. * @returns the width of the render size
  24709. */
  24710. getRenderSize(): number;
  24711. /**
  24712. * Gets the actual render width of the texture.
  24713. * @returns the width of the render size
  24714. */
  24715. getRenderWidth(): number;
  24716. /**
  24717. * Gets the actual render height of the texture.
  24718. * @returns the height of the render size
  24719. */
  24720. getRenderHeight(): number;
  24721. /**
  24722. * Gets the actual number of layers of the texture.
  24723. * @returns the number of layers
  24724. */
  24725. getRenderLayers(): number;
  24726. /**
  24727. * Get if the texture can be rescaled or not.
  24728. */
  24729. get canRescale(): boolean;
  24730. /**
  24731. * Resize the texture using a ratio.
  24732. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  24733. */
  24734. scale(ratio: number): void;
  24735. /**
  24736. * Get the texture reflection matrix used to rotate/transform the reflection.
  24737. * @returns the reflection matrix
  24738. */
  24739. getReflectionTextureMatrix(): Matrix;
  24740. /**
  24741. * Resize the texture to a new desired size.
  24742. * Be carrefull as it will recreate all the data in the new texture.
  24743. * @param size Define the new size. It can be:
  24744. * - a number for squared texture,
  24745. * - an object containing { width: number, height: number }
  24746. * - or an object containing a ratio { ratio: number }
  24747. */
  24748. resize(size: number | {
  24749. width: number;
  24750. height: number;
  24751. } | {
  24752. ratio: number;
  24753. }): void;
  24754. private _defaultRenderListPrepared;
  24755. /**
  24756. * Renders all the objects from the render list into the texture.
  24757. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  24758. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  24759. */
  24760. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  24761. private _bestReflectionRenderTargetDimension;
  24762. private _prepareRenderingManager;
  24763. /**
  24764. * @hidden
  24765. * @param faceIndex face index to bind to if this is a cubetexture
  24766. * @param layer defines the index of the texture to bind in the array
  24767. */
  24768. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  24769. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  24770. private renderToTarget;
  24771. /**
  24772. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  24773. * This allowed control for front to back rendering or reversly depending of the special needs.
  24774. *
  24775. * @param renderingGroupId The rendering group id corresponding to its index
  24776. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  24777. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  24778. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  24779. */
  24780. 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;
  24781. /**
  24782. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  24783. *
  24784. * @param renderingGroupId The rendering group id corresponding to its index
  24785. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  24786. */
  24787. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  24788. /**
  24789. * Clones the texture.
  24790. * @returns the cloned texture
  24791. */
  24792. clone(): RenderTargetTexture;
  24793. /**
  24794. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  24795. * @returns The JSON representation of the texture
  24796. */
  24797. serialize(): any;
  24798. /**
  24799. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  24800. */
  24801. disposeFramebufferObjects(): void;
  24802. /**
  24803. * Dispose the texture and release its associated resources.
  24804. */
  24805. dispose(): void;
  24806. /** @hidden */
  24807. _rebuild(): void;
  24808. /**
  24809. * Clear the info related to rendering groups preventing retention point in material dispose.
  24810. */
  24811. freeRenderingGroups(): void;
  24812. /**
  24813. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  24814. * @returns the view count
  24815. */
  24816. getViewCount(): number;
  24817. }
  24818. }
  24819. declare module "babylonjs/Misc/guid" {
  24820. /**
  24821. * Class used to manipulate GUIDs
  24822. */
  24823. export class GUID {
  24824. /**
  24825. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  24826. * Be aware Math.random() could cause collisions, but:
  24827. * "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"
  24828. * @returns a pseudo random id
  24829. */
  24830. static RandomId(): string;
  24831. }
  24832. }
  24833. declare module "babylonjs/Materials/shadowDepthWrapper" {
  24834. import { Nullable } from "babylonjs/types";
  24835. import { Scene } from "babylonjs/scene";
  24836. import { SubMesh } from "babylonjs/Meshes/subMesh";
  24837. import { Material } from "babylonjs/Materials/material";
  24838. import { Effect } from "babylonjs/Materials/effect";
  24839. import { ShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  24840. /**
  24841. * Options to be used when creating a shadow depth material
  24842. */
  24843. export interface IIOptionShadowDepthMaterial {
  24844. /** Variables in the vertex shader code that need to have their names remapped.
  24845. * The format is: ["var_name", "var_remapped_name", "var_name", "var_remapped_name", ...]
  24846. * "var_name" should be either: worldPos or vNormalW
  24847. * So, if the variable holding the world position in your vertex shader is not named worldPos, you must tell the system
  24848. * the name to use instead by using: ["worldPos", "myWorldPosVar"] assuming the variable is named myWorldPosVar in your code.
  24849. * If the normal must also be remapped: ["worldPos", "myWorldPosVar", "vNormalW", "myWorldNormal"]
  24850. */
  24851. remappedVariables?: string[];
  24852. /** Set standalone to true if the base material wrapped by ShadowDepthMaterial is not used for a regular object but for depth shadow generation only */
  24853. standalone?: boolean;
  24854. }
  24855. /**
  24856. * Class that can be used to wrap a base material to generate accurate shadows when using custom vertex/fragment code in the base material
  24857. */
  24858. export class ShadowDepthWrapper {
  24859. private _scene;
  24860. private _options?;
  24861. private _baseMaterial;
  24862. private _onEffectCreatedObserver;
  24863. private _subMeshToEffect;
  24864. private _subMeshToDepthEffect;
  24865. private _meshes;
  24866. /** @hidden */
  24867. _matriceNames: any;
  24868. /** Gets the standalone status of the wrapper */
  24869. get standalone(): boolean;
  24870. /** Gets the base material the wrapper is built upon */
  24871. get baseMaterial(): Material;
  24872. /**
  24873. * Instantiate a new shadow depth wrapper.
  24874. * It works by injecting some specific code in the vertex/fragment shaders of the base material and is used by a shadow generator to
  24875. * generate the shadow depth map. For more information, please refer to the documentation:
  24876. * https://doc.babylonjs.com/babylon101/shadows
  24877. * @param baseMaterial Material to wrap
  24878. * @param scene Define the scene the material belongs to
  24879. * @param options Options used to create the wrapper
  24880. */
  24881. constructor(baseMaterial: Material, scene: Scene, options?: IIOptionShadowDepthMaterial);
  24882. /**
  24883. * Gets the effect to use to generate the depth map
  24884. * @param subMesh subMesh to get the effect for
  24885. * @param shadowGenerator shadow generator to get the effect for
  24886. * @returns the effect to use to generate the depth map for the subMesh + shadow generator specified
  24887. */
  24888. getEffect(subMesh: Nullable<SubMesh>, shadowGenerator: ShadowGenerator): Nullable<Effect>;
  24889. /**
  24890. * Specifies that the submesh is ready to be used for depth rendering
  24891. * @param subMesh submesh to check
  24892. * @param defines the list of defines to take into account when checking the effect
  24893. * @param shadowGenerator combined with subMesh, it defines the effect to check
  24894. * @param useInstances specifies that instances should be used
  24895. * @returns a boolean indicating that the submesh is ready or not
  24896. */
  24897. isReadyForSubMesh(subMesh: SubMesh, defines: string[], shadowGenerator: ShadowGenerator, useInstances: boolean): boolean;
  24898. /**
  24899. * Disposes the resources
  24900. */
  24901. dispose(): void;
  24902. private _makeEffect;
  24903. }
  24904. }
  24905. declare module "babylonjs/Engines/Extensions/engine.multiRender" {
  24906. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  24907. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  24908. import { Nullable } from "babylonjs/types";
  24909. module "babylonjs/Engines/thinEngine" {
  24910. interface ThinEngine {
  24911. /**
  24912. * Unbind a list of render target textures from the webGL context
  24913. * This is used only when drawBuffer extension or webGL2 are active
  24914. * @param textures defines the render target textures to unbind
  24915. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  24916. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  24917. */
  24918. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  24919. /**
  24920. * Create a multi render target texture
  24921. * @see https://doc.babylonjs.com/features/webgl2#multiple-render-target
  24922. * @param size defines the size of the texture
  24923. * @param options defines the creation options
  24924. * @returns the cube texture as an InternalTexture
  24925. */
  24926. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  24927. /**
  24928. * Update the sample count for a given multiple render target texture
  24929. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  24930. * @param textures defines the textures to update
  24931. * @param samples defines the sample count to set
  24932. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  24933. */
  24934. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  24935. /**
  24936. * Select a subsets of attachments to draw to.
  24937. * @param attachments gl attachments
  24938. */
  24939. bindAttachments(attachments: number[]): void;
  24940. }
  24941. }
  24942. }
  24943. declare module "babylonjs/Materials/Textures/multiRenderTarget" {
  24944. import { Scene } from "babylonjs/scene";
  24945. import { Engine } from "babylonjs/Engines/engine";
  24946. import { Texture } from "babylonjs/Materials/Textures/texture";
  24947. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  24948. import "babylonjs/Engines/Extensions/engine.multiRender";
  24949. /**
  24950. * Creation options of the multi render target texture.
  24951. */
  24952. export interface IMultiRenderTargetOptions {
  24953. /**
  24954. * Define if the texture needs to create mip maps after render.
  24955. */
  24956. generateMipMaps?: boolean;
  24957. /**
  24958. * Define the types of all the draw buffers we want to create
  24959. */
  24960. types?: number[];
  24961. /**
  24962. * Define the sampling modes of all the draw buffers we want to create
  24963. */
  24964. samplingModes?: number[];
  24965. /**
  24966. * Define if a depth buffer is required
  24967. */
  24968. generateDepthBuffer?: boolean;
  24969. /**
  24970. * Define if a stencil buffer is required
  24971. */
  24972. generateStencilBuffer?: boolean;
  24973. /**
  24974. * Define if a depth texture is required instead of a depth buffer
  24975. */
  24976. generateDepthTexture?: boolean;
  24977. /**
  24978. * Define the number of desired draw buffers
  24979. */
  24980. textureCount?: number;
  24981. /**
  24982. * Define if aspect ratio should be adapted to the texture or stay the scene one
  24983. */
  24984. doNotChangeAspectRatio?: boolean;
  24985. /**
  24986. * Define the default type of the buffers we are creating
  24987. */
  24988. defaultType?: number;
  24989. }
  24990. /**
  24991. * A multi render target, like a render target provides the ability to render to a texture.
  24992. * Unlike the render target, it can render to several draw buffers in one draw.
  24993. * This is specially interesting in deferred rendering or for any effects requiring more than
  24994. * just one color from a single pass.
  24995. */
  24996. export class MultiRenderTarget extends RenderTargetTexture {
  24997. private _internalTextures;
  24998. private _textures;
  24999. private _multiRenderTargetOptions;
  25000. private _count;
  25001. /**
  25002. * Get if draw buffers are currently supported by the used hardware and browser.
  25003. */
  25004. get isSupported(): boolean;
  25005. /**
  25006. * Get the list of textures generated by the multi render target.
  25007. */
  25008. get textures(): Texture[];
  25009. /**
  25010. * Gets the number of textures in this MRT. This number can be different from `_textures.length` in case a depth texture is generated.
  25011. */
  25012. get count(): number;
  25013. /**
  25014. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  25015. */
  25016. get depthTexture(): Texture;
  25017. /**
  25018. * Set the wrapping mode on U of all the textures we are rendering to.
  25019. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  25020. */
  25021. set wrapU(wrap: number);
  25022. /**
  25023. * Set the wrapping mode on V of all the textures we are rendering to.
  25024. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  25025. */
  25026. set wrapV(wrap: number);
  25027. /**
  25028. * Instantiate a new multi render target texture.
  25029. * A multi render target, like a render target provides the ability to render to a texture.
  25030. * Unlike the render target, it can render to several draw buffers in one draw.
  25031. * This is specially interesting in deferred rendering or for any effects requiring more than
  25032. * just one color from a single pass.
  25033. * @param name Define the name of the texture
  25034. * @param size Define the size of the buffers to render to
  25035. * @param count Define the number of target we are rendering into
  25036. * @param scene Define the scene the texture belongs to
  25037. * @param options Define the options used to create the multi render target
  25038. */
  25039. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  25040. /** @hidden */
  25041. _rebuild(): void;
  25042. private _createInternalTextures;
  25043. private _createTextures;
  25044. /**
  25045. * Define the number of samples used if MSAA is enabled.
  25046. */
  25047. get samples(): number;
  25048. set samples(value: number);
  25049. /**
  25050. * Resize all the textures in the multi render target.
  25051. * Be carrefull as it will recreate all the data in the new texture.
  25052. * @param size Define the new size
  25053. */
  25054. resize(size: any): void;
  25055. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  25056. /**
  25057. * Dispose the render targets and their associated resources
  25058. */
  25059. dispose(): void;
  25060. /**
  25061. * Release all the underlying texture used as draw buffers.
  25062. */
  25063. releaseInternalTextures(): void;
  25064. }
  25065. }
  25066. declare module "babylonjs/Shaders/imageProcessing.fragment" {
  25067. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  25068. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  25069. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  25070. /** @hidden */
  25071. export var imageProcessingPixelShader: {
  25072. name: string;
  25073. shader: string;
  25074. };
  25075. }
  25076. declare module "babylonjs/PostProcesses/imageProcessingPostProcess" {
  25077. import { Nullable } from "babylonjs/types";
  25078. import { Color4 } from "babylonjs/Maths/math.color";
  25079. import { Camera } from "babylonjs/Cameras/camera";
  25080. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  25081. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  25082. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  25083. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  25084. import { Engine } from "babylonjs/Engines/engine";
  25085. import "babylonjs/Shaders/imageProcessing.fragment";
  25086. import "babylonjs/Shaders/postprocess.vertex";
  25087. /**
  25088. * ImageProcessingPostProcess
  25089. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  25090. */
  25091. export class ImageProcessingPostProcess extends PostProcess {
  25092. /**
  25093. * Default configuration related to image processing available in the PBR Material.
  25094. */
  25095. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  25096. /**
  25097. * Gets the image processing configuration used either in this material.
  25098. */
  25099. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  25100. /**
  25101. * Sets the Default image processing configuration used either in the this material.
  25102. *
  25103. * If sets to null, the scene one is in use.
  25104. */
  25105. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  25106. /**
  25107. * Keep track of the image processing observer to allow dispose and replace.
  25108. */
  25109. private _imageProcessingObserver;
  25110. /**
  25111. * Attaches a new image processing configuration to the PBR Material.
  25112. * @param configuration
  25113. */
  25114. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  25115. /**
  25116. * If the post process is supported.
  25117. */
  25118. get isSupported(): boolean;
  25119. /**
  25120. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  25121. */
  25122. get colorCurves(): Nullable<ColorCurves>;
  25123. /**
  25124. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  25125. */
  25126. set colorCurves(value: Nullable<ColorCurves>);
  25127. /**
  25128. * Gets wether the color curves effect is enabled.
  25129. */
  25130. get colorCurvesEnabled(): boolean;
  25131. /**
  25132. * Sets wether the color curves effect is enabled.
  25133. */
  25134. set colorCurvesEnabled(value: boolean);
  25135. /**
  25136. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  25137. */
  25138. get colorGradingTexture(): Nullable<BaseTexture>;
  25139. /**
  25140. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  25141. */
  25142. set colorGradingTexture(value: Nullable<BaseTexture>);
  25143. /**
  25144. * Gets wether the color grading effect is enabled.
  25145. */
  25146. get colorGradingEnabled(): boolean;
  25147. /**
  25148. * Gets wether the color grading effect is enabled.
  25149. */
  25150. set colorGradingEnabled(value: boolean);
  25151. /**
  25152. * Gets exposure used in the effect.
  25153. */
  25154. get exposure(): number;
  25155. /**
  25156. * Sets exposure used in the effect.
  25157. */
  25158. set exposure(value: number);
  25159. /**
  25160. * Gets wether tonemapping is enabled or not.
  25161. */
  25162. get toneMappingEnabled(): boolean;
  25163. /**
  25164. * Sets wether tonemapping is enabled or not
  25165. */
  25166. set toneMappingEnabled(value: boolean);
  25167. /**
  25168. * Gets the type of tone mapping effect.
  25169. */
  25170. get toneMappingType(): number;
  25171. /**
  25172. * Sets the type of tone mapping effect.
  25173. */
  25174. set toneMappingType(value: number);
  25175. /**
  25176. * Gets contrast used in the effect.
  25177. */
  25178. get contrast(): number;
  25179. /**
  25180. * Sets contrast used in the effect.
  25181. */
  25182. set contrast(value: number);
  25183. /**
  25184. * Gets Vignette stretch size.
  25185. */
  25186. get vignetteStretch(): number;
  25187. /**
  25188. * Sets Vignette stretch size.
  25189. */
  25190. set vignetteStretch(value: number);
  25191. /**
  25192. * Gets Vignette centre X Offset.
  25193. */
  25194. get vignetteCentreX(): number;
  25195. /**
  25196. * Sets Vignette centre X Offset.
  25197. */
  25198. set vignetteCentreX(value: number);
  25199. /**
  25200. * Gets Vignette centre Y Offset.
  25201. */
  25202. get vignetteCentreY(): number;
  25203. /**
  25204. * Sets Vignette centre Y Offset.
  25205. */
  25206. set vignetteCentreY(value: number);
  25207. /**
  25208. * Gets Vignette weight or intensity of the vignette effect.
  25209. */
  25210. get vignetteWeight(): number;
  25211. /**
  25212. * Sets Vignette weight or intensity of the vignette effect.
  25213. */
  25214. set vignetteWeight(value: number);
  25215. /**
  25216. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  25217. * if vignetteEnabled is set to true.
  25218. */
  25219. get vignetteColor(): Color4;
  25220. /**
  25221. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  25222. * if vignetteEnabled is set to true.
  25223. */
  25224. set vignetteColor(value: Color4);
  25225. /**
  25226. * Gets Camera field of view used by the Vignette effect.
  25227. */
  25228. get vignetteCameraFov(): number;
  25229. /**
  25230. * Sets Camera field of view used by the Vignette effect.
  25231. */
  25232. set vignetteCameraFov(value: number);
  25233. /**
  25234. * Gets the vignette blend mode allowing different kind of effect.
  25235. */
  25236. get vignetteBlendMode(): number;
  25237. /**
  25238. * Sets the vignette blend mode allowing different kind of effect.
  25239. */
  25240. set vignetteBlendMode(value: number);
  25241. /**
  25242. * Gets wether the vignette effect is enabled.
  25243. */
  25244. get vignetteEnabled(): boolean;
  25245. /**
  25246. * Sets wether the vignette effect is enabled.
  25247. */
  25248. set vignetteEnabled(value: boolean);
  25249. private _fromLinearSpace;
  25250. /**
  25251. * Gets wether the input of the processing is in Gamma or Linear Space.
  25252. */
  25253. get fromLinearSpace(): boolean;
  25254. /**
  25255. * Sets wether the input of the processing is in Gamma or Linear Space.
  25256. */
  25257. set fromLinearSpace(value: boolean);
  25258. /**
  25259. * Defines cache preventing GC.
  25260. */
  25261. private _defines;
  25262. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  25263. /**
  25264. * "ImageProcessingPostProcess"
  25265. * @returns "ImageProcessingPostProcess"
  25266. */
  25267. getClassName(): string;
  25268. /**
  25269. * @hidden
  25270. */
  25271. _updateParameters(): void;
  25272. dispose(camera?: Camera): void;
  25273. }
  25274. }
  25275. declare module "babylonjs/Shaders/ShadersInclude/fibonacci" {
  25276. /** @hidden */
  25277. export var fibonacci: {
  25278. name: string;
  25279. shader: string;
  25280. };
  25281. }
  25282. declare module "babylonjs/Shaders/ShadersInclude/subSurfaceScatteringFunctions" {
  25283. /** @hidden */
  25284. export var subSurfaceScatteringFunctions: {
  25285. name: string;
  25286. shader: string;
  25287. };
  25288. }
  25289. declare module "babylonjs/Shaders/ShadersInclude/diffusionProfile" {
  25290. /** @hidden */
  25291. export var diffusionProfile: {
  25292. name: string;
  25293. shader: string;
  25294. };
  25295. }
  25296. declare module "babylonjs/Shaders/subSurfaceScattering.fragment" {
  25297. import "babylonjs/Shaders/ShadersInclude/fibonacci";
  25298. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  25299. import "babylonjs/Shaders/ShadersInclude/subSurfaceScatteringFunctions";
  25300. import "babylonjs/Shaders/ShadersInclude/diffusionProfile";
  25301. /** @hidden */
  25302. export var subSurfaceScatteringPixelShader: {
  25303. name: string;
  25304. shader: string;
  25305. };
  25306. }
  25307. declare module "babylonjs/PostProcesses/subSurfaceScatteringPostProcess" {
  25308. import { Nullable } from "babylonjs/types";
  25309. import { Camera } from "babylonjs/Cameras/camera";
  25310. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  25311. import { Engine } from "babylonjs/Engines/engine";
  25312. import { Scene } from "babylonjs/scene";
  25313. import "babylonjs/Shaders/imageProcessing.fragment";
  25314. import "babylonjs/Shaders/subSurfaceScattering.fragment";
  25315. import "babylonjs/Shaders/postprocess.vertex";
  25316. /**
  25317. * Sub surface scattering post process
  25318. */
  25319. export class SubSurfaceScatteringPostProcess extends PostProcess {
  25320. /**
  25321. * Gets a string identifying the name of the class
  25322. * @returns "SubSurfaceScatteringPostProcess" string
  25323. */
  25324. getClassName(): string;
  25325. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  25326. }
  25327. }
  25328. declare module "babylonjs/Rendering/prePassEffectConfiguration" {
  25329. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  25330. /**
  25331. * Interface for defining prepass effects in the prepass post-process pipeline
  25332. */
  25333. export interface PrePassEffectConfiguration {
  25334. /**
  25335. * Post process to attach for this effect
  25336. */
  25337. postProcess: PostProcess;
  25338. /**
  25339. * Is the effect enabled
  25340. */
  25341. enabled: boolean;
  25342. /**
  25343. * Disposes the effect configuration
  25344. */
  25345. dispose(): void;
  25346. /**
  25347. * Disposes the effect configuration
  25348. */
  25349. createPostProcess: () => PostProcess;
  25350. }
  25351. }
  25352. declare module "babylonjs/Rendering/subSurfaceConfiguration" {
  25353. import { Scene } from "babylonjs/scene";
  25354. import { Color3 } from "babylonjs/Maths/math.color";
  25355. import { SubSurfaceScatteringPostProcess } from "babylonjs/PostProcesses/subSurfaceScatteringPostProcess";
  25356. import { PrePassEffectConfiguration } from "babylonjs/Rendering/prePassEffectConfiguration";
  25357. /**
  25358. * Contains all parameters needed for the prepass to perform
  25359. * screen space subsurface scattering
  25360. */
  25361. export class SubSurfaceConfiguration implements PrePassEffectConfiguration {
  25362. private _ssDiffusionS;
  25363. private _ssFilterRadii;
  25364. private _ssDiffusionD;
  25365. /**
  25366. * Post process to attach for screen space subsurface scattering
  25367. */
  25368. postProcess: SubSurfaceScatteringPostProcess;
  25369. /**
  25370. * Diffusion profile color for subsurface scattering
  25371. */
  25372. get ssDiffusionS(): number[];
  25373. /**
  25374. * Diffusion profile max color channel value for subsurface scattering
  25375. */
  25376. get ssDiffusionD(): number[];
  25377. /**
  25378. * Diffusion profile filter radius for subsurface scattering
  25379. */
  25380. get ssFilterRadii(): number[];
  25381. /**
  25382. * Is subsurface enabled
  25383. */
  25384. enabled: boolean;
  25385. /**
  25386. * Diffusion profile colors for subsurface scattering
  25387. * You can add one diffusion color using `addDiffusionProfile` on `scene.prePassRenderer`
  25388. * See ...
  25389. * Note that you can only store up to 5 of them
  25390. */
  25391. ssDiffusionProfileColors: Color3[];
  25392. /**
  25393. * Defines the ratio real world => scene units.
  25394. * Used for subsurface scattering
  25395. */
  25396. metersPerUnit: number;
  25397. private _scene;
  25398. /**
  25399. * Builds a subsurface configuration object
  25400. * @param scene The scene
  25401. */
  25402. constructor(scene: Scene);
  25403. /**
  25404. * Adds a new diffusion profile.
  25405. * Useful for more realistic subsurface scattering on diverse materials.
  25406. * @param color The color of the diffusion profile. Should be the average color of the material.
  25407. * @return The index of the diffusion profile for the material subsurface configuration
  25408. */
  25409. addDiffusionProfile(color: Color3): number;
  25410. /**
  25411. * Creates the sss post process
  25412. * @return The created post process
  25413. */
  25414. createPostProcess(): SubSurfaceScatteringPostProcess;
  25415. /**
  25416. * Deletes all diffusion profiles.
  25417. * Note that in order to render subsurface scattering, you should have at least 1 diffusion profile.
  25418. */
  25419. clearAllDiffusionProfiles(): void;
  25420. /**
  25421. * Disposes this object
  25422. */
  25423. dispose(): void;
  25424. /**
  25425. * @hidden
  25426. * https://zero-radiance.github.io/post/sampling-diffusion/
  25427. *
  25428. * Importance sample the normalized diffuse reflectance profile for the computed value of 's'.
  25429. * ------------------------------------------------------------------------------------
  25430. * R[r, phi, s] = s * (Exp[-r * s] + Exp[-r * s / 3]) / (8 * Pi * r)
  25431. * PDF[r, phi, s] = r * R[r, phi, s]
  25432. * CDF[r, s] = 1 - 1/4 * Exp[-r * s] - 3/4 * Exp[-r * s / 3]
  25433. * ------------------------------------------------------------------------------------
  25434. * We importance sample the color channel with the widest scattering distance.
  25435. */
  25436. getDiffusionProfileParameters(color: Color3): number;
  25437. /**
  25438. * Performs sampling of a Normalized Burley diffusion profile in polar coordinates.
  25439. * 'u' is the random number (the value of the CDF): [0, 1).
  25440. * rcp(s) = 1 / ShapeParam = ScatteringDistance.
  25441. * Returns the sampled radial distance, s.t. (u = 0 -> r = 0) and (u = 1 -> r = Inf).
  25442. */
  25443. private _sampleBurleyDiffusionProfile;
  25444. }
  25445. }
  25446. declare module "babylonjs/Rendering/prePassRenderer" {
  25447. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  25448. import { Scene } from "babylonjs/scene";
  25449. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  25450. import { Effect } from "babylonjs/Materials/effect";
  25451. import { SubSurfaceConfiguration } from "babylonjs/Rendering/subSurfaceConfiguration";
  25452. /**
  25453. * Renders a pre pass of the scene
  25454. * This means every mesh in the scene will be rendered to a render target texture
  25455. * And then this texture will be composited to the rendering canvas with post processes
  25456. * It is necessary for effects like subsurface scattering or deferred shading
  25457. */
  25458. export class PrePassRenderer {
  25459. /** @hidden */
  25460. static _SceneComponentInitialization: (scene: Scene) => void;
  25461. private _scene;
  25462. private _engine;
  25463. private _isDirty;
  25464. /**
  25465. * Number of textures in the multi render target texture where the scene is directly rendered
  25466. */
  25467. readonly mrtCount: number;
  25468. /**
  25469. * The render target where the scene is directly rendered
  25470. */
  25471. prePassRT: MultiRenderTarget;
  25472. private _mrtTypes;
  25473. private _multiRenderAttachments;
  25474. private _defaultAttachments;
  25475. private _clearAttachments;
  25476. private _postProcesses;
  25477. private readonly _clearColor;
  25478. /**
  25479. * Image processing post process for composition
  25480. */
  25481. imageProcessingPostProcess: ImageProcessingPostProcess;
  25482. /**
  25483. * Configuration for sub surface scattering post process
  25484. */
  25485. subSurfaceConfiguration: SubSurfaceConfiguration;
  25486. /**
  25487. * Should materials render their geometry on the MRT
  25488. */
  25489. materialsShouldRenderGeometry: boolean;
  25490. /**
  25491. * Should materials render the irradiance information on the MRT
  25492. */
  25493. materialsShouldRenderIrradiance: boolean;
  25494. private _enabled;
  25495. /**
  25496. * Indicates if the prepass is enabled
  25497. */
  25498. get enabled(): boolean;
  25499. /**
  25500. * How many samples are used for MSAA of the scene render target
  25501. */
  25502. get samples(): number;
  25503. set samples(n: number);
  25504. /**
  25505. * Instanciates a prepass renderer
  25506. * @param scene The scene
  25507. */
  25508. constructor(scene: Scene);
  25509. private _initializeAttachments;
  25510. private _createCompositionEffect;
  25511. /**
  25512. * Indicates if rendering a prepass is supported
  25513. */
  25514. get isSupported(): boolean;
  25515. /**
  25516. * Sets the proper output textures to draw in the engine.
  25517. * @param effect The effect that is drawn. It can be or not be compatible with drawing to several output textures.
  25518. */
  25519. bindAttachmentsForEffect(effect: Effect): void;
  25520. /**
  25521. * @hidden
  25522. */
  25523. _beforeCameraDraw(): void;
  25524. /**
  25525. * @hidden
  25526. */
  25527. _afterCameraDraw(): void;
  25528. private _checkRTSize;
  25529. private _bindFrameBuffer;
  25530. /**
  25531. * Clears the scene render target (in the sense of settings pixels to the scene clear color value)
  25532. */
  25533. clear(): void;
  25534. private _setState;
  25535. private _enable;
  25536. private _disable;
  25537. private _resetPostProcessChain;
  25538. private _bindPostProcessChain;
  25539. /**
  25540. * Marks the prepass renderer as dirty, triggering a check if the prepass is necessary for the next rendering.
  25541. */
  25542. markAsDirty(): void;
  25543. private _update;
  25544. /**
  25545. * Disposes the prepass renderer.
  25546. */
  25547. dispose(): void;
  25548. }
  25549. }
  25550. declare module "babylonjs/Materials/material" {
  25551. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  25552. import { SmartArray } from "babylonjs/Misc/smartArray";
  25553. import { Observable } from "babylonjs/Misc/observable";
  25554. import { Nullable } from "babylonjs/types";
  25555. import { Scene } from "babylonjs/scene";
  25556. import { Matrix } from "babylonjs/Maths/math.vector";
  25557. import { SubMesh } from "babylonjs/Meshes/subMesh";
  25558. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25559. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  25560. import { Effect } from "babylonjs/Materials/effect";
  25561. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  25562. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  25563. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  25564. import { IInspectable } from "babylonjs/Misc/iInspectable";
  25565. import { ShadowDepthWrapper } from "babylonjs/Materials/shadowDepthWrapper";
  25566. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  25567. import { Mesh } from "babylonjs/Meshes/mesh";
  25568. import { Animation } from "babylonjs/Animations/animation";
  25569. /**
  25570. * Options for compiling materials.
  25571. */
  25572. export interface IMaterialCompilationOptions {
  25573. /**
  25574. * Defines whether clip planes are enabled.
  25575. */
  25576. clipPlane: boolean;
  25577. /**
  25578. * Defines whether instances are enabled.
  25579. */
  25580. useInstances: boolean;
  25581. }
  25582. /**
  25583. * Options passed when calling customShaderNameResolve
  25584. */
  25585. export interface ICustomShaderNameResolveOptions {
  25586. /**
  25587. * 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
  25588. */
  25589. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  25590. }
  25591. /**
  25592. * Base class for the main features of a material in Babylon.js
  25593. */
  25594. export class Material implements IAnimatable {
  25595. /**
  25596. * Returns the triangle fill mode
  25597. */
  25598. static readonly TriangleFillMode: number;
  25599. /**
  25600. * Returns the wireframe mode
  25601. */
  25602. static readonly WireFrameFillMode: number;
  25603. /**
  25604. * Returns the point fill mode
  25605. */
  25606. static readonly PointFillMode: number;
  25607. /**
  25608. * Returns the point list draw mode
  25609. */
  25610. static readonly PointListDrawMode: number;
  25611. /**
  25612. * Returns the line list draw mode
  25613. */
  25614. static readonly LineListDrawMode: number;
  25615. /**
  25616. * Returns the line loop draw mode
  25617. */
  25618. static readonly LineLoopDrawMode: number;
  25619. /**
  25620. * Returns the line strip draw mode
  25621. */
  25622. static readonly LineStripDrawMode: number;
  25623. /**
  25624. * Returns the triangle strip draw mode
  25625. */
  25626. static readonly TriangleStripDrawMode: number;
  25627. /**
  25628. * Returns the triangle fan draw mode
  25629. */
  25630. static readonly TriangleFanDrawMode: number;
  25631. /**
  25632. * Stores the clock-wise side orientation
  25633. */
  25634. static readonly ClockWiseSideOrientation: number;
  25635. /**
  25636. * Stores the counter clock-wise side orientation
  25637. */
  25638. static readonly CounterClockWiseSideOrientation: number;
  25639. /**
  25640. * The dirty texture flag value
  25641. */
  25642. static readonly TextureDirtyFlag: number;
  25643. /**
  25644. * The dirty light flag value
  25645. */
  25646. static readonly LightDirtyFlag: number;
  25647. /**
  25648. * The dirty fresnel flag value
  25649. */
  25650. static readonly FresnelDirtyFlag: number;
  25651. /**
  25652. * The dirty attribute flag value
  25653. */
  25654. static readonly AttributesDirtyFlag: number;
  25655. /**
  25656. * The dirty misc flag value
  25657. */
  25658. static readonly MiscDirtyFlag: number;
  25659. /**
  25660. * The all dirty flag value
  25661. */
  25662. static readonly AllDirtyFlag: number;
  25663. /**
  25664. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  25665. */
  25666. static readonly MATERIAL_OPAQUE: number;
  25667. /**
  25668. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  25669. */
  25670. static readonly MATERIAL_ALPHATEST: number;
  25671. /**
  25672. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  25673. */
  25674. static readonly MATERIAL_ALPHABLEND: number;
  25675. /**
  25676. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  25677. * They are also discarded below the alpha cutoff threshold to improve performances.
  25678. */
  25679. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  25680. /**
  25681. * The Whiteout method is used to blend normals.
  25682. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  25683. */
  25684. static readonly MATERIAL_NORMALBLENDMETHOD_WHITEOUT: number;
  25685. /**
  25686. * The Reoriented Normal Mapping method is used to blend normals.
  25687. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  25688. */
  25689. static readonly MATERIAL_NORMALBLENDMETHOD_RNM: number;
  25690. /**
  25691. * Custom callback helping to override the default shader used in the material.
  25692. */
  25693. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: MaterialDefines | string[], attributes?: string[], options?: ICustomShaderNameResolveOptions) => string;
  25694. /**
  25695. * Custom shadow depth material to use for shadow rendering instead of the in-built one
  25696. */
  25697. shadowDepthWrapper: Nullable<ShadowDepthWrapper>;
  25698. /**
  25699. * Gets or sets a boolean indicating that the material is allowed (if supported) to do shader hot swapping.
  25700. * This means that the material can keep using a previous shader while a new one is being compiled.
  25701. * This is mostly used when shader parallel compilation is supported (true by default)
  25702. */
  25703. allowShaderHotSwapping: boolean;
  25704. /**
  25705. * The ID of the material
  25706. */
  25707. id: string;
  25708. /**
  25709. * Gets or sets the unique id of the material
  25710. */
  25711. uniqueId: number;
  25712. /**
  25713. * The name of the material
  25714. */
  25715. name: string;
  25716. /**
  25717. * Gets or sets user defined metadata
  25718. */
  25719. metadata: any;
  25720. /**
  25721. * For internal use only. Please do not use.
  25722. */
  25723. reservedDataStore: any;
  25724. /**
  25725. * Specifies if the ready state should be checked on each call
  25726. */
  25727. checkReadyOnEveryCall: boolean;
  25728. /**
  25729. * Specifies if the ready state should be checked once
  25730. */
  25731. checkReadyOnlyOnce: boolean;
  25732. /**
  25733. * The state of the material
  25734. */
  25735. state: string;
  25736. /**
  25737. * If the material can be rendered to several textures with MRT extension
  25738. */
  25739. get canRenderToMRT(): boolean;
  25740. /**
  25741. * The alpha value of the material
  25742. */
  25743. protected _alpha: number;
  25744. /**
  25745. * List of inspectable custom properties (used by the Inspector)
  25746. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  25747. */
  25748. inspectableCustomProperties: IInspectable[];
  25749. /**
  25750. * Sets the alpha value of the material
  25751. */
  25752. set alpha(value: number);
  25753. /**
  25754. * Gets the alpha value of the material
  25755. */
  25756. get alpha(): number;
  25757. /**
  25758. * Specifies if back face culling is enabled
  25759. */
  25760. protected _backFaceCulling: boolean;
  25761. /**
  25762. * Sets the back-face culling state
  25763. */
  25764. set backFaceCulling(value: boolean);
  25765. /**
  25766. * Gets the back-face culling state
  25767. */
  25768. get backFaceCulling(): boolean;
  25769. /**
  25770. * Stores the value for side orientation
  25771. */
  25772. sideOrientation: number;
  25773. /**
  25774. * Callback triggered when the material is compiled
  25775. */
  25776. onCompiled: Nullable<(effect: Effect) => void>;
  25777. /**
  25778. * Callback triggered when an error occurs
  25779. */
  25780. onError: Nullable<(effect: Effect, errors: string) => void>;
  25781. /**
  25782. * Callback triggered to get the render target textures
  25783. */
  25784. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  25785. /**
  25786. * Gets a boolean indicating that current material needs to register RTT
  25787. */
  25788. get hasRenderTargetTextures(): boolean;
  25789. /**
  25790. * Specifies if the material should be serialized
  25791. */
  25792. doNotSerialize: boolean;
  25793. /**
  25794. * @hidden
  25795. */
  25796. _storeEffectOnSubMeshes: boolean;
  25797. /**
  25798. * Stores the animations for the material
  25799. */
  25800. animations: Nullable<Array<Animation>>;
  25801. /**
  25802. * An event triggered when the material is disposed
  25803. */
  25804. onDisposeObservable: Observable<Material>;
  25805. /**
  25806. * An observer which watches for dispose events
  25807. */
  25808. private _onDisposeObserver;
  25809. private _onUnBindObservable;
  25810. /**
  25811. * Called during a dispose event
  25812. */
  25813. set onDispose(callback: () => void);
  25814. private _onBindObservable;
  25815. /**
  25816. * An event triggered when the material is bound
  25817. */
  25818. get onBindObservable(): Observable<AbstractMesh>;
  25819. /**
  25820. * An observer which watches for bind events
  25821. */
  25822. private _onBindObserver;
  25823. /**
  25824. * Called during a bind event
  25825. */
  25826. set onBind(callback: (Mesh: AbstractMesh) => void);
  25827. /**
  25828. * An event triggered when the material is unbound
  25829. */
  25830. get onUnBindObservable(): Observable<Material>;
  25831. protected _onEffectCreatedObservable: Nullable<Observable<{
  25832. effect: Effect;
  25833. subMesh: Nullable<SubMesh>;
  25834. }>>;
  25835. /**
  25836. * An event triggered when the effect is (re)created
  25837. */
  25838. get onEffectCreatedObservable(): Observable<{
  25839. effect: Effect;
  25840. subMesh: Nullable<SubMesh>;
  25841. }>;
  25842. /**
  25843. * Stores the value of the alpha mode
  25844. */
  25845. private _alphaMode;
  25846. /**
  25847. * Sets the value of the alpha mode.
  25848. *
  25849. * | Value | Type | Description |
  25850. * | --- | --- | --- |
  25851. * | 0 | ALPHA_DISABLE | |
  25852. * | 1 | ALPHA_ADD | |
  25853. * | 2 | ALPHA_COMBINE | |
  25854. * | 3 | ALPHA_SUBTRACT | |
  25855. * | 4 | ALPHA_MULTIPLY | |
  25856. * | 5 | ALPHA_MAXIMIZED | |
  25857. * | 6 | ALPHA_ONEONE | |
  25858. * | 7 | ALPHA_PREMULTIPLIED | |
  25859. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  25860. * | 9 | ALPHA_INTERPOLATE | |
  25861. * | 10 | ALPHA_SCREENMODE | |
  25862. *
  25863. */
  25864. set alphaMode(value: number);
  25865. /**
  25866. * Gets the value of the alpha mode
  25867. */
  25868. get alphaMode(): number;
  25869. /**
  25870. * Stores the state of the need depth pre-pass value
  25871. */
  25872. private _needDepthPrePass;
  25873. /**
  25874. * Sets the need depth pre-pass value
  25875. */
  25876. set needDepthPrePass(value: boolean);
  25877. /**
  25878. * Gets the depth pre-pass value
  25879. */
  25880. get needDepthPrePass(): boolean;
  25881. /**
  25882. * Specifies if depth writing should be disabled
  25883. */
  25884. disableDepthWrite: boolean;
  25885. /**
  25886. * Specifies if color writing should be disabled
  25887. */
  25888. disableColorWrite: boolean;
  25889. /**
  25890. * Specifies if depth writing should be forced
  25891. */
  25892. forceDepthWrite: boolean;
  25893. /**
  25894. * Specifies the depth function that should be used. 0 means the default engine function
  25895. */
  25896. depthFunction: number;
  25897. /**
  25898. * Specifies if there should be a separate pass for culling
  25899. */
  25900. separateCullingPass: boolean;
  25901. /**
  25902. * Stores the state specifing if fog should be enabled
  25903. */
  25904. private _fogEnabled;
  25905. /**
  25906. * Sets the state for enabling fog
  25907. */
  25908. set fogEnabled(value: boolean);
  25909. /**
  25910. * Gets the value of the fog enabled state
  25911. */
  25912. get fogEnabled(): boolean;
  25913. /**
  25914. * Stores the size of points
  25915. */
  25916. pointSize: number;
  25917. /**
  25918. * Stores the z offset value
  25919. */
  25920. zOffset: number;
  25921. get wireframe(): boolean;
  25922. /**
  25923. * Sets the state of wireframe mode
  25924. */
  25925. set wireframe(value: boolean);
  25926. /**
  25927. * Gets the value specifying if point clouds are enabled
  25928. */
  25929. get pointsCloud(): boolean;
  25930. /**
  25931. * Sets the state of point cloud mode
  25932. */
  25933. set pointsCloud(value: boolean);
  25934. /**
  25935. * Gets the material fill mode
  25936. */
  25937. get fillMode(): number;
  25938. /**
  25939. * Sets the material fill mode
  25940. */
  25941. set fillMode(value: number);
  25942. /**
  25943. * @hidden
  25944. * Stores the effects for the material
  25945. */
  25946. _effect: Nullable<Effect>;
  25947. /**
  25948. * Specifies if uniform buffers should be used
  25949. */
  25950. private _useUBO;
  25951. /**
  25952. * Stores a reference to the scene
  25953. */
  25954. private _scene;
  25955. /**
  25956. * Stores the fill mode state
  25957. */
  25958. private _fillMode;
  25959. /**
  25960. * Specifies if the depth write state should be cached
  25961. */
  25962. private _cachedDepthWriteState;
  25963. /**
  25964. * Specifies if the color write state should be cached
  25965. */
  25966. private _cachedColorWriteState;
  25967. /**
  25968. * Specifies if the depth function state should be cached
  25969. */
  25970. private _cachedDepthFunctionState;
  25971. /**
  25972. * Stores the uniform buffer
  25973. */
  25974. protected _uniformBuffer: UniformBuffer;
  25975. /** @hidden */
  25976. _indexInSceneMaterialArray: number;
  25977. /** @hidden */
  25978. meshMap: Nullable<{
  25979. [id: string]: AbstractMesh | undefined;
  25980. }>;
  25981. /**
  25982. * Creates a material instance
  25983. * @param name defines the name of the material
  25984. * @param scene defines the scene to reference
  25985. * @param doNotAdd specifies if the material should be added to the scene
  25986. */
  25987. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  25988. /**
  25989. * Returns a string representation of the current material
  25990. * @param fullDetails defines a boolean indicating which levels of logging is desired
  25991. * @returns a string with material information
  25992. */
  25993. toString(fullDetails?: boolean): string;
  25994. /**
  25995. * Gets the class name of the material
  25996. * @returns a string with the class name of the material
  25997. */
  25998. getClassName(): string;
  25999. /**
  26000. * Specifies if updates for the material been locked
  26001. */
  26002. get isFrozen(): boolean;
  26003. /**
  26004. * Locks updates for the material
  26005. */
  26006. freeze(): void;
  26007. /**
  26008. * Unlocks updates for the material
  26009. */
  26010. unfreeze(): void;
  26011. /**
  26012. * Specifies if the material is ready to be used
  26013. * @param mesh defines the mesh to check
  26014. * @param useInstances specifies if instances should be used
  26015. * @returns a boolean indicating if the material is ready to be used
  26016. */
  26017. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  26018. /**
  26019. * Specifies that the submesh is ready to be used
  26020. * @param mesh defines the mesh to check
  26021. * @param subMesh defines which submesh to check
  26022. * @param useInstances specifies that instances should be used
  26023. * @returns a boolean indicating that the submesh is ready or not
  26024. */
  26025. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  26026. /**
  26027. * Returns the material effect
  26028. * @returns the effect associated with the material
  26029. */
  26030. getEffect(): Nullable<Effect>;
  26031. /**
  26032. * Returns the current scene
  26033. * @returns a Scene
  26034. */
  26035. getScene(): Scene;
  26036. /**
  26037. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  26038. */
  26039. protected _forceAlphaTest: boolean;
  26040. /**
  26041. * The transparency mode of the material.
  26042. */
  26043. protected _transparencyMode: Nullable<number>;
  26044. /**
  26045. * Gets the current transparency mode.
  26046. */
  26047. get transparencyMode(): Nullable<number>;
  26048. /**
  26049. * Sets the transparency mode of the material.
  26050. *
  26051. * | Value | Type | Description |
  26052. * | ----- | ----------------------------------- | ----------- |
  26053. * | 0 | OPAQUE | |
  26054. * | 1 | ALPHATEST | |
  26055. * | 2 | ALPHABLEND | |
  26056. * | 3 | ALPHATESTANDBLEND | |
  26057. *
  26058. */
  26059. set transparencyMode(value: Nullable<number>);
  26060. /**
  26061. * Returns true if alpha blending should be disabled.
  26062. */
  26063. protected get _disableAlphaBlending(): boolean;
  26064. /**
  26065. * Specifies whether or not this material should be rendered in alpha blend mode.
  26066. * @returns a boolean specifying if alpha blending is needed
  26067. */
  26068. needAlphaBlending(): boolean;
  26069. /**
  26070. * Specifies if the mesh will require alpha blending
  26071. * @param mesh defines the mesh to check
  26072. * @returns a boolean specifying if alpha blending is needed for the mesh
  26073. */
  26074. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  26075. /**
  26076. * Specifies whether or not this material should be rendered in alpha test mode.
  26077. * @returns a boolean specifying if an alpha test is needed.
  26078. */
  26079. needAlphaTesting(): boolean;
  26080. /**
  26081. * Specifies if material alpha testing should be turned on for the mesh
  26082. * @param mesh defines the mesh to check
  26083. */
  26084. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  26085. /**
  26086. * Gets the texture used for the alpha test
  26087. * @returns the texture to use for alpha testing
  26088. */
  26089. getAlphaTestTexture(): Nullable<BaseTexture>;
  26090. /**
  26091. * Marks the material to indicate that it needs to be re-calculated
  26092. */
  26093. markDirty(): void;
  26094. /** @hidden */
  26095. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  26096. /**
  26097. * Binds the material to the mesh
  26098. * @param world defines the world transformation matrix
  26099. * @param mesh defines the mesh to bind the material to
  26100. */
  26101. bind(world: Matrix, mesh?: Mesh): void;
  26102. /**
  26103. * Binds the submesh to the material
  26104. * @param world defines the world transformation matrix
  26105. * @param mesh defines the mesh containing the submesh
  26106. * @param subMesh defines the submesh to bind the material to
  26107. */
  26108. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  26109. /**
  26110. * Binds the world matrix to the material
  26111. * @param world defines the world transformation matrix
  26112. */
  26113. bindOnlyWorldMatrix(world: Matrix): void;
  26114. /**
  26115. * Binds the scene's uniform buffer to the effect.
  26116. * @param effect defines the effect to bind to the scene uniform buffer
  26117. * @param sceneUbo defines the uniform buffer storing scene data
  26118. */
  26119. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  26120. /**
  26121. * Binds the view matrix to the effect
  26122. * @param effect defines the effect to bind the view matrix to
  26123. */
  26124. bindView(effect: Effect): void;
  26125. /**
  26126. * Binds the view projection matrix to the effect
  26127. * @param effect defines the effect to bind the view projection matrix to
  26128. */
  26129. bindViewProjection(effect: Effect): void;
  26130. /**
  26131. * Processes to execute after binding the material to a mesh
  26132. * @param mesh defines the rendered mesh
  26133. */
  26134. protected _afterBind(mesh?: Mesh): void;
  26135. /**
  26136. * Unbinds the material from the mesh
  26137. */
  26138. unbind(): void;
  26139. /**
  26140. * Gets the active textures from the material
  26141. * @returns an array of textures
  26142. */
  26143. getActiveTextures(): BaseTexture[];
  26144. /**
  26145. * Specifies if the material uses a texture
  26146. * @param texture defines the texture to check against the material
  26147. * @returns a boolean specifying if the material uses the texture
  26148. */
  26149. hasTexture(texture: BaseTexture): boolean;
  26150. /**
  26151. * Makes a duplicate of the material, and gives it a new name
  26152. * @param name defines the new name for the duplicated material
  26153. * @returns the cloned material
  26154. */
  26155. clone(name: string): Nullable<Material>;
  26156. /**
  26157. * Gets the meshes bound to the material
  26158. * @returns an array of meshes bound to the material
  26159. */
  26160. getBindedMeshes(): AbstractMesh[];
  26161. /**
  26162. * Force shader compilation
  26163. * @param mesh defines the mesh associated with this material
  26164. * @param onCompiled defines a function to execute once the material is compiled
  26165. * @param options defines the options to configure the compilation
  26166. * @param onError defines a function to execute if the material fails compiling
  26167. */
  26168. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  26169. /**
  26170. * Force shader compilation
  26171. * @param mesh defines the mesh that will use this material
  26172. * @param options defines additional options for compiling the shaders
  26173. * @returns a promise that resolves when the compilation completes
  26174. */
  26175. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  26176. private static readonly _AllDirtyCallBack;
  26177. private static readonly _ImageProcessingDirtyCallBack;
  26178. private static readonly _TextureDirtyCallBack;
  26179. private static readonly _FresnelDirtyCallBack;
  26180. private static readonly _MiscDirtyCallBack;
  26181. private static readonly _LightsDirtyCallBack;
  26182. private static readonly _AttributeDirtyCallBack;
  26183. private static _FresnelAndMiscDirtyCallBack;
  26184. private static _TextureAndMiscDirtyCallBack;
  26185. private static readonly _DirtyCallbackArray;
  26186. private static readonly _RunDirtyCallBacks;
  26187. /**
  26188. * Marks a define in the material to indicate that it needs to be re-computed
  26189. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  26190. */
  26191. markAsDirty(flag: number): void;
  26192. /**
  26193. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  26194. * @param func defines a function which checks material defines against the submeshes
  26195. */
  26196. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  26197. /**
  26198. * Indicates that the scene should check if the rendering now needs a prepass
  26199. */
  26200. protected _markScenePrePassDirty(): void;
  26201. /**
  26202. * Indicates that we need to re-calculated for all submeshes
  26203. */
  26204. protected _markAllSubMeshesAsAllDirty(): void;
  26205. /**
  26206. * Indicates that image processing needs to be re-calculated for all submeshes
  26207. */
  26208. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  26209. /**
  26210. * Indicates that textures need to be re-calculated for all submeshes
  26211. */
  26212. protected _markAllSubMeshesAsTexturesDirty(): void;
  26213. /**
  26214. * Indicates that fresnel needs to be re-calculated for all submeshes
  26215. */
  26216. protected _markAllSubMeshesAsFresnelDirty(): void;
  26217. /**
  26218. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  26219. */
  26220. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  26221. /**
  26222. * Indicates that lights need to be re-calculated for all submeshes
  26223. */
  26224. protected _markAllSubMeshesAsLightsDirty(): void;
  26225. /**
  26226. * Indicates that attributes need to be re-calculated for all submeshes
  26227. */
  26228. protected _markAllSubMeshesAsAttributesDirty(): void;
  26229. /**
  26230. * Indicates that misc needs to be re-calculated for all submeshes
  26231. */
  26232. protected _markAllSubMeshesAsMiscDirty(): void;
  26233. /**
  26234. * Indicates that textures and misc need to be re-calculated for all submeshes
  26235. */
  26236. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  26237. /**
  26238. * Sets the required values to the prepass renderer.
  26239. * @param prePassRenderer defines the prepass renderer to setup.
  26240. * @returns true if the pre pass is needed.
  26241. */
  26242. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  26243. /**
  26244. * Disposes the material
  26245. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  26246. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  26247. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  26248. */
  26249. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  26250. /** @hidden */
  26251. private releaseVertexArrayObject;
  26252. /**
  26253. * Serializes this material
  26254. * @returns the serialized material object
  26255. */
  26256. serialize(): any;
  26257. /**
  26258. * Creates a material from parsed material data
  26259. * @param parsedMaterial defines parsed material data
  26260. * @param scene defines the hosting scene
  26261. * @param rootUrl defines the root URL to use to load textures
  26262. * @returns a new material
  26263. */
  26264. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  26265. }
  26266. }
  26267. declare module "babylonjs/Materials/multiMaterial" {
  26268. import { Nullable } from "babylonjs/types";
  26269. import { Scene } from "babylonjs/scene";
  26270. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26271. import { SubMesh } from "babylonjs/Meshes/subMesh";
  26272. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  26273. import { Material } from "babylonjs/Materials/material";
  26274. /**
  26275. * A multi-material is used to apply different materials to different parts of the same object without the need of
  26276. * separate meshes. This can be use to improve performances.
  26277. * @see https://doc.babylonjs.com/how_to/multi_materials
  26278. */
  26279. export class MultiMaterial extends Material {
  26280. private _subMaterials;
  26281. /**
  26282. * Gets or Sets the list of Materials used within the multi material.
  26283. * They need to be ordered according to the submeshes order in the associated mesh
  26284. */
  26285. get subMaterials(): Nullable<Material>[];
  26286. set subMaterials(value: Nullable<Material>[]);
  26287. /**
  26288. * Function used to align with Node.getChildren()
  26289. * @returns the list of Materials used within the multi material
  26290. */
  26291. getChildren(): Nullable<Material>[];
  26292. /**
  26293. * Instantiates a new Multi Material
  26294. * A multi-material is used to apply different materials to different parts of the same object without the need of
  26295. * separate meshes. This can be use to improve performances.
  26296. * @see https://doc.babylonjs.com/how_to/multi_materials
  26297. * @param name Define the name in the scene
  26298. * @param scene Define the scene the material belongs to
  26299. */
  26300. constructor(name: string, scene: Scene);
  26301. private _hookArray;
  26302. /**
  26303. * Get one of the submaterial by its index in the submaterials array
  26304. * @param index The index to look the sub material at
  26305. * @returns The Material if the index has been defined
  26306. */
  26307. getSubMaterial(index: number): Nullable<Material>;
  26308. /**
  26309. * Get the list of active textures for the whole sub materials list.
  26310. * @returns All the textures that will be used during the rendering
  26311. */
  26312. getActiveTextures(): BaseTexture[];
  26313. /**
  26314. * Gets the current class name of the material e.g. "MultiMaterial"
  26315. * Mainly use in serialization.
  26316. * @returns the class name
  26317. */
  26318. getClassName(): string;
  26319. /**
  26320. * Checks if the material is ready to render the requested sub mesh
  26321. * @param mesh Define the mesh the submesh belongs to
  26322. * @param subMesh Define the sub mesh to look readyness for
  26323. * @param useInstances Define whether or not the material is used with instances
  26324. * @returns true if ready, otherwise false
  26325. */
  26326. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  26327. /**
  26328. * Clones the current material and its related sub materials
  26329. * @param name Define the name of the newly cloned material
  26330. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  26331. * @returns the cloned material
  26332. */
  26333. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  26334. /**
  26335. * Serializes the materials into a JSON representation.
  26336. * @returns the JSON representation
  26337. */
  26338. serialize(): any;
  26339. /**
  26340. * Dispose the material and release its associated resources
  26341. * @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)
  26342. * @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)
  26343. * @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)
  26344. */
  26345. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  26346. /**
  26347. * Creates a MultiMaterial from parsed MultiMaterial data.
  26348. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  26349. * @param scene defines the hosting scene
  26350. * @returns a new MultiMaterial
  26351. */
  26352. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  26353. }
  26354. }
  26355. declare module "babylonjs/Meshes/subMesh" {
  26356. import { Nullable, IndicesArray, DeepImmutable, FloatArray } from "babylonjs/types";
  26357. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  26358. import { Engine } from "babylonjs/Engines/engine";
  26359. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  26360. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  26361. import { Effect } from "babylonjs/Materials/effect";
  26362. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  26363. import { Plane } from "babylonjs/Maths/math.plane";
  26364. import { Collider } from "babylonjs/Collisions/collider";
  26365. import { Material } from "babylonjs/Materials/material";
  26366. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  26367. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26368. import { Mesh } from "babylonjs/Meshes/mesh";
  26369. import { Ray } from "babylonjs/Culling/ray";
  26370. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  26371. /**
  26372. * Defines a subdivision inside a mesh
  26373. */
  26374. export class SubMesh implements ICullable {
  26375. /** the material index to use */
  26376. materialIndex: number;
  26377. /** vertex index start */
  26378. verticesStart: number;
  26379. /** vertices count */
  26380. verticesCount: number;
  26381. /** index start */
  26382. indexStart: number;
  26383. /** indices count */
  26384. indexCount: number;
  26385. /** @hidden */
  26386. _materialDefines: Nullable<MaterialDefines>;
  26387. /** @hidden */
  26388. _materialEffect: Nullable<Effect>;
  26389. /** @hidden */
  26390. _effectOverride: Nullable<Effect>;
  26391. /**
  26392. * Gets material defines used by the effect associated to the sub mesh
  26393. */
  26394. get materialDefines(): Nullable<MaterialDefines>;
  26395. /**
  26396. * Sets material defines used by the effect associated to the sub mesh
  26397. */
  26398. set materialDefines(defines: Nullable<MaterialDefines>);
  26399. /**
  26400. * Gets associated effect
  26401. */
  26402. get effect(): Nullable<Effect>;
  26403. /**
  26404. * Sets associated effect (effect used to render this submesh)
  26405. * @param effect defines the effect to associate with
  26406. * @param defines defines the set of defines used to compile this effect
  26407. */
  26408. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  26409. /** @hidden */
  26410. _linesIndexCount: number;
  26411. private _mesh;
  26412. private _renderingMesh;
  26413. private _boundingInfo;
  26414. private _linesIndexBuffer;
  26415. /** @hidden */
  26416. _lastColliderWorldVertices: Nullable<Vector3[]>;
  26417. /** @hidden */
  26418. _trianglePlanes: Plane[];
  26419. /** @hidden */
  26420. _lastColliderTransformMatrix: Nullable<Matrix>;
  26421. /** @hidden */
  26422. _renderId: number;
  26423. /** @hidden */
  26424. _alphaIndex: number;
  26425. /** @hidden */
  26426. _distanceToCamera: number;
  26427. /** @hidden */
  26428. _id: number;
  26429. private _currentMaterial;
  26430. /**
  26431. * Add a new submesh to a mesh
  26432. * @param materialIndex defines the material index to use
  26433. * @param verticesStart defines vertex index start
  26434. * @param verticesCount defines vertices count
  26435. * @param indexStart defines index start
  26436. * @param indexCount defines indices count
  26437. * @param mesh defines the parent mesh
  26438. * @param renderingMesh defines an optional rendering mesh
  26439. * @param createBoundingBox defines if bounding box should be created for this submesh
  26440. * @returns the new submesh
  26441. */
  26442. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  26443. /**
  26444. * Creates a new submesh
  26445. * @param materialIndex defines the material index to use
  26446. * @param verticesStart defines vertex index start
  26447. * @param verticesCount defines vertices count
  26448. * @param indexStart defines index start
  26449. * @param indexCount defines indices count
  26450. * @param mesh defines the parent mesh
  26451. * @param renderingMesh defines an optional rendering mesh
  26452. * @param createBoundingBox defines if bounding box should be created for this submesh
  26453. * @param addToMesh defines a boolean indicating that the submesh must be added to the mesh.subMeshes array (true by default)
  26454. */
  26455. constructor(
  26456. /** the material index to use */
  26457. materialIndex: number,
  26458. /** vertex index start */
  26459. verticesStart: number,
  26460. /** vertices count */
  26461. verticesCount: number,
  26462. /** index start */
  26463. indexStart: number,
  26464. /** indices count */
  26465. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean, addToMesh?: boolean);
  26466. /**
  26467. * Returns true if this submesh covers the entire parent mesh
  26468. * @ignorenaming
  26469. */
  26470. get IsGlobal(): boolean;
  26471. /**
  26472. * Returns the submesh BoudingInfo object
  26473. * @returns current bounding info (or mesh's one if the submesh is global)
  26474. */
  26475. getBoundingInfo(): BoundingInfo;
  26476. /**
  26477. * Sets the submesh BoundingInfo
  26478. * @param boundingInfo defines the new bounding info to use
  26479. * @returns the SubMesh
  26480. */
  26481. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  26482. /**
  26483. * Returns the mesh of the current submesh
  26484. * @return the parent mesh
  26485. */
  26486. getMesh(): AbstractMesh;
  26487. /**
  26488. * Returns the rendering mesh of the submesh
  26489. * @returns the rendering mesh (could be different from parent mesh)
  26490. */
  26491. getRenderingMesh(): Mesh;
  26492. /**
  26493. * Returns the replacement mesh of the submesh
  26494. * @returns the replacement mesh (could be different from parent mesh)
  26495. */
  26496. getReplacementMesh(): Nullable<AbstractMesh>;
  26497. /**
  26498. * Returns the effective mesh of the submesh
  26499. * @returns the effective mesh (could be different from parent mesh)
  26500. */
  26501. getEffectiveMesh(): AbstractMesh;
  26502. /**
  26503. * Returns the submesh material
  26504. * @returns null or the current material
  26505. */
  26506. getMaterial(): Nullable<Material>;
  26507. private _IsMultiMaterial;
  26508. /**
  26509. * Sets a new updated BoundingInfo object to the submesh
  26510. * @param data defines an optional position array to use to determine the bounding info
  26511. * @returns the SubMesh
  26512. */
  26513. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  26514. /** @hidden */
  26515. _checkCollision(collider: Collider): boolean;
  26516. /**
  26517. * Updates the submesh BoundingInfo
  26518. * @param world defines the world matrix to use to update the bounding info
  26519. * @returns the submesh
  26520. */
  26521. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  26522. /**
  26523. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  26524. * @param frustumPlanes defines the frustum planes
  26525. * @returns true if the submesh is intersecting with the frustum
  26526. */
  26527. isInFrustum(frustumPlanes: Plane[]): boolean;
  26528. /**
  26529. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  26530. * @param frustumPlanes defines the frustum planes
  26531. * @returns true if the submesh is inside the frustum
  26532. */
  26533. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  26534. /**
  26535. * Renders the submesh
  26536. * @param enableAlphaMode defines if alpha needs to be used
  26537. * @returns the submesh
  26538. */
  26539. render(enableAlphaMode: boolean): SubMesh;
  26540. /**
  26541. * @hidden
  26542. */
  26543. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  26544. /**
  26545. * Checks if the submesh intersects with a ray
  26546. * @param ray defines the ray to test
  26547. * @returns true is the passed ray intersects the submesh bounding box
  26548. */
  26549. canIntersects(ray: Ray): boolean;
  26550. /**
  26551. * Intersects current submesh with a ray
  26552. * @param ray defines the ray to test
  26553. * @param positions defines mesh's positions array
  26554. * @param indices defines mesh's indices array
  26555. * @param fastCheck defines if the first intersection will be used (and not the closest)
  26556. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  26557. * @returns intersection info or null if no intersection
  26558. */
  26559. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  26560. /** @hidden */
  26561. private _intersectLines;
  26562. /** @hidden */
  26563. private _intersectUnIndexedLines;
  26564. /** @hidden */
  26565. private _intersectTriangles;
  26566. /** @hidden */
  26567. private _intersectUnIndexedTriangles;
  26568. /** @hidden */
  26569. _rebuild(): void;
  26570. /**
  26571. * Creates a new submesh from the passed mesh
  26572. * @param newMesh defines the new hosting mesh
  26573. * @param newRenderingMesh defines an optional rendering mesh
  26574. * @returns the new submesh
  26575. */
  26576. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  26577. /**
  26578. * Release associated resources
  26579. */
  26580. dispose(): void;
  26581. /**
  26582. * Gets the class name
  26583. * @returns the string "SubMesh".
  26584. */
  26585. getClassName(): string;
  26586. /**
  26587. * Creates a new submesh from indices data
  26588. * @param materialIndex the index of the main mesh material
  26589. * @param startIndex the index where to start the copy in the mesh indices array
  26590. * @param indexCount the number of indices to copy then from the startIndex
  26591. * @param mesh the main mesh to create the submesh from
  26592. * @param renderingMesh the optional rendering mesh
  26593. * @returns a new submesh
  26594. */
  26595. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  26596. }
  26597. }
  26598. declare module "babylonjs/Loading/sceneLoaderFlags" {
  26599. /**
  26600. * Class used to represent data loading progression
  26601. */
  26602. export class SceneLoaderFlags {
  26603. private static _ForceFullSceneLoadingForIncremental;
  26604. private static _ShowLoadingScreen;
  26605. private static _CleanBoneMatrixWeights;
  26606. private static _loggingLevel;
  26607. /**
  26608. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  26609. */
  26610. static get ForceFullSceneLoadingForIncremental(): boolean;
  26611. static set ForceFullSceneLoadingForIncremental(value: boolean);
  26612. /**
  26613. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  26614. */
  26615. static get ShowLoadingScreen(): boolean;
  26616. static set ShowLoadingScreen(value: boolean);
  26617. /**
  26618. * Defines the current logging level (while loading the scene)
  26619. * @ignorenaming
  26620. */
  26621. static get loggingLevel(): number;
  26622. static set loggingLevel(value: number);
  26623. /**
  26624. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  26625. */
  26626. static get CleanBoneMatrixWeights(): boolean;
  26627. static set CleanBoneMatrixWeights(value: boolean);
  26628. }
  26629. }
  26630. declare module "babylonjs/Meshes/geometry" {
  26631. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  26632. import { Scene } from "babylonjs/scene";
  26633. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  26634. import { Engine } from "babylonjs/Engines/engine";
  26635. import { IGetSetVerticesData, VertexData } from "babylonjs/Meshes/mesh.vertexData";
  26636. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  26637. import { Effect } from "babylonjs/Materials/effect";
  26638. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  26639. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  26640. import { Mesh } from "babylonjs/Meshes/mesh";
  26641. /**
  26642. * Class used to store geometry data (vertex buffers + index buffer)
  26643. */
  26644. export class Geometry implements IGetSetVerticesData {
  26645. /**
  26646. * Gets or sets the ID of the geometry
  26647. */
  26648. id: string;
  26649. /**
  26650. * Gets or sets the unique ID of the geometry
  26651. */
  26652. uniqueId: number;
  26653. /**
  26654. * Gets the delay loading state of the geometry (none by default which means not delayed)
  26655. */
  26656. delayLoadState: number;
  26657. /**
  26658. * Gets the file containing the data to load when running in delay load state
  26659. */
  26660. delayLoadingFile: Nullable<string>;
  26661. /**
  26662. * Callback called when the geometry is updated
  26663. */
  26664. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  26665. private _scene;
  26666. private _engine;
  26667. private _meshes;
  26668. private _totalVertices;
  26669. /** @hidden */
  26670. _indices: IndicesArray;
  26671. /** @hidden */
  26672. _vertexBuffers: {
  26673. [key: string]: VertexBuffer;
  26674. };
  26675. private _isDisposed;
  26676. private _extend;
  26677. private _boundingBias;
  26678. /** @hidden */
  26679. _delayInfo: Array<string>;
  26680. private _indexBuffer;
  26681. private _indexBufferIsUpdatable;
  26682. /** @hidden */
  26683. _boundingInfo: Nullable<BoundingInfo>;
  26684. /** @hidden */
  26685. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  26686. /** @hidden */
  26687. _softwareSkinningFrameId: number;
  26688. private _vertexArrayObjects;
  26689. private _updatable;
  26690. /** @hidden */
  26691. _positions: Nullable<Vector3[]>;
  26692. /**
  26693. * 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
  26694. */
  26695. get boundingBias(): Vector2;
  26696. /**
  26697. * 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
  26698. */
  26699. set boundingBias(value: Vector2);
  26700. /**
  26701. * Static function used to attach a new empty geometry to a mesh
  26702. * @param mesh defines the mesh to attach the geometry to
  26703. * @returns the new Geometry
  26704. */
  26705. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  26706. /** Get the list of meshes using this geometry */
  26707. get meshes(): Mesh[];
  26708. /**
  26709. * 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
  26710. * and won't be computed based on the vertex positions (which is what we get when useBoundingInfoFromGeometry = false)
  26711. */
  26712. useBoundingInfoFromGeometry: boolean;
  26713. /**
  26714. * Creates a new geometry
  26715. * @param id defines the unique ID
  26716. * @param scene defines the hosting scene
  26717. * @param vertexData defines the VertexData used to get geometry data
  26718. * @param updatable defines if geometry must be updatable (false by default)
  26719. * @param mesh defines the mesh that will be associated with the geometry
  26720. */
  26721. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  26722. /**
  26723. * Gets the current extend of the geometry
  26724. */
  26725. get extend(): {
  26726. minimum: Vector3;
  26727. maximum: Vector3;
  26728. };
  26729. /**
  26730. * Gets the hosting scene
  26731. * @returns the hosting Scene
  26732. */
  26733. getScene(): Scene;
  26734. /**
  26735. * Gets the hosting engine
  26736. * @returns the hosting Engine
  26737. */
  26738. getEngine(): Engine;
  26739. /**
  26740. * Defines if the geometry is ready to use
  26741. * @returns true if the geometry is ready to be used
  26742. */
  26743. isReady(): boolean;
  26744. /**
  26745. * Gets a value indicating that the geometry should not be serialized
  26746. */
  26747. get doNotSerialize(): boolean;
  26748. /** @hidden */
  26749. _rebuild(): void;
  26750. /**
  26751. * Affects all geometry data in one call
  26752. * @param vertexData defines the geometry data
  26753. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  26754. */
  26755. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  26756. /**
  26757. * Set specific vertex data
  26758. * @param kind defines the data kind (Position, normal, etc...)
  26759. * @param data defines the vertex data to use
  26760. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  26761. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  26762. */
  26763. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  26764. /**
  26765. * Removes a specific vertex data
  26766. * @param kind defines the data kind (Position, normal, etc...)
  26767. */
  26768. removeVerticesData(kind: string): void;
  26769. /**
  26770. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  26771. * @param buffer defines the vertex buffer to use
  26772. * @param totalVertices defines the total number of vertices for position kind (could be null)
  26773. */
  26774. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  26775. /**
  26776. * Update a specific vertex buffer
  26777. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  26778. * It will do nothing if the buffer is not updatable
  26779. * @param kind defines the data kind (Position, normal, etc...)
  26780. * @param data defines the data to use
  26781. * @param offset defines the offset in the target buffer where to store the data
  26782. * @param useBytes set to true if the offset is in bytes
  26783. */
  26784. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  26785. /**
  26786. * Update a specific vertex buffer
  26787. * This function will create a new buffer if the current one is not updatable
  26788. * @param kind defines the data kind (Position, normal, etc...)
  26789. * @param data defines the data to use
  26790. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  26791. */
  26792. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  26793. private _updateBoundingInfo;
  26794. /** @hidden */
  26795. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  26796. /**
  26797. * Gets total number of vertices
  26798. * @returns the total number of vertices
  26799. */
  26800. getTotalVertices(): number;
  26801. /**
  26802. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  26803. * @param kind defines the data kind (Position, normal, etc...)
  26804. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  26805. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  26806. * @returns a float array containing vertex data
  26807. */
  26808. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  26809. /**
  26810. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  26811. * @param kind defines the data kind (Position, normal, etc...)
  26812. * @returns true if the vertex buffer with the specified kind is updatable
  26813. */
  26814. isVertexBufferUpdatable(kind: string): boolean;
  26815. /**
  26816. * Gets a specific vertex buffer
  26817. * @param kind defines the data kind (Position, normal, etc...)
  26818. * @returns a VertexBuffer
  26819. */
  26820. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  26821. /**
  26822. * Returns all vertex buffers
  26823. * @return an object holding all vertex buffers indexed by kind
  26824. */
  26825. getVertexBuffers(): Nullable<{
  26826. [key: string]: VertexBuffer;
  26827. }>;
  26828. /**
  26829. * Gets a boolean indicating if specific vertex buffer is present
  26830. * @param kind defines the data kind (Position, normal, etc...)
  26831. * @returns true if data is present
  26832. */
  26833. isVerticesDataPresent(kind: string): boolean;
  26834. /**
  26835. * Gets a list of all attached data kinds (Position, normal, etc...)
  26836. * @returns a list of string containing all kinds
  26837. */
  26838. getVerticesDataKinds(): string[];
  26839. /**
  26840. * Update index buffer
  26841. * @param indices defines the indices to store in the index buffer
  26842. * @param offset defines the offset in the target buffer where to store the data
  26843. * @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)
  26844. */
  26845. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  26846. /**
  26847. * Creates a new index buffer
  26848. * @param indices defines the indices to store in the index buffer
  26849. * @param totalVertices defines the total number of vertices (could be null)
  26850. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  26851. */
  26852. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  26853. /**
  26854. * Return the total number of indices
  26855. * @returns the total number of indices
  26856. */
  26857. getTotalIndices(): number;
  26858. /**
  26859. * Gets the index buffer array
  26860. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  26861. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  26862. * @returns the index buffer array
  26863. */
  26864. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  26865. /**
  26866. * Gets the index buffer
  26867. * @return the index buffer
  26868. */
  26869. getIndexBuffer(): Nullable<DataBuffer>;
  26870. /** @hidden */
  26871. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  26872. /**
  26873. * Release the associated resources for a specific mesh
  26874. * @param mesh defines the source mesh
  26875. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  26876. */
  26877. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  26878. /**
  26879. * Apply current geometry to a given mesh
  26880. * @param mesh defines the mesh to apply geometry to
  26881. */
  26882. applyToMesh(mesh: Mesh): void;
  26883. private _updateExtend;
  26884. private _applyToMesh;
  26885. private notifyUpdate;
  26886. /**
  26887. * Load the geometry if it was flagged as delay loaded
  26888. * @param scene defines the hosting scene
  26889. * @param onLoaded defines a callback called when the geometry is loaded
  26890. */
  26891. load(scene: Scene, onLoaded?: () => void): void;
  26892. private _queueLoad;
  26893. /**
  26894. * Invert the geometry to move from a right handed system to a left handed one.
  26895. */
  26896. toLeftHanded(): void;
  26897. /** @hidden */
  26898. _resetPointsArrayCache(): void;
  26899. /** @hidden */
  26900. _generatePointsArray(): boolean;
  26901. /**
  26902. * Gets a value indicating if the geometry is disposed
  26903. * @returns true if the geometry was disposed
  26904. */
  26905. isDisposed(): boolean;
  26906. private _disposeVertexArrayObjects;
  26907. /**
  26908. * Free all associated resources
  26909. */
  26910. dispose(): void;
  26911. /**
  26912. * Clone the current geometry into a new geometry
  26913. * @param id defines the unique ID of the new geometry
  26914. * @returns a new geometry object
  26915. */
  26916. copy(id: string): Geometry;
  26917. /**
  26918. * Serialize the current geometry info (and not the vertices data) into a JSON object
  26919. * @return a JSON representation of the current geometry data (without the vertices data)
  26920. */
  26921. serialize(): any;
  26922. private toNumberArray;
  26923. /**
  26924. * Serialize all vertices data into a JSON oject
  26925. * @returns a JSON representation of the current geometry data
  26926. */
  26927. serializeVerticeData(): any;
  26928. /**
  26929. * Extracts a clone of a mesh geometry
  26930. * @param mesh defines the source mesh
  26931. * @param id defines the unique ID of the new geometry object
  26932. * @returns the new geometry object
  26933. */
  26934. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  26935. /**
  26936. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  26937. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  26938. * Be aware Math.random() could cause collisions, but:
  26939. * "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"
  26940. * @returns a string containing a new GUID
  26941. */
  26942. static RandomId(): string;
  26943. /** @hidden */
  26944. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  26945. private static _CleanMatricesWeights;
  26946. /**
  26947. * Create a new geometry from persisted data (Using .babylon file format)
  26948. * @param parsedVertexData defines the persisted data
  26949. * @param scene defines the hosting scene
  26950. * @param rootUrl defines the root url to use to load assets (like delayed data)
  26951. * @returns the new geometry object
  26952. */
  26953. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  26954. }
  26955. }
  26956. declare module "babylonjs/Meshes/mesh.vertexData" {
  26957. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  26958. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  26959. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  26960. import { Geometry } from "babylonjs/Meshes/geometry";
  26961. import { Mesh } from "babylonjs/Meshes/mesh";
  26962. import { ICreateCapsuleOptions } from "babylonjs/Meshes/Builders/capsuleBuilder";
  26963. /**
  26964. * Define an interface for all classes that will get and set the data on vertices
  26965. */
  26966. export interface IGetSetVerticesData {
  26967. /**
  26968. * Gets a boolean indicating if specific vertex data is present
  26969. * @param kind defines the vertex data kind to use
  26970. * @returns true is data kind is present
  26971. */
  26972. isVerticesDataPresent(kind: string): boolean;
  26973. /**
  26974. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  26975. * @param kind defines the data kind (Position, normal, etc...)
  26976. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  26977. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  26978. * @returns a float array containing vertex data
  26979. */
  26980. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  26981. /**
  26982. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  26983. * @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.
  26984. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  26985. * @returns the indices array or an empty array if the mesh has no geometry
  26986. */
  26987. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  26988. /**
  26989. * Set specific vertex data
  26990. * @param kind defines the data kind (Position, normal, etc...)
  26991. * @param data defines the vertex data to use
  26992. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  26993. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  26994. */
  26995. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  26996. /**
  26997. * Update a specific associated vertex buffer
  26998. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  26999. * - VertexBuffer.PositionKind
  27000. * - VertexBuffer.UVKind
  27001. * - VertexBuffer.UV2Kind
  27002. * - VertexBuffer.UV3Kind
  27003. * - VertexBuffer.UV4Kind
  27004. * - VertexBuffer.UV5Kind
  27005. * - VertexBuffer.UV6Kind
  27006. * - VertexBuffer.ColorKind
  27007. * - VertexBuffer.MatricesIndicesKind
  27008. * - VertexBuffer.MatricesIndicesExtraKind
  27009. * - VertexBuffer.MatricesWeightsKind
  27010. * - VertexBuffer.MatricesWeightsExtraKind
  27011. * @param data defines the data source
  27012. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  27013. * @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)
  27014. */
  27015. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  27016. /**
  27017. * Creates a new index buffer
  27018. * @param indices defines the indices to store in the index buffer
  27019. * @param totalVertices defines the total number of vertices (could be null)
  27020. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  27021. */
  27022. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  27023. }
  27024. /**
  27025. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  27026. */
  27027. export class VertexData {
  27028. /**
  27029. * Mesh side orientation : usually the external or front surface
  27030. */
  27031. static readonly FRONTSIDE: number;
  27032. /**
  27033. * Mesh side orientation : usually the internal or back surface
  27034. */
  27035. static readonly BACKSIDE: number;
  27036. /**
  27037. * Mesh side orientation : both internal and external or front and back surfaces
  27038. */
  27039. static readonly DOUBLESIDE: number;
  27040. /**
  27041. * Mesh side orientation : by default, `FRONTSIDE`
  27042. */
  27043. static readonly DEFAULTSIDE: number;
  27044. /**
  27045. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  27046. */
  27047. positions: Nullable<FloatArray>;
  27048. /**
  27049. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  27050. */
  27051. normals: Nullable<FloatArray>;
  27052. /**
  27053. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  27054. */
  27055. tangents: Nullable<FloatArray>;
  27056. /**
  27057. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  27058. */
  27059. uvs: Nullable<FloatArray>;
  27060. /**
  27061. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  27062. */
  27063. uvs2: Nullable<FloatArray>;
  27064. /**
  27065. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  27066. */
  27067. uvs3: Nullable<FloatArray>;
  27068. /**
  27069. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  27070. */
  27071. uvs4: Nullable<FloatArray>;
  27072. /**
  27073. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  27074. */
  27075. uvs5: Nullable<FloatArray>;
  27076. /**
  27077. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  27078. */
  27079. uvs6: Nullable<FloatArray>;
  27080. /**
  27081. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  27082. */
  27083. colors: Nullable<FloatArray>;
  27084. /**
  27085. * 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).
  27086. */
  27087. matricesIndices: Nullable<FloatArray>;
  27088. /**
  27089. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  27090. */
  27091. matricesWeights: Nullable<FloatArray>;
  27092. /**
  27093. * An array extending the number of possible indices
  27094. */
  27095. matricesIndicesExtra: Nullable<FloatArray>;
  27096. /**
  27097. * An array extending the number of possible weights when the number of indices is extended
  27098. */
  27099. matricesWeightsExtra: Nullable<FloatArray>;
  27100. /**
  27101. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  27102. */
  27103. indices: Nullable<IndicesArray>;
  27104. /**
  27105. * Uses the passed data array to set the set the values for the specified kind of data
  27106. * @param data a linear array of floating numbers
  27107. * @param kind the type of data that is being set, eg positions, colors etc
  27108. */
  27109. set(data: FloatArray, kind: string): void;
  27110. /**
  27111. * Associates the vertexData to the passed Mesh.
  27112. * Sets it as updatable or not (default `false`)
  27113. * @param mesh the mesh the vertexData is applied to
  27114. * @param updatable when used and having the value true allows new data to update the vertexData
  27115. * @returns the VertexData
  27116. */
  27117. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  27118. /**
  27119. * Associates the vertexData to the passed Geometry.
  27120. * Sets it as updatable or not (default `false`)
  27121. * @param geometry the geometry the vertexData is applied to
  27122. * @param updatable when used and having the value true allows new data to update the vertexData
  27123. * @returns VertexData
  27124. */
  27125. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  27126. /**
  27127. * Updates the associated mesh
  27128. * @param mesh the mesh to be updated
  27129. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  27130. * @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
  27131. * @returns VertexData
  27132. */
  27133. updateMesh(mesh: Mesh): VertexData;
  27134. /**
  27135. * Updates the associated geometry
  27136. * @param geometry the geometry to be updated
  27137. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  27138. * @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
  27139. * @returns VertexData.
  27140. */
  27141. updateGeometry(geometry: Geometry): VertexData;
  27142. private _applyTo;
  27143. private _update;
  27144. /**
  27145. * Transforms each position and each normal of the vertexData according to the passed Matrix
  27146. * @param matrix the transforming matrix
  27147. * @returns the VertexData
  27148. */
  27149. transform(matrix: Matrix): VertexData;
  27150. /**
  27151. * Merges the passed VertexData into the current one
  27152. * @param other the VertexData to be merged into the current one
  27153. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  27154. * @returns the modified VertexData
  27155. */
  27156. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  27157. private _mergeElement;
  27158. private _validate;
  27159. /**
  27160. * Serializes the VertexData
  27161. * @returns a serialized object
  27162. */
  27163. serialize(): any;
  27164. /**
  27165. * Extracts the vertexData from a mesh
  27166. * @param mesh the mesh from which to extract the VertexData
  27167. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  27168. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  27169. * @returns the object VertexData associated to the passed mesh
  27170. */
  27171. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  27172. /**
  27173. * Extracts the vertexData from the geometry
  27174. * @param geometry the geometry from which to extract the VertexData
  27175. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  27176. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  27177. * @returns the object VertexData associated to the passed mesh
  27178. */
  27179. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  27180. private static _ExtractFrom;
  27181. /**
  27182. * Creates the VertexData for a Ribbon
  27183. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  27184. * * pathArray array of paths, each of which an array of successive Vector3
  27185. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  27186. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  27187. * * 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
  27188. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27189. * * 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)
  27190. * * 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)
  27191. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  27192. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  27193. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  27194. * @returns the VertexData of the ribbon
  27195. */
  27196. static CreateRibbon(options: {
  27197. pathArray: Vector3[][];
  27198. closeArray?: boolean;
  27199. closePath?: boolean;
  27200. offset?: number;
  27201. sideOrientation?: number;
  27202. frontUVs?: Vector4;
  27203. backUVs?: Vector4;
  27204. invertUV?: boolean;
  27205. uvs?: Vector2[];
  27206. colors?: Color4[];
  27207. }): VertexData;
  27208. /**
  27209. * Creates the VertexData for a box
  27210. * @param options an object used to set the following optional parameters for the box, required but can be empty
  27211. * * size sets the width, height and depth of the box to the value of size, optional default 1
  27212. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  27213. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  27214. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  27215. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  27216. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  27217. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27218. * * 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)
  27219. * * 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)
  27220. * @returns the VertexData of the box
  27221. */
  27222. static CreateBox(options: {
  27223. size?: number;
  27224. width?: number;
  27225. height?: number;
  27226. depth?: number;
  27227. faceUV?: Vector4[];
  27228. faceColors?: Color4[];
  27229. sideOrientation?: number;
  27230. frontUVs?: Vector4;
  27231. backUVs?: Vector4;
  27232. }): VertexData;
  27233. /**
  27234. * Creates the VertexData for a tiled box
  27235. * @param options an object used to set the following optional parameters for the box, required but can be empty
  27236. * * faceTiles sets the pattern, tile size and number of tiles for a face
  27237. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  27238. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  27239. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27240. * @returns the VertexData of the box
  27241. */
  27242. static CreateTiledBox(options: {
  27243. pattern?: number;
  27244. width?: number;
  27245. height?: number;
  27246. depth?: number;
  27247. tileSize?: number;
  27248. tileWidth?: number;
  27249. tileHeight?: number;
  27250. alignHorizontal?: number;
  27251. alignVertical?: number;
  27252. faceUV?: Vector4[];
  27253. faceColors?: Color4[];
  27254. sideOrientation?: number;
  27255. }): VertexData;
  27256. /**
  27257. * Creates the VertexData for a tiled plane
  27258. * @param options an object used to set the following optional parameters for the box, required but can be empty
  27259. * * pattern a limited pattern arrangement depending on the number
  27260. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  27261. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  27262. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  27263. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27264. * * 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)
  27265. * * 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)
  27266. * @returns the VertexData of the tiled plane
  27267. */
  27268. static CreateTiledPlane(options: {
  27269. pattern?: number;
  27270. tileSize?: number;
  27271. tileWidth?: number;
  27272. tileHeight?: number;
  27273. size?: number;
  27274. width?: number;
  27275. height?: number;
  27276. alignHorizontal?: number;
  27277. alignVertical?: number;
  27278. sideOrientation?: number;
  27279. frontUVs?: Vector4;
  27280. backUVs?: Vector4;
  27281. }): VertexData;
  27282. /**
  27283. * Creates the VertexData for an ellipsoid, defaults to a sphere
  27284. * @param options an object used to set the following optional parameters for the box, required but can be empty
  27285. * * segments sets the number of horizontal strips optional, default 32
  27286. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  27287. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  27288. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  27289. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  27290. * * 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
  27291. * * 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
  27292. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27293. * * 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)
  27294. * * 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)
  27295. * @returns the VertexData of the ellipsoid
  27296. */
  27297. static CreateSphere(options: {
  27298. segments?: number;
  27299. diameter?: number;
  27300. diameterX?: number;
  27301. diameterY?: number;
  27302. diameterZ?: number;
  27303. arc?: number;
  27304. slice?: number;
  27305. sideOrientation?: number;
  27306. frontUVs?: Vector4;
  27307. backUVs?: Vector4;
  27308. }): VertexData;
  27309. /**
  27310. * Creates the VertexData for a cylinder, cone or prism
  27311. * @param options an object used to set the following optional parameters for the box, required but can be empty
  27312. * * height sets the height (y direction) of the cylinder, optional, default 2
  27313. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  27314. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  27315. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  27316. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  27317. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  27318. * * 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
  27319. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  27320. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  27321. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  27322. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  27323. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27324. * * 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)
  27325. * * 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)
  27326. * @returns the VertexData of the cylinder, cone or prism
  27327. */
  27328. static CreateCylinder(options: {
  27329. height?: number;
  27330. diameterTop?: number;
  27331. diameterBottom?: number;
  27332. diameter?: number;
  27333. tessellation?: number;
  27334. subdivisions?: number;
  27335. arc?: number;
  27336. faceColors?: Color4[];
  27337. faceUV?: Vector4[];
  27338. hasRings?: boolean;
  27339. enclose?: boolean;
  27340. sideOrientation?: number;
  27341. frontUVs?: Vector4;
  27342. backUVs?: Vector4;
  27343. }): VertexData;
  27344. /**
  27345. * Creates the VertexData for a torus
  27346. * @param options an object used to set the following optional parameters for the box, required but can be empty
  27347. * * diameter the diameter of the torus, optional default 1
  27348. * * thickness the diameter of the tube forming the torus, optional default 0.5
  27349. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  27350. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27351. * * 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)
  27352. * * 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)
  27353. * @returns the VertexData of the torus
  27354. */
  27355. static CreateTorus(options: {
  27356. diameter?: number;
  27357. thickness?: number;
  27358. tessellation?: number;
  27359. sideOrientation?: number;
  27360. frontUVs?: Vector4;
  27361. backUVs?: Vector4;
  27362. }): VertexData;
  27363. /**
  27364. * Creates the VertexData of the LineSystem
  27365. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  27366. * - lines an array of lines, each line being an array of successive Vector3
  27367. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  27368. * @returns the VertexData of the LineSystem
  27369. */
  27370. static CreateLineSystem(options: {
  27371. lines: Vector3[][];
  27372. colors?: Nullable<Color4[][]>;
  27373. }): VertexData;
  27374. /**
  27375. * Create the VertexData for a DashedLines
  27376. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  27377. * - points an array successive Vector3
  27378. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  27379. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  27380. * - dashNb the intended total number of dashes, optional, default 200
  27381. * @returns the VertexData for the DashedLines
  27382. */
  27383. static CreateDashedLines(options: {
  27384. points: Vector3[];
  27385. dashSize?: number;
  27386. gapSize?: number;
  27387. dashNb?: number;
  27388. }): VertexData;
  27389. /**
  27390. * Creates the VertexData for a Ground
  27391. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  27392. * - width the width (x direction) of the ground, optional, default 1
  27393. * - height the height (z direction) of the ground, optional, default 1
  27394. * - subdivisions the number of subdivisions per side, optional, default 1
  27395. * @returns the VertexData of the Ground
  27396. */
  27397. static CreateGround(options: {
  27398. width?: number;
  27399. height?: number;
  27400. subdivisions?: number;
  27401. subdivisionsX?: number;
  27402. subdivisionsY?: number;
  27403. }): VertexData;
  27404. /**
  27405. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  27406. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  27407. * * xmin the ground minimum X coordinate, optional, default -1
  27408. * * zmin the ground minimum Z coordinate, optional, default -1
  27409. * * xmax the ground maximum X coordinate, optional, default 1
  27410. * * zmax the ground maximum Z coordinate, optional, default 1
  27411. * * 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}
  27412. * * 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}
  27413. * @returns the VertexData of the TiledGround
  27414. */
  27415. static CreateTiledGround(options: {
  27416. xmin: number;
  27417. zmin: number;
  27418. xmax: number;
  27419. zmax: number;
  27420. subdivisions?: {
  27421. w: number;
  27422. h: number;
  27423. };
  27424. precision?: {
  27425. w: number;
  27426. h: number;
  27427. };
  27428. }): VertexData;
  27429. /**
  27430. * Creates the VertexData of the Ground designed from a heightmap
  27431. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  27432. * * width the width (x direction) of the ground
  27433. * * height the height (z direction) of the ground
  27434. * * subdivisions the number of subdivisions per side
  27435. * * minHeight the minimum altitude on the ground, optional, default 0
  27436. * * maxHeight the maximum altitude on the ground, optional default 1
  27437. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  27438. * * buffer the array holding the image color data
  27439. * * bufferWidth the width of image
  27440. * * bufferHeight the height of image
  27441. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  27442. * @returns the VertexData of the Ground designed from a heightmap
  27443. */
  27444. static CreateGroundFromHeightMap(options: {
  27445. width: number;
  27446. height: number;
  27447. subdivisions: number;
  27448. minHeight: number;
  27449. maxHeight: number;
  27450. colorFilter: Color3;
  27451. buffer: Uint8Array;
  27452. bufferWidth: number;
  27453. bufferHeight: number;
  27454. alphaFilter: number;
  27455. }): VertexData;
  27456. /**
  27457. * Creates the VertexData for a Plane
  27458. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  27459. * * size sets the width and height of the plane to the value of size, optional default 1
  27460. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  27461. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  27462. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27463. * * 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)
  27464. * * 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)
  27465. * @returns the VertexData of the box
  27466. */
  27467. static CreatePlane(options: {
  27468. size?: number;
  27469. width?: number;
  27470. height?: number;
  27471. sideOrientation?: number;
  27472. frontUVs?: Vector4;
  27473. backUVs?: Vector4;
  27474. }): VertexData;
  27475. /**
  27476. * Creates the VertexData of the Disc or regular Polygon
  27477. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  27478. * * radius the radius of the disc, optional default 0.5
  27479. * * tessellation the number of polygon sides, optional, default 64
  27480. * * 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
  27481. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27482. * * 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)
  27483. * * 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)
  27484. * @returns the VertexData of the box
  27485. */
  27486. static CreateDisc(options: {
  27487. radius?: number;
  27488. tessellation?: number;
  27489. arc?: number;
  27490. sideOrientation?: number;
  27491. frontUVs?: Vector4;
  27492. backUVs?: Vector4;
  27493. }): VertexData;
  27494. /**
  27495. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  27496. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  27497. * @param polygon a mesh built from polygonTriangulation.build()
  27498. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27499. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  27500. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  27501. * @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)
  27502. * @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)
  27503. * @param wrap a boolean, default false, when true and fUVs used texture is wrapped around all sides, when false texture is applied side
  27504. * @returns the VertexData of the Polygon
  27505. */
  27506. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4, wrap?: boolean): VertexData;
  27507. /**
  27508. * Creates the VertexData of the IcoSphere
  27509. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  27510. * * radius the radius of the IcoSphere, optional default 1
  27511. * * radiusX allows stretching in the x direction, optional, default radius
  27512. * * radiusY allows stretching in the y direction, optional, default radius
  27513. * * radiusZ allows stretching in the z direction, optional, default radius
  27514. * * flat when true creates a flat shaded mesh, optional, default true
  27515. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  27516. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27517. * * 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)
  27518. * * 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)
  27519. * @returns the VertexData of the IcoSphere
  27520. */
  27521. static CreateIcoSphere(options: {
  27522. radius?: number;
  27523. radiusX?: number;
  27524. radiusY?: number;
  27525. radiusZ?: number;
  27526. flat?: boolean;
  27527. subdivisions?: number;
  27528. sideOrientation?: number;
  27529. frontUVs?: Vector4;
  27530. backUVs?: Vector4;
  27531. }): VertexData;
  27532. /**
  27533. * Creates the VertexData for a Polyhedron
  27534. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  27535. * * type provided types are:
  27536. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  27537. * * 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)
  27538. * * size the size of the IcoSphere, optional default 1
  27539. * * sizeX allows stretching in the x direction, optional, default size
  27540. * * sizeY allows stretching in the y direction, optional, default size
  27541. * * sizeZ allows stretching in the z direction, optional, default size
  27542. * * 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
  27543. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  27544. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  27545. * * flat when true creates a flat shaded mesh, optional, default true
  27546. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  27547. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27548. * * 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)
  27549. * * 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)
  27550. * @returns the VertexData of the Polyhedron
  27551. */
  27552. static CreatePolyhedron(options: {
  27553. type?: number;
  27554. size?: number;
  27555. sizeX?: number;
  27556. sizeY?: number;
  27557. sizeZ?: number;
  27558. custom?: any;
  27559. faceUV?: Vector4[];
  27560. faceColors?: Color4[];
  27561. flat?: boolean;
  27562. sideOrientation?: number;
  27563. frontUVs?: Vector4;
  27564. backUVs?: Vector4;
  27565. }): VertexData;
  27566. /**
  27567. * Creates the VertexData for a Capsule, inspired from https://github.com/maximeq/three-js-capsule-geometry/blob/master/src/CapsuleBufferGeometry.js
  27568. * @param options an object used to set the following optional parameters for the capsule, required but can be empty
  27569. * @returns the VertexData of the Capsule
  27570. */
  27571. static CreateCapsule(options?: ICreateCapsuleOptions): VertexData;
  27572. /**
  27573. * Creates the VertexData for a TorusKnot
  27574. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  27575. * * radius the radius of the torus knot, optional, default 2
  27576. * * tube the thickness of the tube, optional, default 0.5
  27577. * * radialSegments the number of sides on each tube segments, optional, default 32
  27578. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  27579. * * p the number of windings around the z axis, optional, default 2
  27580. * * q the number of windings around the x axis, optional, default 3
  27581. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27582. * * 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)
  27583. * * 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)
  27584. * @returns the VertexData of the Torus Knot
  27585. */
  27586. static CreateTorusKnot(options: {
  27587. radius?: number;
  27588. tube?: number;
  27589. radialSegments?: number;
  27590. tubularSegments?: number;
  27591. p?: number;
  27592. q?: number;
  27593. sideOrientation?: number;
  27594. frontUVs?: Vector4;
  27595. backUVs?: Vector4;
  27596. }): VertexData;
  27597. /**
  27598. * Compute normals for given positions and indices
  27599. * @param positions an array of vertex positions, [...., x, y, z, ......]
  27600. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  27601. * @param normals an array of vertex normals, [...., x, y, z, ......]
  27602. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  27603. * * facetNormals : optional array of facet normals (vector3)
  27604. * * facetPositions : optional array of facet positions (vector3)
  27605. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  27606. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  27607. * * bInfo : optional bounding info, required for facetPartitioning computation
  27608. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  27609. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  27610. * * useRightHandedSystem: optional boolean to for right handed system computation
  27611. * * depthSort : optional boolean to enable the facet depth sort computation
  27612. * * distanceTo : optional Vector3 to compute the facet depth from this location
  27613. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  27614. */
  27615. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  27616. facetNormals?: any;
  27617. facetPositions?: any;
  27618. facetPartitioning?: any;
  27619. ratio?: number;
  27620. bInfo?: any;
  27621. bbSize?: Vector3;
  27622. subDiv?: any;
  27623. useRightHandedSystem?: boolean;
  27624. depthSort?: boolean;
  27625. distanceTo?: Vector3;
  27626. depthSortedFacets?: any;
  27627. }): void;
  27628. /** @hidden */
  27629. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  27630. /**
  27631. * Applies VertexData created from the imported parameters to the geometry
  27632. * @param parsedVertexData the parsed data from an imported file
  27633. * @param geometry the geometry to apply the VertexData to
  27634. */
  27635. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  27636. }
  27637. }
  27638. declare module "babylonjs/Morph/morphTarget" {
  27639. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  27640. import { Observable } from "babylonjs/Misc/observable";
  27641. import { Nullable, FloatArray } from "babylonjs/types";
  27642. import { Scene } from "babylonjs/scene";
  27643. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  27644. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  27645. /**
  27646. * Defines a target to use with MorphTargetManager
  27647. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  27648. */
  27649. export class MorphTarget implements IAnimatable {
  27650. /** defines the name of the target */
  27651. name: string;
  27652. /**
  27653. * Gets or sets the list of animations
  27654. */
  27655. animations: import("babylonjs/Animations/animation").Animation[];
  27656. private _scene;
  27657. private _positions;
  27658. private _normals;
  27659. private _tangents;
  27660. private _uvs;
  27661. private _influence;
  27662. private _uniqueId;
  27663. /**
  27664. * Observable raised when the influence changes
  27665. */
  27666. onInfluenceChanged: Observable<boolean>;
  27667. /** @hidden */
  27668. _onDataLayoutChanged: Observable<void>;
  27669. /**
  27670. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  27671. */
  27672. get influence(): number;
  27673. set influence(influence: number);
  27674. /**
  27675. * Gets or sets the id of the morph Target
  27676. */
  27677. id: string;
  27678. private _animationPropertiesOverride;
  27679. /**
  27680. * Gets or sets the animation properties override
  27681. */
  27682. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  27683. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  27684. /**
  27685. * Creates a new MorphTarget
  27686. * @param name defines the name of the target
  27687. * @param influence defines the influence to use
  27688. * @param scene defines the scene the morphtarget belongs to
  27689. */
  27690. constructor(
  27691. /** defines the name of the target */
  27692. name: string, influence?: number, scene?: Nullable<Scene>);
  27693. /**
  27694. * Gets the unique ID of this manager
  27695. */
  27696. get uniqueId(): number;
  27697. /**
  27698. * Gets a boolean defining if the target contains position data
  27699. */
  27700. get hasPositions(): boolean;
  27701. /**
  27702. * Gets a boolean defining if the target contains normal data
  27703. */
  27704. get hasNormals(): boolean;
  27705. /**
  27706. * Gets a boolean defining if the target contains tangent data
  27707. */
  27708. get hasTangents(): boolean;
  27709. /**
  27710. * Gets a boolean defining if the target contains texture coordinates data
  27711. */
  27712. get hasUVs(): boolean;
  27713. /**
  27714. * Affects position data to this target
  27715. * @param data defines the position data to use
  27716. */
  27717. setPositions(data: Nullable<FloatArray>): void;
  27718. /**
  27719. * Gets the position data stored in this target
  27720. * @returns a FloatArray containing the position data (or null if not present)
  27721. */
  27722. getPositions(): Nullable<FloatArray>;
  27723. /**
  27724. * Affects normal data to this target
  27725. * @param data defines the normal data to use
  27726. */
  27727. setNormals(data: Nullable<FloatArray>): void;
  27728. /**
  27729. * Gets the normal data stored in this target
  27730. * @returns a FloatArray containing the normal data (or null if not present)
  27731. */
  27732. getNormals(): Nullable<FloatArray>;
  27733. /**
  27734. * Affects tangent data to this target
  27735. * @param data defines the tangent data to use
  27736. */
  27737. setTangents(data: Nullable<FloatArray>): void;
  27738. /**
  27739. * Gets the tangent data stored in this target
  27740. * @returns a FloatArray containing the tangent data (or null if not present)
  27741. */
  27742. getTangents(): Nullable<FloatArray>;
  27743. /**
  27744. * Affects texture coordinates data to this target
  27745. * @param data defines the texture coordinates data to use
  27746. */
  27747. setUVs(data: Nullable<FloatArray>): void;
  27748. /**
  27749. * Gets the texture coordinates data stored in this target
  27750. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  27751. */
  27752. getUVs(): Nullable<FloatArray>;
  27753. /**
  27754. * Clone the current target
  27755. * @returns a new MorphTarget
  27756. */
  27757. clone(): MorphTarget;
  27758. /**
  27759. * Serializes the current target into a Serialization object
  27760. * @returns the serialized object
  27761. */
  27762. serialize(): any;
  27763. /**
  27764. * Returns the string "MorphTarget"
  27765. * @returns "MorphTarget"
  27766. */
  27767. getClassName(): string;
  27768. /**
  27769. * Creates a new target from serialized data
  27770. * @param serializationObject defines the serialized data to use
  27771. * @returns a new MorphTarget
  27772. */
  27773. static Parse(serializationObject: any): MorphTarget;
  27774. /**
  27775. * Creates a MorphTarget from mesh data
  27776. * @param mesh defines the source mesh
  27777. * @param name defines the name to use for the new target
  27778. * @param influence defines the influence to attach to the target
  27779. * @returns a new MorphTarget
  27780. */
  27781. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  27782. }
  27783. }
  27784. declare module "babylonjs/Morph/morphTargetManager" {
  27785. import { Nullable } from "babylonjs/types";
  27786. import { Scene } from "babylonjs/scene";
  27787. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  27788. /**
  27789. * This class is used to deform meshes using morphing between different targets
  27790. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  27791. */
  27792. export class MorphTargetManager {
  27793. private _targets;
  27794. private _targetInfluenceChangedObservers;
  27795. private _targetDataLayoutChangedObservers;
  27796. private _activeTargets;
  27797. private _scene;
  27798. private _influences;
  27799. private _supportsNormals;
  27800. private _supportsTangents;
  27801. private _supportsUVs;
  27802. private _vertexCount;
  27803. private _uniqueId;
  27804. private _tempInfluences;
  27805. /**
  27806. * Gets or sets a boolean indicating if normals must be morphed
  27807. */
  27808. enableNormalMorphing: boolean;
  27809. /**
  27810. * Gets or sets a boolean indicating if tangents must be morphed
  27811. */
  27812. enableTangentMorphing: boolean;
  27813. /**
  27814. * Gets or sets a boolean indicating if UV must be morphed
  27815. */
  27816. enableUVMorphing: boolean;
  27817. /**
  27818. * Creates a new MorphTargetManager
  27819. * @param scene defines the current scene
  27820. */
  27821. constructor(scene?: Nullable<Scene>);
  27822. /**
  27823. * Gets the unique ID of this manager
  27824. */
  27825. get uniqueId(): number;
  27826. /**
  27827. * Gets the number of vertices handled by this manager
  27828. */
  27829. get vertexCount(): number;
  27830. /**
  27831. * Gets a boolean indicating if this manager supports morphing of normals
  27832. */
  27833. get supportsNormals(): boolean;
  27834. /**
  27835. * Gets a boolean indicating if this manager supports morphing of tangents
  27836. */
  27837. get supportsTangents(): boolean;
  27838. /**
  27839. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  27840. */
  27841. get supportsUVs(): boolean;
  27842. /**
  27843. * Gets the number of targets stored in this manager
  27844. */
  27845. get numTargets(): number;
  27846. /**
  27847. * Gets the number of influencers (ie. the number of targets with influences > 0)
  27848. */
  27849. get numInfluencers(): number;
  27850. /**
  27851. * Gets the list of influences (one per target)
  27852. */
  27853. get influences(): Float32Array;
  27854. /**
  27855. * Gets the active target at specified index. An active target is a target with an influence > 0
  27856. * @param index defines the index to check
  27857. * @returns the requested target
  27858. */
  27859. getActiveTarget(index: number): MorphTarget;
  27860. /**
  27861. * Gets the target at specified index
  27862. * @param index defines the index to check
  27863. * @returns the requested target
  27864. */
  27865. getTarget(index: number): MorphTarget;
  27866. /**
  27867. * Add a new target to this manager
  27868. * @param target defines the target to add
  27869. */
  27870. addTarget(target: MorphTarget): void;
  27871. /**
  27872. * Removes a target from the manager
  27873. * @param target defines the target to remove
  27874. */
  27875. removeTarget(target: MorphTarget): void;
  27876. /**
  27877. * Clone the current manager
  27878. * @returns a new MorphTargetManager
  27879. */
  27880. clone(): MorphTargetManager;
  27881. /**
  27882. * Serializes the current manager into a Serialization object
  27883. * @returns the serialized object
  27884. */
  27885. serialize(): any;
  27886. private _syncActiveTargets;
  27887. /**
  27888. * Syncrhonize the targets with all the meshes using this morph target manager
  27889. */
  27890. synchronize(): void;
  27891. /**
  27892. * Creates a new MorphTargetManager from serialized data
  27893. * @param serializationObject defines the serialized data
  27894. * @param scene defines the hosting scene
  27895. * @returns the new MorphTargetManager
  27896. */
  27897. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  27898. }
  27899. }
  27900. declare module "babylonjs/Meshes/meshLODLevel" {
  27901. import { Mesh } from "babylonjs/Meshes/mesh";
  27902. import { Nullable } from "babylonjs/types";
  27903. /**
  27904. * Class used to represent a specific level of detail of a mesh
  27905. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  27906. */
  27907. export class MeshLODLevel {
  27908. /** Defines the distance where this level should start being displayed */
  27909. distance: number;
  27910. /** Defines the mesh to use to render this level */
  27911. mesh: Nullable<Mesh>;
  27912. /**
  27913. * Creates a new LOD level
  27914. * @param distance defines the distance where this level should star being displayed
  27915. * @param mesh defines the mesh to use to render this level
  27916. */
  27917. constructor(
  27918. /** Defines the distance where this level should start being displayed */
  27919. distance: number,
  27920. /** Defines the mesh to use to render this level */
  27921. mesh: Nullable<Mesh>);
  27922. }
  27923. }
  27924. declare module "babylonjs/Misc/canvasGenerator" {
  27925. /**
  27926. * Helper class used to generate a canvas to manipulate images
  27927. */
  27928. export class CanvasGenerator {
  27929. /**
  27930. * Create a new canvas (or offscreen canvas depending on the context)
  27931. * @param width defines the expected width
  27932. * @param height defines the expected height
  27933. * @return a new canvas or offscreen canvas
  27934. */
  27935. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  27936. }
  27937. }
  27938. declare module "babylonjs/Meshes/groundMesh" {
  27939. import { Scene } from "babylonjs/scene";
  27940. import { Vector3 } from "babylonjs/Maths/math.vector";
  27941. import { Mesh } from "babylonjs/Meshes/mesh";
  27942. /**
  27943. * Mesh representing the gorund
  27944. */
  27945. export class GroundMesh extends Mesh {
  27946. /** If octree should be generated */
  27947. generateOctree: boolean;
  27948. private _heightQuads;
  27949. /** @hidden */
  27950. _subdivisionsX: number;
  27951. /** @hidden */
  27952. _subdivisionsY: number;
  27953. /** @hidden */
  27954. _width: number;
  27955. /** @hidden */
  27956. _height: number;
  27957. /** @hidden */
  27958. _minX: number;
  27959. /** @hidden */
  27960. _maxX: number;
  27961. /** @hidden */
  27962. _minZ: number;
  27963. /** @hidden */
  27964. _maxZ: number;
  27965. constructor(name: string, scene: Scene);
  27966. /**
  27967. * "GroundMesh"
  27968. * @returns "GroundMesh"
  27969. */
  27970. getClassName(): string;
  27971. /**
  27972. * The minimum of x and y subdivisions
  27973. */
  27974. get subdivisions(): number;
  27975. /**
  27976. * X subdivisions
  27977. */
  27978. get subdivisionsX(): number;
  27979. /**
  27980. * Y subdivisions
  27981. */
  27982. get subdivisionsY(): number;
  27983. /**
  27984. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  27985. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  27986. * @param chunksCount the number of subdivisions for x and y
  27987. * @param octreeBlocksSize (Default: 32)
  27988. */
  27989. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  27990. /**
  27991. * Returns a height (y) value in the Worl system :
  27992. * the ground altitude at the coordinates (x, z) expressed in the World system.
  27993. * @param x x coordinate
  27994. * @param z z coordinate
  27995. * @returns the ground y position if (x, z) are outside the ground surface.
  27996. */
  27997. getHeightAtCoordinates(x: number, z: number): number;
  27998. /**
  27999. * Returns a normalized vector (Vector3) orthogonal to the ground
  28000. * at the ground coordinates (x, z) expressed in the World system.
  28001. * @param x x coordinate
  28002. * @param z z coordinate
  28003. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  28004. */
  28005. getNormalAtCoordinates(x: number, z: number): Vector3;
  28006. /**
  28007. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  28008. * at the ground coordinates (x, z) expressed in the World system.
  28009. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  28010. * @param x x coordinate
  28011. * @param z z coordinate
  28012. * @param ref vector to store the result
  28013. * @returns the GroundMesh.
  28014. */
  28015. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  28016. /**
  28017. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  28018. * if the ground has been updated.
  28019. * This can be used in the render loop.
  28020. * @returns the GroundMesh.
  28021. */
  28022. updateCoordinateHeights(): GroundMesh;
  28023. private _getFacetAt;
  28024. private _initHeightQuads;
  28025. private _computeHeightQuads;
  28026. /**
  28027. * Serializes this ground mesh
  28028. * @param serializationObject object to write serialization to
  28029. */
  28030. serialize(serializationObject: any): void;
  28031. /**
  28032. * Parses a serialized ground mesh
  28033. * @param parsedMesh the serialized mesh
  28034. * @param scene the scene to create the ground mesh in
  28035. * @returns the created ground mesh
  28036. */
  28037. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  28038. }
  28039. }
  28040. declare module "babylonjs/Physics/physicsJoint" {
  28041. import { Vector3 } from "babylonjs/Maths/math.vector";
  28042. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  28043. /**
  28044. * Interface for Physics-Joint data
  28045. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  28046. */
  28047. export interface PhysicsJointData {
  28048. /**
  28049. * The main pivot of the joint
  28050. */
  28051. mainPivot?: Vector3;
  28052. /**
  28053. * The connected pivot of the joint
  28054. */
  28055. connectedPivot?: Vector3;
  28056. /**
  28057. * The main axis of the joint
  28058. */
  28059. mainAxis?: Vector3;
  28060. /**
  28061. * The connected axis of the joint
  28062. */
  28063. connectedAxis?: Vector3;
  28064. /**
  28065. * The collision of the joint
  28066. */
  28067. collision?: boolean;
  28068. /**
  28069. * Native Oimo/Cannon/Energy data
  28070. */
  28071. nativeParams?: any;
  28072. }
  28073. /**
  28074. * This is a holder class for the physics joint created by the physics plugin
  28075. * It holds a set of functions to control the underlying joint
  28076. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  28077. */
  28078. export class PhysicsJoint {
  28079. /**
  28080. * The type of the physics joint
  28081. */
  28082. type: number;
  28083. /**
  28084. * The data for the physics joint
  28085. */
  28086. jointData: PhysicsJointData;
  28087. private _physicsJoint;
  28088. protected _physicsPlugin: IPhysicsEnginePlugin;
  28089. /**
  28090. * Initializes the physics joint
  28091. * @param type The type of the physics joint
  28092. * @param jointData The data for the physics joint
  28093. */
  28094. constructor(
  28095. /**
  28096. * The type of the physics joint
  28097. */
  28098. type: number,
  28099. /**
  28100. * The data for the physics joint
  28101. */
  28102. jointData: PhysicsJointData);
  28103. /**
  28104. * Gets the physics joint
  28105. */
  28106. get physicsJoint(): any;
  28107. /**
  28108. * Sets the physics joint
  28109. */
  28110. set physicsJoint(newJoint: any);
  28111. /**
  28112. * Sets the physics plugin
  28113. */
  28114. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  28115. /**
  28116. * Execute a function that is physics-plugin specific.
  28117. * @param {Function} func the function that will be executed.
  28118. * It accepts two parameters: the physics world and the physics joint
  28119. */
  28120. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  28121. /**
  28122. * Distance-Joint type
  28123. */
  28124. static DistanceJoint: number;
  28125. /**
  28126. * Hinge-Joint type
  28127. */
  28128. static HingeJoint: number;
  28129. /**
  28130. * Ball-and-Socket joint type
  28131. */
  28132. static BallAndSocketJoint: number;
  28133. /**
  28134. * Wheel-Joint type
  28135. */
  28136. static WheelJoint: number;
  28137. /**
  28138. * Slider-Joint type
  28139. */
  28140. static SliderJoint: number;
  28141. /**
  28142. * Prismatic-Joint type
  28143. */
  28144. static PrismaticJoint: number;
  28145. /**
  28146. * Universal-Joint type
  28147. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  28148. */
  28149. static UniversalJoint: number;
  28150. /**
  28151. * Hinge-Joint 2 type
  28152. */
  28153. static Hinge2Joint: number;
  28154. /**
  28155. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  28156. */
  28157. static PointToPointJoint: number;
  28158. /**
  28159. * Spring-Joint type
  28160. */
  28161. static SpringJoint: number;
  28162. /**
  28163. * Lock-Joint type
  28164. */
  28165. static LockJoint: number;
  28166. }
  28167. /**
  28168. * A class representing a physics distance joint
  28169. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  28170. */
  28171. export class DistanceJoint extends PhysicsJoint {
  28172. /**
  28173. *
  28174. * @param jointData The data for the Distance-Joint
  28175. */
  28176. constructor(jointData: DistanceJointData);
  28177. /**
  28178. * Update the predefined distance.
  28179. * @param maxDistance The maximum preferred distance
  28180. * @param minDistance The minimum preferred distance
  28181. */
  28182. updateDistance(maxDistance: number, minDistance?: number): void;
  28183. }
  28184. /**
  28185. * Represents a Motor-Enabled Joint
  28186. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  28187. */
  28188. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  28189. /**
  28190. * Initializes the Motor-Enabled Joint
  28191. * @param type The type of the joint
  28192. * @param jointData The physica joint data for the joint
  28193. */
  28194. constructor(type: number, jointData: PhysicsJointData);
  28195. /**
  28196. * Set the motor values.
  28197. * Attention, this function is plugin specific. Engines won't react 100% the same.
  28198. * @param force the force to apply
  28199. * @param maxForce max force for this motor.
  28200. */
  28201. setMotor(force?: number, maxForce?: number): void;
  28202. /**
  28203. * Set the motor's limits.
  28204. * Attention, this function is plugin specific. Engines won't react 100% the same.
  28205. * @param upperLimit The upper limit of the motor
  28206. * @param lowerLimit The lower limit of the motor
  28207. */
  28208. setLimit(upperLimit: number, lowerLimit?: number): void;
  28209. }
  28210. /**
  28211. * This class represents a single physics Hinge-Joint
  28212. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  28213. */
  28214. export class HingeJoint extends MotorEnabledJoint {
  28215. /**
  28216. * Initializes the Hinge-Joint
  28217. * @param jointData The joint data for the Hinge-Joint
  28218. */
  28219. constructor(jointData: PhysicsJointData);
  28220. /**
  28221. * Set the motor values.
  28222. * Attention, this function is plugin specific. Engines won't react 100% the same.
  28223. * @param {number} force the force to apply
  28224. * @param {number} maxForce max force for this motor.
  28225. */
  28226. setMotor(force?: number, maxForce?: number): void;
  28227. /**
  28228. * Set the motor's limits.
  28229. * Attention, this function is plugin specific. Engines won't react 100% the same.
  28230. * @param upperLimit The upper limit of the motor
  28231. * @param lowerLimit The lower limit of the motor
  28232. */
  28233. setLimit(upperLimit: number, lowerLimit?: number): void;
  28234. }
  28235. /**
  28236. * This class represents a dual hinge physics joint (same as wheel joint)
  28237. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  28238. */
  28239. export class Hinge2Joint extends MotorEnabledJoint {
  28240. /**
  28241. * Initializes the Hinge2-Joint
  28242. * @param jointData The joint data for the Hinge2-Joint
  28243. */
  28244. constructor(jointData: PhysicsJointData);
  28245. /**
  28246. * Set the motor values.
  28247. * Attention, this function is plugin specific. Engines won't react 100% the same.
  28248. * @param {number} targetSpeed the speed the motor is to reach
  28249. * @param {number} maxForce max force for this motor.
  28250. * @param {motorIndex} the motor's index, 0 or 1.
  28251. */
  28252. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  28253. /**
  28254. * Set the motor limits.
  28255. * Attention, this function is plugin specific. Engines won't react 100% the same.
  28256. * @param {number} upperLimit the upper limit
  28257. * @param {number} lowerLimit lower limit
  28258. * @param {motorIndex} the motor's index, 0 or 1.
  28259. */
  28260. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  28261. }
  28262. /**
  28263. * Interface for a motor enabled joint
  28264. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  28265. */
  28266. export interface IMotorEnabledJoint {
  28267. /**
  28268. * Physics joint
  28269. */
  28270. physicsJoint: any;
  28271. /**
  28272. * Sets the motor of the motor-enabled joint
  28273. * @param force The force of the motor
  28274. * @param maxForce The maximum force of the motor
  28275. * @param motorIndex The index of the motor
  28276. */
  28277. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  28278. /**
  28279. * Sets the limit of the motor
  28280. * @param upperLimit The upper limit of the motor
  28281. * @param lowerLimit The lower limit of the motor
  28282. * @param motorIndex The index of the motor
  28283. */
  28284. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  28285. }
  28286. /**
  28287. * Joint data for a Distance-Joint
  28288. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  28289. */
  28290. export interface DistanceJointData extends PhysicsJointData {
  28291. /**
  28292. * Max distance the 2 joint objects can be apart
  28293. */
  28294. maxDistance: number;
  28295. }
  28296. /**
  28297. * Joint data from a spring joint
  28298. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  28299. */
  28300. export interface SpringJointData extends PhysicsJointData {
  28301. /**
  28302. * Length of the spring
  28303. */
  28304. length: number;
  28305. /**
  28306. * Stiffness of the spring
  28307. */
  28308. stiffness: number;
  28309. /**
  28310. * Damping of the spring
  28311. */
  28312. damping: number;
  28313. /** this callback will be called when applying the force to the impostors. */
  28314. forceApplicationCallback: () => void;
  28315. }
  28316. }
  28317. declare module "babylonjs/Physics/physicsRaycastResult" {
  28318. import { Vector3 } from "babylonjs/Maths/math.vector";
  28319. /**
  28320. * Holds the data for the raycast result
  28321. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  28322. */
  28323. export class PhysicsRaycastResult {
  28324. private _hasHit;
  28325. private _hitDistance;
  28326. private _hitNormalWorld;
  28327. private _hitPointWorld;
  28328. private _rayFromWorld;
  28329. private _rayToWorld;
  28330. /**
  28331. * Gets if there was a hit
  28332. */
  28333. get hasHit(): boolean;
  28334. /**
  28335. * Gets the distance from the hit
  28336. */
  28337. get hitDistance(): number;
  28338. /**
  28339. * Gets the hit normal/direction in the world
  28340. */
  28341. get hitNormalWorld(): Vector3;
  28342. /**
  28343. * Gets the hit point in the world
  28344. */
  28345. get hitPointWorld(): Vector3;
  28346. /**
  28347. * Gets the ray "start point" of the ray in the world
  28348. */
  28349. get rayFromWorld(): Vector3;
  28350. /**
  28351. * Gets the ray "end point" of the ray in the world
  28352. */
  28353. get rayToWorld(): Vector3;
  28354. /**
  28355. * Sets the hit data (normal & point in world space)
  28356. * @param hitNormalWorld defines the normal in world space
  28357. * @param hitPointWorld defines the point in world space
  28358. */
  28359. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  28360. /**
  28361. * Sets the distance from the start point to the hit point
  28362. * @param distance
  28363. */
  28364. setHitDistance(distance: number): void;
  28365. /**
  28366. * Calculates the distance manually
  28367. */
  28368. calculateHitDistance(): void;
  28369. /**
  28370. * Resets all the values to default
  28371. * @param from The from point on world space
  28372. * @param to The to point on world space
  28373. */
  28374. reset(from?: Vector3, to?: Vector3): void;
  28375. }
  28376. /**
  28377. * Interface for the size containing width and height
  28378. */
  28379. interface IXYZ {
  28380. /**
  28381. * X
  28382. */
  28383. x: number;
  28384. /**
  28385. * Y
  28386. */
  28387. y: number;
  28388. /**
  28389. * Z
  28390. */
  28391. z: number;
  28392. }
  28393. }
  28394. declare module "babylonjs/Physics/IPhysicsEngine" {
  28395. import { Nullable } from "babylonjs/types";
  28396. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  28397. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  28398. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  28399. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  28400. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  28401. /**
  28402. * Interface used to describe a physics joint
  28403. */
  28404. export interface PhysicsImpostorJoint {
  28405. /** Defines the main impostor to which the joint is linked */
  28406. mainImpostor: PhysicsImpostor;
  28407. /** Defines the impostor that is connected to the main impostor using this joint */
  28408. connectedImpostor: PhysicsImpostor;
  28409. /** Defines the joint itself */
  28410. joint: PhysicsJoint;
  28411. }
  28412. /** @hidden */
  28413. export interface IPhysicsEnginePlugin {
  28414. world: any;
  28415. name: string;
  28416. setGravity(gravity: Vector3): void;
  28417. setTimeStep(timeStep: number): void;
  28418. getTimeStep(): number;
  28419. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  28420. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  28421. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  28422. generatePhysicsBody(impostor: PhysicsImpostor): void;
  28423. removePhysicsBody(impostor: PhysicsImpostor): void;
  28424. generateJoint(joint: PhysicsImpostorJoint): void;
  28425. removeJoint(joint: PhysicsImpostorJoint): void;
  28426. isSupported(): boolean;
  28427. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  28428. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  28429. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  28430. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  28431. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  28432. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  28433. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  28434. getBodyMass(impostor: PhysicsImpostor): number;
  28435. getBodyFriction(impostor: PhysicsImpostor): number;
  28436. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  28437. getBodyRestitution(impostor: PhysicsImpostor): number;
  28438. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  28439. getBodyPressure?(impostor: PhysicsImpostor): number;
  28440. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  28441. getBodyStiffness?(impostor: PhysicsImpostor): number;
  28442. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  28443. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  28444. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  28445. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  28446. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  28447. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  28448. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  28449. sleepBody(impostor: PhysicsImpostor): void;
  28450. wakeUpBody(impostor: PhysicsImpostor): void;
  28451. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  28452. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  28453. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  28454. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  28455. getRadius(impostor: PhysicsImpostor): number;
  28456. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  28457. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  28458. dispose(): void;
  28459. }
  28460. /**
  28461. * Interface used to define a physics engine
  28462. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  28463. */
  28464. export interface IPhysicsEngine {
  28465. /**
  28466. * Gets the gravity vector used by the simulation
  28467. */
  28468. gravity: Vector3;
  28469. /**
  28470. * Sets the gravity vector used by the simulation
  28471. * @param gravity defines the gravity vector to use
  28472. */
  28473. setGravity(gravity: Vector3): void;
  28474. /**
  28475. * Set the time step of the physics engine.
  28476. * Default is 1/60.
  28477. * To slow it down, enter 1/600 for example.
  28478. * To speed it up, 1/30
  28479. * @param newTimeStep the new timestep to apply to this world.
  28480. */
  28481. setTimeStep(newTimeStep: number): void;
  28482. /**
  28483. * Get the time step of the physics engine.
  28484. * @returns the current time step
  28485. */
  28486. getTimeStep(): number;
  28487. /**
  28488. * Set the sub time step of the physics engine.
  28489. * Default is 0 meaning there is no sub steps
  28490. * To increase physics resolution precision, set a small value (like 1 ms)
  28491. * @param subTimeStep defines the new sub timestep used for physics resolution.
  28492. */
  28493. setSubTimeStep(subTimeStep: number): void;
  28494. /**
  28495. * Get the sub time step of the physics engine.
  28496. * @returns the current sub time step
  28497. */
  28498. getSubTimeStep(): number;
  28499. /**
  28500. * Release all resources
  28501. */
  28502. dispose(): void;
  28503. /**
  28504. * Gets the name of the current physics plugin
  28505. * @returns the name of the plugin
  28506. */
  28507. getPhysicsPluginName(): string;
  28508. /**
  28509. * Adding a new impostor for the impostor tracking.
  28510. * This will be done by the impostor itself.
  28511. * @param impostor the impostor to add
  28512. */
  28513. addImpostor(impostor: PhysicsImpostor): void;
  28514. /**
  28515. * Remove an impostor from the engine.
  28516. * This impostor and its mesh will not longer be updated by the physics engine.
  28517. * @param impostor the impostor to remove
  28518. */
  28519. removeImpostor(impostor: PhysicsImpostor): void;
  28520. /**
  28521. * Add a joint to the physics engine
  28522. * @param mainImpostor defines the main impostor to which the joint is added.
  28523. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  28524. * @param joint defines the joint that will connect both impostors.
  28525. */
  28526. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  28527. /**
  28528. * Removes a joint from the simulation
  28529. * @param mainImpostor defines the impostor used with the joint
  28530. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  28531. * @param joint defines the joint to remove
  28532. */
  28533. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  28534. /**
  28535. * Gets the current plugin used to run the simulation
  28536. * @returns current plugin
  28537. */
  28538. getPhysicsPlugin(): IPhysicsEnginePlugin;
  28539. /**
  28540. * Gets the list of physic impostors
  28541. * @returns an array of PhysicsImpostor
  28542. */
  28543. getImpostors(): Array<PhysicsImpostor>;
  28544. /**
  28545. * Gets the impostor for a physics enabled object
  28546. * @param object defines the object impersonated by the impostor
  28547. * @returns the PhysicsImpostor or null if not found
  28548. */
  28549. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  28550. /**
  28551. * Gets the impostor for a physics body object
  28552. * @param body defines physics body used by the impostor
  28553. * @returns the PhysicsImpostor or null if not found
  28554. */
  28555. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  28556. /**
  28557. * Does a raycast in the physics world
  28558. * @param from when should the ray start?
  28559. * @param to when should the ray end?
  28560. * @returns PhysicsRaycastResult
  28561. */
  28562. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  28563. /**
  28564. * Called by the scene. No need to call it.
  28565. * @param delta defines the timespam between frames
  28566. */
  28567. _step(delta: number): void;
  28568. }
  28569. }
  28570. declare module "babylonjs/Physics/physicsImpostor" {
  28571. import { Nullable, IndicesArray } from "babylonjs/types";
  28572. import { Vector3, Matrix, Quaternion } from "babylonjs/Maths/math.vector";
  28573. import { TransformNode } from "babylonjs/Meshes/transformNode";
  28574. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  28575. import { Scene } from "babylonjs/scene";
  28576. import { Bone } from "babylonjs/Bones/bone";
  28577. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  28578. import { PhysicsJoint, PhysicsJointData } from "babylonjs/Physics/physicsJoint";
  28579. import { Space } from "babylonjs/Maths/math.axis";
  28580. /**
  28581. * The interface for the physics imposter parameters
  28582. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  28583. */
  28584. export interface PhysicsImpostorParameters {
  28585. /**
  28586. * The mass of the physics imposter
  28587. */
  28588. mass: number;
  28589. /**
  28590. * The friction of the physics imposter
  28591. */
  28592. friction?: number;
  28593. /**
  28594. * The coefficient of restitution of the physics imposter
  28595. */
  28596. restitution?: number;
  28597. /**
  28598. * The native options of the physics imposter
  28599. */
  28600. nativeOptions?: any;
  28601. /**
  28602. * Specifies if the parent should be ignored
  28603. */
  28604. ignoreParent?: boolean;
  28605. /**
  28606. * Specifies if bi-directional transformations should be disabled
  28607. */
  28608. disableBidirectionalTransformation?: boolean;
  28609. /**
  28610. * The pressure inside the physics imposter, soft object only
  28611. */
  28612. pressure?: number;
  28613. /**
  28614. * The stiffness the physics imposter, soft object only
  28615. */
  28616. stiffness?: number;
  28617. /**
  28618. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  28619. */
  28620. velocityIterations?: number;
  28621. /**
  28622. * The number of iterations used in maintaining consistent vertex positions, soft object only
  28623. */
  28624. positionIterations?: number;
  28625. /**
  28626. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  28627. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  28628. * Add to fix multiple points
  28629. */
  28630. fixedPoints?: number;
  28631. /**
  28632. * The collision margin around a soft object
  28633. */
  28634. margin?: number;
  28635. /**
  28636. * The collision margin around a soft object
  28637. */
  28638. damping?: number;
  28639. /**
  28640. * The path for a rope based on an extrusion
  28641. */
  28642. path?: any;
  28643. /**
  28644. * The shape of an extrusion used for a rope based on an extrusion
  28645. */
  28646. shape?: any;
  28647. }
  28648. /**
  28649. * Interface for a physics-enabled object
  28650. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  28651. */
  28652. export interface IPhysicsEnabledObject {
  28653. /**
  28654. * The position of the physics-enabled object
  28655. */
  28656. position: Vector3;
  28657. /**
  28658. * The rotation of the physics-enabled object
  28659. */
  28660. rotationQuaternion: Nullable<Quaternion>;
  28661. /**
  28662. * The scale of the physics-enabled object
  28663. */
  28664. scaling: Vector3;
  28665. /**
  28666. * The rotation of the physics-enabled object
  28667. */
  28668. rotation?: Vector3;
  28669. /**
  28670. * The parent of the physics-enabled object
  28671. */
  28672. parent?: any;
  28673. /**
  28674. * The bounding info of the physics-enabled object
  28675. * @returns The bounding info of the physics-enabled object
  28676. */
  28677. getBoundingInfo(): BoundingInfo;
  28678. /**
  28679. * Computes the world matrix
  28680. * @param force Specifies if the world matrix should be computed by force
  28681. * @returns A world matrix
  28682. */
  28683. computeWorldMatrix(force: boolean): Matrix;
  28684. /**
  28685. * Gets the world matrix
  28686. * @returns A world matrix
  28687. */
  28688. getWorldMatrix?(): Matrix;
  28689. /**
  28690. * Gets the child meshes
  28691. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  28692. * @returns An array of abstract meshes
  28693. */
  28694. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  28695. /**
  28696. * Gets the vertex data
  28697. * @param kind The type of vertex data
  28698. * @returns A nullable array of numbers, or a float32 array
  28699. */
  28700. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  28701. /**
  28702. * Gets the indices from the mesh
  28703. * @returns A nullable array of index arrays
  28704. */
  28705. getIndices?(): Nullable<IndicesArray>;
  28706. /**
  28707. * Gets the scene from the mesh
  28708. * @returns the indices array or null
  28709. */
  28710. getScene?(): Scene;
  28711. /**
  28712. * Gets the absolute position from the mesh
  28713. * @returns the absolute position
  28714. */
  28715. getAbsolutePosition(): Vector3;
  28716. /**
  28717. * Gets the absolute pivot point from the mesh
  28718. * @returns the absolute pivot point
  28719. */
  28720. getAbsolutePivotPoint(): Vector3;
  28721. /**
  28722. * Rotates the mesh
  28723. * @param axis The axis of rotation
  28724. * @param amount The amount of rotation
  28725. * @param space The space of the rotation
  28726. * @returns The rotation transform node
  28727. */
  28728. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  28729. /**
  28730. * Translates the mesh
  28731. * @param axis The axis of translation
  28732. * @param distance The distance of translation
  28733. * @param space The space of the translation
  28734. * @returns The transform node
  28735. */
  28736. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  28737. /**
  28738. * Sets the absolute position of the mesh
  28739. * @param absolutePosition The absolute position of the mesh
  28740. * @returns The transform node
  28741. */
  28742. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  28743. /**
  28744. * Gets the class name of the mesh
  28745. * @returns The class name
  28746. */
  28747. getClassName(): string;
  28748. }
  28749. /**
  28750. * Represents a physics imposter
  28751. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  28752. */
  28753. export class PhysicsImpostor {
  28754. /**
  28755. * The physics-enabled object used as the physics imposter
  28756. */
  28757. object: IPhysicsEnabledObject;
  28758. /**
  28759. * The type of the physics imposter
  28760. */
  28761. type: number;
  28762. private _options;
  28763. private _scene?;
  28764. /**
  28765. * The default object size of the imposter
  28766. */
  28767. static DEFAULT_OBJECT_SIZE: Vector3;
  28768. /**
  28769. * The identity quaternion of the imposter
  28770. */
  28771. static IDENTITY_QUATERNION: Quaternion;
  28772. /** @hidden */
  28773. _pluginData: any;
  28774. private _physicsEngine;
  28775. private _physicsBody;
  28776. private _bodyUpdateRequired;
  28777. private _onBeforePhysicsStepCallbacks;
  28778. private _onAfterPhysicsStepCallbacks;
  28779. /** @hidden */
  28780. _onPhysicsCollideCallbacks: Array<{
  28781. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  28782. otherImpostors: Array<PhysicsImpostor>;
  28783. }>;
  28784. private _deltaPosition;
  28785. private _deltaRotation;
  28786. private _deltaRotationConjugated;
  28787. /** @hidden */
  28788. _isFromLine: boolean;
  28789. private _parent;
  28790. private _isDisposed;
  28791. private static _tmpVecs;
  28792. private static _tmpQuat;
  28793. /**
  28794. * Specifies if the physics imposter is disposed
  28795. */
  28796. get isDisposed(): boolean;
  28797. /**
  28798. * Gets the mass of the physics imposter
  28799. */
  28800. get mass(): number;
  28801. set mass(value: number);
  28802. /**
  28803. * Gets the coefficient of friction
  28804. */
  28805. get friction(): number;
  28806. /**
  28807. * Sets the coefficient of friction
  28808. */
  28809. set friction(value: number);
  28810. /**
  28811. * Gets the coefficient of restitution
  28812. */
  28813. get restitution(): number;
  28814. /**
  28815. * Sets the coefficient of restitution
  28816. */
  28817. set restitution(value: number);
  28818. /**
  28819. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  28820. */
  28821. get pressure(): number;
  28822. /**
  28823. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  28824. */
  28825. set pressure(value: number);
  28826. /**
  28827. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  28828. */
  28829. get stiffness(): number;
  28830. /**
  28831. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  28832. */
  28833. set stiffness(value: number);
  28834. /**
  28835. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  28836. */
  28837. get velocityIterations(): number;
  28838. /**
  28839. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  28840. */
  28841. set velocityIterations(value: number);
  28842. /**
  28843. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  28844. */
  28845. get positionIterations(): number;
  28846. /**
  28847. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  28848. */
  28849. set positionIterations(value: number);
  28850. /**
  28851. * The unique id of the physics imposter
  28852. * set by the physics engine when adding this impostor to the array
  28853. */
  28854. uniqueId: number;
  28855. /**
  28856. * @hidden
  28857. */
  28858. soft: boolean;
  28859. /**
  28860. * @hidden
  28861. */
  28862. segments: number;
  28863. private _joints;
  28864. /**
  28865. * Initializes the physics imposter
  28866. * @param object The physics-enabled object used as the physics imposter
  28867. * @param type The type of the physics imposter
  28868. * @param _options The options for the physics imposter
  28869. * @param _scene The Babylon scene
  28870. */
  28871. constructor(
  28872. /**
  28873. * The physics-enabled object used as the physics imposter
  28874. */
  28875. object: IPhysicsEnabledObject,
  28876. /**
  28877. * The type of the physics imposter
  28878. */
  28879. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  28880. /**
  28881. * This function will completly initialize this impostor.
  28882. * It will create a new body - but only if this mesh has no parent.
  28883. * If it has, this impostor will not be used other than to define the impostor
  28884. * of the child mesh.
  28885. * @hidden
  28886. */
  28887. _init(): void;
  28888. private _getPhysicsParent;
  28889. /**
  28890. * Should a new body be generated.
  28891. * @returns boolean specifying if body initialization is required
  28892. */
  28893. isBodyInitRequired(): boolean;
  28894. /**
  28895. * Sets the updated scaling
  28896. * @param updated Specifies if the scaling is updated
  28897. */
  28898. setScalingUpdated(): void;
  28899. /**
  28900. * Force a regeneration of this or the parent's impostor's body.
  28901. * Use under cautious - This will remove all joints already implemented.
  28902. */
  28903. forceUpdate(): void;
  28904. /**
  28905. * Gets the body that holds this impostor. Either its own, or its parent.
  28906. */
  28907. get physicsBody(): any;
  28908. /**
  28909. * Get the parent of the physics imposter
  28910. * @returns Physics imposter or null
  28911. */
  28912. get parent(): Nullable<PhysicsImpostor>;
  28913. /**
  28914. * Sets the parent of the physics imposter
  28915. */
  28916. set parent(value: Nullable<PhysicsImpostor>);
  28917. /**
  28918. * Set the physics body. Used mainly by the physics engine/plugin
  28919. */
  28920. set physicsBody(physicsBody: any);
  28921. /**
  28922. * Resets the update flags
  28923. */
  28924. resetUpdateFlags(): void;
  28925. /**
  28926. * Gets the object extend size
  28927. * @returns the object extend size
  28928. */
  28929. getObjectExtendSize(): Vector3;
  28930. /**
  28931. * Gets the object center
  28932. * @returns The object center
  28933. */
  28934. getObjectCenter(): Vector3;
  28935. /**
  28936. * Get a specific parameter from the options parameters
  28937. * @param paramName The object parameter name
  28938. * @returns The object parameter
  28939. */
  28940. getParam(paramName: string): any;
  28941. /**
  28942. * Sets a specific parameter in the options given to the physics plugin
  28943. * @param paramName The parameter name
  28944. * @param value The value of the parameter
  28945. */
  28946. setParam(paramName: string, value: number): void;
  28947. /**
  28948. * Specifically change the body's mass option. Won't recreate the physics body object
  28949. * @param mass The mass of the physics imposter
  28950. */
  28951. setMass(mass: number): void;
  28952. /**
  28953. * Gets the linear velocity
  28954. * @returns linear velocity or null
  28955. */
  28956. getLinearVelocity(): Nullable<Vector3>;
  28957. /**
  28958. * Sets the linear velocity
  28959. * @param velocity linear velocity or null
  28960. */
  28961. setLinearVelocity(velocity: Nullable<Vector3>): void;
  28962. /**
  28963. * Gets the angular velocity
  28964. * @returns angular velocity or null
  28965. */
  28966. getAngularVelocity(): Nullable<Vector3>;
  28967. /**
  28968. * Sets the angular velocity
  28969. * @param velocity The velocity or null
  28970. */
  28971. setAngularVelocity(velocity: Nullable<Vector3>): void;
  28972. /**
  28973. * Execute a function with the physics plugin native code
  28974. * Provide a function the will have two variables - the world object and the physics body object
  28975. * @param func The function to execute with the physics plugin native code
  28976. */
  28977. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  28978. /**
  28979. * Register a function that will be executed before the physics world is stepping forward
  28980. * @param func The function to execute before the physics world is stepped forward
  28981. */
  28982. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  28983. /**
  28984. * Unregister a function that will be executed before the physics world is stepping forward
  28985. * @param func The function to execute before the physics world is stepped forward
  28986. */
  28987. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  28988. /**
  28989. * Register a function that will be executed after the physics step
  28990. * @param func The function to execute after physics step
  28991. */
  28992. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  28993. /**
  28994. * Unregisters a function that will be executed after the physics step
  28995. * @param func The function to execute after physics step
  28996. */
  28997. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  28998. /**
  28999. * register a function that will be executed when this impostor collides against a different body
  29000. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  29001. * @param func Callback that is executed on collision
  29002. */
  29003. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  29004. /**
  29005. * Unregisters the physics imposter on contact
  29006. * @param collideAgainst The physics object to collide against
  29007. * @param func Callback to execute on collision
  29008. */
  29009. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  29010. private _tmpQuat;
  29011. private _tmpQuat2;
  29012. /**
  29013. * Get the parent rotation
  29014. * @returns The parent rotation
  29015. */
  29016. getParentsRotation(): Quaternion;
  29017. /**
  29018. * this function is executed by the physics engine.
  29019. */
  29020. beforeStep: () => void;
  29021. /**
  29022. * this function is executed by the physics engine
  29023. */
  29024. afterStep: () => void;
  29025. /**
  29026. * Legacy collision detection event support
  29027. */
  29028. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  29029. /**
  29030. * event and body object due to cannon's event-based architecture.
  29031. */
  29032. onCollide: (e: {
  29033. body: any;
  29034. }) => void;
  29035. /**
  29036. * Apply a force
  29037. * @param force The force to apply
  29038. * @param contactPoint The contact point for the force
  29039. * @returns The physics imposter
  29040. */
  29041. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  29042. /**
  29043. * Apply an impulse
  29044. * @param force The impulse force
  29045. * @param contactPoint The contact point for the impulse force
  29046. * @returns The physics imposter
  29047. */
  29048. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  29049. /**
  29050. * A help function to create a joint
  29051. * @param otherImpostor A physics imposter used to create a joint
  29052. * @param jointType The type of joint
  29053. * @param jointData The data for the joint
  29054. * @returns The physics imposter
  29055. */
  29056. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  29057. /**
  29058. * Add a joint to this impostor with a different impostor
  29059. * @param otherImpostor A physics imposter used to add a joint
  29060. * @param joint The joint to add
  29061. * @returns The physics imposter
  29062. */
  29063. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  29064. /**
  29065. * Add an anchor to a cloth impostor
  29066. * @param otherImpostor rigid impostor to anchor to
  29067. * @param width ratio across width from 0 to 1
  29068. * @param height ratio up height from 0 to 1
  29069. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  29070. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  29071. * @returns impostor the soft imposter
  29072. */
  29073. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  29074. /**
  29075. * Add a hook to a rope impostor
  29076. * @param otherImpostor rigid impostor to anchor to
  29077. * @param length ratio across rope from 0 to 1
  29078. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  29079. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  29080. * @returns impostor the rope imposter
  29081. */
  29082. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  29083. /**
  29084. * Will keep this body still, in a sleep mode.
  29085. * @returns the physics imposter
  29086. */
  29087. sleep(): PhysicsImpostor;
  29088. /**
  29089. * Wake the body up.
  29090. * @returns The physics imposter
  29091. */
  29092. wakeUp(): PhysicsImpostor;
  29093. /**
  29094. * Clones the physics imposter
  29095. * @param newObject The physics imposter clones to this physics-enabled object
  29096. * @returns A nullable physics imposter
  29097. */
  29098. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  29099. /**
  29100. * Disposes the physics imposter
  29101. */
  29102. dispose(): void;
  29103. /**
  29104. * Sets the delta position
  29105. * @param position The delta position amount
  29106. */
  29107. setDeltaPosition(position: Vector3): void;
  29108. /**
  29109. * Sets the delta rotation
  29110. * @param rotation The delta rotation amount
  29111. */
  29112. setDeltaRotation(rotation: Quaternion): void;
  29113. /**
  29114. * Gets the box size of the physics imposter and stores the result in the input parameter
  29115. * @param result Stores the box size
  29116. * @returns The physics imposter
  29117. */
  29118. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  29119. /**
  29120. * Gets the radius of the physics imposter
  29121. * @returns Radius of the physics imposter
  29122. */
  29123. getRadius(): number;
  29124. /**
  29125. * Sync a bone with this impostor
  29126. * @param bone The bone to sync to the impostor.
  29127. * @param boneMesh The mesh that the bone is influencing.
  29128. * @param jointPivot The pivot of the joint / bone in local space.
  29129. * @param distToJoint Optional distance from the impostor to the joint.
  29130. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  29131. */
  29132. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  29133. /**
  29134. * Sync impostor to a bone
  29135. * @param bone The bone that the impostor will be synced to.
  29136. * @param boneMesh The mesh that the bone is influencing.
  29137. * @param jointPivot The pivot of the joint / bone in local space.
  29138. * @param distToJoint Optional distance from the impostor to the joint.
  29139. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  29140. * @param boneAxis Optional vector3 axis the bone is aligned with
  29141. */
  29142. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  29143. /**
  29144. * No-Imposter type
  29145. */
  29146. static NoImpostor: number;
  29147. /**
  29148. * Sphere-Imposter type
  29149. */
  29150. static SphereImpostor: number;
  29151. /**
  29152. * Box-Imposter type
  29153. */
  29154. static BoxImpostor: number;
  29155. /**
  29156. * Plane-Imposter type
  29157. */
  29158. static PlaneImpostor: number;
  29159. /**
  29160. * Mesh-imposter type
  29161. */
  29162. static MeshImpostor: number;
  29163. /**
  29164. * Capsule-Impostor type (Ammo.js plugin only)
  29165. */
  29166. static CapsuleImpostor: number;
  29167. /**
  29168. * Cylinder-Imposter type
  29169. */
  29170. static CylinderImpostor: number;
  29171. /**
  29172. * Particle-Imposter type
  29173. */
  29174. static ParticleImpostor: number;
  29175. /**
  29176. * Heightmap-Imposter type
  29177. */
  29178. static HeightmapImpostor: number;
  29179. /**
  29180. * ConvexHull-Impostor type (Ammo.js plugin only)
  29181. */
  29182. static ConvexHullImpostor: number;
  29183. /**
  29184. * Custom-Imposter type (Ammo.js plugin only)
  29185. */
  29186. static CustomImpostor: number;
  29187. /**
  29188. * Rope-Imposter type
  29189. */
  29190. static RopeImpostor: number;
  29191. /**
  29192. * Cloth-Imposter type
  29193. */
  29194. static ClothImpostor: number;
  29195. /**
  29196. * Softbody-Imposter type
  29197. */
  29198. static SoftbodyImpostor: number;
  29199. }
  29200. }
  29201. declare module "babylonjs/Meshes/mesh" {
  29202. import { Observable } from "babylonjs/Misc/observable";
  29203. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  29204. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  29205. import { Camera } from "babylonjs/Cameras/camera";
  29206. import { Scene } from "babylonjs/scene";
  29207. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  29208. import { Color4 } from "babylonjs/Maths/math.color";
  29209. import { Engine } from "babylonjs/Engines/engine";
  29210. import { Node } from "babylonjs/node";
  29211. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  29212. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  29213. import { Buffer } from "babylonjs/Meshes/buffer";
  29214. import { Geometry } from "babylonjs/Meshes/geometry";
  29215. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  29216. import { SubMesh } from "babylonjs/Meshes/subMesh";
  29217. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  29218. import { Effect } from "babylonjs/Materials/effect";
  29219. import { Material } from "babylonjs/Materials/material";
  29220. import { Skeleton } from "babylonjs/Bones/skeleton";
  29221. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  29222. import { MeshLODLevel } from "babylonjs/Meshes/meshLODLevel";
  29223. import { Path3D } from "babylonjs/Maths/math.path";
  29224. import { Plane } from "babylonjs/Maths/math.plane";
  29225. import { TransformNode } from "babylonjs/Meshes/transformNode";
  29226. import { ICreateCapsuleOptions } from "babylonjs/Meshes/Builders/capsuleBuilder";
  29227. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  29228. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  29229. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  29230. import { IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  29231. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  29232. /**
  29233. * @hidden
  29234. **/
  29235. export class _CreationDataStorage {
  29236. closePath?: boolean;
  29237. closeArray?: boolean;
  29238. idx: number[];
  29239. dashSize: number;
  29240. gapSize: number;
  29241. path3D: Path3D;
  29242. pathArray: Vector3[][];
  29243. arc: number;
  29244. radius: number;
  29245. cap: number;
  29246. tessellation: number;
  29247. }
  29248. /**
  29249. * @hidden
  29250. **/
  29251. class _InstanceDataStorage {
  29252. visibleInstances: any;
  29253. batchCache: _InstancesBatch;
  29254. instancesBufferSize: number;
  29255. instancesBuffer: Nullable<Buffer>;
  29256. instancesData: Float32Array;
  29257. overridenInstanceCount: number;
  29258. isFrozen: boolean;
  29259. previousBatch: Nullable<_InstancesBatch>;
  29260. hardwareInstancedRendering: boolean;
  29261. sideOrientation: number;
  29262. manualUpdate: boolean;
  29263. previousRenderId: number;
  29264. }
  29265. /**
  29266. * @hidden
  29267. **/
  29268. export class _InstancesBatch {
  29269. mustReturn: boolean;
  29270. visibleInstances: Nullable<import("babylonjs/Meshes/instancedMesh").InstancedMesh[]>[];
  29271. renderSelf: boolean[];
  29272. hardwareInstancedRendering: boolean[];
  29273. }
  29274. /**
  29275. * @hidden
  29276. **/
  29277. class _ThinInstanceDataStorage {
  29278. instancesCount: number;
  29279. matrixBuffer: Nullable<Buffer>;
  29280. matrixBufferSize: number;
  29281. matrixData: Nullable<Float32Array>;
  29282. boundingVectors: Array<Vector3>;
  29283. worldMatrices: Nullable<Matrix[]>;
  29284. }
  29285. /**
  29286. * Class used to represent renderable models
  29287. */
  29288. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  29289. /**
  29290. * Mesh side orientation : usually the external or front surface
  29291. */
  29292. static readonly FRONTSIDE: number;
  29293. /**
  29294. * Mesh side orientation : usually the internal or back surface
  29295. */
  29296. static readonly BACKSIDE: number;
  29297. /**
  29298. * Mesh side orientation : both internal and external or front and back surfaces
  29299. */
  29300. static readonly DOUBLESIDE: number;
  29301. /**
  29302. * Mesh side orientation : by default, `FRONTSIDE`
  29303. */
  29304. static readonly DEFAULTSIDE: number;
  29305. /**
  29306. * Mesh cap setting : no cap
  29307. */
  29308. static readonly NO_CAP: number;
  29309. /**
  29310. * Mesh cap setting : one cap at the beginning of the mesh
  29311. */
  29312. static readonly CAP_START: number;
  29313. /**
  29314. * Mesh cap setting : one cap at the end of the mesh
  29315. */
  29316. static readonly CAP_END: number;
  29317. /**
  29318. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  29319. */
  29320. static readonly CAP_ALL: number;
  29321. /**
  29322. * Mesh pattern setting : no flip or rotate
  29323. */
  29324. static readonly NO_FLIP: number;
  29325. /**
  29326. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  29327. */
  29328. static readonly FLIP_TILE: number;
  29329. /**
  29330. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  29331. */
  29332. static readonly ROTATE_TILE: number;
  29333. /**
  29334. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  29335. */
  29336. static readonly FLIP_ROW: number;
  29337. /**
  29338. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  29339. */
  29340. static readonly ROTATE_ROW: number;
  29341. /**
  29342. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  29343. */
  29344. static readonly FLIP_N_ROTATE_TILE: number;
  29345. /**
  29346. * Mesh pattern setting : rotate pattern and rotate
  29347. */
  29348. static readonly FLIP_N_ROTATE_ROW: number;
  29349. /**
  29350. * Mesh tile positioning : part tiles same on left/right or top/bottom
  29351. */
  29352. static readonly CENTER: number;
  29353. /**
  29354. * Mesh tile positioning : part tiles on left
  29355. */
  29356. static readonly LEFT: number;
  29357. /**
  29358. * Mesh tile positioning : part tiles on right
  29359. */
  29360. static readonly RIGHT: number;
  29361. /**
  29362. * Mesh tile positioning : part tiles on top
  29363. */
  29364. static readonly TOP: number;
  29365. /**
  29366. * Mesh tile positioning : part tiles on bottom
  29367. */
  29368. static readonly BOTTOM: number;
  29369. /**
  29370. * Gets the default side orientation.
  29371. * @param orientation the orientation to value to attempt to get
  29372. * @returns the default orientation
  29373. * @hidden
  29374. */
  29375. static _GetDefaultSideOrientation(orientation?: number): number;
  29376. private _internalMeshDataInfo;
  29377. get computeBonesUsingShaders(): boolean;
  29378. set computeBonesUsingShaders(value: boolean);
  29379. /**
  29380. * An event triggered before rendering the mesh
  29381. */
  29382. get onBeforeRenderObservable(): Observable<Mesh>;
  29383. /**
  29384. * An event triggered before binding the mesh
  29385. */
  29386. get onBeforeBindObservable(): Observable<Mesh>;
  29387. /**
  29388. * An event triggered after rendering the mesh
  29389. */
  29390. get onAfterRenderObservable(): Observable<Mesh>;
  29391. /**
  29392. * An event triggered before drawing the mesh
  29393. */
  29394. get onBeforeDrawObservable(): Observable<Mesh>;
  29395. private _onBeforeDrawObserver;
  29396. /**
  29397. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  29398. */
  29399. set onBeforeDraw(callback: () => void);
  29400. get hasInstances(): boolean;
  29401. get hasThinInstances(): boolean;
  29402. /**
  29403. * Gets the delay loading state of the mesh (when delay loading is turned on)
  29404. * @see https://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  29405. */
  29406. delayLoadState: number;
  29407. /**
  29408. * Gets the list of instances created from this mesh
  29409. * it is not supposed to be modified manually.
  29410. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  29411. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  29412. */
  29413. instances: import("babylonjs/Meshes/instancedMesh").InstancedMesh[];
  29414. /**
  29415. * Gets the file containing delay loading data for this mesh
  29416. */
  29417. delayLoadingFile: string;
  29418. /** @hidden */
  29419. _binaryInfo: any;
  29420. /**
  29421. * User defined function used to change how LOD level selection is done
  29422. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  29423. */
  29424. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  29425. /**
  29426. * Gets or sets the morph target manager
  29427. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  29428. */
  29429. get morphTargetManager(): Nullable<MorphTargetManager>;
  29430. set morphTargetManager(value: Nullable<MorphTargetManager>);
  29431. /** @hidden */
  29432. _creationDataStorage: Nullable<_CreationDataStorage>;
  29433. /** @hidden */
  29434. _geometry: Nullable<Geometry>;
  29435. /** @hidden */
  29436. _delayInfo: Array<string>;
  29437. /** @hidden */
  29438. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  29439. /** @hidden */
  29440. _instanceDataStorage: _InstanceDataStorage;
  29441. /** @hidden */
  29442. _thinInstanceDataStorage: _ThinInstanceDataStorage;
  29443. private _effectiveMaterial;
  29444. /** @hidden */
  29445. _shouldGenerateFlatShading: boolean;
  29446. /** @hidden */
  29447. _originalBuilderSideOrientation: number;
  29448. /**
  29449. * Use this property to change the original side orientation defined at construction time
  29450. */
  29451. overrideMaterialSideOrientation: Nullable<number>;
  29452. /**
  29453. * Gets the source mesh (the one used to clone this one from)
  29454. */
  29455. get source(): Nullable<Mesh>;
  29456. /**
  29457. * Gets the list of clones of this mesh
  29458. * The scene must have been constructed with useClonedMeshMap=true for this to work!
  29459. * Note that useClonedMeshMap=true is the default setting
  29460. */
  29461. get cloneMeshMap(): Nullable<{
  29462. [id: string]: Mesh | undefined;
  29463. }>;
  29464. /**
  29465. * Gets or sets a boolean indicating that this mesh does not use index buffer
  29466. */
  29467. get isUnIndexed(): boolean;
  29468. set isUnIndexed(value: boolean);
  29469. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  29470. get worldMatrixInstancedBuffer(): Float32Array;
  29471. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  29472. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  29473. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  29474. /**
  29475. * @constructor
  29476. * @param name The value used by scene.getMeshByName() to do a lookup.
  29477. * @param scene The scene to add this mesh to.
  29478. * @param parent The parent of this mesh, if it has one
  29479. * @param source An optional Mesh from which geometry is shared, cloned.
  29480. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  29481. * When false, achieved by calling a clone(), also passing False.
  29482. * This will make creation of children, recursive.
  29483. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  29484. */
  29485. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  29486. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  29487. doNotInstantiate: boolean;
  29488. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  29489. /**
  29490. * Gets the class name
  29491. * @returns the string "Mesh".
  29492. */
  29493. getClassName(): string;
  29494. /** @hidden */
  29495. get _isMesh(): boolean;
  29496. /**
  29497. * Returns a description of this mesh
  29498. * @param fullDetails define if full details about this mesh must be used
  29499. * @returns a descriptive string representing this mesh
  29500. */
  29501. toString(fullDetails?: boolean): string;
  29502. /** @hidden */
  29503. _unBindEffect(): void;
  29504. /**
  29505. * Gets a boolean indicating if this mesh has LOD
  29506. */
  29507. get hasLODLevels(): boolean;
  29508. /**
  29509. * Gets the list of MeshLODLevel associated with the current mesh
  29510. * @returns an array of MeshLODLevel
  29511. */
  29512. getLODLevels(): MeshLODLevel[];
  29513. private _sortLODLevels;
  29514. /**
  29515. * Add a mesh as LOD level triggered at the given distance.
  29516. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  29517. * @param distance The distance from the center of the object to show this level
  29518. * @param mesh The mesh to be added as LOD level (can be null)
  29519. * @return This mesh (for chaining)
  29520. */
  29521. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  29522. /**
  29523. * Returns the LOD level mesh at the passed distance or null if not found.
  29524. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  29525. * @param distance The distance from the center of the object to show this level
  29526. * @returns a Mesh or `null`
  29527. */
  29528. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  29529. /**
  29530. * Remove a mesh from the LOD array
  29531. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  29532. * @param mesh defines the mesh to be removed
  29533. * @return This mesh (for chaining)
  29534. */
  29535. removeLODLevel(mesh: Mesh): Mesh;
  29536. /**
  29537. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  29538. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  29539. * @param camera defines the camera to use to compute distance
  29540. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  29541. * @return This mesh (for chaining)
  29542. */
  29543. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  29544. /**
  29545. * Gets the mesh internal Geometry object
  29546. */
  29547. get geometry(): Nullable<Geometry>;
  29548. /**
  29549. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  29550. * @returns the total number of vertices
  29551. */
  29552. getTotalVertices(): number;
  29553. /**
  29554. * Returns the content of an associated vertex buffer
  29555. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  29556. * - VertexBuffer.PositionKind
  29557. * - VertexBuffer.UVKind
  29558. * - VertexBuffer.UV2Kind
  29559. * - VertexBuffer.UV3Kind
  29560. * - VertexBuffer.UV4Kind
  29561. * - VertexBuffer.UV5Kind
  29562. * - VertexBuffer.UV6Kind
  29563. * - VertexBuffer.ColorKind
  29564. * - VertexBuffer.MatricesIndicesKind
  29565. * - VertexBuffer.MatricesIndicesExtraKind
  29566. * - VertexBuffer.MatricesWeightsKind
  29567. * - VertexBuffer.MatricesWeightsExtraKind
  29568. * @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
  29569. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  29570. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  29571. */
  29572. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  29573. /**
  29574. * Returns the mesh VertexBuffer object from the requested `kind`
  29575. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  29576. * - VertexBuffer.PositionKind
  29577. * - VertexBuffer.NormalKind
  29578. * - VertexBuffer.UVKind
  29579. * - VertexBuffer.UV2Kind
  29580. * - VertexBuffer.UV3Kind
  29581. * - VertexBuffer.UV4Kind
  29582. * - VertexBuffer.UV5Kind
  29583. * - VertexBuffer.UV6Kind
  29584. * - VertexBuffer.ColorKind
  29585. * - VertexBuffer.MatricesIndicesKind
  29586. * - VertexBuffer.MatricesIndicesExtraKind
  29587. * - VertexBuffer.MatricesWeightsKind
  29588. * - VertexBuffer.MatricesWeightsExtraKind
  29589. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  29590. */
  29591. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  29592. /**
  29593. * Tests if a specific vertex buffer is associated with this mesh
  29594. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  29595. * - VertexBuffer.PositionKind
  29596. * - VertexBuffer.NormalKind
  29597. * - VertexBuffer.UVKind
  29598. * - VertexBuffer.UV2Kind
  29599. * - VertexBuffer.UV3Kind
  29600. * - VertexBuffer.UV4Kind
  29601. * - VertexBuffer.UV5Kind
  29602. * - VertexBuffer.UV6Kind
  29603. * - VertexBuffer.ColorKind
  29604. * - VertexBuffer.MatricesIndicesKind
  29605. * - VertexBuffer.MatricesIndicesExtraKind
  29606. * - VertexBuffer.MatricesWeightsKind
  29607. * - VertexBuffer.MatricesWeightsExtraKind
  29608. * @returns a boolean
  29609. */
  29610. isVerticesDataPresent(kind: string): boolean;
  29611. /**
  29612. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  29613. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  29614. * - VertexBuffer.PositionKind
  29615. * - VertexBuffer.UVKind
  29616. * - VertexBuffer.UV2Kind
  29617. * - VertexBuffer.UV3Kind
  29618. * - VertexBuffer.UV4Kind
  29619. * - VertexBuffer.UV5Kind
  29620. * - VertexBuffer.UV6Kind
  29621. * - VertexBuffer.ColorKind
  29622. * - VertexBuffer.MatricesIndicesKind
  29623. * - VertexBuffer.MatricesIndicesExtraKind
  29624. * - VertexBuffer.MatricesWeightsKind
  29625. * - VertexBuffer.MatricesWeightsExtraKind
  29626. * @returns a boolean
  29627. */
  29628. isVertexBufferUpdatable(kind: string): boolean;
  29629. /**
  29630. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  29631. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  29632. * - VertexBuffer.PositionKind
  29633. * - VertexBuffer.NormalKind
  29634. * - VertexBuffer.UVKind
  29635. * - VertexBuffer.UV2Kind
  29636. * - VertexBuffer.UV3Kind
  29637. * - VertexBuffer.UV4Kind
  29638. * - VertexBuffer.UV5Kind
  29639. * - VertexBuffer.UV6Kind
  29640. * - VertexBuffer.ColorKind
  29641. * - VertexBuffer.MatricesIndicesKind
  29642. * - VertexBuffer.MatricesIndicesExtraKind
  29643. * - VertexBuffer.MatricesWeightsKind
  29644. * - VertexBuffer.MatricesWeightsExtraKind
  29645. * @returns an array of strings
  29646. */
  29647. getVerticesDataKinds(): string[];
  29648. /**
  29649. * Returns a positive integer : the total number of indices in this mesh geometry.
  29650. * @returns the numner of indices or zero if the mesh has no geometry.
  29651. */
  29652. getTotalIndices(): number;
  29653. /**
  29654. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  29655. * @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.
  29656. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  29657. * @returns the indices array or an empty array if the mesh has no geometry
  29658. */
  29659. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  29660. get isBlocked(): boolean;
  29661. /**
  29662. * Determine if the current mesh is ready to be rendered
  29663. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  29664. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  29665. * @returns true if all associated assets are ready (material, textures, shaders)
  29666. */
  29667. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  29668. /**
  29669. * 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.
  29670. */
  29671. get areNormalsFrozen(): boolean;
  29672. /**
  29673. * 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.
  29674. * @returns the current mesh
  29675. */
  29676. freezeNormals(): Mesh;
  29677. /**
  29678. * 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
  29679. * @returns the current mesh
  29680. */
  29681. unfreezeNormals(): Mesh;
  29682. /**
  29683. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  29684. */
  29685. set overridenInstanceCount(count: number);
  29686. /** @hidden */
  29687. _preActivate(): Mesh;
  29688. /** @hidden */
  29689. _preActivateForIntermediateRendering(renderId: number): Mesh;
  29690. /** @hidden */
  29691. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  29692. protected _afterComputeWorldMatrix(): void;
  29693. /** @hidden */
  29694. _postActivate(): void;
  29695. /**
  29696. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  29697. * This means the mesh underlying bounding box and sphere are recomputed.
  29698. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  29699. * @returns the current mesh
  29700. */
  29701. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  29702. /** @hidden */
  29703. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  29704. /**
  29705. * This function will subdivide the mesh into multiple submeshes
  29706. * @param count defines the expected number of submeshes
  29707. */
  29708. subdivide(count: number): void;
  29709. /**
  29710. * Copy a FloatArray into a specific associated vertex buffer
  29711. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  29712. * - VertexBuffer.PositionKind
  29713. * - VertexBuffer.UVKind
  29714. * - VertexBuffer.UV2Kind
  29715. * - VertexBuffer.UV3Kind
  29716. * - VertexBuffer.UV4Kind
  29717. * - VertexBuffer.UV5Kind
  29718. * - VertexBuffer.UV6Kind
  29719. * - VertexBuffer.ColorKind
  29720. * - VertexBuffer.MatricesIndicesKind
  29721. * - VertexBuffer.MatricesIndicesExtraKind
  29722. * - VertexBuffer.MatricesWeightsKind
  29723. * - VertexBuffer.MatricesWeightsExtraKind
  29724. * @param data defines the data source
  29725. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  29726. * @param stride defines the data stride size (can be null)
  29727. * @returns the current mesh
  29728. */
  29729. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  29730. /**
  29731. * Delete a vertex buffer associated with this mesh
  29732. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  29733. * - VertexBuffer.PositionKind
  29734. * - VertexBuffer.UVKind
  29735. * - VertexBuffer.UV2Kind
  29736. * - VertexBuffer.UV3Kind
  29737. * - VertexBuffer.UV4Kind
  29738. * - VertexBuffer.UV5Kind
  29739. * - VertexBuffer.UV6Kind
  29740. * - VertexBuffer.ColorKind
  29741. * - VertexBuffer.MatricesIndicesKind
  29742. * - VertexBuffer.MatricesIndicesExtraKind
  29743. * - VertexBuffer.MatricesWeightsKind
  29744. * - VertexBuffer.MatricesWeightsExtraKind
  29745. */
  29746. removeVerticesData(kind: string): void;
  29747. /**
  29748. * Flags an associated vertex buffer as updatable
  29749. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  29750. * - VertexBuffer.PositionKind
  29751. * - VertexBuffer.UVKind
  29752. * - VertexBuffer.UV2Kind
  29753. * - VertexBuffer.UV3Kind
  29754. * - VertexBuffer.UV4Kind
  29755. * - VertexBuffer.UV5Kind
  29756. * - VertexBuffer.UV6Kind
  29757. * - VertexBuffer.ColorKind
  29758. * - VertexBuffer.MatricesIndicesKind
  29759. * - VertexBuffer.MatricesIndicesExtraKind
  29760. * - VertexBuffer.MatricesWeightsKind
  29761. * - VertexBuffer.MatricesWeightsExtraKind
  29762. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  29763. */
  29764. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  29765. /**
  29766. * Sets the mesh global Vertex Buffer
  29767. * @param buffer defines the buffer to use
  29768. * @returns the current mesh
  29769. */
  29770. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  29771. /**
  29772. * Update a specific associated vertex buffer
  29773. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  29774. * - VertexBuffer.PositionKind
  29775. * - VertexBuffer.UVKind
  29776. * - VertexBuffer.UV2Kind
  29777. * - VertexBuffer.UV3Kind
  29778. * - VertexBuffer.UV4Kind
  29779. * - VertexBuffer.UV5Kind
  29780. * - VertexBuffer.UV6Kind
  29781. * - VertexBuffer.ColorKind
  29782. * - VertexBuffer.MatricesIndicesKind
  29783. * - VertexBuffer.MatricesIndicesExtraKind
  29784. * - VertexBuffer.MatricesWeightsKind
  29785. * - VertexBuffer.MatricesWeightsExtraKind
  29786. * @param data defines the data source
  29787. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  29788. * @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)
  29789. * @returns the current mesh
  29790. */
  29791. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  29792. /**
  29793. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  29794. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  29795. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  29796. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  29797. * @returns the current mesh
  29798. */
  29799. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  29800. /**
  29801. * Creates a un-shared specific occurence of the geometry for the mesh.
  29802. * @returns the current mesh
  29803. */
  29804. makeGeometryUnique(): Mesh;
  29805. /**
  29806. * Set the index buffer of this mesh
  29807. * @param indices defines the source data
  29808. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  29809. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  29810. * @returns the current mesh
  29811. */
  29812. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  29813. /**
  29814. * Update the current index buffer
  29815. * @param indices defines the source data
  29816. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  29817. * @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)
  29818. * @returns the current mesh
  29819. */
  29820. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  29821. /**
  29822. * Invert the geometry to move from a right handed system to a left handed one.
  29823. * @returns the current mesh
  29824. */
  29825. toLeftHanded(): Mesh;
  29826. /** @hidden */
  29827. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  29828. /** @hidden */
  29829. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  29830. /**
  29831. * Registers for this mesh a javascript function called just before the rendering process
  29832. * @param func defines the function to call before rendering this mesh
  29833. * @returns the current mesh
  29834. */
  29835. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  29836. /**
  29837. * Disposes a previously registered javascript function called before the rendering
  29838. * @param func defines the function to remove
  29839. * @returns the current mesh
  29840. */
  29841. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  29842. /**
  29843. * Registers for this mesh a javascript function called just after the rendering is complete
  29844. * @param func defines the function to call after rendering this mesh
  29845. * @returns the current mesh
  29846. */
  29847. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  29848. /**
  29849. * Disposes a previously registered javascript function called after the rendering.
  29850. * @param func defines the function to remove
  29851. * @returns the current mesh
  29852. */
  29853. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  29854. /** @hidden */
  29855. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  29856. /** @hidden */
  29857. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  29858. /** @hidden */
  29859. _renderWithThinInstances(subMesh: SubMesh, fillMode: number, effect: Effect, engine: Engine): void;
  29860. /** @hidden */
  29861. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  29862. /** @hidden */
  29863. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  29864. /** @hidden */
  29865. _rebuild(): void;
  29866. /** @hidden */
  29867. _freeze(): void;
  29868. /** @hidden */
  29869. _unFreeze(): void;
  29870. /**
  29871. * 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
  29872. * @param subMesh defines the subMesh to render
  29873. * @param enableAlphaMode defines if alpha mode can be changed
  29874. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  29875. * @returns the current mesh
  29876. */
  29877. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  29878. private _onBeforeDraw;
  29879. /**
  29880. * Renormalize the mesh and patch it up if there are no weights
  29881. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  29882. * However in the case of zero weights then we set just a single influence to 1.
  29883. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  29884. */
  29885. cleanMatrixWeights(): void;
  29886. private normalizeSkinFourWeights;
  29887. private normalizeSkinWeightsAndExtra;
  29888. /**
  29889. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  29890. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  29891. * the user know there was an issue with importing the mesh
  29892. * @returns a validation object with skinned, valid and report string
  29893. */
  29894. validateSkinning(): {
  29895. skinned: boolean;
  29896. valid: boolean;
  29897. report: string;
  29898. };
  29899. /** @hidden */
  29900. _checkDelayState(): Mesh;
  29901. private _queueLoad;
  29902. /**
  29903. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  29904. * A mesh is in the frustum if its bounding box intersects the frustum
  29905. * @param frustumPlanes defines the frustum to test
  29906. * @returns true if the mesh is in the frustum planes
  29907. */
  29908. isInFrustum(frustumPlanes: Plane[]): boolean;
  29909. /**
  29910. * Sets the mesh material by the material or multiMaterial `id` property
  29911. * @param id is a string identifying the material or the multiMaterial
  29912. * @returns the current mesh
  29913. */
  29914. setMaterialByID(id: string): Mesh;
  29915. /**
  29916. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  29917. * @returns an array of IAnimatable
  29918. */
  29919. getAnimatables(): IAnimatable[];
  29920. /**
  29921. * Modifies the mesh geometry according to the passed transformation matrix.
  29922. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  29923. * The mesh normals are modified using the same transformation.
  29924. * Note that, under the hood, this method sets a new VertexBuffer each call.
  29925. * @param transform defines the transform matrix to use
  29926. * @see https://doc.babylonjs.com/resources/baking_transformations
  29927. * @returns the current mesh
  29928. */
  29929. bakeTransformIntoVertices(transform: Matrix): Mesh;
  29930. /**
  29931. * Modifies the mesh geometry according to its own current World Matrix.
  29932. * The mesh World Matrix is then reset.
  29933. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  29934. * Note that, under the hood, this method sets a new VertexBuffer each call.
  29935. * @see https://doc.babylonjs.com/resources/baking_transformations
  29936. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  29937. * @returns the current mesh
  29938. */
  29939. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  29940. /** @hidden */
  29941. get _positions(): Nullable<Vector3[]>;
  29942. /** @hidden */
  29943. _resetPointsArrayCache(): Mesh;
  29944. /** @hidden */
  29945. _generatePointsArray(): boolean;
  29946. /**
  29947. * Returns a new Mesh object generated from the current mesh properties.
  29948. * This method must not get confused with createInstance()
  29949. * @param name is a string, the name given to the new mesh
  29950. * @param newParent can be any Node object (default `null`)
  29951. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  29952. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  29953. * @returns a new mesh
  29954. */
  29955. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  29956. /**
  29957. * Releases resources associated with this mesh.
  29958. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  29959. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  29960. */
  29961. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  29962. /** @hidden */
  29963. _disposeInstanceSpecificData(): void;
  29964. /** @hidden */
  29965. _disposeThinInstanceSpecificData(): void;
  29966. /**
  29967. * Modifies the mesh geometry according to a displacement map.
  29968. * 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.
  29969. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  29970. * @param url is a string, the URL from the image file is to be downloaded.
  29971. * @param minHeight is the lower limit of the displacement.
  29972. * @param maxHeight is the upper limit of the displacement.
  29973. * @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.
  29974. * @param uvOffset is an optional vector2 used to offset UV.
  29975. * @param uvScale is an optional vector2 used to scale UV.
  29976. * @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.
  29977. * @returns the Mesh.
  29978. */
  29979. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  29980. /**
  29981. * Modifies the mesh geometry according to a displacementMap buffer.
  29982. * 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.
  29983. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  29984. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  29985. * @param heightMapWidth is the width of the buffer image.
  29986. * @param heightMapHeight is the height of the buffer image.
  29987. * @param minHeight is the lower limit of the displacement.
  29988. * @param maxHeight is the upper limit of the displacement.
  29989. * @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.
  29990. * @param uvOffset is an optional vector2 used to offset UV.
  29991. * @param uvScale is an optional vector2 used to scale UV.
  29992. * @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.
  29993. * @returns the Mesh.
  29994. */
  29995. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  29996. /**
  29997. * Modify the mesh to get a flat shading rendering.
  29998. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  29999. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  30000. * @returns current mesh
  30001. */
  30002. convertToFlatShadedMesh(): Mesh;
  30003. /**
  30004. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  30005. * In other words, more vertices, no more indices and a single bigger VBO.
  30006. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  30007. * @returns current mesh
  30008. */
  30009. convertToUnIndexedMesh(): Mesh;
  30010. /**
  30011. * Inverses facet orientations.
  30012. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  30013. * @param flipNormals will also inverts the normals
  30014. * @returns current mesh
  30015. */
  30016. flipFaces(flipNormals?: boolean): Mesh;
  30017. /**
  30018. * Increase the number of facets and hence vertices in a mesh
  30019. * Vertex normals are interpolated from existing vertex normals
  30020. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  30021. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  30022. */
  30023. increaseVertices(numberPerEdge: number): void;
  30024. /**
  30025. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  30026. * This will undo any application of covertToFlatShadedMesh
  30027. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  30028. */
  30029. forceSharedVertices(): void;
  30030. /** @hidden */
  30031. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  30032. /** @hidden */
  30033. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  30034. /**
  30035. * Creates a new InstancedMesh object from the mesh model.
  30036. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  30037. * @param name defines the name of the new instance
  30038. * @returns a new InstancedMesh
  30039. */
  30040. createInstance(name: string): InstancedMesh;
  30041. /**
  30042. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  30043. * After this call, all the mesh instances have the same submeshes than the current mesh.
  30044. * @returns the current mesh
  30045. */
  30046. synchronizeInstances(): Mesh;
  30047. /**
  30048. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  30049. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  30050. * This should be used together with the simplification to avoid disappearing triangles.
  30051. * @param successCallback an optional success callback to be called after the optimization finished.
  30052. * @returns the current mesh
  30053. */
  30054. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  30055. /**
  30056. * Serialize current mesh
  30057. * @param serializationObject defines the object which will receive the serialization data
  30058. */
  30059. serialize(serializationObject: any): void;
  30060. /** @hidden */
  30061. _syncGeometryWithMorphTargetManager(): void;
  30062. /** @hidden */
  30063. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  30064. /**
  30065. * Returns a new Mesh object parsed from the source provided.
  30066. * @param parsedMesh is the source
  30067. * @param scene defines the hosting scene
  30068. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  30069. * @returns a new Mesh
  30070. */
  30071. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  30072. /**
  30073. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  30074. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  30075. * @param name defines the name of the mesh to create
  30076. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  30077. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  30078. * @param closePath creates a seam between the first and the last points of each path of the path array
  30079. * @param offset is taken in account only if the `pathArray` is containing a single path
  30080. * @param scene defines the hosting scene
  30081. * @param updatable defines if the mesh must be flagged as updatable
  30082. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  30083. * @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)
  30084. * @returns a new Mesh
  30085. */
  30086. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  30087. /**
  30088. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  30089. * @param name defines the name of the mesh to create
  30090. * @param radius sets the radius size (float) of the polygon (default 0.5)
  30091. * @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
  30092. * @param scene defines the hosting scene
  30093. * @param updatable defines if the mesh must be flagged as updatable
  30094. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  30095. * @returns a new Mesh
  30096. */
  30097. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  30098. /**
  30099. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  30100. * @param name defines the name of the mesh to create
  30101. * @param size sets the size (float) of each box side (default 1)
  30102. * @param scene defines the hosting scene
  30103. * @param updatable defines if the mesh must be flagged as updatable
  30104. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  30105. * @returns a new Mesh
  30106. */
  30107. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  30108. /**
  30109. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  30110. * @param name defines the name of the mesh to create
  30111. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  30112. * @param diameter sets the diameter size (float) of the sphere (default 1)
  30113. * @param scene defines the hosting scene
  30114. * @param updatable defines if the mesh must be flagged as updatable
  30115. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  30116. * @returns a new Mesh
  30117. */
  30118. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  30119. /**
  30120. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  30121. * @param name defines the name of the mesh to create
  30122. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  30123. * @param diameter sets the diameter size (float) of the sphere (default 1)
  30124. * @param scene defines the hosting scene
  30125. * @returns a new Mesh
  30126. */
  30127. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  30128. /**
  30129. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  30130. * @param name defines the name of the mesh to create
  30131. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  30132. * @param diameterTop set the top cap diameter (floats, default 1)
  30133. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  30134. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  30135. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  30136. * @param scene defines the hosting scene
  30137. * @param updatable defines if the mesh must be flagged as updatable
  30138. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  30139. * @returns a new Mesh
  30140. */
  30141. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  30142. /**
  30143. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  30144. * @param name defines the name of the mesh to create
  30145. * @param diameter sets the diameter size (float) of the torus (default 1)
  30146. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  30147. * @param tessellation sets the number of torus sides (postive integer, default 16)
  30148. * @param scene defines the hosting scene
  30149. * @param updatable defines if the mesh must be flagged as updatable
  30150. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  30151. * @returns a new Mesh
  30152. */
  30153. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  30154. /**
  30155. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  30156. * @param name defines the name of the mesh to create
  30157. * @param radius sets the global radius size (float) of the torus knot (default 2)
  30158. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  30159. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  30160. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  30161. * @param p the number of windings on X axis (positive integers, default 2)
  30162. * @param q the number of windings on Y axis (positive integers, default 3)
  30163. * @param scene defines the hosting scene
  30164. * @param updatable defines if the mesh must be flagged as updatable
  30165. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  30166. * @returns a new Mesh
  30167. */
  30168. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  30169. /**
  30170. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  30171. * @param name defines the name of the mesh to create
  30172. * @param points is an array successive Vector3
  30173. * @param scene defines the hosting scene
  30174. * @param updatable defines if the mesh must be flagged as updatable
  30175. * @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).
  30176. * @returns a new Mesh
  30177. */
  30178. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  30179. /**
  30180. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  30181. * @param name defines the name of the mesh to create
  30182. * @param points is an array successive Vector3
  30183. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  30184. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  30185. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  30186. * @param scene defines the hosting scene
  30187. * @param updatable defines if the mesh must be flagged as updatable
  30188. * @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)
  30189. * @returns a new Mesh
  30190. */
  30191. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  30192. /**
  30193. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  30194. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  30195. * 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.
  30196. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  30197. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  30198. * Remember you can only change the shape positions, not their number when updating a polygon.
  30199. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  30200. * @param name defines the name of the mesh to create
  30201. * @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
  30202. * @param scene defines the hosting scene
  30203. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  30204. * @param updatable defines if the mesh must be flagged as updatable
  30205. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  30206. * @param earcutInjection can be used to inject your own earcut reference
  30207. * @returns a new Mesh
  30208. */
  30209. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  30210. /**
  30211. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  30212. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  30213. * @param name defines the name of the mesh to create
  30214. * @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
  30215. * @param depth defines the height of extrusion
  30216. * @param scene defines the hosting scene
  30217. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  30218. * @param updatable defines if the mesh must be flagged as updatable
  30219. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  30220. * @param earcutInjection can be used to inject your own earcut reference
  30221. * @returns a new Mesh
  30222. */
  30223. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  30224. /**
  30225. * Creates an extruded shape mesh.
  30226. * 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
  30227. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  30228. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  30229. * @param name defines the name of the mesh to create
  30230. * @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
  30231. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  30232. * @param scale is the value to scale the shape
  30233. * @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
  30234. * @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
  30235. * @param scene defines the hosting scene
  30236. * @param updatable defines if the mesh must be flagged as updatable
  30237. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  30238. * @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)
  30239. * @returns a new Mesh
  30240. */
  30241. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  30242. /**
  30243. * Creates an custom extruded shape mesh.
  30244. * The custom extrusion is a parametric shape.
  30245. * It has no predefined shape. Its final shape will depend on the input parameters.
  30246. * Please consider using the same method from the MeshBuilder class instead
  30247. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  30248. * @param name defines the name of the mesh to create
  30249. * @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
  30250. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  30251. * @param scaleFunction is a custom Javascript function called on each path point
  30252. * @param rotationFunction is a custom Javascript function called on each path point
  30253. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  30254. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  30255. * @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
  30256. * @param scene defines the hosting scene
  30257. * @param updatable defines if the mesh must be flagged as updatable
  30258. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  30259. * @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)
  30260. * @returns a new Mesh
  30261. */
  30262. 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;
  30263. /**
  30264. * Creates lathe mesh.
  30265. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  30266. * Please consider using the same method from the MeshBuilder class instead
  30267. * @param name defines the name of the mesh to create
  30268. * @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
  30269. * @param radius is the radius value of the lathe
  30270. * @param tessellation is the side number of the lathe.
  30271. * @param scene defines the hosting scene
  30272. * @param updatable defines if the mesh must be flagged as updatable
  30273. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  30274. * @returns a new Mesh
  30275. */
  30276. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  30277. /**
  30278. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  30279. * @param name defines the name of the mesh to create
  30280. * @param size sets the size (float) of both sides of the plane at once (default 1)
  30281. * @param scene defines the hosting scene
  30282. * @param updatable defines if the mesh must be flagged as updatable
  30283. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  30284. * @returns a new Mesh
  30285. */
  30286. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  30287. /**
  30288. * Creates a ground mesh.
  30289. * Please consider using the same method from the MeshBuilder class instead
  30290. * @param name defines the name of the mesh to create
  30291. * @param width set the width of the ground
  30292. * @param height set the height of the ground
  30293. * @param subdivisions sets the number of subdivisions per side
  30294. * @param scene defines the hosting scene
  30295. * @param updatable defines if the mesh must be flagged as updatable
  30296. * @returns a new Mesh
  30297. */
  30298. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  30299. /**
  30300. * Creates a tiled ground mesh.
  30301. * Please consider using the same method from the MeshBuilder class instead
  30302. * @param name defines the name of the mesh to create
  30303. * @param xmin set the ground minimum X coordinate
  30304. * @param zmin set the ground minimum Y coordinate
  30305. * @param xmax set the ground maximum X coordinate
  30306. * @param zmax set the ground maximum Z coordinate
  30307. * @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
  30308. * @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
  30309. * @param scene defines the hosting scene
  30310. * @param updatable defines if the mesh must be flagged as updatable
  30311. * @returns a new Mesh
  30312. */
  30313. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  30314. w: number;
  30315. h: number;
  30316. }, precision: {
  30317. w: number;
  30318. h: number;
  30319. }, scene: Scene, updatable?: boolean): Mesh;
  30320. /**
  30321. * Creates a ground mesh from a height map.
  30322. * Please consider using the same method from the MeshBuilder class instead
  30323. * @see https://doc.babylonjs.com/babylon101/height_map
  30324. * @param name defines the name of the mesh to create
  30325. * @param url sets the URL of the height map image resource
  30326. * @param width set the ground width size
  30327. * @param height set the ground height size
  30328. * @param subdivisions sets the number of subdivision per side
  30329. * @param minHeight is the minimum altitude on the ground
  30330. * @param maxHeight is the maximum altitude on the ground
  30331. * @param scene defines the hosting scene
  30332. * @param updatable defines if the mesh must be flagged as updatable
  30333. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  30334. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  30335. * @returns a new Mesh
  30336. */
  30337. 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;
  30338. /**
  30339. * Creates a tube mesh.
  30340. * The tube is a parametric shape.
  30341. * It has no predefined shape. Its final shape will depend on the input parameters.
  30342. * Please consider using the same method from the MeshBuilder class instead
  30343. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  30344. * @param name defines the name of the mesh to create
  30345. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  30346. * @param radius sets the tube radius size
  30347. * @param tessellation is the number of sides on the tubular surface
  30348. * @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
  30349. * @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
  30350. * @param scene defines the hosting scene
  30351. * @param updatable defines if the mesh must be flagged as updatable
  30352. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  30353. * @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)
  30354. * @returns a new Mesh
  30355. */
  30356. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  30357. (i: number, distance: number): number;
  30358. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  30359. /**
  30360. * Creates a polyhedron mesh.
  30361. * Please consider using the same method from the MeshBuilder class instead.
  30362. * * 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
  30363. * * The parameter `size` (positive float, default 1) sets the polygon size
  30364. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  30365. * * 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`
  30366. * * 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
  30367. * * 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)`)
  30368. * * 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
  30369. * * 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
  30370. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  30371. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  30372. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  30373. * @param name defines the name of the mesh to create
  30374. * @param options defines the options used to create the mesh
  30375. * @param scene defines the hosting scene
  30376. * @returns a new Mesh
  30377. */
  30378. static CreatePolyhedron(name: string, options: {
  30379. type?: number;
  30380. size?: number;
  30381. sizeX?: number;
  30382. sizeY?: number;
  30383. sizeZ?: number;
  30384. custom?: any;
  30385. faceUV?: Vector4[];
  30386. faceColors?: Color4[];
  30387. updatable?: boolean;
  30388. sideOrientation?: number;
  30389. }, scene: Scene): Mesh;
  30390. /**
  30391. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  30392. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  30393. * * 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`)
  30394. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  30395. * * 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
  30396. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  30397. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  30398. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  30399. * @param name defines the name of the mesh
  30400. * @param options defines the options used to create the mesh
  30401. * @param scene defines the hosting scene
  30402. * @returns a new Mesh
  30403. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  30404. */
  30405. static CreateIcoSphere(name: string, options: {
  30406. radius?: number;
  30407. flat?: boolean;
  30408. subdivisions?: number;
  30409. sideOrientation?: number;
  30410. updatable?: boolean;
  30411. }, scene: Scene): Mesh;
  30412. /**
  30413. * Creates a decal mesh.
  30414. * Please consider using the same method from the MeshBuilder class instead.
  30415. * A decal is a mesh usually applied as a model onto the surface of another mesh
  30416. * @param name defines the name of the mesh
  30417. * @param sourceMesh defines the mesh receiving the decal
  30418. * @param position sets the position of the decal in world coordinates
  30419. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  30420. * @param size sets the decal scaling
  30421. * @param angle sets the angle to rotate the decal
  30422. * @returns a new Mesh
  30423. */
  30424. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  30425. /** Creates a Capsule Mesh
  30426. * @param name defines the name of the mesh.
  30427. * @param options the constructors options used to shape the mesh.
  30428. * @param scene defines the scene the mesh is scoped to.
  30429. * @returns the capsule mesh
  30430. * @see https://doc.babylonjs.com/how_to/capsule_shape
  30431. */
  30432. static CreateCapsule(name: string, options: ICreateCapsuleOptions, scene: Scene): Mesh;
  30433. /**
  30434. * Prepare internal position array for software CPU skinning
  30435. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  30436. */
  30437. setPositionsForCPUSkinning(): Float32Array;
  30438. /**
  30439. * Prepare internal normal array for software CPU skinning
  30440. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  30441. */
  30442. setNormalsForCPUSkinning(): Float32Array;
  30443. /**
  30444. * Updates the vertex buffer by applying transformation from the bones
  30445. * @param skeleton defines the skeleton to apply to current mesh
  30446. * @returns the current mesh
  30447. */
  30448. applySkeleton(skeleton: Skeleton): Mesh;
  30449. /**
  30450. * 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
  30451. * @param meshes defines the list of meshes to scan
  30452. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  30453. */
  30454. static MinMax(meshes: AbstractMesh[]): {
  30455. min: Vector3;
  30456. max: Vector3;
  30457. };
  30458. /**
  30459. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  30460. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  30461. * @returns a vector3
  30462. */
  30463. static Center(meshesOrMinMaxVector: {
  30464. min: Vector3;
  30465. max: Vector3;
  30466. } | AbstractMesh[]): Vector3;
  30467. /**
  30468. * Merge the array of meshes into a single mesh for performance reasons.
  30469. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  30470. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  30471. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  30472. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  30473. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  30474. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  30475. * @returns a new mesh
  30476. */
  30477. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  30478. /** @hidden */
  30479. addInstance(instance: InstancedMesh): void;
  30480. /** @hidden */
  30481. removeInstance(instance: InstancedMesh): void;
  30482. }
  30483. }
  30484. declare module "babylonjs/Cameras/camera" {
  30485. import { SmartArray } from "babylonjs/Misc/smartArray";
  30486. import { Observable } from "babylonjs/Misc/observable";
  30487. import { Nullable } from "babylonjs/types";
  30488. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  30489. import { Scene } from "babylonjs/scene";
  30490. import { Matrix, Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  30491. import { Node } from "babylonjs/node";
  30492. import { Mesh } from "babylonjs/Meshes/mesh";
  30493. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  30494. import { ICullable } from "babylonjs/Culling/boundingInfo";
  30495. import { Viewport } from "babylonjs/Maths/math.viewport";
  30496. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  30497. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  30498. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  30499. import { Ray } from "babylonjs/Culling/ray";
  30500. /**
  30501. * This is the base class of all the camera used in the application.
  30502. * @see https://doc.babylonjs.com/features/cameras
  30503. */
  30504. export class Camera extends Node {
  30505. /** @hidden */
  30506. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  30507. /**
  30508. * This is the default projection mode used by the cameras.
  30509. * It helps recreating a feeling of perspective and better appreciate depth.
  30510. * This is the best way to simulate real life cameras.
  30511. */
  30512. static readonly PERSPECTIVE_CAMERA: number;
  30513. /**
  30514. * This helps creating camera with an orthographic mode.
  30515. * 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.
  30516. */
  30517. static readonly ORTHOGRAPHIC_CAMERA: number;
  30518. /**
  30519. * This is the default FOV mode for perspective cameras.
  30520. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  30521. */
  30522. static readonly FOVMODE_VERTICAL_FIXED: number;
  30523. /**
  30524. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  30525. */
  30526. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  30527. /**
  30528. * This specifies ther is no need for a camera rig.
  30529. * Basically only one eye is rendered corresponding to the camera.
  30530. */
  30531. static readonly RIG_MODE_NONE: number;
  30532. /**
  30533. * Simulates a camera Rig with one blue eye and one red eye.
  30534. * This can be use with 3d blue and red glasses.
  30535. */
  30536. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  30537. /**
  30538. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  30539. */
  30540. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  30541. /**
  30542. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  30543. */
  30544. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  30545. /**
  30546. * Defines that both eyes of the camera will be rendered over under each other.
  30547. */
  30548. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  30549. /**
  30550. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  30551. */
  30552. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  30553. /**
  30554. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  30555. */
  30556. static readonly RIG_MODE_VR: number;
  30557. /**
  30558. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  30559. */
  30560. static readonly RIG_MODE_WEBVR: number;
  30561. /**
  30562. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  30563. */
  30564. static readonly RIG_MODE_CUSTOM: number;
  30565. /**
  30566. * Defines if by default attaching controls should prevent the default javascript event to continue.
  30567. */
  30568. static ForceAttachControlToAlwaysPreventDefault: boolean;
  30569. /**
  30570. * Define the input manager associated with the camera.
  30571. */
  30572. inputs: CameraInputsManager<Camera>;
  30573. /** @hidden */
  30574. _position: Vector3;
  30575. /**
  30576. * Define the current local position of the camera in the scene
  30577. */
  30578. get position(): Vector3;
  30579. set position(newPosition: Vector3);
  30580. protected _upVector: Vector3;
  30581. /**
  30582. * The vector the camera should consider as up.
  30583. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  30584. */
  30585. set upVector(vec: Vector3);
  30586. get upVector(): Vector3;
  30587. /**
  30588. * Define the current limit on the left side for an orthographic camera
  30589. * In scene unit
  30590. */
  30591. orthoLeft: Nullable<number>;
  30592. /**
  30593. * Define the current limit on the right side for an orthographic camera
  30594. * In scene unit
  30595. */
  30596. orthoRight: Nullable<number>;
  30597. /**
  30598. * Define the current limit on the bottom side for an orthographic camera
  30599. * In scene unit
  30600. */
  30601. orthoBottom: Nullable<number>;
  30602. /**
  30603. * Define the current limit on the top side for an orthographic camera
  30604. * In scene unit
  30605. */
  30606. orthoTop: Nullable<number>;
  30607. /**
  30608. * Field Of View is set in Radians. (default is 0.8)
  30609. */
  30610. fov: number;
  30611. /**
  30612. * Define the minimum distance the camera can see from.
  30613. * This is important to note that the depth buffer are not infinite and the closer it starts
  30614. * the more your scene might encounter depth fighting issue.
  30615. */
  30616. minZ: number;
  30617. /**
  30618. * Define the maximum distance the camera can see to.
  30619. * This is important to note that the depth buffer are not infinite and the further it end
  30620. * the more your scene might encounter depth fighting issue.
  30621. */
  30622. maxZ: number;
  30623. /**
  30624. * Define the default inertia of the camera.
  30625. * This helps giving a smooth feeling to the camera movement.
  30626. */
  30627. inertia: number;
  30628. /**
  30629. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  30630. */
  30631. mode: number;
  30632. /**
  30633. * Define whether the camera is intermediate.
  30634. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  30635. */
  30636. isIntermediate: boolean;
  30637. /**
  30638. * Define the viewport of the camera.
  30639. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  30640. */
  30641. viewport: Viewport;
  30642. /**
  30643. * Restricts the camera to viewing objects with the same layerMask.
  30644. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  30645. */
  30646. layerMask: number;
  30647. /**
  30648. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  30649. */
  30650. fovMode: number;
  30651. /**
  30652. * Rig mode of the camera.
  30653. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  30654. * This is normally controlled byt the camera themselves as internal use.
  30655. */
  30656. cameraRigMode: number;
  30657. /**
  30658. * Defines the distance between both "eyes" in case of a RIG
  30659. */
  30660. interaxialDistance: number;
  30661. /**
  30662. * Defines if stereoscopic rendering is done side by side or over under.
  30663. */
  30664. isStereoscopicSideBySide: boolean;
  30665. /**
  30666. * 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
  30667. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  30668. * else in the scene. (Eg. security camera)
  30669. *
  30670. * 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)
  30671. */
  30672. customRenderTargets: import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture[];
  30673. /**
  30674. * When set, the camera will render to this render target instead of the default canvas
  30675. *
  30676. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  30677. */
  30678. outputRenderTarget: Nullable<RenderTargetTexture>;
  30679. /**
  30680. * Observable triggered when the camera view matrix has changed.
  30681. */
  30682. onViewMatrixChangedObservable: Observable<Camera>;
  30683. /**
  30684. * Observable triggered when the camera Projection matrix has changed.
  30685. */
  30686. onProjectionMatrixChangedObservable: Observable<Camera>;
  30687. /**
  30688. * Observable triggered when the inputs have been processed.
  30689. */
  30690. onAfterCheckInputsObservable: Observable<Camera>;
  30691. /**
  30692. * Observable triggered when reset has been called and applied to the camera.
  30693. */
  30694. onRestoreStateObservable: Observable<Camera>;
  30695. /**
  30696. * Is this camera a part of a rig system?
  30697. */
  30698. isRigCamera: boolean;
  30699. /**
  30700. * If isRigCamera set to true this will be set with the parent camera.
  30701. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  30702. */
  30703. rigParent?: Camera;
  30704. /** @hidden */
  30705. _cameraRigParams: any;
  30706. /** @hidden */
  30707. _rigCameras: Camera[];
  30708. /** @hidden */
  30709. _rigPostProcess: Nullable<PostProcess>;
  30710. protected _webvrViewMatrix: Matrix;
  30711. /** @hidden */
  30712. _skipRendering: boolean;
  30713. /** @hidden */
  30714. _projectionMatrix: Matrix;
  30715. /** @hidden */
  30716. _postProcesses: Nullable<import("babylonjs/PostProcesses/postProcess").PostProcess>[];
  30717. /** @hidden */
  30718. _activeMeshes: SmartArray<AbstractMesh>;
  30719. protected _globalPosition: Vector3;
  30720. /** @hidden */
  30721. _computedViewMatrix: Matrix;
  30722. private _doNotComputeProjectionMatrix;
  30723. private _transformMatrix;
  30724. private _frustumPlanes;
  30725. private _refreshFrustumPlanes;
  30726. private _storedFov;
  30727. private _stateStored;
  30728. /**
  30729. * Instantiates a new camera object.
  30730. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  30731. * @see https://doc.babylonjs.com/features/cameras
  30732. * @param name Defines the name of the camera in the scene
  30733. * @param position Defines the position of the camera
  30734. * @param scene Defines the scene the camera belongs too
  30735. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  30736. */
  30737. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  30738. /**
  30739. * Store current camera state (fov, position, etc..)
  30740. * @returns the camera
  30741. */
  30742. storeState(): Camera;
  30743. /**
  30744. * Restores the camera state values if it has been stored. You must call storeState() first
  30745. */
  30746. protected _restoreStateValues(): boolean;
  30747. /**
  30748. * Restored camera state. You must call storeState() first.
  30749. * @returns true if restored and false otherwise
  30750. */
  30751. restoreState(): boolean;
  30752. /**
  30753. * Gets the class name of the camera.
  30754. * @returns the class name
  30755. */
  30756. getClassName(): string;
  30757. /** @hidden */
  30758. readonly _isCamera: boolean;
  30759. /**
  30760. * Gets a string representation of the camera useful for debug purpose.
  30761. * @param fullDetails Defines that a more verboe level of logging is required
  30762. * @returns the string representation
  30763. */
  30764. toString(fullDetails?: boolean): string;
  30765. /**
  30766. * Gets the current world space position of the camera.
  30767. */
  30768. get globalPosition(): Vector3;
  30769. /**
  30770. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  30771. * @returns the active meshe list
  30772. */
  30773. getActiveMeshes(): SmartArray<AbstractMesh>;
  30774. /**
  30775. * Check whether a mesh is part of the current active mesh list of the camera
  30776. * @param mesh Defines the mesh to check
  30777. * @returns true if active, false otherwise
  30778. */
  30779. isActiveMesh(mesh: Mesh): boolean;
  30780. /**
  30781. * Is this camera ready to be used/rendered
  30782. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  30783. * @return true if the camera is ready
  30784. */
  30785. isReady(completeCheck?: boolean): boolean;
  30786. /** @hidden */
  30787. _initCache(): void;
  30788. /** @hidden */
  30789. _updateCache(ignoreParentClass?: boolean): void;
  30790. /** @hidden */
  30791. _isSynchronized(): boolean;
  30792. /** @hidden */
  30793. _isSynchronizedViewMatrix(): boolean;
  30794. /** @hidden */
  30795. _isSynchronizedProjectionMatrix(): boolean;
  30796. /**
  30797. * Attach the input controls to a specific dom element to get the input from.
  30798. * @param element Defines the element the controls should be listened from
  30799. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  30800. */
  30801. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  30802. /**
  30803. * Detach the current controls from the specified dom element.
  30804. * @param element Defines the element to stop listening the inputs from
  30805. */
  30806. detachControl(element: HTMLElement): void;
  30807. /**
  30808. * Update the camera state according to the different inputs gathered during the frame.
  30809. */
  30810. update(): void;
  30811. /** @hidden */
  30812. _checkInputs(): void;
  30813. /** @hidden */
  30814. get rigCameras(): Camera[];
  30815. /**
  30816. * Gets the post process used by the rig cameras
  30817. */
  30818. get rigPostProcess(): Nullable<PostProcess>;
  30819. /**
  30820. * Internal, gets the first post proces.
  30821. * @returns the first post process to be run on this camera.
  30822. */
  30823. _getFirstPostProcess(): Nullable<PostProcess>;
  30824. private _cascadePostProcessesToRigCams;
  30825. /**
  30826. * Attach a post process to the camera.
  30827. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  30828. * @param postProcess The post process to attach to the camera
  30829. * @param insertAt The position of the post process in case several of them are in use in the scene
  30830. * @returns the position the post process has been inserted at
  30831. */
  30832. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  30833. /**
  30834. * Detach a post process to the camera.
  30835. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  30836. * @param postProcess The post process to detach from the camera
  30837. */
  30838. detachPostProcess(postProcess: PostProcess): void;
  30839. /**
  30840. * Gets the current world matrix of the camera
  30841. */
  30842. getWorldMatrix(): Matrix;
  30843. /** @hidden */
  30844. _getViewMatrix(): Matrix;
  30845. /**
  30846. * Gets the current view matrix of the camera.
  30847. * @param force forces the camera to recompute the matrix without looking at the cached state
  30848. * @returns the view matrix
  30849. */
  30850. getViewMatrix(force?: boolean): Matrix;
  30851. /**
  30852. * Freeze the projection matrix.
  30853. * It will prevent the cache check of the camera projection compute and can speed up perf
  30854. * if no parameter of the camera are meant to change
  30855. * @param projection Defines manually a projection if necessary
  30856. */
  30857. freezeProjectionMatrix(projection?: Matrix): void;
  30858. /**
  30859. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  30860. */
  30861. unfreezeProjectionMatrix(): void;
  30862. /**
  30863. * Gets the current projection matrix of the camera.
  30864. * @param force forces the camera to recompute the matrix without looking at the cached state
  30865. * @returns the projection matrix
  30866. */
  30867. getProjectionMatrix(force?: boolean): Matrix;
  30868. /**
  30869. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  30870. * @returns a Matrix
  30871. */
  30872. getTransformationMatrix(): Matrix;
  30873. private _updateFrustumPlanes;
  30874. /**
  30875. * Checks if a cullable object (mesh...) is in the camera frustum
  30876. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  30877. * @param target The object to check
  30878. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  30879. * @returns true if the object is in frustum otherwise false
  30880. */
  30881. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  30882. /**
  30883. * Checks if a cullable object (mesh...) is in the camera frustum
  30884. * Unlike isInFrustum this cheks the full bounding box
  30885. * @param target The object to check
  30886. * @returns true if the object is in frustum otherwise false
  30887. */
  30888. isCompletelyInFrustum(target: ICullable): boolean;
  30889. /**
  30890. * Gets a ray in the forward direction from the camera.
  30891. * @param length Defines the length of the ray to create
  30892. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  30893. * @param origin Defines the start point of the ray which defaults to the camera position
  30894. * @returns the forward ray
  30895. */
  30896. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  30897. /**
  30898. * Gets a ray in the forward direction from the camera.
  30899. * @param refRay the ray to (re)use when setting the values
  30900. * @param length Defines the length of the ray to create
  30901. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  30902. * @param origin Defines the start point of the ray which defaults to the camera position
  30903. * @returns the forward ray
  30904. */
  30905. getForwardRayToRef(refRay: Ray, length?: number, transform?: Matrix, origin?: Vector3): Ray;
  30906. /**
  30907. * Releases resources associated with this node.
  30908. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  30909. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  30910. */
  30911. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  30912. /** @hidden */
  30913. _isLeftCamera: boolean;
  30914. /**
  30915. * Gets the left camera of a rig setup in case of Rigged Camera
  30916. */
  30917. get isLeftCamera(): boolean;
  30918. /** @hidden */
  30919. _isRightCamera: boolean;
  30920. /**
  30921. * Gets the right camera of a rig setup in case of Rigged Camera
  30922. */
  30923. get isRightCamera(): boolean;
  30924. /**
  30925. * Gets the left camera of a rig setup in case of Rigged Camera
  30926. */
  30927. get leftCamera(): Nullable<FreeCamera>;
  30928. /**
  30929. * Gets the right camera of a rig setup in case of Rigged Camera
  30930. */
  30931. get rightCamera(): Nullable<FreeCamera>;
  30932. /**
  30933. * Gets the left camera target of a rig setup in case of Rigged Camera
  30934. * @returns the target position
  30935. */
  30936. getLeftTarget(): Nullable<Vector3>;
  30937. /**
  30938. * Gets the right camera target of a rig setup in case of Rigged Camera
  30939. * @returns the target position
  30940. */
  30941. getRightTarget(): Nullable<Vector3>;
  30942. /**
  30943. * @hidden
  30944. */
  30945. setCameraRigMode(mode: number, rigParams: any): void;
  30946. /** @hidden */
  30947. static _setStereoscopicRigMode(camera: Camera): void;
  30948. /** @hidden */
  30949. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  30950. /** @hidden */
  30951. static _setVRRigMode(camera: Camera, rigParams: any): void;
  30952. /** @hidden */
  30953. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  30954. /** @hidden */
  30955. _getVRProjectionMatrix(): Matrix;
  30956. protected _updateCameraRotationMatrix(): void;
  30957. protected _updateWebVRCameraRotationMatrix(): void;
  30958. /**
  30959. * This function MUST be overwritten by the different WebVR cameras available.
  30960. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  30961. * @hidden
  30962. */
  30963. _getWebVRProjectionMatrix(): Matrix;
  30964. /**
  30965. * This function MUST be overwritten by the different WebVR cameras available.
  30966. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  30967. * @hidden
  30968. */
  30969. _getWebVRViewMatrix(): Matrix;
  30970. /** @hidden */
  30971. setCameraRigParameter(name: string, value: any): void;
  30972. /**
  30973. * needs to be overridden by children so sub has required properties to be copied
  30974. * @hidden
  30975. */
  30976. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  30977. /**
  30978. * May need to be overridden by children
  30979. * @hidden
  30980. */
  30981. _updateRigCameras(): void;
  30982. /** @hidden */
  30983. _setupInputs(): void;
  30984. /**
  30985. * Serialiaze the camera setup to a json represention
  30986. * @returns the JSON representation
  30987. */
  30988. serialize(): any;
  30989. /**
  30990. * Clones the current camera.
  30991. * @param name The cloned camera name
  30992. * @returns the cloned camera
  30993. */
  30994. clone(name: string): Camera;
  30995. /**
  30996. * Gets the direction of the camera relative to a given local axis.
  30997. * @param localAxis Defines the reference axis to provide a relative direction.
  30998. * @return the direction
  30999. */
  31000. getDirection(localAxis: Vector3): Vector3;
  31001. /**
  31002. * Returns the current camera absolute rotation
  31003. */
  31004. get absoluteRotation(): Quaternion;
  31005. /**
  31006. * Gets the direction of the camera relative to a given local axis into a passed vector.
  31007. * @param localAxis Defines the reference axis to provide a relative direction.
  31008. * @param result Defines the vector to store the result in
  31009. */
  31010. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  31011. /**
  31012. * Gets a camera constructor for a given camera type
  31013. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  31014. * @param name The name of the camera the result will be able to instantiate
  31015. * @param scene The scene the result will construct the camera in
  31016. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  31017. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  31018. * @returns a factory method to construc the camera
  31019. */
  31020. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  31021. /**
  31022. * Compute the world matrix of the camera.
  31023. * @returns the camera world matrix
  31024. */
  31025. computeWorldMatrix(): Matrix;
  31026. /**
  31027. * Parse a JSON and creates the camera from the parsed information
  31028. * @param parsedCamera The JSON to parse
  31029. * @param scene The scene to instantiate the camera in
  31030. * @returns the newly constructed camera
  31031. */
  31032. static Parse(parsedCamera: any, scene: Scene): Camera;
  31033. }
  31034. }
  31035. declare module "babylonjs/Meshes/Builders/discBuilder" {
  31036. import { Nullable } from "babylonjs/types";
  31037. import { Scene } from "babylonjs/scene";
  31038. import { Vector4 } from "babylonjs/Maths/math.vector";
  31039. import { Mesh } from "babylonjs/Meshes/mesh";
  31040. /**
  31041. * Class containing static functions to help procedurally build meshes
  31042. */
  31043. export class DiscBuilder {
  31044. /**
  31045. * Creates a plane polygonal mesh. By default, this is a disc
  31046. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  31047. * * 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
  31048. * * 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
  31049. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  31050. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  31051. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  31052. * @param name defines the name of the mesh
  31053. * @param options defines the options used to create the mesh
  31054. * @param scene defines the hosting scene
  31055. * @returns the plane polygonal mesh
  31056. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  31057. */
  31058. static CreateDisc(name: string, options: {
  31059. radius?: number;
  31060. tessellation?: number;
  31061. arc?: number;
  31062. updatable?: boolean;
  31063. sideOrientation?: number;
  31064. frontUVs?: Vector4;
  31065. backUVs?: Vector4;
  31066. }, scene?: Nullable<Scene>): Mesh;
  31067. }
  31068. }
  31069. declare module "babylonjs/Materials/fresnelParameters" {
  31070. import { DeepImmutable } from "babylonjs/types";
  31071. import { Color3 } from "babylonjs/Maths/math.color";
  31072. /**
  31073. * Options to be used when creating a FresnelParameters.
  31074. */
  31075. export type IFresnelParametersCreationOptions = {
  31076. /**
  31077. * Define the color used on edges (grazing angle)
  31078. */
  31079. leftColor?: Color3;
  31080. /**
  31081. * Define the color used on center
  31082. */
  31083. rightColor?: Color3;
  31084. /**
  31085. * Define bias applied to computed fresnel term
  31086. */
  31087. bias?: number;
  31088. /**
  31089. * Defined the power exponent applied to fresnel term
  31090. */
  31091. power?: number;
  31092. /**
  31093. * Define if the fresnel effect is enable or not.
  31094. */
  31095. isEnabled?: boolean;
  31096. };
  31097. /**
  31098. * Serialized format for FresnelParameters.
  31099. */
  31100. export type IFresnelParametersSerialized = {
  31101. /**
  31102. * Define the color used on edges (grazing angle) [as an array]
  31103. */
  31104. leftColor: number[];
  31105. /**
  31106. * Define the color used on center [as an array]
  31107. */
  31108. rightColor: number[];
  31109. /**
  31110. * Define bias applied to computed fresnel term
  31111. */
  31112. bias: number;
  31113. /**
  31114. * Defined the power exponent applied to fresnel term
  31115. */
  31116. power?: number;
  31117. /**
  31118. * Define if the fresnel effect is enable or not.
  31119. */
  31120. isEnabled: boolean;
  31121. };
  31122. /**
  31123. * This represents all the required information to add a fresnel effect on a material:
  31124. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  31125. */
  31126. export class FresnelParameters {
  31127. private _isEnabled;
  31128. /**
  31129. * Define if the fresnel effect is enable or not.
  31130. */
  31131. get isEnabled(): boolean;
  31132. set isEnabled(value: boolean);
  31133. /**
  31134. * Define the color used on edges (grazing angle)
  31135. */
  31136. leftColor: Color3;
  31137. /**
  31138. * Define the color used on center
  31139. */
  31140. rightColor: Color3;
  31141. /**
  31142. * Define bias applied to computed fresnel term
  31143. */
  31144. bias: number;
  31145. /**
  31146. * Defined the power exponent applied to fresnel term
  31147. */
  31148. power: number;
  31149. /**
  31150. * Creates a new FresnelParameters object.
  31151. *
  31152. * @param options provide your own settings to optionally to override defaults
  31153. */
  31154. constructor(options?: IFresnelParametersCreationOptions);
  31155. /**
  31156. * Clones the current fresnel and its valuues
  31157. * @returns a clone fresnel configuration
  31158. */
  31159. clone(): FresnelParameters;
  31160. /**
  31161. * Determines equality between FresnelParameters objects
  31162. * @param otherFresnelParameters defines the second operand
  31163. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  31164. */
  31165. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  31166. /**
  31167. * Serializes the current fresnel parameters to a JSON representation.
  31168. * @return the JSON serialization
  31169. */
  31170. serialize(): IFresnelParametersSerialized;
  31171. /**
  31172. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  31173. * @param parsedFresnelParameters Define the JSON representation
  31174. * @returns the parsed parameters
  31175. */
  31176. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  31177. }
  31178. }
  31179. declare module "babylonjs/Materials/materialFlags" {
  31180. /**
  31181. * This groups all the flags used to control the materials channel.
  31182. */
  31183. export class MaterialFlags {
  31184. private static _DiffuseTextureEnabled;
  31185. /**
  31186. * Are diffuse textures enabled in the application.
  31187. */
  31188. static get DiffuseTextureEnabled(): boolean;
  31189. static set DiffuseTextureEnabled(value: boolean);
  31190. private static _DetailTextureEnabled;
  31191. /**
  31192. * Are detail textures enabled in the application.
  31193. */
  31194. static get DetailTextureEnabled(): boolean;
  31195. static set DetailTextureEnabled(value: boolean);
  31196. private static _AmbientTextureEnabled;
  31197. /**
  31198. * Are ambient textures enabled in the application.
  31199. */
  31200. static get AmbientTextureEnabled(): boolean;
  31201. static set AmbientTextureEnabled(value: boolean);
  31202. private static _OpacityTextureEnabled;
  31203. /**
  31204. * Are opacity textures enabled in the application.
  31205. */
  31206. static get OpacityTextureEnabled(): boolean;
  31207. static set OpacityTextureEnabled(value: boolean);
  31208. private static _ReflectionTextureEnabled;
  31209. /**
  31210. * Are reflection textures enabled in the application.
  31211. */
  31212. static get ReflectionTextureEnabled(): boolean;
  31213. static set ReflectionTextureEnabled(value: boolean);
  31214. private static _EmissiveTextureEnabled;
  31215. /**
  31216. * Are emissive textures enabled in the application.
  31217. */
  31218. static get EmissiveTextureEnabled(): boolean;
  31219. static set EmissiveTextureEnabled(value: boolean);
  31220. private static _SpecularTextureEnabled;
  31221. /**
  31222. * Are specular textures enabled in the application.
  31223. */
  31224. static get SpecularTextureEnabled(): boolean;
  31225. static set SpecularTextureEnabled(value: boolean);
  31226. private static _BumpTextureEnabled;
  31227. /**
  31228. * Are bump textures enabled in the application.
  31229. */
  31230. static get BumpTextureEnabled(): boolean;
  31231. static set BumpTextureEnabled(value: boolean);
  31232. private static _LightmapTextureEnabled;
  31233. /**
  31234. * Are lightmap textures enabled in the application.
  31235. */
  31236. static get LightmapTextureEnabled(): boolean;
  31237. static set LightmapTextureEnabled(value: boolean);
  31238. private static _RefractionTextureEnabled;
  31239. /**
  31240. * Are refraction textures enabled in the application.
  31241. */
  31242. static get RefractionTextureEnabled(): boolean;
  31243. static set RefractionTextureEnabled(value: boolean);
  31244. private static _ColorGradingTextureEnabled;
  31245. /**
  31246. * Are color grading textures enabled in the application.
  31247. */
  31248. static get ColorGradingTextureEnabled(): boolean;
  31249. static set ColorGradingTextureEnabled(value: boolean);
  31250. private static _FresnelEnabled;
  31251. /**
  31252. * Are fresnels enabled in the application.
  31253. */
  31254. static get FresnelEnabled(): boolean;
  31255. static set FresnelEnabled(value: boolean);
  31256. private static _ClearCoatTextureEnabled;
  31257. /**
  31258. * Are clear coat textures enabled in the application.
  31259. */
  31260. static get ClearCoatTextureEnabled(): boolean;
  31261. static set ClearCoatTextureEnabled(value: boolean);
  31262. private static _ClearCoatBumpTextureEnabled;
  31263. /**
  31264. * Are clear coat bump textures enabled in the application.
  31265. */
  31266. static get ClearCoatBumpTextureEnabled(): boolean;
  31267. static set ClearCoatBumpTextureEnabled(value: boolean);
  31268. private static _ClearCoatTintTextureEnabled;
  31269. /**
  31270. * Are clear coat tint textures enabled in the application.
  31271. */
  31272. static get ClearCoatTintTextureEnabled(): boolean;
  31273. static set ClearCoatTintTextureEnabled(value: boolean);
  31274. private static _SheenTextureEnabled;
  31275. /**
  31276. * Are sheen textures enabled in the application.
  31277. */
  31278. static get SheenTextureEnabled(): boolean;
  31279. static set SheenTextureEnabled(value: boolean);
  31280. private static _AnisotropicTextureEnabled;
  31281. /**
  31282. * Are anisotropic textures enabled in the application.
  31283. */
  31284. static get AnisotropicTextureEnabled(): boolean;
  31285. static set AnisotropicTextureEnabled(value: boolean);
  31286. private static _ThicknessTextureEnabled;
  31287. /**
  31288. * Are thickness textures enabled in the application.
  31289. */
  31290. static get ThicknessTextureEnabled(): boolean;
  31291. static set ThicknessTextureEnabled(value: boolean);
  31292. }
  31293. }
  31294. declare module "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration" {
  31295. /** @hidden */
  31296. export var defaultFragmentDeclaration: {
  31297. name: string;
  31298. shader: string;
  31299. };
  31300. }
  31301. declare module "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration" {
  31302. /** @hidden */
  31303. export var defaultUboDeclaration: {
  31304. name: string;
  31305. shader: string;
  31306. };
  31307. }
  31308. declare module "babylonjs/Shaders/ShadersInclude/prePassDeclaration" {
  31309. /** @hidden */
  31310. export var prePassDeclaration: {
  31311. name: string;
  31312. shader: string;
  31313. };
  31314. }
  31315. declare module "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration" {
  31316. /** @hidden */
  31317. export var lightFragmentDeclaration: {
  31318. name: string;
  31319. shader: string;
  31320. };
  31321. }
  31322. declare module "babylonjs/Shaders/ShadersInclude/lightUboDeclaration" {
  31323. /** @hidden */
  31324. export var lightUboDeclaration: {
  31325. name: string;
  31326. shader: string;
  31327. };
  31328. }
  31329. declare module "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions" {
  31330. /** @hidden */
  31331. export var lightsFragmentFunctions: {
  31332. name: string;
  31333. shader: string;
  31334. };
  31335. }
  31336. declare module "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions" {
  31337. /** @hidden */
  31338. export var shadowsFragmentFunctions: {
  31339. name: string;
  31340. shader: string;
  31341. };
  31342. }
  31343. declare module "babylonjs/Shaders/ShadersInclude/fresnelFunction" {
  31344. /** @hidden */
  31345. export var fresnelFunction: {
  31346. name: string;
  31347. shader: string;
  31348. };
  31349. }
  31350. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions" {
  31351. /** @hidden */
  31352. export var bumpFragmentMainFunctions: {
  31353. name: string;
  31354. shader: string;
  31355. };
  31356. }
  31357. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions" {
  31358. /** @hidden */
  31359. export var bumpFragmentFunctions: {
  31360. name: string;
  31361. shader: string;
  31362. };
  31363. }
  31364. declare module "babylonjs/Shaders/ShadersInclude/logDepthDeclaration" {
  31365. /** @hidden */
  31366. export var logDepthDeclaration: {
  31367. name: string;
  31368. shader: string;
  31369. };
  31370. }
  31371. declare module "babylonjs/Shaders/ShadersInclude/bumpFragment" {
  31372. /** @hidden */
  31373. export var bumpFragment: {
  31374. name: string;
  31375. shader: string;
  31376. };
  31377. }
  31378. declare module "babylonjs/Shaders/ShadersInclude/depthPrePass" {
  31379. /** @hidden */
  31380. export var depthPrePass: {
  31381. name: string;
  31382. shader: string;
  31383. };
  31384. }
  31385. declare module "babylonjs/Shaders/ShadersInclude/lightFragment" {
  31386. /** @hidden */
  31387. export var lightFragment: {
  31388. name: string;
  31389. shader: string;
  31390. };
  31391. }
  31392. declare module "babylonjs/Shaders/ShadersInclude/logDepthFragment" {
  31393. /** @hidden */
  31394. export var logDepthFragment: {
  31395. name: string;
  31396. shader: string;
  31397. };
  31398. }
  31399. declare module "babylonjs/Shaders/default.fragment" {
  31400. import "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration";
  31401. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  31402. import "babylonjs/Shaders/ShadersInclude/prePassDeclaration";
  31403. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  31404. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  31405. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  31406. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  31407. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  31408. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  31409. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  31410. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  31411. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  31412. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  31413. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  31414. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  31415. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  31416. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  31417. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  31418. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  31419. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  31420. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  31421. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  31422. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  31423. /** @hidden */
  31424. export var defaultPixelShader: {
  31425. name: string;
  31426. shader: string;
  31427. };
  31428. }
  31429. declare module "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration" {
  31430. /** @hidden */
  31431. export var defaultVertexDeclaration: {
  31432. name: string;
  31433. shader: string;
  31434. };
  31435. }
  31436. declare module "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration" {
  31437. /** @hidden */
  31438. export var bumpVertexDeclaration: {
  31439. name: string;
  31440. shader: string;
  31441. };
  31442. }
  31443. declare module "babylonjs/Shaders/ShadersInclude/bumpVertex" {
  31444. /** @hidden */
  31445. export var bumpVertex: {
  31446. name: string;
  31447. shader: string;
  31448. };
  31449. }
  31450. declare module "babylonjs/Shaders/ShadersInclude/fogVertex" {
  31451. /** @hidden */
  31452. export var fogVertex: {
  31453. name: string;
  31454. shader: string;
  31455. };
  31456. }
  31457. declare module "babylonjs/Shaders/ShadersInclude/shadowsVertex" {
  31458. /** @hidden */
  31459. export var shadowsVertex: {
  31460. name: string;
  31461. shader: string;
  31462. };
  31463. }
  31464. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertex" {
  31465. /** @hidden */
  31466. export var pointCloudVertex: {
  31467. name: string;
  31468. shader: string;
  31469. };
  31470. }
  31471. declare module "babylonjs/Shaders/ShadersInclude/logDepthVertex" {
  31472. /** @hidden */
  31473. export var logDepthVertex: {
  31474. name: string;
  31475. shader: string;
  31476. };
  31477. }
  31478. declare module "babylonjs/Shaders/default.vertex" {
  31479. import "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration";
  31480. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  31481. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  31482. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  31483. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  31484. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  31485. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  31486. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  31487. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  31488. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  31489. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  31490. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  31491. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  31492. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  31493. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  31494. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  31495. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  31496. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  31497. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  31498. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  31499. import "babylonjs/Shaders/ShadersInclude/pointCloudVertex";
  31500. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  31501. /** @hidden */
  31502. export var defaultVertexShader: {
  31503. name: string;
  31504. shader: string;
  31505. };
  31506. }
  31507. declare module "babylonjs/Materials/material.detailMapConfiguration" {
  31508. import { Nullable } from "babylonjs/types";
  31509. import { Scene } from "babylonjs/scene";
  31510. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  31511. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  31512. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  31513. /**
  31514. * @hidden
  31515. */
  31516. export interface IMaterialDetailMapDefines {
  31517. DETAIL: boolean;
  31518. DETAILDIRECTUV: number;
  31519. DETAIL_NORMALBLENDMETHOD: number;
  31520. /** @hidden */
  31521. _areTexturesDirty: boolean;
  31522. }
  31523. /**
  31524. * Define the code related to the detail map parameters of a material
  31525. *
  31526. * Inspired from:
  31527. * 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
  31528. * Unreal: https://docs.unrealengine.com/en-US/Engine/Rendering/Materials/HowTo/DetailTexturing/index.html
  31529. * Cryengine: https://docs.cryengine.com/display/SDKDOC2/Detail+Maps
  31530. */
  31531. export class DetailMapConfiguration {
  31532. private _texture;
  31533. /**
  31534. * The detail texture of the material.
  31535. */
  31536. texture: Nullable<BaseTexture>;
  31537. /**
  31538. * Defines how strongly the detail diffuse/albedo channel is blended with the regular diffuse/albedo texture
  31539. * Bigger values mean stronger blending
  31540. */
  31541. diffuseBlendLevel: number;
  31542. /**
  31543. * Defines how strongly the detail roughness channel is blended with the regular roughness value
  31544. * Bigger values mean stronger blending. Only used with PBR materials
  31545. */
  31546. roughnessBlendLevel: number;
  31547. /**
  31548. * Defines how strong the bump effect from the detail map is
  31549. * Bigger values mean stronger effect
  31550. */
  31551. bumpLevel: number;
  31552. private _normalBlendMethod;
  31553. /**
  31554. * The method used to blend the bump and detail normals together
  31555. */
  31556. normalBlendMethod: number;
  31557. private _isEnabled;
  31558. /**
  31559. * Enable or disable the detail map on this material
  31560. */
  31561. isEnabled: boolean;
  31562. /** @hidden */
  31563. private _internalMarkAllSubMeshesAsTexturesDirty;
  31564. /** @hidden */
  31565. _markAllSubMeshesAsTexturesDirty(): void;
  31566. /**
  31567. * Instantiate a new detail map
  31568. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  31569. */
  31570. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  31571. /**
  31572. * Gets whether the submesh is ready to be used or not.
  31573. * @param defines the list of "defines" to update.
  31574. * @param scene defines the scene the material belongs to.
  31575. * @returns - boolean indicating that the submesh is ready or not.
  31576. */
  31577. isReadyForSubMesh(defines: IMaterialDetailMapDefines, scene: Scene): boolean;
  31578. /**
  31579. * Update the defines for detail map usage
  31580. * @param defines the list of "defines" to update.
  31581. * @param scene defines the scene the material belongs to.
  31582. */
  31583. prepareDefines(defines: IMaterialDetailMapDefines, scene: Scene): void;
  31584. /**
  31585. * Binds the material data.
  31586. * @param uniformBuffer defines the Uniform buffer to fill in.
  31587. * @param scene defines the scene the material belongs to.
  31588. * @param isFrozen defines whether the material is frozen or not.
  31589. */
  31590. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  31591. /**
  31592. * Checks to see if a texture is used in the material.
  31593. * @param texture - Base texture to use.
  31594. * @returns - Boolean specifying if a texture is used in the material.
  31595. */
  31596. hasTexture(texture: BaseTexture): boolean;
  31597. /**
  31598. * Returns an array of the actively used textures.
  31599. * @param activeTextures Array of BaseTextures
  31600. */
  31601. getActiveTextures(activeTextures: BaseTexture[]): void;
  31602. /**
  31603. * Returns the animatable textures.
  31604. * @param animatables Array of animatable textures.
  31605. */
  31606. getAnimatables(animatables: IAnimatable[]): void;
  31607. /**
  31608. * Disposes the resources of the material.
  31609. * @param forceDisposeTextures - Forces the disposal of all textures.
  31610. */
  31611. dispose(forceDisposeTextures?: boolean): void;
  31612. /**
  31613. * Get the current class name useful for serialization or dynamic coding.
  31614. * @returns "DetailMap"
  31615. */
  31616. getClassName(): string;
  31617. /**
  31618. * Add the required uniforms to the current list.
  31619. * @param uniforms defines the current uniform list.
  31620. */
  31621. static AddUniforms(uniforms: string[]): void;
  31622. /**
  31623. * Add the required samplers to the current list.
  31624. * @param samplers defines the current sampler list.
  31625. */
  31626. static AddSamplers(samplers: string[]): void;
  31627. /**
  31628. * Add the required uniforms to the current buffer.
  31629. * @param uniformBuffer defines the current uniform buffer.
  31630. */
  31631. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  31632. /**
  31633. * Makes a duplicate of the current instance into another one.
  31634. * @param detailMap define the instance where to copy the info
  31635. */
  31636. copyTo(detailMap: DetailMapConfiguration): void;
  31637. /**
  31638. * Serializes this detail map instance
  31639. * @returns - An object with the serialized instance.
  31640. */
  31641. serialize(): any;
  31642. /**
  31643. * Parses a detail map setting from a serialized object.
  31644. * @param source - Serialized object.
  31645. * @param scene Defines the scene we are parsing for
  31646. * @param rootUrl Defines the rootUrl to load from
  31647. */
  31648. parse(source: any, scene: Scene, rootUrl: string): void;
  31649. }
  31650. }
  31651. declare module "babylonjs/Materials/standardMaterial" {
  31652. import { SmartArray } from "babylonjs/Misc/smartArray";
  31653. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  31654. import { Nullable } from "babylonjs/types";
  31655. import { Scene } from "babylonjs/scene";
  31656. import { Matrix } from "babylonjs/Maths/math.vector";
  31657. import { Color3 } from "babylonjs/Maths/math.color";
  31658. import { SubMesh } from "babylonjs/Meshes/subMesh";
  31659. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  31660. import { Mesh } from "babylonjs/Meshes/mesh";
  31661. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  31662. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  31663. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  31664. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  31665. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  31666. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  31667. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  31668. import "babylonjs/Shaders/default.fragment";
  31669. import "babylonjs/Shaders/default.vertex";
  31670. import { IMaterialDetailMapDefines, DetailMapConfiguration } from "babylonjs/Materials/material.detailMapConfiguration";
  31671. /** @hidden */
  31672. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialDetailMapDefines {
  31673. MAINUV1: boolean;
  31674. MAINUV2: boolean;
  31675. DIFFUSE: boolean;
  31676. DIFFUSEDIRECTUV: number;
  31677. DETAIL: boolean;
  31678. DETAILDIRECTUV: number;
  31679. DETAIL_NORMALBLENDMETHOD: number;
  31680. AMBIENT: boolean;
  31681. AMBIENTDIRECTUV: number;
  31682. OPACITY: boolean;
  31683. OPACITYDIRECTUV: number;
  31684. OPACITYRGB: boolean;
  31685. REFLECTION: boolean;
  31686. EMISSIVE: boolean;
  31687. EMISSIVEDIRECTUV: number;
  31688. SPECULAR: boolean;
  31689. SPECULARDIRECTUV: number;
  31690. BUMP: boolean;
  31691. BUMPDIRECTUV: number;
  31692. PARALLAX: boolean;
  31693. PARALLAXOCCLUSION: boolean;
  31694. SPECULAROVERALPHA: boolean;
  31695. CLIPPLANE: boolean;
  31696. CLIPPLANE2: boolean;
  31697. CLIPPLANE3: boolean;
  31698. CLIPPLANE4: boolean;
  31699. CLIPPLANE5: boolean;
  31700. CLIPPLANE6: boolean;
  31701. ALPHATEST: boolean;
  31702. DEPTHPREPASS: boolean;
  31703. ALPHAFROMDIFFUSE: boolean;
  31704. POINTSIZE: boolean;
  31705. FOG: boolean;
  31706. SPECULARTERM: boolean;
  31707. DIFFUSEFRESNEL: boolean;
  31708. OPACITYFRESNEL: boolean;
  31709. REFLECTIONFRESNEL: boolean;
  31710. REFRACTIONFRESNEL: boolean;
  31711. EMISSIVEFRESNEL: boolean;
  31712. FRESNEL: boolean;
  31713. NORMAL: boolean;
  31714. UV1: boolean;
  31715. UV2: boolean;
  31716. VERTEXCOLOR: boolean;
  31717. VERTEXALPHA: boolean;
  31718. NUM_BONE_INFLUENCERS: number;
  31719. BonesPerMesh: number;
  31720. BONETEXTURE: boolean;
  31721. INSTANCES: boolean;
  31722. THIN_INSTANCES: boolean;
  31723. GLOSSINESS: boolean;
  31724. ROUGHNESS: boolean;
  31725. EMISSIVEASILLUMINATION: boolean;
  31726. LINKEMISSIVEWITHDIFFUSE: boolean;
  31727. REFLECTIONFRESNELFROMSPECULAR: boolean;
  31728. LIGHTMAP: boolean;
  31729. LIGHTMAPDIRECTUV: number;
  31730. OBJECTSPACE_NORMALMAP: boolean;
  31731. USELIGHTMAPASSHADOWMAP: boolean;
  31732. REFLECTIONMAP_3D: boolean;
  31733. REFLECTIONMAP_SPHERICAL: boolean;
  31734. REFLECTIONMAP_PLANAR: boolean;
  31735. REFLECTIONMAP_CUBIC: boolean;
  31736. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  31737. REFLECTIONMAP_PROJECTION: boolean;
  31738. REFLECTIONMAP_SKYBOX: boolean;
  31739. REFLECTIONMAP_EXPLICIT: boolean;
  31740. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  31741. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  31742. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  31743. INVERTCUBICMAP: boolean;
  31744. LOGARITHMICDEPTH: boolean;
  31745. REFRACTION: boolean;
  31746. REFRACTIONMAP_3D: boolean;
  31747. REFLECTIONOVERALPHA: boolean;
  31748. TWOSIDEDLIGHTING: boolean;
  31749. SHADOWFLOAT: boolean;
  31750. MORPHTARGETS: boolean;
  31751. MORPHTARGETS_NORMAL: boolean;
  31752. MORPHTARGETS_TANGENT: boolean;
  31753. MORPHTARGETS_UV: boolean;
  31754. NUM_MORPH_INFLUENCERS: number;
  31755. NONUNIFORMSCALING: boolean;
  31756. PREMULTIPLYALPHA: boolean;
  31757. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  31758. ALPHABLEND: boolean;
  31759. PREPASS: boolean;
  31760. SCENE_MRT_COUNT: number;
  31761. RGBDLIGHTMAP: boolean;
  31762. RGBDREFLECTION: boolean;
  31763. RGBDREFRACTION: boolean;
  31764. IMAGEPROCESSING: boolean;
  31765. VIGNETTE: boolean;
  31766. VIGNETTEBLENDMODEMULTIPLY: boolean;
  31767. VIGNETTEBLENDMODEOPAQUE: boolean;
  31768. TONEMAPPING: boolean;
  31769. TONEMAPPING_ACES: boolean;
  31770. CONTRAST: boolean;
  31771. COLORCURVES: boolean;
  31772. COLORGRADING: boolean;
  31773. COLORGRADING3D: boolean;
  31774. SAMPLER3DGREENDEPTH: boolean;
  31775. SAMPLER3DBGRMAP: boolean;
  31776. IMAGEPROCESSINGPOSTPROCESS: boolean;
  31777. MULTIVIEW: boolean;
  31778. /**
  31779. * If the reflection texture on this material is in linear color space
  31780. * @hidden
  31781. */
  31782. IS_REFLECTION_LINEAR: boolean;
  31783. /**
  31784. * If the refraction texture on this material is in linear color space
  31785. * @hidden
  31786. */
  31787. IS_REFRACTION_LINEAR: boolean;
  31788. EXPOSURE: boolean;
  31789. constructor();
  31790. setReflectionMode(modeToEnable: string): void;
  31791. }
  31792. /**
  31793. * This is the default material used in Babylon. It is the best trade off between quality
  31794. * and performances.
  31795. * @see https://doc.babylonjs.com/babylon101/materials
  31796. */
  31797. export class StandardMaterial extends PushMaterial {
  31798. private _diffuseTexture;
  31799. /**
  31800. * The basic texture of the material as viewed under a light.
  31801. */
  31802. diffuseTexture: Nullable<BaseTexture>;
  31803. private _ambientTexture;
  31804. /**
  31805. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  31806. */
  31807. ambientTexture: Nullable<BaseTexture>;
  31808. private _opacityTexture;
  31809. /**
  31810. * Define the transparency of the material from a texture.
  31811. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  31812. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  31813. */
  31814. opacityTexture: Nullable<BaseTexture>;
  31815. private _reflectionTexture;
  31816. /**
  31817. * Define the texture used to display the reflection.
  31818. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  31819. */
  31820. reflectionTexture: Nullable<BaseTexture>;
  31821. private _emissiveTexture;
  31822. /**
  31823. * Define texture of the material as if self lit.
  31824. * This will be mixed in the final result even in the absence of light.
  31825. */
  31826. emissiveTexture: Nullable<BaseTexture>;
  31827. private _specularTexture;
  31828. /**
  31829. * Define how the color and intensity of the highlight given by the light in the material.
  31830. */
  31831. specularTexture: Nullable<BaseTexture>;
  31832. private _bumpTexture;
  31833. /**
  31834. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  31835. * 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.
  31836. * @see https://doc.babylonjs.com/how_to/more_materials#bump-map
  31837. */
  31838. bumpTexture: Nullable<BaseTexture>;
  31839. private _lightmapTexture;
  31840. /**
  31841. * Complex lighting can be computationally expensive to compute at runtime.
  31842. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  31843. * @see https://doc.babylonjs.com/babylon101/lights#lightmaps
  31844. */
  31845. lightmapTexture: Nullable<BaseTexture>;
  31846. private _refractionTexture;
  31847. /**
  31848. * Define the texture used to display the refraction.
  31849. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  31850. */
  31851. refractionTexture: Nullable<BaseTexture>;
  31852. /**
  31853. * The color of the material lit by the environmental background lighting.
  31854. * @see https://doc.babylonjs.com/babylon101/materials#ambient-color-example
  31855. */
  31856. ambientColor: Color3;
  31857. /**
  31858. * The basic color of the material as viewed under a light.
  31859. */
  31860. diffuseColor: Color3;
  31861. /**
  31862. * Define how the color and intensity of the highlight given by the light in the material.
  31863. */
  31864. specularColor: Color3;
  31865. /**
  31866. * Define the color of the material as if self lit.
  31867. * This will be mixed in the final result even in the absence of light.
  31868. */
  31869. emissiveColor: Color3;
  31870. /**
  31871. * Defines how sharp are the highlights in the material.
  31872. * The bigger the value the sharper giving a more glossy feeling to the result.
  31873. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  31874. */
  31875. specularPower: number;
  31876. private _useAlphaFromDiffuseTexture;
  31877. /**
  31878. * Does the transparency come from the diffuse texture alpha channel.
  31879. */
  31880. useAlphaFromDiffuseTexture: boolean;
  31881. private _useEmissiveAsIllumination;
  31882. /**
  31883. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  31884. */
  31885. useEmissiveAsIllumination: boolean;
  31886. private _linkEmissiveWithDiffuse;
  31887. /**
  31888. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  31889. * the emissive level when the final color is close to one.
  31890. */
  31891. linkEmissiveWithDiffuse: boolean;
  31892. private _useSpecularOverAlpha;
  31893. /**
  31894. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  31895. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  31896. */
  31897. useSpecularOverAlpha: boolean;
  31898. private _useReflectionOverAlpha;
  31899. /**
  31900. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  31901. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  31902. */
  31903. useReflectionOverAlpha: boolean;
  31904. private _disableLighting;
  31905. /**
  31906. * Does lights from the scene impacts this material.
  31907. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  31908. */
  31909. disableLighting: boolean;
  31910. private _useObjectSpaceNormalMap;
  31911. /**
  31912. * Allows using an object space normal map (instead of tangent space).
  31913. */
  31914. useObjectSpaceNormalMap: boolean;
  31915. private _useParallax;
  31916. /**
  31917. * Is parallax enabled or not.
  31918. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  31919. */
  31920. useParallax: boolean;
  31921. private _useParallaxOcclusion;
  31922. /**
  31923. * Is parallax occlusion enabled or not.
  31924. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  31925. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  31926. */
  31927. useParallaxOcclusion: boolean;
  31928. /**
  31929. * 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.
  31930. */
  31931. parallaxScaleBias: number;
  31932. private _roughness;
  31933. /**
  31934. * Helps to define how blurry the reflections should appears in the material.
  31935. */
  31936. roughness: number;
  31937. /**
  31938. * In case of refraction, define the value of the index of refraction.
  31939. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  31940. */
  31941. indexOfRefraction: number;
  31942. /**
  31943. * Invert the refraction texture alongside the y axis.
  31944. * It can be useful with procedural textures or probe for instance.
  31945. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  31946. */
  31947. invertRefractionY: boolean;
  31948. /**
  31949. * Defines the alpha limits in alpha test mode.
  31950. */
  31951. alphaCutOff: number;
  31952. private _useLightmapAsShadowmap;
  31953. /**
  31954. * In case of light mapping, define whether the map contains light or shadow informations.
  31955. */
  31956. useLightmapAsShadowmap: boolean;
  31957. private _diffuseFresnelParameters;
  31958. /**
  31959. * Define the diffuse fresnel parameters of the material.
  31960. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  31961. */
  31962. diffuseFresnelParameters: FresnelParameters;
  31963. private _opacityFresnelParameters;
  31964. /**
  31965. * Define the opacity fresnel parameters of the material.
  31966. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  31967. */
  31968. opacityFresnelParameters: FresnelParameters;
  31969. private _reflectionFresnelParameters;
  31970. /**
  31971. * Define the reflection fresnel parameters of the material.
  31972. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  31973. */
  31974. reflectionFresnelParameters: FresnelParameters;
  31975. private _refractionFresnelParameters;
  31976. /**
  31977. * Define the refraction fresnel parameters of the material.
  31978. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  31979. */
  31980. refractionFresnelParameters: FresnelParameters;
  31981. private _emissiveFresnelParameters;
  31982. /**
  31983. * Define the emissive fresnel parameters of the material.
  31984. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  31985. */
  31986. emissiveFresnelParameters: FresnelParameters;
  31987. private _useReflectionFresnelFromSpecular;
  31988. /**
  31989. * If true automatically deducts the fresnels values from the material specularity.
  31990. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  31991. */
  31992. useReflectionFresnelFromSpecular: boolean;
  31993. private _useGlossinessFromSpecularMapAlpha;
  31994. /**
  31995. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  31996. */
  31997. useGlossinessFromSpecularMapAlpha: boolean;
  31998. private _maxSimultaneousLights;
  31999. /**
  32000. * Defines the maximum number of lights that can be used in the material
  32001. */
  32002. maxSimultaneousLights: number;
  32003. private _invertNormalMapX;
  32004. /**
  32005. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  32006. */
  32007. invertNormalMapX: boolean;
  32008. private _invertNormalMapY;
  32009. /**
  32010. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  32011. */
  32012. invertNormalMapY: boolean;
  32013. private _twoSidedLighting;
  32014. /**
  32015. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  32016. */
  32017. twoSidedLighting: boolean;
  32018. /**
  32019. * Default configuration related to image processing available in the standard Material.
  32020. */
  32021. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  32022. /**
  32023. * Gets the image processing configuration used either in this material.
  32024. */
  32025. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  32026. /**
  32027. * Sets the Default image processing configuration used either in the this material.
  32028. *
  32029. * If sets to null, the scene one is in use.
  32030. */
  32031. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  32032. /**
  32033. * Keep track of the image processing observer to allow dispose and replace.
  32034. */
  32035. private _imageProcessingObserver;
  32036. /**
  32037. * Attaches a new image processing configuration to the Standard Material.
  32038. * @param configuration
  32039. */
  32040. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  32041. /**
  32042. * Gets wether the color curves effect is enabled.
  32043. */
  32044. get cameraColorCurvesEnabled(): boolean;
  32045. /**
  32046. * Sets wether the color curves effect is enabled.
  32047. */
  32048. set cameraColorCurvesEnabled(value: boolean);
  32049. /**
  32050. * Gets wether the color grading effect is enabled.
  32051. */
  32052. get cameraColorGradingEnabled(): boolean;
  32053. /**
  32054. * Gets wether the color grading effect is enabled.
  32055. */
  32056. set cameraColorGradingEnabled(value: boolean);
  32057. /**
  32058. * Gets wether tonemapping is enabled or not.
  32059. */
  32060. get cameraToneMappingEnabled(): boolean;
  32061. /**
  32062. * Sets wether tonemapping is enabled or not
  32063. */
  32064. set cameraToneMappingEnabled(value: boolean);
  32065. /**
  32066. * The camera exposure used on this material.
  32067. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  32068. * This corresponds to a photographic exposure.
  32069. */
  32070. get cameraExposure(): number;
  32071. /**
  32072. * The camera exposure used on this material.
  32073. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  32074. * This corresponds to a photographic exposure.
  32075. */
  32076. set cameraExposure(value: number);
  32077. /**
  32078. * Gets The camera contrast used on this material.
  32079. */
  32080. get cameraContrast(): number;
  32081. /**
  32082. * Sets The camera contrast used on this material.
  32083. */
  32084. set cameraContrast(value: number);
  32085. /**
  32086. * Gets the Color Grading 2D Lookup Texture.
  32087. */
  32088. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  32089. /**
  32090. * Sets the Color Grading 2D Lookup Texture.
  32091. */
  32092. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  32093. /**
  32094. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  32095. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  32096. * 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;
  32097. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  32098. */
  32099. get cameraColorCurves(): Nullable<ColorCurves>;
  32100. /**
  32101. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  32102. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  32103. * 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;
  32104. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  32105. */
  32106. set cameraColorCurves(value: Nullable<ColorCurves>);
  32107. /**
  32108. * Can this material render to several textures at once
  32109. */
  32110. get canRenderToMRT(): boolean;
  32111. /**
  32112. * Defines the detail map parameters for the material.
  32113. */
  32114. readonly detailMap: DetailMapConfiguration;
  32115. protected _renderTargets: SmartArray<RenderTargetTexture>;
  32116. protected _worldViewProjectionMatrix: Matrix;
  32117. protected _globalAmbientColor: Color3;
  32118. protected _useLogarithmicDepth: boolean;
  32119. protected _rebuildInParallel: boolean;
  32120. /**
  32121. * Instantiates a new standard material.
  32122. * This is the default material used in Babylon. It is the best trade off between quality
  32123. * and performances.
  32124. * @see https://doc.babylonjs.com/babylon101/materials
  32125. * @param name Define the name of the material in the scene
  32126. * @param scene Define the scene the material belong to
  32127. */
  32128. constructor(name: string, scene: Scene);
  32129. /**
  32130. * Gets a boolean indicating that current material needs to register RTT
  32131. */
  32132. get hasRenderTargetTextures(): boolean;
  32133. /**
  32134. * Gets the current class name of the material e.g. "StandardMaterial"
  32135. * Mainly use in serialization.
  32136. * @returns the class name
  32137. */
  32138. getClassName(): string;
  32139. /**
  32140. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  32141. * You can try switching to logarithmic depth.
  32142. * @see https://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  32143. */
  32144. get useLogarithmicDepth(): boolean;
  32145. set useLogarithmicDepth(value: boolean);
  32146. /**
  32147. * Specifies if the material will require alpha blending
  32148. * @returns a boolean specifying if alpha blending is needed
  32149. */
  32150. needAlphaBlending(): boolean;
  32151. /**
  32152. * Specifies if this material should be rendered in alpha test mode
  32153. * @returns a boolean specifying if an alpha test is needed.
  32154. */
  32155. needAlphaTesting(): boolean;
  32156. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  32157. /**
  32158. * Get the texture used for alpha test purpose.
  32159. * @returns the diffuse texture in case of the standard material.
  32160. */
  32161. getAlphaTestTexture(): Nullable<BaseTexture>;
  32162. /**
  32163. * Get if the submesh is ready to be used and all its information available.
  32164. * Child classes can use it to update shaders
  32165. * @param mesh defines the mesh to check
  32166. * @param subMesh defines which submesh to check
  32167. * @param useInstances specifies that instances should be used
  32168. * @returns a boolean indicating that the submesh is ready or not
  32169. */
  32170. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  32171. /**
  32172. * Builds the material UBO layouts.
  32173. * Used internally during the effect preparation.
  32174. */
  32175. buildUniformLayout(): void;
  32176. /**
  32177. * Unbinds the material from the mesh
  32178. */
  32179. unbind(): void;
  32180. /**
  32181. * Binds the submesh to this material by preparing the effect and shader to draw
  32182. * @param world defines the world transformation matrix
  32183. * @param mesh defines the mesh containing the submesh
  32184. * @param subMesh defines the submesh to bind the material to
  32185. */
  32186. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  32187. /**
  32188. * Get the list of animatables in the material.
  32189. * @returns the list of animatables object used in the material
  32190. */
  32191. getAnimatables(): IAnimatable[];
  32192. /**
  32193. * Gets the active textures from the material
  32194. * @returns an array of textures
  32195. */
  32196. getActiveTextures(): BaseTexture[];
  32197. /**
  32198. * Specifies if the material uses a texture
  32199. * @param texture defines the texture to check against the material
  32200. * @returns a boolean specifying if the material uses the texture
  32201. */
  32202. hasTexture(texture: BaseTexture): boolean;
  32203. /**
  32204. * Disposes the material
  32205. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  32206. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  32207. */
  32208. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  32209. /**
  32210. * Makes a duplicate of the material, and gives it a new name
  32211. * @param name defines the new name for the duplicated material
  32212. * @returns the cloned material
  32213. */
  32214. clone(name: string): StandardMaterial;
  32215. /**
  32216. * Serializes this material in a JSON representation
  32217. * @returns the serialized material object
  32218. */
  32219. serialize(): any;
  32220. /**
  32221. * Creates a standard material from parsed material data
  32222. * @param source defines the JSON representation of the material
  32223. * @param scene defines the hosting scene
  32224. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  32225. * @returns a new standard material
  32226. */
  32227. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  32228. /**
  32229. * Are diffuse textures enabled in the application.
  32230. */
  32231. static get DiffuseTextureEnabled(): boolean;
  32232. static set DiffuseTextureEnabled(value: boolean);
  32233. /**
  32234. * Are detail textures enabled in the application.
  32235. */
  32236. static get DetailTextureEnabled(): boolean;
  32237. static set DetailTextureEnabled(value: boolean);
  32238. /**
  32239. * Are ambient textures enabled in the application.
  32240. */
  32241. static get AmbientTextureEnabled(): boolean;
  32242. static set AmbientTextureEnabled(value: boolean);
  32243. /**
  32244. * Are opacity textures enabled in the application.
  32245. */
  32246. static get OpacityTextureEnabled(): boolean;
  32247. static set OpacityTextureEnabled(value: boolean);
  32248. /**
  32249. * Are reflection textures enabled in the application.
  32250. */
  32251. static get ReflectionTextureEnabled(): boolean;
  32252. static set ReflectionTextureEnabled(value: boolean);
  32253. /**
  32254. * Are emissive textures enabled in the application.
  32255. */
  32256. static get EmissiveTextureEnabled(): boolean;
  32257. static set EmissiveTextureEnabled(value: boolean);
  32258. /**
  32259. * Are specular textures enabled in the application.
  32260. */
  32261. static get SpecularTextureEnabled(): boolean;
  32262. static set SpecularTextureEnabled(value: boolean);
  32263. /**
  32264. * Are bump textures enabled in the application.
  32265. */
  32266. static get BumpTextureEnabled(): boolean;
  32267. static set BumpTextureEnabled(value: boolean);
  32268. /**
  32269. * Are lightmap textures enabled in the application.
  32270. */
  32271. static get LightmapTextureEnabled(): boolean;
  32272. static set LightmapTextureEnabled(value: boolean);
  32273. /**
  32274. * Are refraction textures enabled in the application.
  32275. */
  32276. static get RefractionTextureEnabled(): boolean;
  32277. static set RefractionTextureEnabled(value: boolean);
  32278. /**
  32279. * Are color grading textures enabled in the application.
  32280. */
  32281. static get ColorGradingTextureEnabled(): boolean;
  32282. static set ColorGradingTextureEnabled(value: boolean);
  32283. /**
  32284. * Are fresnels enabled in the application.
  32285. */
  32286. static get FresnelEnabled(): boolean;
  32287. static set FresnelEnabled(value: boolean);
  32288. }
  32289. }
  32290. declare module "babylonjs/Particles/solidParticleSystem" {
  32291. import { Nullable } from "babylonjs/types";
  32292. import { Mesh } from "babylonjs/Meshes/mesh";
  32293. import { Scene, IDisposable } from "babylonjs/scene";
  32294. import { DepthSortedParticle, SolidParticle, SolidParticleVertex } from "babylonjs/Particles/solidParticle";
  32295. import { Material } from "babylonjs/Materials/material";
  32296. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  32297. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  32298. /**
  32299. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  32300. *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.
  32301. * The SPS is also a particle system. It provides some methods to manage the particles.
  32302. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  32303. *
  32304. * Full documentation here : https://doc.babylonjs.com/how_to/Solid_Particle_System
  32305. */
  32306. export class SolidParticleSystem implements IDisposable {
  32307. /**
  32308. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  32309. * Example : var p = SPS.particles[i];
  32310. */
  32311. particles: SolidParticle[];
  32312. /**
  32313. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  32314. */
  32315. nbParticles: number;
  32316. /**
  32317. * If the particles must ever face the camera (default false). Useful for planar particles.
  32318. */
  32319. billboard: boolean;
  32320. /**
  32321. * Recompute normals when adding a shape
  32322. */
  32323. recomputeNormals: boolean;
  32324. /**
  32325. * This a counter ofr your own usage. It's not set by any SPS functions.
  32326. */
  32327. counter: number;
  32328. /**
  32329. * The SPS name. This name is also given to the underlying mesh.
  32330. */
  32331. name: string;
  32332. /**
  32333. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  32334. */
  32335. mesh: Mesh;
  32336. /**
  32337. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  32338. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  32339. */
  32340. vars: any;
  32341. /**
  32342. * This array is populated when the SPS is set as 'pickable'.
  32343. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  32344. * Each element of this array is an object `{idx: int, faceId: int}`.
  32345. * `idx` is the picked particle index in the `SPS.particles` array
  32346. * `faceId` is the picked face index counted within this particle.
  32347. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  32348. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  32349. * Use the method SPS.pickedParticle(pickingInfo) instead.
  32350. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  32351. */
  32352. pickedParticles: {
  32353. idx: number;
  32354. faceId: number;
  32355. }[];
  32356. /**
  32357. * This array is populated when the SPS is set as 'pickable'
  32358. * Each key of this array is a submesh index.
  32359. * Each element of this array is a second array defined like this :
  32360. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  32361. * Each element of this second array is an object `{idx: int, faceId: int}`.
  32362. * `idx` is the picked particle index in the `SPS.particles` array
  32363. * `faceId` is the picked face index counted within this particle.
  32364. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  32365. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  32366. */
  32367. pickedBySubMesh: {
  32368. idx: number;
  32369. faceId: number;
  32370. }[][];
  32371. /**
  32372. * This array is populated when `enableDepthSort` is set to true.
  32373. * Each element of this array is an instance of the class DepthSortedParticle.
  32374. */
  32375. depthSortedParticles: DepthSortedParticle[];
  32376. /**
  32377. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  32378. * @hidden
  32379. */
  32380. _bSphereOnly: boolean;
  32381. /**
  32382. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  32383. * @hidden
  32384. */
  32385. _bSphereRadiusFactor: number;
  32386. private _scene;
  32387. private _positions;
  32388. private _indices;
  32389. private _normals;
  32390. private _colors;
  32391. private _uvs;
  32392. private _indices32;
  32393. private _positions32;
  32394. private _normals32;
  32395. private _fixedNormal32;
  32396. private _colors32;
  32397. private _uvs32;
  32398. private _index;
  32399. private _updatable;
  32400. private _pickable;
  32401. private _isVisibilityBoxLocked;
  32402. private _alwaysVisible;
  32403. private _depthSort;
  32404. private _expandable;
  32405. private _shapeCounter;
  32406. private _copy;
  32407. private _color;
  32408. private _computeParticleColor;
  32409. private _computeParticleTexture;
  32410. private _computeParticleRotation;
  32411. private _computeParticleVertex;
  32412. private _computeBoundingBox;
  32413. private _depthSortParticles;
  32414. private _camera;
  32415. private _mustUnrotateFixedNormals;
  32416. private _particlesIntersect;
  32417. private _needs32Bits;
  32418. private _isNotBuilt;
  32419. private _lastParticleId;
  32420. private _idxOfId;
  32421. private _multimaterialEnabled;
  32422. private _useModelMaterial;
  32423. private _indicesByMaterial;
  32424. private _materialIndexes;
  32425. private _depthSortFunction;
  32426. private _materialSortFunction;
  32427. private _materials;
  32428. private _multimaterial;
  32429. private _materialIndexesById;
  32430. private _defaultMaterial;
  32431. private _autoUpdateSubMeshes;
  32432. private _tmpVertex;
  32433. /**
  32434. * Creates a SPS (Solid Particle System) object.
  32435. * @param name (String) is the SPS name, this will be the underlying mesh name.
  32436. * @param scene (Scene) is the scene in which the SPS is added.
  32437. * @param options defines the options of the sps e.g.
  32438. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  32439. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  32440. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  32441. * * 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.
  32442. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  32443. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  32444. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  32445. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  32446. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  32447. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  32448. */
  32449. constructor(name: string, scene: Scene, options?: {
  32450. updatable?: boolean;
  32451. isPickable?: boolean;
  32452. enableDepthSort?: boolean;
  32453. particleIntersection?: boolean;
  32454. boundingSphereOnly?: boolean;
  32455. bSphereRadiusFactor?: number;
  32456. expandable?: boolean;
  32457. useModelMaterial?: boolean;
  32458. enableMultiMaterial?: boolean;
  32459. });
  32460. /**
  32461. * Builds the SPS underlying mesh. Returns a standard Mesh.
  32462. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  32463. * @returns the created mesh
  32464. */
  32465. buildMesh(): Mesh;
  32466. /**
  32467. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  32468. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  32469. * Thus the particles generated from `digest()` have their property `position` set yet.
  32470. * @param mesh ( Mesh ) is the mesh to be digested
  32471. * @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
  32472. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  32473. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  32474. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  32475. * @returns the current SPS
  32476. */
  32477. digest(mesh: Mesh, options?: {
  32478. facetNb?: number;
  32479. number?: number;
  32480. delta?: number;
  32481. storage?: [];
  32482. }): SolidParticleSystem;
  32483. /**
  32484. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  32485. * @hidden
  32486. */
  32487. private _unrotateFixedNormals;
  32488. /**
  32489. * Resets the temporary working copy particle
  32490. * @hidden
  32491. */
  32492. private _resetCopy;
  32493. /**
  32494. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  32495. * @param p the current index in the positions array to be updated
  32496. * @param ind the current index in the indices array
  32497. * @param shape a Vector3 array, the shape geometry
  32498. * @param positions the positions array to be updated
  32499. * @param meshInd the shape indices array
  32500. * @param indices the indices array to be updated
  32501. * @param meshUV the shape uv array
  32502. * @param uvs the uv array to be updated
  32503. * @param meshCol the shape color array
  32504. * @param colors the color array to be updated
  32505. * @param meshNor the shape normals array
  32506. * @param normals the normals array to be updated
  32507. * @param idx the particle index
  32508. * @param idxInShape the particle index in its shape
  32509. * @param options the addShape() method passed options
  32510. * @model the particle model
  32511. * @hidden
  32512. */
  32513. private _meshBuilder;
  32514. /**
  32515. * Returns a shape Vector3 array from positions float array
  32516. * @param positions float array
  32517. * @returns a vector3 array
  32518. * @hidden
  32519. */
  32520. private _posToShape;
  32521. /**
  32522. * Returns a shapeUV array from a float uvs (array deep copy)
  32523. * @param uvs as a float array
  32524. * @returns a shapeUV array
  32525. * @hidden
  32526. */
  32527. private _uvsToShapeUV;
  32528. /**
  32529. * Adds a new particle object in the particles array
  32530. * @param idx particle index in particles array
  32531. * @param id particle id
  32532. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  32533. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  32534. * @param model particle ModelShape object
  32535. * @param shapeId model shape identifier
  32536. * @param idxInShape index of the particle in the current model
  32537. * @param bInfo model bounding info object
  32538. * @param storage target storage array, if any
  32539. * @hidden
  32540. */
  32541. private _addParticle;
  32542. /**
  32543. * Adds some particles to the SPS from the model shape. Returns the shape id.
  32544. * Please read the doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  32545. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  32546. * @param nb (positive integer) the number of particles to be created from this model
  32547. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  32548. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  32549. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  32550. * @returns the number of shapes in the system
  32551. */
  32552. addShape(mesh: Mesh, nb: number, options?: {
  32553. positionFunction?: any;
  32554. vertexFunction?: any;
  32555. storage?: [];
  32556. }): number;
  32557. /**
  32558. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  32559. * @hidden
  32560. */
  32561. private _rebuildParticle;
  32562. /**
  32563. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  32564. * @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.
  32565. * @returns the SPS.
  32566. */
  32567. rebuildMesh(reset?: boolean): SolidParticleSystem;
  32568. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  32569. * Returns an array with the removed particles.
  32570. * 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.
  32571. * The SPS can't be empty so at least one particle needs to remain in place.
  32572. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  32573. * @param start index of the first particle to remove
  32574. * @param end index of the last particle to remove (included)
  32575. * @returns an array populated with the removed particles
  32576. */
  32577. removeParticles(start: number, end: number): SolidParticle[];
  32578. /**
  32579. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  32580. * @param solidParticleArray an array populated with Solid Particles objects
  32581. * @returns the SPS
  32582. */
  32583. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  32584. /**
  32585. * Creates a new particle and modifies the SPS mesh geometry :
  32586. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  32587. * - calls _addParticle() to populate the particle array
  32588. * factorized code from addShape() and insertParticlesFromArray()
  32589. * @param idx particle index in the particles array
  32590. * @param i particle index in its shape
  32591. * @param modelShape particle ModelShape object
  32592. * @param shape shape vertex array
  32593. * @param meshInd shape indices array
  32594. * @param meshUV shape uv array
  32595. * @param meshCol shape color array
  32596. * @param meshNor shape normals array
  32597. * @param bbInfo shape bounding info
  32598. * @param storage target particle storage
  32599. * @options addShape() passed options
  32600. * @hidden
  32601. */
  32602. private _insertNewParticle;
  32603. /**
  32604. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  32605. * This method calls `updateParticle()` for each particle of the SPS.
  32606. * For an animated SPS, it is usually called within the render loop.
  32607. * 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.
  32608. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  32609. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  32610. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  32611. * @returns the SPS.
  32612. */
  32613. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  32614. /**
  32615. * Disposes the SPS.
  32616. */
  32617. dispose(): void;
  32618. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  32619. * idx is the particle index in the SPS
  32620. * faceId is the picked face index counted within this particle.
  32621. * Returns null if the pickInfo can't identify a picked particle.
  32622. * @param pickingInfo (PickingInfo object)
  32623. * @returns {idx: number, faceId: number} or null
  32624. */
  32625. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  32626. idx: number;
  32627. faceId: number;
  32628. }>;
  32629. /**
  32630. * Returns a SolidParticle object from its identifier : particle.id
  32631. * @param id (integer) the particle Id
  32632. * @returns the searched particle or null if not found in the SPS.
  32633. */
  32634. getParticleById(id: number): Nullable<SolidParticle>;
  32635. /**
  32636. * Returns a new array populated with the particles having the passed shapeId.
  32637. * @param shapeId (integer) the shape identifier
  32638. * @returns a new solid particle array
  32639. */
  32640. getParticlesByShapeId(shapeId: number): SolidParticle[];
  32641. /**
  32642. * Populates the passed array "ref" with the particles having the passed shapeId.
  32643. * @param shapeId the shape identifier
  32644. * @returns the SPS
  32645. * @param ref
  32646. */
  32647. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  32648. /**
  32649. * Computes the required SubMeshes according the materials assigned to the particles.
  32650. * @returns the solid particle system.
  32651. * Does nothing if called before the SPS mesh is built.
  32652. */
  32653. computeSubMeshes(): SolidParticleSystem;
  32654. /**
  32655. * Sorts the solid particles by material when MultiMaterial is enabled.
  32656. * Updates the indices32 array.
  32657. * Updates the indicesByMaterial array.
  32658. * Updates the mesh indices array.
  32659. * @returns the SPS
  32660. * @hidden
  32661. */
  32662. private _sortParticlesByMaterial;
  32663. /**
  32664. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  32665. * @hidden
  32666. */
  32667. private _setMaterialIndexesById;
  32668. /**
  32669. * Returns an array with unique values of Materials from the passed array
  32670. * @param array the material array to be checked and filtered
  32671. * @hidden
  32672. */
  32673. private _filterUniqueMaterialId;
  32674. /**
  32675. * Sets a new Standard Material as _defaultMaterial if not already set.
  32676. * @hidden
  32677. */
  32678. private _setDefaultMaterial;
  32679. /**
  32680. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  32681. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  32682. * @returns the SPS.
  32683. */
  32684. refreshVisibleSize(): SolidParticleSystem;
  32685. /**
  32686. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  32687. * @param size the size (float) of the visibility box
  32688. * note : this doesn't lock the SPS mesh bounding box.
  32689. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  32690. */
  32691. setVisibilityBox(size: number): void;
  32692. /**
  32693. * Gets whether the SPS as always visible or not
  32694. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  32695. */
  32696. get isAlwaysVisible(): boolean;
  32697. /**
  32698. * Sets the SPS as always visible or not
  32699. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  32700. */
  32701. set isAlwaysVisible(val: boolean);
  32702. /**
  32703. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  32704. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  32705. */
  32706. set isVisibilityBoxLocked(val: boolean);
  32707. /**
  32708. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  32709. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  32710. */
  32711. get isVisibilityBoxLocked(): boolean;
  32712. /**
  32713. * Tells to `setParticles()` to compute the particle rotations or not.
  32714. * Default value : true. The SPS is faster when it's set to false.
  32715. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  32716. */
  32717. set computeParticleRotation(val: boolean);
  32718. /**
  32719. * Tells to `setParticles()` to compute the particle colors or not.
  32720. * Default value : true. The SPS is faster when it's set to false.
  32721. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  32722. */
  32723. set computeParticleColor(val: boolean);
  32724. set computeParticleTexture(val: boolean);
  32725. /**
  32726. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  32727. * Default value : false. The SPS is faster when it's set to false.
  32728. * Note : the particle custom vertex positions aren't stored values.
  32729. */
  32730. set computeParticleVertex(val: boolean);
  32731. /**
  32732. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  32733. */
  32734. set computeBoundingBox(val: boolean);
  32735. /**
  32736. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  32737. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  32738. * Default : `true`
  32739. */
  32740. set depthSortParticles(val: boolean);
  32741. /**
  32742. * Gets if `setParticles()` computes the particle rotations or not.
  32743. * Default value : true. The SPS is faster when it's set to false.
  32744. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  32745. */
  32746. get computeParticleRotation(): boolean;
  32747. /**
  32748. * Gets if `setParticles()` computes the particle colors or not.
  32749. * Default value : true. The SPS is faster when it's set to false.
  32750. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  32751. */
  32752. get computeParticleColor(): boolean;
  32753. /**
  32754. * Gets if `setParticles()` computes the particle textures or not.
  32755. * Default value : true. The SPS is faster when it's set to false.
  32756. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  32757. */
  32758. get computeParticleTexture(): boolean;
  32759. /**
  32760. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  32761. * Default value : false. The SPS is faster when it's set to false.
  32762. * Note : the particle custom vertex positions aren't stored values.
  32763. */
  32764. get computeParticleVertex(): boolean;
  32765. /**
  32766. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  32767. */
  32768. get computeBoundingBox(): boolean;
  32769. /**
  32770. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  32771. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  32772. * Default : `true`
  32773. */
  32774. get depthSortParticles(): boolean;
  32775. /**
  32776. * Gets if the SPS is created as expandable at construction time.
  32777. * Default : `false`
  32778. */
  32779. get expandable(): boolean;
  32780. /**
  32781. * Gets if the SPS supports the Multi Materials
  32782. */
  32783. get multimaterialEnabled(): boolean;
  32784. /**
  32785. * Gets if the SPS uses the model materials for its own multimaterial.
  32786. */
  32787. get useModelMaterial(): boolean;
  32788. /**
  32789. * The SPS used material array.
  32790. */
  32791. get materials(): Material[];
  32792. /**
  32793. * Sets the SPS MultiMaterial from the passed materials.
  32794. * Note : the passed array is internally copied and not used then by reference.
  32795. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  32796. */
  32797. setMultiMaterial(materials: Material[]): void;
  32798. /**
  32799. * The SPS computed multimaterial object
  32800. */
  32801. get multimaterial(): MultiMaterial;
  32802. set multimaterial(mm: MultiMaterial);
  32803. /**
  32804. * If the subMeshes must be updated on the next call to setParticles()
  32805. */
  32806. get autoUpdateSubMeshes(): boolean;
  32807. set autoUpdateSubMeshes(val: boolean);
  32808. /**
  32809. * This function does nothing. It may be overwritten to set all the particle first values.
  32810. * The SPS doesn't call this function, you may have to call it by your own.
  32811. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  32812. */
  32813. initParticles(): void;
  32814. /**
  32815. * This function does nothing. It may be overwritten to recycle a particle.
  32816. * The SPS doesn't call this function, you may have to call it by your own.
  32817. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  32818. * @param particle The particle to recycle
  32819. * @returns the recycled particle
  32820. */
  32821. recycleParticle(particle: SolidParticle): SolidParticle;
  32822. /**
  32823. * Updates a particle : this function should be overwritten by the user.
  32824. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  32825. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  32826. * @example : just set a particle position or velocity and recycle conditions
  32827. * @param particle The particle to update
  32828. * @returns the updated particle
  32829. */
  32830. updateParticle(particle: SolidParticle): SolidParticle;
  32831. /**
  32832. * Updates a vertex of a particle : it can be overwritten by the user.
  32833. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  32834. * @param particle the current particle
  32835. * @param vertex the current vertex of the current particle : a SolidParticleVertex object
  32836. * @param pt the index of the current vertex in the particle shape
  32837. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  32838. * @example : just set a vertex particle position or color
  32839. * @returns the sps
  32840. */
  32841. updateParticleVertex(particle: SolidParticle, vertex: SolidParticleVertex, pt: number): SolidParticleSystem;
  32842. /**
  32843. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  32844. * This does nothing and may be overwritten by the user.
  32845. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  32846. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  32847. * @param update the boolean update value actually passed to setParticles()
  32848. */
  32849. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  32850. /**
  32851. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  32852. * This will be passed three parameters.
  32853. * This does nothing and may be overwritten by the user.
  32854. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  32855. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  32856. * @param update the boolean update value actually passed to setParticles()
  32857. */
  32858. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  32859. }
  32860. }
  32861. declare module "babylonjs/Particles/solidParticle" {
  32862. import { Nullable } from "babylonjs/types";
  32863. import { Vector3, Matrix, Quaternion, Vector4, Vector2 } from "babylonjs/Maths/math.vector";
  32864. import { Color4 } from "babylonjs/Maths/math.color";
  32865. import { Mesh } from "babylonjs/Meshes/mesh";
  32866. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  32867. import { SolidParticleSystem } from "babylonjs/Particles/solidParticleSystem";
  32868. import { Plane } from "babylonjs/Maths/math.plane";
  32869. import { Material } from "babylonjs/Materials/material";
  32870. /**
  32871. * Represents one particle of a solid particle system.
  32872. */
  32873. export class SolidParticle {
  32874. /**
  32875. * particle global index
  32876. */
  32877. idx: number;
  32878. /**
  32879. * particle identifier
  32880. */
  32881. id: number;
  32882. /**
  32883. * The color of the particle
  32884. */
  32885. color: Nullable<Color4>;
  32886. /**
  32887. * The world space position of the particle.
  32888. */
  32889. position: Vector3;
  32890. /**
  32891. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  32892. */
  32893. rotation: Vector3;
  32894. /**
  32895. * The world space rotation quaternion of the particle.
  32896. */
  32897. rotationQuaternion: Nullable<Quaternion>;
  32898. /**
  32899. * The scaling of the particle.
  32900. */
  32901. scaling: Vector3;
  32902. /**
  32903. * The uvs of the particle.
  32904. */
  32905. uvs: Vector4;
  32906. /**
  32907. * The current speed of the particle.
  32908. */
  32909. velocity: Vector3;
  32910. /**
  32911. * The pivot point in the particle local space.
  32912. */
  32913. pivot: Vector3;
  32914. /**
  32915. * Must the particle be translated from its pivot point in its local space ?
  32916. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  32917. * Default : false
  32918. */
  32919. translateFromPivot: boolean;
  32920. /**
  32921. * Is the particle active or not ?
  32922. */
  32923. alive: boolean;
  32924. /**
  32925. * Is the particle visible or not ?
  32926. */
  32927. isVisible: boolean;
  32928. /**
  32929. * Index of this particle in the global "positions" array (Internal use)
  32930. * @hidden
  32931. */
  32932. _pos: number;
  32933. /**
  32934. * @hidden Index of this particle in the global "indices" array (Internal use)
  32935. */
  32936. _ind: number;
  32937. /**
  32938. * @hidden ModelShape of this particle (Internal use)
  32939. */
  32940. _model: ModelShape;
  32941. /**
  32942. * ModelShape id of this particle
  32943. */
  32944. shapeId: number;
  32945. /**
  32946. * Index of the particle in its shape id
  32947. */
  32948. idxInShape: number;
  32949. /**
  32950. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  32951. */
  32952. _modelBoundingInfo: BoundingInfo;
  32953. /**
  32954. * @hidden Particle BoundingInfo object (Internal use)
  32955. */
  32956. _boundingInfo: BoundingInfo;
  32957. /**
  32958. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  32959. */
  32960. _sps: SolidParticleSystem;
  32961. /**
  32962. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  32963. */
  32964. _stillInvisible: boolean;
  32965. /**
  32966. * @hidden Last computed particle rotation matrix
  32967. */
  32968. _rotationMatrix: number[];
  32969. /**
  32970. * Parent particle Id, if any.
  32971. * Default null.
  32972. */
  32973. parentId: Nullable<number>;
  32974. /**
  32975. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  32976. */
  32977. materialIndex: Nullable<number>;
  32978. /**
  32979. * Custom object or properties.
  32980. */
  32981. props: Nullable<any>;
  32982. /**
  32983. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  32984. * The possible values are :
  32985. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  32986. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  32987. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  32988. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  32989. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  32990. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  32991. * */
  32992. cullingStrategy: number;
  32993. /**
  32994. * @hidden Internal global position in the SPS.
  32995. */
  32996. _globalPosition: Vector3;
  32997. /**
  32998. * Creates a Solid Particle object.
  32999. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  33000. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  33001. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  33002. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  33003. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  33004. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  33005. * @param shapeId (integer) is the model shape identifier in the SPS.
  33006. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  33007. * @param sps defines the sps it is associated to
  33008. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  33009. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  33010. */
  33011. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  33012. /**
  33013. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  33014. * @param target the particle target
  33015. * @returns the current particle
  33016. */
  33017. copyToRef(target: SolidParticle): SolidParticle;
  33018. /**
  33019. * Legacy support, changed scale to scaling
  33020. */
  33021. get scale(): Vector3;
  33022. /**
  33023. * Legacy support, changed scale to scaling
  33024. */
  33025. set scale(scale: Vector3);
  33026. /**
  33027. * Legacy support, changed quaternion to rotationQuaternion
  33028. */
  33029. get quaternion(): Nullable<Quaternion>;
  33030. /**
  33031. * Legacy support, changed quaternion to rotationQuaternion
  33032. */
  33033. set quaternion(q: Nullable<Quaternion>);
  33034. /**
  33035. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  33036. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  33037. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  33038. * @returns true if it intersects
  33039. */
  33040. intersectsMesh(target: Mesh | SolidParticle): boolean;
  33041. /**
  33042. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  33043. * A particle is in the frustum if its bounding box intersects the frustum
  33044. * @param frustumPlanes defines the frustum to test
  33045. * @returns true if the particle is in the frustum planes
  33046. */
  33047. isInFrustum(frustumPlanes: Plane[]): boolean;
  33048. /**
  33049. * get the rotation matrix of the particle
  33050. * @hidden
  33051. */
  33052. getRotationMatrix(m: Matrix): void;
  33053. }
  33054. /**
  33055. * Represents the shape of the model used by one particle of a solid particle system.
  33056. * SPS internal tool, don't use it manually.
  33057. */
  33058. export class ModelShape {
  33059. /**
  33060. * The shape id
  33061. * @hidden
  33062. */
  33063. shapeID: number;
  33064. /**
  33065. * flat array of model positions (internal use)
  33066. * @hidden
  33067. */
  33068. _shape: Vector3[];
  33069. /**
  33070. * flat array of model UVs (internal use)
  33071. * @hidden
  33072. */
  33073. _shapeUV: number[];
  33074. /**
  33075. * color array of the model
  33076. * @hidden
  33077. */
  33078. _shapeColors: number[];
  33079. /**
  33080. * indices array of the model
  33081. * @hidden
  33082. */
  33083. _indices: number[];
  33084. /**
  33085. * normals array of the model
  33086. * @hidden
  33087. */
  33088. _normals: number[];
  33089. /**
  33090. * length of the shape in the model indices array (internal use)
  33091. * @hidden
  33092. */
  33093. _indicesLength: number;
  33094. /**
  33095. * Custom position function (internal use)
  33096. * @hidden
  33097. */
  33098. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  33099. /**
  33100. * Custom vertex function (internal use)
  33101. * @hidden
  33102. */
  33103. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  33104. /**
  33105. * Model material (internal use)
  33106. * @hidden
  33107. */
  33108. _material: Nullable<Material>;
  33109. /**
  33110. * 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.
  33111. * SPS internal tool, don't use it manually.
  33112. * @hidden
  33113. */
  33114. 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>);
  33115. }
  33116. /**
  33117. * Represents a Depth Sorted Particle in the solid particle system.
  33118. * @hidden
  33119. */
  33120. export class DepthSortedParticle {
  33121. /**
  33122. * Particle index
  33123. */
  33124. idx: number;
  33125. /**
  33126. * Index of the particle in the "indices" array
  33127. */
  33128. ind: number;
  33129. /**
  33130. * Length of the particle shape in the "indices" array
  33131. */
  33132. indicesLength: number;
  33133. /**
  33134. * Squared distance from the particle to the camera
  33135. */
  33136. sqDistance: number;
  33137. /**
  33138. * Material index when used with MultiMaterials
  33139. */
  33140. materialIndex: number;
  33141. /**
  33142. * Creates a new sorted particle
  33143. * @param materialIndex
  33144. */
  33145. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  33146. }
  33147. /**
  33148. * Represents a solid particle vertex
  33149. */
  33150. export class SolidParticleVertex {
  33151. /**
  33152. * Vertex position
  33153. */
  33154. position: Vector3;
  33155. /**
  33156. * Vertex color
  33157. */
  33158. color: Color4;
  33159. /**
  33160. * Vertex UV
  33161. */
  33162. uv: Vector2;
  33163. /**
  33164. * Creates a new solid particle vertex
  33165. */
  33166. constructor();
  33167. /** Vertex x coordinate */
  33168. get x(): number;
  33169. set x(val: number);
  33170. /** Vertex y coordinate */
  33171. get y(): number;
  33172. set y(val: number);
  33173. /** Vertex z coordinate */
  33174. get z(): number;
  33175. set z(val: number);
  33176. }
  33177. }
  33178. declare module "babylonjs/Collisions/meshCollisionData" {
  33179. import { Collider } from "babylonjs/Collisions/collider";
  33180. import { Vector3 } from "babylonjs/Maths/math.vector";
  33181. import { Nullable } from "babylonjs/types";
  33182. import { Observer } from "babylonjs/Misc/observable";
  33183. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33184. /**
  33185. * @hidden
  33186. */
  33187. export class _MeshCollisionData {
  33188. _checkCollisions: boolean;
  33189. _collisionMask: number;
  33190. _collisionGroup: number;
  33191. _surroundingMeshes: Nullable<AbstractMesh[]>;
  33192. _collider: Nullable<Collider>;
  33193. _oldPositionForCollisions: Vector3;
  33194. _diffPositionForCollisions: Vector3;
  33195. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  33196. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  33197. _collisionResponse: boolean;
  33198. }
  33199. }
  33200. declare module "babylonjs/Meshes/abstractMesh" {
  33201. import { Observable } from "babylonjs/Misc/observable";
  33202. import { Nullable, FloatArray, IndicesArray, DeepImmutable } from "babylonjs/types";
  33203. import { Camera } from "babylonjs/Cameras/camera";
  33204. import { Scene, IDisposable } from "babylonjs/scene";
  33205. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  33206. import { Node } from "babylonjs/node";
  33207. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  33208. import { TransformNode } from "babylonjs/Meshes/transformNode";
  33209. import { SubMesh } from "babylonjs/Meshes/subMesh";
  33210. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  33211. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  33212. import { Material } from "babylonjs/Materials/material";
  33213. import { Light } from "babylonjs/Lights/light";
  33214. import { Skeleton } from "babylonjs/Bones/skeleton";
  33215. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  33216. import { SolidParticle } from "babylonjs/Particles/solidParticle";
  33217. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  33218. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  33219. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  33220. import { Plane } from "babylonjs/Maths/math.plane";
  33221. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  33222. import { Ray } from "babylonjs/Culling/ray";
  33223. import { Collider } from "babylonjs/Collisions/collider";
  33224. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  33225. import { RenderingGroup } from "babylonjs/Rendering/renderingGroup";
  33226. /** @hidden */
  33227. class _FacetDataStorage {
  33228. facetPositions: Vector3[];
  33229. facetNormals: Vector3[];
  33230. facetPartitioning: number[][];
  33231. facetNb: number;
  33232. partitioningSubdivisions: number;
  33233. partitioningBBoxRatio: number;
  33234. facetDataEnabled: boolean;
  33235. facetParameters: any;
  33236. bbSize: Vector3;
  33237. subDiv: {
  33238. max: number;
  33239. X: number;
  33240. Y: number;
  33241. Z: number;
  33242. };
  33243. facetDepthSort: boolean;
  33244. facetDepthSortEnabled: boolean;
  33245. depthSortedIndices: IndicesArray;
  33246. depthSortedFacets: {
  33247. ind: number;
  33248. sqDistance: number;
  33249. }[];
  33250. facetDepthSortFunction: (f1: {
  33251. ind: number;
  33252. sqDistance: number;
  33253. }, f2: {
  33254. ind: number;
  33255. sqDistance: number;
  33256. }) => number;
  33257. facetDepthSortFrom: Vector3;
  33258. facetDepthSortOrigin: Vector3;
  33259. invertedMatrix: Matrix;
  33260. }
  33261. /**
  33262. * @hidden
  33263. **/
  33264. class _InternalAbstractMeshDataInfo {
  33265. _hasVertexAlpha: boolean;
  33266. _useVertexColors: boolean;
  33267. _numBoneInfluencers: number;
  33268. _applyFog: boolean;
  33269. _receiveShadows: boolean;
  33270. _facetData: _FacetDataStorage;
  33271. _visibility: number;
  33272. _skeleton: Nullable<Skeleton>;
  33273. _layerMask: number;
  33274. _computeBonesUsingShaders: boolean;
  33275. _isActive: boolean;
  33276. _onlyForInstances: boolean;
  33277. _isActiveIntermediate: boolean;
  33278. _onlyForInstancesIntermediate: boolean;
  33279. _actAsRegularMesh: boolean;
  33280. }
  33281. /**
  33282. * Class used to store all common mesh properties
  33283. */
  33284. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  33285. /** No occlusion */
  33286. static OCCLUSION_TYPE_NONE: number;
  33287. /** Occlusion set to optimisitic */
  33288. static OCCLUSION_TYPE_OPTIMISTIC: number;
  33289. /** Occlusion set to strict */
  33290. static OCCLUSION_TYPE_STRICT: number;
  33291. /** Use an accurante occlusion algorithm */
  33292. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  33293. /** Use a conservative occlusion algorithm */
  33294. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  33295. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  33296. * Test order :
  33297. * Is the bounding sphere outside the frustum ?
  33298. * If not, are the bounding box vertices outside the frustum ?
  33299. * It not, then the cullable object is in the frustum.
  33300. */
  33301. static readonly CULLINGSTRATEGY_STANDARD: number;
  33302. /** Culling strategy : Bounding Sphere Only.
  33303. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  33304. * It's also less accurate than the standard because some not visible objects can still be selected.
  33305. * Test : is the bounding sphere outside the frustum ?
  33306. * If not, then the cullable object is in the frustum.
  33307. */
  33308. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  33309. /** Culling strategy : Optimistic Inclusion.
  33310. * This in an inclusion test first, then the standard exclusion test.
  33311. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  33312. * 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.
  33313. * Anyway, it's as accurate as the standard strategy.
  33314. * Test :
  33315. * Is the cullable object bounding sphere center in the frustum ?
  33316. * If not, apply the default culling strategy.
  33317. */
  33318. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  33319. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  33320. * This in an inclusion test first, then the bounding sphere only exclusion test.
  33321. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  33322. * 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.
  33323. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  33324. * Test :
  33325. * Is the cullable object bounding sphere center in the frustum ?
  33326. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  33327. */
  33328. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  33329. /**
  33330. * No billboard
  33331. */
  33332. static get BILLBOARDMODE_NONE(): number;
  33333. /** Billboard on X axis */
  33334. static get BILLBOARDMODE_X(): number;
  33335. /** Billboard on Y axis */
  33336. static get BILLBOARDMODE_Y(): number;
  33337. /** Billboard on Z axis */
  33338. static get BILLBOARDMODE_Z(): number;
  33339. /** Billboard on all axes */
  33340. static get BILLBOARDMODE_ALL(): number;
  33341. /** Billboard on using position instead of orientation */
  33342. static get BILLBOARDMODE_USE_POSITION(): number;
  33343. /** @hidden */
  33344. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  33345. /**
  33346. * The culling strategy to use to check whether the mesh must be rendered or not.
  33347. * This value can be changed at any time and will be used on the next render mesh selection.
  33348. * The possible values are :
  33349. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  33350. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  33351. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  33352. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  33353. * Please read each static variable documentation to get details about the culling process.
  33354. * */
  33355. cullingStrategy: number;
  33356. /**
  33357. * Gets the number of facets in the mesh
  33358. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  33359. */
  33360. get facetNb(): number;
  33361. /**
  33362. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  33363. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  33364. */
  33365. get partitioningSubdivisions(): number;
  33366. set partitioningSubdivisions(nb: number);
  33367. /**
  33368. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  33369. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  33370. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  33371. */
  33372. get partitioningBBoxRatio(): number;
  33373. set partitioningBBoxRatio(ratio: number);
  33374. /**
  33375. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  33376. * Works only for updatable meshes.
  33377. * Doesn't work with multi-materials
  33378. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  33379. */
  33380. get mustDepthSortFacets(): boolean;
  33381. set mustDepthSortFacets(sort: boolean);
  33382. /**
  33383. * The location (Vector3) where the facet depth sort must be computed from.
  33384. * By default, the active camera position.
  33385. * Used only when facet depth sort is enabled
  33386. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  33387. */
  33388. get facetDepthSortFrom(): Vector3;
  33389. set facetDepthSortFrom(location: Vector3);
  33390. /**
  33391. * gets a boolean indicating if facetData is enabled
  33392. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  33393. */
  33394. get isFacetDataEnabled(): boolean;
  33395. /** @hidden */
  33396. _updateNonUniformScalingState(value: boolean): boolean;
  33397. /**
  33398. * An event triggered when this mesh collides with another one
  33399. */
  33400. onCollideObservable: Observable<AbstractMesh>;
  33401. /** Set a function to call when this mesh collides with another one */
  33402. set onCollide(callback: () => void);
  33403. /**
  33404. * An event triggered when the collision's position changes
  33405. */
  33406. onCollisionPositionChangeObservable: Observable<Vector3>;
  33407. /** Set a function to call when the collision's position changes */
  33408. set onCollisionPositionChange(callback: () => void);
  33409. /**
  33410. * An event triggered when material is changed
  33411. */
  33412. onMaterialChangedObservable: Observable<AbstractMesh>;
  33413. /**
  33414. * Gets or sets the orientation for POV movement & rotation
  33415. */
  33416. definedFacingForward: boolean;
  33417. /** @hidden */
  33418. _occlusionQuery: Nullable<WebGLQuery>;
  33419. /** @hidden */
  33420. _renderingGroup: Nullable<RenderingGroup>;
  33421. /**
  33422. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  33423. */
  33424. get visibility(): number;
  33425. /**
  33426. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  33427. */
  33428. set visibility(value: number);
  33429. /** Gets or sets the alpha index used to sort transparent meshes
  33430. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  33431. */
  33432. alphaIndex: number;
  33433. /**
  33434. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  33435. */
  33436. isVisible: boolean;
  33437. /**
  33438. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  33439. */
  33440. isPickable: boolean;
  33441. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  33442. showSubMeshesBoundingBox: boolean;
  33443. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  33444. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  33445. */
  33446. isBlocker: boolean;
  33447. /**
  33448. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  33449. */
  33450. enablePointerMoveEvents: boolean;
  33451. private _renderingGroupId;
  33452. /**
  33453. * Specifies the rendering group id for this mesh (0 by default)
  33454. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  33455. */
  33456. get renderingGroupId(): number;
  33457. set renderingGroupId(value: number);
  33458. private _material;
  33459. /** Gets or sets current material */
  33460. get material(): Nullable<Material>;
  33461. set material(value: Nullable<Material>);
  33462. /**
  33463. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  33464. * @see https://doc.babylonjs.com/babylon101/shadows
  33465. */
  33466. get receiveShadows(): boolean;
  33467. set receiveShadows(value: boolean);
  33468. /** Defines color to use when rendering outline */
  33469. outlineColor: Color3;
  33470. /** Define width to use when rendering outline */
  33471. outlineWidth: number;
  33472. /** Defines color to use when rendering overlay */
  33473. overlayColor: Color3;
  33474. /** Defines alpha to use when rendering overlay */
  33475. overlayAlpha: number;
  33476. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  33477. get hasVertexAlpha(): boolean;
  33478. set hasVertexAlpha(value: boolean);
  33479. /** 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) */
  33480. get useVertexColors(): boolean;
  33481. set useVertexColors(value: boolean);
  33482. /**
  33483. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  33484. */
  33485. get computeBonesUsingShaders(): boolean;
  33486. set computeBonesUsingShaders(value: boolean);
  33487. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  33488. get numBoneInfluencers(): number;
  33489. set numBoneInfluencers(value: number);
  33490. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  33491. get applyFog(): boolean;
  33492. set applyFog(value: boolean);
  33493. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  33494. useOctreeForRenderingSelection: boolean;
  33495. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  33496. useOctreeForPicking: boolean;
  33497. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  33498. useOctreeForCollisions: boolean;
  33499. /**
  33500. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  33501. * @see https://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  33502. */
  33503. get layerMask(): number;
  33504. set layerMask(value: number);
  33505. /**
  33506. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  33507. */
  33508. alwaysSelectAsActiveMesh: boolean;
  33509. /**
  33510. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  33511. */
  33512. doNotSyncBoundingInfo: boolean;
  33513. /**
  33514. * Gets or sets the current action manager
  33515. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  33516. */
  33517. actionManager: Nullable<AbstractActionManager>;
  33518. private _meshCollisionData;
  33519. /**
  33520. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  33521. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33522. */
  33523. ellipsoid: Vector3;
  33524. /**
  33525. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  33526. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33527. */
  33528. ellipsoidOffset: Vector3;
  33529. /**
  33530. * Gets or sets a collision mask used to mask collisions (default is -1).
  33531. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  33532. */
  33533. get collisionMask(): number;
  33534. set collisionMask(mask: number);
  33535. /**
  33536. * Gets or sets a collision response flag (default is true).
  33537. * when collisionResponse is false, events are still triggered but colliding entity has no response
  33538. * This helps creating trigger volume when user wants collision feedback events but not position/velocity
  33539. * to respond to the collision.
  33540. */
  33541. get collisionResponse(): boolean;
  33542. set collisionResponse(response: boolean);
  33543. /**
  33544. * Gets or sets the current collision group mask (-1 by default).
  33545. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  33546. */
  33547. get collisionGroup(): number;
  33548. set collisionGroup(mask: number);
  33549. /**
  33550. * Gets or sets current surrounding meshes (null by default).
  33551. *
  33552. * By default collision detection is tested against every mesh in the scene.
  33553. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  33554. * meshes will be tested for the collision.
  33555. *
  33556. * Note: if set to an empty array no collision will happen when this mesh is moved.
  33557. */
  33558. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  33559. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  33560. /**
  33561. * Defines edge width used when edgesRenderer is enabled
  33562. * @see https://www.babylonjs-playground.com/#10OJSG#13
  33563. */
  33564. edgesWidth: number;
  33565. /**
  33566. * Defines edge color used when edgesRenderer is enabled
  33567. * @see https://www.babylonjs-playground.com/#10OJSG#13
  33568. */
  33569. edgesColor: Color4;
  33570. /** @hidden */
  33571. _edgesRenderer: Nullable<IEdgesRenderer>;
  33572. /** @hidden */
  33573. _masterMesh: Nullable<AbstractMesh>;
  33574. /** @hidden */
  33575. _boundingInfo: Nullable<BoundingInfo>;
  33576. /** @hidden */
  33577. _renderId: number;
  33578. /**
  33579. * Gets or sets the list of subMeshes
  33580. * @see https://doc.babylonjs.com/how_to/multi_materials
  33581. */
  33582. subMeshes: SubMesh[];
  33583. /** @hidden */
  33584. _intersectionsInProgress: AbstractMesh[];
  33585. /** @hidden */
  33586. _unIndexed: boolean;
  33587. /** @hidden */
  33588. _lightSources: Light[];
  33589. /** Gets the list of lights affecting that mesh */
  33590. get lightSources(): Light[];
  33591. /** @hidden */
  33592. get _positions(): Nullable<Vector3[]>;
  33593. /** @hidden */
  33594. _waitingData: {
  33595. lods: Nullable<any>;
  33596. actions: Nullable<any>;
  33597. freezeWorldMatrix: Nullable<boolean>;
  33598. };
  33599. /** @hidden */
  33600. _bonesTransformMatrices: Nullable<Float32Array>;
  33601. /** @hidden */
  33602. _transformMatrixTexture: Nullable<RawTexture>;
  33603. /**
  33604. * Gets or sets a skeleton to apply skining transformations
  33605. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  33606. */
  33607. set skeleton(value: Nullable<Skeleton>);
  33608. get skeleton(): Nullable<Skeleton>;
  33609. /**
  33610. * An event triggered when the mesh is rebuilt.
  33611. */
  33612. onRebuildObservable: Observable<AbstractMesh>;
  33613. /**
  33614. * Creates a new AbstractMesh
  33615. * @param name defines the name of the mesh
  33616. * @param scene defines the hosting scene
  33617. */
  33618. constructor(name: string, scene?: Nullable<Scene>);
  33619. /**
  33620. * Returns the string "AbstractMesh"
  33621. * @returns "AbstractMesh"
  33622. */
  33623. getClassName(): string;
  33624. /**
  33625. * Gets a string representation of the current mesh
  33626. * @param fullDetails defines a boolean indicating if full details must be included
  33627. * @returns a string representation of the current mesh
  33628. */
  33629. toString(fullDetails?: boolean): string;
  33630. /**
  33631. * @hidden
  33632. */
  33633. protected _getEffectiveParent(): Nullable<Node>;
  33634. /** @hidden */
  33635. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  33636. /** @hidden */
  33637. _rebuild(): void;
  33638. /** @hidden */
  33639. _resyncLightSources(): void;
  33640. /** @hidden */
  33641. _resyncLightSource(light: Light): void;
  33642. /** @hidden */
  33643. _unBindEffect(): void;
  33644. /** @hidden */
  33645. _removeLightSource(light: Light, dispose: boolean): void;
  33646. private _markSubMeshesAsDirty;
  33647. /** @hidden */
  33648. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  33649. /** @hidden */
  33650. _markSubMeshesAsAttributesDirty(): void;
  33651. /** @hidden */
  33652. _markSubMeshesAsMiscDirty(): void;
  33653. /**
  33654. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  33655. */
  33656. get scaling(): Vector3;
  33657. set scaling(newScaling: Vector3);
  33658. /**
  33659. * Returns true if the mesh is blocked. Implemented by child classes
  33660. */
  33661. get isBlocked(): boolean;
  33662. /**
  33663. * Returns the mesh itself by default. Implemented by child classes
  33664. * @param camera defines the camera to use to pick the right LOD level
  33665. * @returns the currentAbstractMesh
  33666. */
  33667. getLOD(camera: Camera): Nullable<AbstractMesh>;
  33668. /**
  33669. * Returns 0 by default. Implemented by child classes
  33670. * @returns an integer
  33671. */
  33672. getTotalVertices(): number;
  33673. /**
  33674. * Returns a positive integer : the total number of indices in this mesh geometry.
  33675. * @returns the numner of indices or zero if the mesh has no geometry.
  33676. */
  33677. getTotalIndices(): number;
  33678. /**
  33679. * Returns null by default. Implemented by child classes
  33680. * @returns null
  33681. */
  33682. getIndices(): Nullable<IndicesArray>;
  33683. /**
  33684. * Returns the array of the requested vertex data kind. Implemented by child classes
  33685. * @param kind defines the vertex data kind to use
  33686. * @returns null
  33687. */
  33688. getVerticesData(kind: string): Nullable<FloatArray>;
  33689. /**
  33690. * Sets the vertex data of the mesh geometry for the requested `kind`.
  33691. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  33692. * Note that a new underlying VertexBuffer object is created each call.
  33693. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  33694. * @param kind defines vertex data kind:
  33695. * * VertexBuffer.PositionKind
  33696. * * VertexBuffer.UVKind
  33697. * * VertexBuffer.UV2Kind
  33698. * * VertexBuffer.UV3Kind
  33699. * * VertexBuffer.UV4Kind
  33700. * * VertexBuffer.UV5Kind
  33701. * * VertexBuffer.UV6Kind
  33702. * * VertexBuffer.ColorKind
  33703. * * VertexBuffer.MatricesIndicesKind
  33704. * * VertexBuffer.MatricesIndicesExtraKind
  33705. * * VertexBuffer.MatricesWeightsKind
  33706. * * VertexBuffer.MatricesWeightsExtraKind
  33707. * @param data defines the data source
  33708. * @param updatable defines if the data must be flagged as updatable (or static)
  33709. * @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
  33710. * @returns the current mesh
  33711. */
  33712. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  33713. /**
  33714. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  33715. * If the mesh has no geometry, it is simply returned as it is.
  33716. * @param kind defines vertex data kind:
  33717. * * VertexBuffer.PositionKind
  33718. * * VertexBuffer.UVKind
  33719. * * VertexBuffer.UV2Kind
  33720. * * VertexBuffer.UV3Kind
  33721. * * VertexBuffer.UV4Kind
  33722. * * VertexBuffer.UV5Kind
  33723. * * VertexBuffer.UV6Kind
  33724. * * VertexBuffer.ColorKind
  33725. * * VertexBuffer.MatricesIndicesKind
  33726. * * VertexBuffer.MatricesIndicesExtraKind
  33727. * * VertexBuffer.MatricesWeightsKind
  33728. * * VertexBuffer.MatricesWeightsExtraKind
  33729. * @param data defines the data source
  33730. * @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
  33731. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  33732. * @returns the current mesh
  33733. */
  33734. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  33735. /**
  33736. * Sets the mesh indices,
  33737. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  33738. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  33739. * @param totalVertices Defines the total number of vertices
  33740. * @returns the current mesh
  33741. */
  33742. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  33743. /**
  33744. * Gets a boolean indicating if specific vertex data is present
  33745. * @param kind defines the vertex data kind to use
  33746. * @returns true is data kind is present
  33747. */
  33748. isVerticesDataPresent(kind: string): boolean;
  33749. /**
  33750. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  33751. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  33752. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  33753. * @returns a BoundingInfo
  33754. */
  33755. getBoundingInfo(): BoundingInfo;
  33756. /**
  33757. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  33758. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  33759. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  33760. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  33761. * @returns the current mesh
  33762. */
  33763. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  33764. /**
  33765. * Overwrite the current bounding info
  33766. * @param boundingInfo defines the new bounding info
  33767. * @returns the current mesh
  33768. */
  33769. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  33770. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  33771. get useBones(): boolean;
  33772. /** @hidden */
  33773. _preActivate(): void;
  33774. /** @hidden */
  33775. _preActivateForIntermediateRendering(renderId: number): void;
  33776. /** @hidden */
  33777. _activate(renderId: number, intermediateRendering: boolean): boolean;
  33778. /** @hidden */
  33779. _postActivate(): void;
  33780. /** @hidden */
  33781. _freeze(): void;
  33782. /** @hidden */
  33783. _unFreeze(): void;
  33784. /**
  33785. * Gets the current world matrix
  33786. * @returns a Matrix
  33787. */
  33788. getWorldMatrix(): Matrix;
  33789. /** @hidden */
  33790. _getWorldMatrixDeterminant(): number;
  33791. /**
  33792. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  33793. */
  33794. get isAnInstance(): boolean;
  33795. /**
  33796. * Gets a boolean indicating if this mesh has instances
  33797. */
  33798. get hasInstances(): boolean;
  33799. /**
  33800. * Gets a boolean indicating if this mesh has thin instances
  33801. */
  33802. get hasThinInstances(): boolean;
  33803. /**
  33804. * Perform relative position change from the point of view of behind the front of the mesh.
  33805. * This is performed taking into account the meshes current rotation, so you do not have to care.
  33806. * Supports definition of mesh facing forward or backward
  33807. * @param amountRight defines the distance on the right axis
  33808. * @param amountUp defines the distance on the up axis
  33809. * @param amountForward defines the distance on the forward axis
  33810. * @returns the current mesh
  33811. */
  33812. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  33813. /**
  33814. * Calculate relative position change from the point of view of behind the front of the mesh.
  33815. * This is performed taking into account the meshes current rotation, so you do not have to care.
  33816. * Supports definition of mesh facing forward or backward
  33817. * @param amountRight defines the distance on the right axis
  33818. * @param amountUp defines the distance on the up axis
  33819. * @param amountForward defines the distance on the forward axis
  33820. * @returns the new displacement vector
  33821. */
  33822. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  33823. /**
  33824. * Perform relative rotation change from the point of view of behind the front of the mesh.
  33825. * Supports definition of mesh facing forward or backward
  33826. * @param flipBack defines the flip
  33827. * @param twirlClockwise defines the twirl
  33828. * @param tiltRight defines the tilt
  33829. * @returns the current mesh
  33830. */
  33831. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  33832. /**
  33833. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  33834. * Supports definition of mesh facing forward or backward.
  33835. * @param flipBack defines the flip
  33836. * @param twirlClockwise defines the twirl
  33837. * @param tiltRight defines the tilt
  33838. * @returns the new rotation vector
  33839. */
  33840. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  33841. /**
  33842. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  33843. * This means the mesh underlying bounding box and sphere are recomputed.
  33844. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  33845. * @returns the current mesh
  33846. */
  33847. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  33848. /** @hidden */
  33849. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  33850. /** @hidden */
  33851. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  33852. /** @hidden */
  33853. _updateBoundingInfo(): AbstractMesh;
  33854. /** @hidden */
  33855. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  33856. /** @hidden */
  33857. protected _afterComputeWorldMatrix(): void;
  33858. /** @hidden */
  33859. get _effectiveMesh(): AbstractMesh;
  33860. /**
  33861. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  33862. * A mesh is in the frustum if its bounding box intersects the frustum
  33863. * @param frustumPlanes defines the frustum to test
  33864. * @returns true if the mesh is in the frustum planes
  33865. */
  33866. isInFrustum(frustumPlanes: Plane[]): boolean;
  33867. /**
  33868. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  33869. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  33870. * @param frustumPlanes defines the frustum to test
  33871. * @returns true if the mesh is completely in the frustum planes
  33872. */
  33873. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  33874. /**
  33875. * True if the mesh intersects another mesh or a SolidParticle object
  33876. * @param mesh defines a target mesh or SolidParticle to test
  33877. * @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)
  33878. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  33879. * @returns true if there is an intersection
  33880. */
  33881. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  33882. /**
  33883. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  33884. * @param point defines the point to test
  33885. * @returns true if there is an intersection
  33886. */
  33887. intersectsPoint(point: Vector3): boolean;
  33888. /**
  33889. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  33890. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33891. */
  33892. get checkCollisions(): boolean;
  33893. set checkCollisions(collisionEnabled: boolean);
  33894. /**
  33895. * Gets Collider object used to compute collisions (not physics)
  33896. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33897. */
  33898. get collider(): Nullable<Collider>;
  33899. /**
  33900. * Move the mesh using collision engine
  33901. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33902. * @param displacement defines the requested displacement vector
  33903. * @returns the current mesh
  33904. */
  33905. moveWithCollisions(displacement: Vector3): AbstractMesh;
  33906. private _onCollisionPositionChange;
  33907. /** @hidden */
  33908. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  33909. /** @hidden */
  33910. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  33911. /** @hidden */
  33912. _checkCollision(collider: Collider): AbstractMesh;
  33913. /** @hidden */
  33914. _generatePointsArray(): boolean;
  33915. /**
  33916. * Checks if the passed Ray intersects with the mesh
  33917. * @param ray defines the ray to use
  33918. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  33919. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  33920. * @param onlyBoundingInfo defines a boolean indicating if picking should only happen using bounding info (false by default)
  33921. * @param worldToUse defines the world matrix to use to get the world coordinate of the intersection point
  33922. * @returns the picking info
  33923. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  33924. */
  33925. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate, onlyBoundingInfo?: boolean, worldToUse?: Matrix): PickingInfo;
  33926. /**
  33927. * Clones the current mesh
  33928. * @param name defines the mesh name
  33929. * @param newParent defines the new mesh parent
  33930. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  33931. * @returns the new mesh
  33932. */
  33933. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  33934. /**
  33935. * Disposes all the submeshes of the current meshnp
  33936. * @returns the current mesh
  33937. */
  33938. releaseSubMeshes(): AbstractMesh;
  33939. /**
  33940. * Releases resources associated with this abstract mesh.
  33941. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  33942. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  33943. */
  33944. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  33945. /**
  33946. * Adds the passed mesh as a child to the current mesh
  33947. * @param mesh defines the child mesh
  33948. * @returns the current mesh
  33949. */
  33950. addChild(mesh: AbstractMesh): AbstractMesh;
  33951. /**
  33952. * Removes the passed mesh from the current mesh children list
  33953. * @param mesh defines the child mesh
  33954. * @returns the current mesh
  33955. */
  33956. removeChild(mesh: AbstractMesh): AbstractMesh;
  33957. /** @hidden */
  33958. private _initFacetData;
  33959. /**
  33960. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  33961. * This method can be called within the render loop.
  33962. * 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
  33963. * @returns the current mesh
  33964. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  33965. */
  33966. updateFacetData(): AbstractMesh;
  33967. /**
  33968. * Returns the facetLocalNormals array.
  33969. * The normals are expressed in the mesh local spac
  33970. * @returns an array of Vector3
  33971. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  33972. */
  33973. getFacetLocalNormals(): Vector3[];
  33974. /**
  33975. * Returns the facetLocalPositions array.
  33976. * The facet positions are expressed in the mesh local space
  33977. * @returns an array of Vector3
  33978. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  33979. */
  33980. getFacetLocalPositions(): Vector3[];
  33981. /**
  33982. * Returns the facetLocalPartioning array
  33983. * @returns an array of array of numbers
  33984. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  33985. */
  33986. getFacetLocalPartitioning(): number[][];
  33987. /**
  33988. * Returns the i-th facet position in the world system.
  33989. * This method allocates a new Vector3 per call
  33990. * @param i defines the facet index
  33991. * @returns a new Vector3
  33992. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  33993. */
  33994. getFacetPosition(i: number): Vector3;
  33995. /**
  33996. * Sets the reference Vector3 with the i-th facet position in the world system
  33997. * @param i defines the facet index
  33998. * @param ref defines the target vector
  33999. * @returns the current mesh
  34000. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  34001. */
  34002. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  34003. /**
  34004. * Returns the i-th facet normal in the world system.
  34005. * This method allocates a new Vector3 per call
  34006. * @param i defines the facet index
  34007. * @returns a new Vector3
  34008. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  34009. */
  34010. getFacetNormal(i: number): Vector3;
  34011. /**
  34012. * Sets the reference Vector3 with the i-th facet normal in the world system
  34013. * @param i defines the facet index
  34014. * @param ref defines the target vector
  34015. * @returns the current mesh
  34016. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  34017. */
  34018. getFacetNormalToRef(i: number, ref: Vector3): this;
  34019. /**
  34020. * 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)
  34021. * @param x defines x coordinate
  34022. * @param y defines y coordinate
  34023. * @param z defines z coordinate
  34024. * @returns the array of facet indexes
  34025. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  34026. */
  34027. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  34028. /**
  34029. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  34030. * @param projected sets as the (x,y,z) world projection on the facet
  34031. * @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
  34032. * @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
  34033. * @param x defines x coordinate
  34034. * @param y defines y coordinate
  34035. * @param z defines z coordinate
  34036. * @returns the face index if found (or null instead)
  34037. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  34038. */
  34039. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  34040. /**
  34041. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  34042. * @param projected sets as the (x,y,z) local projection on the facet
  34043. * @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
  34044. * @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
  34045. * @param x defines x coordinate
  34046. * @param y defines y coordinate
  34047. * @param z defines z coordinate
  34048. * @returns the face index if found (or null instead)
  34049. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  34050. */
  34051. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  34052. /**
  34053. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  34054. * @returns the parameters
  34055. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  34056. */
  34057. getFacetDataParameters(): any;
  34058. /**
  34059. * Disables the feature FacetData and frees the related memory
  34060. * @returns the current mesh
  34061. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  34062. */
  34063. disableFacetData(): AbstractMesh;
  34064. /**
  34065. * Updates the AbstractMesh indices array
  34066. * @param indices defines the data source
  34067. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  34068. * @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)
  34069. * @returns the current mesh
  34070. */
  34071. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  34072. /**
  34073. * Creates new normals data for the mesh
  34074. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  34075. * @returns the current mesh
  34076. */
  34077. createNormals(updatable: boolean): AbstractMesh;
  34078. /**
  34079. * Align the mesh with a normal
  34080. * @param normal defines the normal to use
  34081. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  34082. * @returns the current mesh
  34083. */
  34084. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  34085. /** @hidden */
  34086. _checkOcclusionQuery(): boolean;
  34087. /**
  34088. * Disables the mesh edge rendering mode
  34089. * @returns the currentAbstractMesh
  34090. */
  34091. disableEdgesRendering(): AbstractMesh;
  34092. /**
  34093. * Enables the edge rendering mode on the mesh.
  34094. * This mode makes the mesh edges visible
  34095. * @param epsilon defines the maximal distance between two angles to detect a face
  34096. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  34097. * @returns the currentAbstractMesh
  34098. * @see https://www.babylonjs-playground.com/#19O9TU#0
  34099. */
  34100. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  34101. /**
  34102. * This function returns all of the particle systems in the scene that use the mesh as an emitter.
  34103. * @returns an array of particle systems in the scene that use the mesh as an emitter
  34104. */
  34105. getConnectedParticleSystems(): IParticleSystem[];
  34106. }
  34107. }
  34108. declare module "babylonjs/Actions/actionEvent" {
  34109. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  34110. import { Nullable } from "babylonjs/types";
  34111. import { Sprite } from "babylonjs/Sprites/sprite";
  34112. import { Scene } from "babylonjs/scene";
  34113. import { Vector2 } from "babylonjs/Maths/math.vector";
  34114. /**
  34115. * Interface used to define ActionEvent
  34116. */
  34117. export interface IActionEvent {
  34118. /** The mesh or sprite that triggered the action */
  34119. source: any;
  34120. /** The X mouse cursor position at the time of the event */
  34121. pointerX: number;
  34122. /** The Y mouse cursor position at the time of the event */
  34123. pointerY: number;
  34124. /** The mesh that is currently pointed at (can be null) */
  34125. meshUnderPointer: Nullable<AbstractMesh>;
  34126. /** the original (browser) event that triggered the ActionEvent */
  34127. sourceEvent?: any;
  34128. /** additional data for the event */
  34129. additionalData?: any;
  34130. }
  34131. /**
  34132. * ActionEvent is the event being sent when an action is triggered.
  34133. */
  34134. export class ActionEvent implements IActionEvent {
  34135. /** The mesh or sprite that triggered the action */
  34136. source: any;
  34137. /** The X mouse cursor position at the time of the event */
  34138. pointerX: number;
  34139. /** The Y mouse cursor position at the time of the event */
  34140. pointerY: number;
  34141. /** The mesh that is currently pointed at (can be null) */
  34142. meshUnderPointer: Nullable<AbstractMesh>;
  34143. /** the original (browser) event that triggered the ActionEvent */
  34144. sourceEvent?: any;
  34145. /** additional data for the event */
  34146. additionalData?: any;
  34147. /**
  34148. * Creates a new ActionEvent
  34149. * @param source The mesh or sprite that triggered the action
  34150. * @param pointerX The X mouse cursor position at the time of the event
  34151. * @param pointerY The Y mouse cursor position at the time of the event
  34152. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  34153. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  34154. * @param additionalData additional data for the event
  34155. */
  34156. constructor(
  34157. /** The mesh or sprite that triggered the action */
  34158. source: any,
  34159. /** The X mouse cursor position at the time of the event */
  34160. pointerX: number,
  34161. /** The Y mouse cursor position at the time of the event */
  34162. pointerY: number,
  34163. /** The mesh that is currently pointed at (can be null) */
  34164. meshUnderPointer: Nullable<AbstractMesh>,
  34165. /** the original (browser) event that triggered the ActionEvent */
  34166. sourceEvent?: any,
  34167. /** additional data for the event */
  34168. additionalData?: any);
  34169. /**
  34170. * Helper function to auto-create an ActionEvent from a source mesh.
  34171. * @param source The source mesh that triggered the event
  34172. * @param evt The original (browser) event
  34173. * @param additionalData additional data for the event
  34174. * @returns the new ActionEvent
  34175. */
  34176. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  34177. /**
  34178. * Helper function to auto-create an ActionEvent from a source sprite
  34179. * @param source The source sprite that triggered the event
  34180. * @param scene Scene associated with the sprite
  34181. * @param evt The original (browser) event
  34182. * @param additionalData additional data for the event
  34183. * @returns the new ActionEvent
  34184. */
  34185. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  34186. /**
  34187. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  34188. * @param scene the scene where the event occurred
  34189. * @param evt The original (browser) event
  34190. * @returns the new ActionEvent
  34191. */
  34192. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  34193. /**
  34194. * Helper function to auto-create an ActionEvent from a primitive
  34195. * @param prim defines the target primitive
  34196. * @param pointerPos defines the pointer position
  34197. * @param evt The original (browser) event
  34198. * @param additionalData additional data for the event
  34199. * @returns the new ActionEvent
  34200. */
  34201. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  34202. }
  34203. }
  34204. declare module "babylonjs/Actions/abstractActionManager" {
  34205. import { IDisposable } from "babylonjs/scene";
  34206. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  34207. import { IAction } from "babylonjs/Actions/action";
  34208. import { Nullable } from "babylonjs/types";
  34209. /**
  34210. * Abstract class used to decouple action Manager from scene and meshes.
  34211. * Do not instantiate.
  34212. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  34213. */
  34214. export abstract class AbstractActionManager implements IDisposable {
  34215. /** Gets the list of active triggers */
  34216. static Triggers: {
  34217. [key: string]: number;
  34218. };
  34219. /** Gets the cursor to use when hovering items */
  34220. hoverCursor: string;
  34221. /** Gets the list of actions */
  34222. actions: IAction[];
  34223. /**
  34224. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  34225. */
  34226. isRecursive: boolean;
  34227. /**
  34228. * Releases all associated resources
  34229. */
  34230. abstract dispose(): void;
  34231. /**
  34232. * Does this action manager has pointer triggers
  34233. */
  34234. abstract get hasPointerTriggers(): boolean;
  34235. /**
  34236. * Does this action manager has pick triggers
  34237. */
  34238. abstract get hasPickTriggers(): boolean;
  34239. /**
  34240. * Process a specific trigger
  34241. * @param trigger defines the trigger to process
  34242. * @param evt defines the event details to be processed
  34243. */
  34244. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  34245. /**
  34246. * Does this action manager handles actions of any of the given triggers
  34247. * @param triggers defines the triggers to be tested
  34248. * @return a boolean indicating whether one (or more) of the triggers is handled
  34249. */
  34250. abstract hasSpecificTriggers(triggers: number[]): boolean;
  34251. /**
  34252. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  34253. * speed.
  34254. * @param triggerA defines the trigger to be tested
  34255. * @param triggerB defines the trigger to be tested
  34256. * @return a boolean indicating whether one (or more) of the triggers is handled
  34257. */
  34258. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  34259. /**
  34260. * Does this action manager handles actions of a given trigger
  34261. * @param trigger defines the trigger to be tested
  34262. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  34263. * @return whether the trigger is handled
  34264. */
  34265. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  34266. /**
  34267. * Serialize this manager to a JSON object
  34268. * @param name defines the property name to store this manager
  34269. * @returns a JSON representation of this manager
  34270. */
  34271. abstract serialize(name: string): any;
  34272. /**
  34273. * Registers an action to this action manager
  34274. * @param action defines the action to be registered
  34275. * @return the action amended (prepared) after registration
  34276. */
  34277. abstract registerAction(action: IAction): Nullable<IAction>;
  34278. /**
  34279. * Unregisters an action to this action manager
  34280. * @param action defines the action to be unregistered
  34281. * @return a boolean indicating whether the action has been unregistered
  34282. */
  34283. abstract unregisterAction(action: IAction): Boolean;
  34284. /**
  34285. * Does exist one action manager with at least one trigger
  34286. **/
  34287. static get HasTriggers(): boolean;
  34288. /**
  34289. * Does exist one action manager with at least one pick trigger
  34290. **/
  34291. static get HasPickTriggers(): boolean;
  34292. /**
  34293. * Does exist one action manager that handles actions of a given trigger
  34294. * @param trigger defines the trigger to be tested
  34295. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  34296. **/
  34297. static HasSpecificTrigger(trigger: number): boolean;
  34298. }
  34299. }
  34300. declare module "babylonjs/node" {
  34301. import { Scene } from "babylonjs/scene";
  34302. import { Nullable } from "babylonjs/types";
  34303. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  34304. import { Engine } from "babylonjs/Engines/engine";
  34305. import { IBehaviorAware, Behavior } from "babylonjs/Behaviors/behavior";
  34306. import { Observable } from "babylonjs/Misc/observable";
  34307. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  34308. import { IInspectable } from "babylonjs/Misc/iInspectable";
  34309. import { Animatable } from "babylonjs/Animations/animatable";
  34310. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  34311. import { Animation } from "babylonjs/Animations/animation";
  34312. import { AnimationRange } from "babylonjs/Animations/animationRange";
  34313. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  34314. /**
  34315. * Defines how a node can be built from a string name.
  34316. */
  34317. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  34318. /**
  34319. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  34320. */
  34321. export class Node implements IBehaviorAware<Node> {
  34322. /** @hidden */
  34323. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  34324. private static _NodeConstructors;
  34325. /**
  34326. * Add a new node constructor
  34327. * @param type defines the type name of the node to construct
  34328. * @param constructorFunc defines the constructor function
  34329. */
  34330. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  34331. /**
  34332. * Returns a node constructor based on type name
  34333. * @param type defines the type name
  34334. * @param name defines the new node name
  34335. * @param scene defines the hosting scene
  34336. * @param options defines optional options to transmit to constructors
  34337. * @returns the new constructor or null
  34338. */
  34339. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  34340. /**
  34341. * Gets or sets the name of the node
  34342. */
  34343. name: string;
  34344. /**
  34345. * Gets or sets the id of the node
  34346. */
  34347. id: string;
  34348. /**
  34349. * Gets or sets the unique id of the node
  34350. */
  34351. uniqueId: number;
  34352. /**
  34353. * Gets or sets a string used to store user defined state for the node
  34354. */
  34355. state: string;
  34356. /**
  34357. * Gets or sets an object used to store user defined information for the node
  34358. */
  34359. metadata: any;
  34360. /**
  34361. * For internal use only. Please do not use.
  34362. */
  34363. reservedDataStore: any;
  34364. /**
  34365. * List of inspectable custom properties (used by the Inspector)
  34366. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  34367. */
  34368. inspectableCustomProperties: IInspectable[];
  34369. private _doNotSerialize;
  34370. /**
  34371. * Gets or sets a boolean used to define if the node must be serialized
  34372. */
  34373. get doNotSerialize(): boolean;
  34374. set doNotSerialize(value: boolean);
  34375. /** @hidden */
  34376. _isDisposed: boolean;
  34377. /**
  34378. * Gets a list of Animations associated with the node
  34379. */
  34380. animations: import("babylonjs/Animations/animation").Animation[];
  34381. protected _ranges: {
  34382. [name: string]: Nullable<AnimationRange>;
  34383. };
  34384. /**
  34385. * Callback raised when the node is ready to be used
  34386. */
  34387. onReady: Nullable<(node: Node) => void>;
  34388. private _isEnabled;
  34389. private _isParentEnabled;
  34390. private _isReady;
  34391. /** @hidden */
  34392. _currentRenderId: number;
  34393. private _parentUpdateId;
  34394. /** @hidden */
  34395. _childUpdateId: number;
  34396. /** @hidden */
  34397. _waitingParentId: Nullable<string>;
  34398. /** @hidden */
  34399. _scene: Scene;
  34400. /** @hidden */
  34401. _cache: any;
  34402. private _parentNode;
  34403. private _children;
  34404. /** @hidden */
  34405. _worldMatrix: Matrix;
  34406. /** @hidden */
  34407. _worldMatrixDeterminant: number;
  34408. /** @hidden */
  34409. _worldMatrixDeterminantIsDirty: boolean;
  34410. /** @hidden */
  34411. private _sceneRootNodesIndex;
  34412. /**
  34413. * Gets a boolean indicating if the node has been disposed
  34414. * @returns true if the node was disposed
  34415. */
  34416. isDisposed(): boolean;
  34417. /**
  34418. * Gets or sets the parent of the node (without keeping the current position in the scene)
  34419. * @see https://doc.babylonjs.com/how_to/parenting
  34420. */
  34421. set parent(parent: Nullable<Node>);
  34422. get parent(): Nullable<Node>;
  34423. /** @hidden */
  34424. _addToSceneRootNodes(): void;
  34425. /** @hidden */
  34426. _removeFromSceneRootNodes(): void;
  34427. private _animationPropertiesOverride;
  34428. /**
  34429. * Gets or sets the animation properties override
  34430. */
  34431. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  34432. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  34433. /**
  34434. * Gets a string identifying the name of the class
  34435. * @returns "Node" string
  34436. */
  34437. getClassName(): string;
  34438. /** @hidden */
  34439. readonly _isNode: boolean;
  34440. /**
  34441. * An event triggered when the mesh is disposed
  34442. */
  34443. onDisposeObservable: Observable<Node>;
  34444. private _onDisposeObserver;
  34445. /**
  34446. * Sets a callback that will be raised when the node will be disposed
  34447. */
  34448. set onDispose(callback: () => void);
  34449. /**
  34450. * Creates a new Node
  34451. * @param name the name and id to be given to this node
  34452. * @param scene the scene this node will be added to
  34453. */
  34454. constructor(name: string, scene?: Nullable<Scene>);
  34455. /**
  34456. * Gets the scene of the node
  34457. * @returns a scene
  34458. */
  34459. getScene(): Scene;
  34460. /**
  34461. * Gets the engine of the node
  34462. * @returns a Engine
  34463. */
  34464. getEngine(): Engine;
  34465. private _behaviors;
  34466. /**
  34467. * Attach a behavior to the node
  34468. * @see https://doc.babylonjs.com/features/behaviour
  34469. * @param behavior defines the behavior to attach
  34470. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  34471. * @returns the current Node
  34472. */
  34473. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  34474. /**
  34475. * Remove an attached behavior
  34476. * @see https://doc.babylonjs.com/features/behaviour
  34477. * @param behavior defines the behavior to attach
  34478. * @returns the current Node
  34479. */
  34480. removeBehavior(behavior: Behavior<Node>): Node;
  34481. /**
  34482. * Gets the list of attached behaviors
  34483. * @see https://doc.babylonjs.com/features/behaviour
  34484. */
  34485. get behaviors(): Behavior<Node>[];
  34486. /**
  34487. * Gets an attached behavior by name
  34488. * @param name defines the name of the behavior to look for
  34489. * @see https://doc.babylonjs.com/features/behaviour
  34490. * @returns null if behavior was not found else the requested behavior
  34491. */
  34492. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  34493. /**
  34494. * Returns the latest update of the World matrix
  34495. * @returns a Matrix
  34496. */
  34497. getWorldMatrix(): Matrix;
  34498. /** @hidden */
  34499. _getWorldMatrixDeterminant(): number;
  34500. /**
  34501. * Returns directly the latest state of the mesh World matrix.
  34502. * A Matrix is returned.
  34503. */
  34504. get worldMatrixFromCache(): Matrix;
  34505. /** @hidden */
  34506. _initCache(): void;
  34507. /** @hidden */
  34508. updateCache(force?: boolean): void;
  34509. /** @hidden */
  34510. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  34511. /** @hidden */
  34512. _updateCache(ignoreParentClass?: boolean): void;
  34513. /** @hidden */
  34514. _isSynchronized(): boolean;
  34515. /** @hidden */
  34516. _markSyncedWithParent(): void;
  34517. /** @hidden */
  34518. isSynchronizedWithParent(): boolean;
  34519. /** @hidden */
  34520. isSynchronized(): boolean;
  34521. /**
  34522. * Is this node ready to be used/rendered
  34523. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  34524. * @return true if the node is ready
  34525. */
  34526. isReady(completeCheck?: boolean): boolean;
  34527. /**
  34528. * Is this node enabled?
  34529. * 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
  34530. * @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
  34531. * @return whether this node (and its parent) is enabled
  34532. */
  34533. isEnabled(checkAncestors?: boolean): boolean;
  34534. /** @hidden */
  34535. protected _syncParentEnabledState(): void;
  34536. /**
  34537. * Set the enabled state of this node
  34538. * @param value defines the new enabled state
  34539. */
  34540. setEnabled(value: boolean): void;
  34541. /**
  34542. * Is this node a descendant of the given node?
  34543. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  34544. * @param ancestor defines the parent node to inspect
  34545. * @returns a boolean indicating if this node is a descendant of the given node
  34546. */
  34547. isDescendantOf(ancestor: Node): boolean;
  34548. /** @hidden */
  34549. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  34550. /**
  34551. * Will return all nodes that have this node as ascendant
  34552. * @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
  34553. * @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
  34554. * @return all children nodes of all types
  34555. */
  34556. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  34557. /**
  34558. * Get all child-meshes of this node
  34559. * @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)
  34560. * @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
  34561. * @returns an array of AbstractMesh
  34562. */
  34563. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  34564. /**
  34565. * Get all direct children of this node
  34566. * @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
  34567. * @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)
  34568. * @returns an array of Node
  34569. */
  34570. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  34571. /** @hidden */
  34572. _setReady(state: boolean): void;
  34573. /**
  34574. * Get an animation by name
  34575. * @param name defines the name of the animation to look for
  34576. * @returns null if not found else the requested animation
  34577. */
  34578. getAnimationByName(name: string): Nullable<Animation>;
  34579. /**
  34580. * Creates an animation range for this node
  34581. * @param name defines the name of the range
  34582. * @param from defines the starting key
  34583. * @param to defines the end key
  34584. */
  34585. createAnimationRange(name: string, from: number, to: number): void;
  34586. /**
  34587. * Delete a specific animation range
  34588. * @param name defines the name of the range to delete
  34589. * @param deleteFrames defines if animation frames from the range must be deleted as well
  34590. */
  34591. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  34592. /**
  34593. * Get an animation range by name
  34594. * @param name defines the name of the animation range to look for
  34595. * @returns null if not found else the requested animation range
  34596. */
  34597. getAnimationRange(name: string): Nullable<AnimationRange>;
  34598. /**
  34599. * Gets the list of all animation ranges defined on this node
  34600. * @returns an array
  34601. */
  34602. getAnimationRanges(): Nullable<AnimationRange>[];
  34603. /**
  34604. * Will start the animation sequence
  34605. * @param name defines the range frames for animation sequence
  34606. * @param loop defines if the animation should loop (false by default)
  34607. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  34608. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  34609. * @returns the object created for this animation. If range does not exist, it will return null
  34610. */
  34611. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  34612. /**
  34613. * Serialize animation ranges into a JSON compatible object
  34614. * @returns serialization object
  34615. */
  34616. serializeAnimationRanges(): any;
  34617. /**
  34618. * Computes the world matrix of the node
  34619. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  34620. * @returns the world matrix
  34621. */
  34622. computeWorldMatrix(force?: boolean): Matrix;
  34623. /**
  34624. * Releases resources associated with this node.
  34625. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  34626. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  34627. */
  34628. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  34629. /**
  34630. * Parse animation range data from a serialization object and store them into a given node
  34631. * @param node defines where to store the animation ranges
  34632. * @param parsedNode defines the serialization object to read data from
  34633. * @param scene defines the hosting scene
  34634. */
  34635. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  34636. /**
  34637. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  34638. * @param includeDescendants Include bounding info from descendants as well (true by default)
  34639. * @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
  34640. * @returns the new bounding vectors
  34641. */
  34642. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  34643. min: Vector3;
  34644. max: Vector3;
  34645. };
  34646. }
  34647. }
  34648. declare module "babylonjs/Animations/animation" {
  34649. import { IEasingFunction, EasingFunction } from "babylonjs/Animations/easing";
  34650. import { Vector3, Quaternion, Vector2, Matrix } from "babylonjs/Maths/math.vector";
  34651. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  34652. import { Nullable } from "babylonjs/types";
  34653. import { Scene } from "babylonjs/scene";
  34654. import { IAnimationKey } from "babylonjs/Animations/animationKey";
  34655. import { AnimationRange } from "babylonjs/Animations/animationRange";
  34656. import { AnimationEvent } from "babylonjs/Animations/animationEvent";
  34657. import { Node } from "babylonjs/node";
  34658. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  34659. import { Size } from "babylonjs/Maths/math.size";
  34660. import { Animatable } from "babylonjs/Animations/animatable";
  34661. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  34662. /**
  34663. * @hidden
  34664. */
  34665. export class _IAnimationState {
  34666. key: number;
  34667. repeatCount: number;
  34668. workValue?: any;
  34669. loopMode?: number;
  34670. offsetValue?: any;
  34671. highLimitValue?: any;
  34672. }
  34673. /**
  34674. * Class used to store any kind of animation
  34675. */
  34676. export class Animation {
  34677. /**Name of the animation */
  34678. name: string;
  34679. /**Property to animate */
  34680. targetProperty: string;
  34681. /**The frames per second of the animation */
  34682. framePerSecond: number;
  34683. /**The data type of the animation */
  34684. dataType: number;
  34685. /**The loop mode of the animation */
  34686. loopMode?: number | undefined;
  34687. /**Specifies if blending should be enabled */
  34688. enableBlending?: boolean | undefined;
  34689. /**
  34690. * Use matrix interpolation instead of using direct key value when animating matrices
  34691. */
  34692. static AllowMatricesInterpolation: boolean;
  34693. /**
  34694. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  34695. */
  34696. static AllowMatrixDecomposeForInterpolation: boolean;
  34697. /** Define the Url to load snippets */
  34698. static SnippetUrl: string;
  34699. /** Snippet ID if the animation was created from the snippet server */
  34700. snippetId: string;
  34701. /**
  34702. * Stores the key frames of the animation
  34703. */
  34704. private _keys;
  34705. /**
  34706. * Stores the easing function of the animation
  34707. */
  34708. private _easingFunction;
  34709. /**
  34710. * @hidden Internal use only
  34711. */
  34712. _runtimeAnimations: import("babylonjs/Animations/runtimeAnimation").RuntimeAnimation[];
  34713. /**
  34714. * The set of event that will be linked to this animation
  34715. */
  34716. private _events;
  34717. /**
  34718. * Stores an array of target property paths
  34719. */
  34720. targetPropertyPath: string[];
  34721. /**
  34722. * Stores the blending speed of the animation
  34723. */
  34724. blendingSpeed: number;
  34725. /**
  34726. * Stores the animation ranges for the animation
  34727. */
  34728. private _ranges;
  34729. /**
  34730. * @hidden Internal use
  34731. */
  34732. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  34733. /**
  34734. * Sets up an animation
  34735. * @param property The property to animate
  34736. * @param animationType The animation type to apply
  34737. * @param framePerSecond The frames per second of the animation
  34738. * @param easingFunction The easing function used in the animation
  34739. * @returns The created animation
  34740. */
  34741. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  34742. /**
  34743. * Create and start an animation on a node
  34744. * @param name defines the name of the global animation that will be run on all nodes
  34745. * @param node defines the root node where the animation will take place
  34746. * @param targetProperty defines property to animate
  34747. * @param framePerSecond defines the number of frame per second yo use
  34748. * @param totalFrame defines the number of frames in total
  34749. * @param from defines the initial value
  34750. * @param to defines the final value
  34751. * @param loopMode defines which loop mode you want to use (off by default)
  34752. * @param easingFunction defines the easing function to use (linear by default)
  34753. * @param onAnimationEnd defines the callback to call when animation end
  34754. * @returns the animatable created for this animation
  34755. */
  34756. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  34757. /**
  34758. * Create and start an animation on a node and its descendants
  34759. * @param name defines the name of the global animation that will be run on all nodes
  34760. * @param node defines the root node where the animation will take place
  34761. * @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
  34762. * @param targetProperty defines property to animate
  34763. * @param framePerSecond defines the number of frame per second to use
  34764. * @param totalFrame defines the number of frames in total
  34765. * @param from defines the initial value
  34766. * @param to defines the final value
  34767. * @param loopMode defines which loop mode you want to use (off by default)
  34768. * @param easingFunction defines the easing function to use (linear by default)
  34769. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  34770. * @returns the list of animatables created for all nodes
  34771. * @example https://www.babylonjs-playground.com/#MH0VLI
  34772. */
  34773. 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[]>;
  34774. /**
  34775. * Creates a new animation, merges it with the existing animations and starts it
  34776. * @param name Name of the animation
  34777. * @param node Node which contains the scene that begins the animations
  34778. * @param targetProperty Specifies which property to animate
  34779. * @param framePerSecond The frames per second of the animation
  34780. * @param totalFrame The total number of frames
  34781. * @param from The frame at the beginning of the animation
  34782. * @param to The frame at the end of the animation
  34783. * @param loopMode Specifies the loop mode of the animation
  34784. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  34785. * @param onAnimationEnd Callback to run once the animation is complete
  34786. * @returns Nullable animation
  34787. */
  34788. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  34789. /**
  34790. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  34791. * @param sourceAnimation defines the Animation containing keyframes to convert
  34792. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  34793. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  34794. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  34795. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  34796. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  34797. */
  34798. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  34799. /**
  34800. * Transition property of an host to the target Value
  34801. * @param property The property to transition
  34802. * @param targetValue The target Value of the property
  34803. * @param host The object where the property to animate belongs
  34804. * @param scene Scene used to run the animation
  34805. * @param frameRate Framerate (in frame/s) to use
  34806. * @param transition The transition type we want to use
  34807. * @param duration The duration of the animation, in milliseconds
  34808. * @param onAnimationEnd Callback trigger at the end of the animation
  34809. * @returns Nullable animation
  34810. */
  34811. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  34812. /**
  34813. * Return the array of runtime animations currently using this animation
  34814. */
  34815. get runtimeAnimations(): RuntimeAnimation[];
  34816. /**
  34817. * Specifies if any of the runtime animations are currently running
  34818. */
  34819. get hasRunningRuntimeAnimations(): boolean;
  34820. /**
  34821. * Initializes the animation
  34822. * @param name Name of the animation
  34823. * @param targetProperty Property to animate
  34824. * @param framePerSecond The frames per second of the animation
  34825. * @param dataType The data type of the animation
  34826. * @param loopMode The loop mode of the animation
  34827. * @param enableBlending Specifies if blending should be enabled
  34828. */
  34829. constructor(
  34830. /**Name of the animation */
  34831. name: string,
  34832. /**Property to animate */
  34833. targetProperty: string,
  34834. /**The frames per second of the animation */
  34835. framePerSecond: number,
  34836. /**The data type of the animation */
  34837. dataType: number,
  34838. /**The loop mode of the animation */
  34839. loopMode?: number | undefined,
  34840. /**Specifies if blending should be enabled */
  34841. enableBlending?: boolean | undefined);
  34842. /**
  34843. * Converts the animation to a string
  34844. * @param fullDetails support for multiple levels of logging within scene loading
  34845. * @returns String form of the animation
  34846. */
  34847. toString(fullDetails?: boolean): string;
  34848. /**
  34849. * Add an event to this animation
  34850. * @param event Event to add
  34851. */
  34852. addEvent(event: AnimationEvent): void;
  34853. /**
  34854. * Remove all events found at the given frame
  34855. * @param frame The frame to remove events from
  34856. */
  34857. removeEvents(frame: number): void;
  34858. /**
  34859. * Retrieves all the events from the animation
  34860. * @returns Events from the animation
  34861. */
  34862. getEvents(): AnimationEvent[];
  34863. /**
  34864. * Creates an animation range
  34865. * @param name Name of the animation range
  34866. * @param from Starting frame of the animation range
  34867. * @param to Ending frame of the animation
  34868. */
  34869. createRange(name: string, from: number, to: number): void;
  34870. /**
  34871. * Deletes an animation range by name
  34872. * @param name Name of the animation range to delete
  34873. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  34874. */
  34875. deleteRange(name: string, deleteFrames?: boolean): void;
  34876. /**
  34877. * Gets the animation range by name, or null if not defined
  34878. * @param name Name of the animation range
  34879. * @returns Nullable animation range
  34880. */
  34881. getRange(name: string): Nullable<AnimationRange>;
  34882. /**
  34883. * Gets the key frames from the animation
  34884. * @returns The key frames of the animation
  34885. */
  34886. getKeys(): Array<IAnimationKey>;
  34887. /**
  34888. * Gets the highest frame rate of the animation
  34889. * @returns Highest frame rate of the animation
  34890. */
  34891. getHighestFrame(): number;
  34892. /**
  34893. * Gets the easing function of the animation
  34894. * @returns Easing function of the animation
  34895. */
  34896. getEasingFunction(): IEasingFunction;
  34897. /**
  34898. * Sets the easing function of the animation
  34899. * @param easingFunction A custom mathematical formula for animation
  34900. */
  34901. setEasingFunction(easingFunction: EasingFunction): void;
  34902. /**
  34903. * Interpolates a scalar linearly
  34904. * @param startValue Start value of the animation curve
  34905. * @param endValue End value of the animation curve
  34906. * @param gradient Scalar amount to interpolate
  34907. * @returns Interpolated scalar value
  34908. */
  34909. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  34910. /**
  34911. * Interpolates a scalar cubically
  34912. * @param startValue Start value of the animation curve
  34913. * @param outTangent End tangent of the animation
  34914. * @param endValue End value of the animation curve
  34915. * @param inTangent Start tangent of the animation curve
  34916. * @param gradient Scalar amount to interpolate
  34917. * @returns Interpolated scalar value
  34918. */
  34919. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  34920. /**
  34921. * Interpolates a quaternion using a spherical linear interpolation
  34922. * @param startValue Start value of the animation curve
  34923. * @param endValue End value of the animation curve
  34924. * @param gradient Scalar amount to interpolate
  34925. * @returns Interpolated quaternion value
  34926. */
  34927. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  34928. /**
  34929. * Interpolates a quaternion cubically
  34930. * @param startValue Start value of the animation curve
  34931. * @param outTangent End tangent of the animation curve
  34932. * @param endValue End value of the animation curve
  34933. * @param inTangent Start tangent of the animation curve
  34934. * @param gradient Scalar amount to interpolate
  34935. * @returns Interpolated quaternion value
  34936. */
  34937. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  34938. /**
  34939. * Interpolates a Vector3 linearl
  34940. * @param startValue Start value of the animation curve
  34941. * @param endValue End value of the animation curve
  34942. * @param gradient Scalar amount to interpolate
  34943. * @returns Interpolated scalar value
  34944. */
  34945. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  34946. /**
  34947. * Interpolates a Vector3 cubically
  34948. * @param startValue Start value of the animation curve
  34949. * @param outTangent End tangent of the animation
  34950. * @param endValue End value of the animation curve
  34951. * @param inTangent Start tangent of the animation curve
  34952. * @param gradient Scalar amount to interpolate
  34953. * @returns InterpolatedVector3 value
  34954. */
  34955. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  34956. /**
  34957. * Interpolates a Vector2 linearly
  34958. * @param startValue Start value of the animation curve
  34959. * @param endValue End value of the animation curve
  34960. * @param gradient Scalar amount to interpolate
  34961. * @returns Interpolated Vector2 value
  34962. */
  34963. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  34964. /**
  34965. * Interpolates a Vector2 cubically
  34966. * @param startValue Start value of the animation curve
  34967. * @param outTangent End tangent of the animation
  34968. * @param endValue End value of the animation curve
  34969. * @param inTangent Start tangent of the animation curve
  34970. * @param gradient Scalar amount to interpolate
  34971. * @returns Interpolated Vector2 value
  34972. */
  34973. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  34974. /**
  34975. * Interpolates a size linearly
  34976. * @param startValue Start value of the animation curve
  34977. * @param endValue End value of the animation curve
  34978. * @param gradient Scalar amount to interpolate
  34979. * @returns Interpolated Size value
  34980. */
  34981. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  34982. /**
  34983. * Interpolates a Color3 linearly
  34984. * @param startValue Start value of the animation curve
  34985. * @param endValue End value of the animation curve
  34986. * @param gradient Scalar amount to interpolate
  34987. * @returns Interpolated Color3 value
  34988. */
  34989. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  34990. /**
  34991. * Interpolates a Color4 linearly
  34992. * @param startValue Start value of the animation curve
  34993. * @param endValue End value of the animation curve
  34994. * @param gradient Scalar amount to interpolate
  34995. * @returns Interpolated Color3 value
  34996. */
  34997. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  34998. /**
  34999. * @hidden Internal use only
  35000. */
  35001. _getKeyValue(value: any): any;
  35002. /**
  35003. * @hidden Internal use only
  35004. */
  35005. _interpolate(currentFrame: number, state: _IAnimationState): any;
  35006. /**
  35007. * Defines the function to use to interpolate matrices
  35008. * @param startValue defines the start matrix
  35009. * @param endValue defines the end matrix
  35010. * @param gradient defines the gradient between both matrices
  35011. * @param result defines an optional target matrix where to store the interpolation
  35012. * @returns the interpolated matrix
  35013. */
  35014. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  35015. /**
  35016. * Makes a copy of the animation
  35017. * @returns Cloned animation
  35018. */
  35019. clone(): Animation;
  35020. /**
  35021. * Sets the key frames of the animation
  35022. * @param values The animation key frames to set
  35023. */
  35024. setKeys(values: Array<IAnimationKey>): void;
  35025. /**
  35026. * Serializes the animation to an object
  35027. * @returns Serialized object
  35028. */
  35029. serialize(): any;
  35030. /**
  35031. * Float animation type
  35032. */
  35033. static readonly ANIMATIONTYPE_FLOAT: number;
  35034. /**
  35035. * Vector3 animation type
  35036. */
  35037. static readonly ANIMATIONTYPE_VECTOR3: number;
  35038. /**
  35039. * Quaternion animation type
  35040. */
  35041. static readonly ANIMATIONTYPE_QUATERNION: number;
  35042. /**
  35043. * Matrix animation type
  35044. */
  35045. static readonly ANIMATIONTYPE_MATRIX: number;
  35046. /**
  35047. * Color3 animation type
  35048. */
  35049. static readonly ANIMATIONTYPE_COLOR3: number;
  35050. /**
  35051. * Color3 animation type
  35052. */
  35053. static readonly ANIMATIONTYPE_COLOR4: number;
  35054. /**
  35055. * Vector2 animation type
  35056. */
  35057. static readonly ANIMATIONTYPE_VECTOR2: number;
  35058. /**
  35059. * Size animation type
  35060. */
  35061. static readonly ANIMATIONTYPE_SIZE: number;
  35062. /**
  35063. * Relative Loop Mode
  35064. */
  35065. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  35066. /**
  35067. * Cycle Loop Mode
  35068. */
  35069. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  35070. /**
  35071. * Constant Loop Mode
  35072. */
  35073. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  35074. /** @hidden */
  35075. static _UniversalLerp(left: any, right: any, amount: number): any;
  35076. /**
  35077. * Parses an animation object and creates an animation
  35078. * @param parsedAnimation Parsed animation object
  35079. * @returns Animation object
  35080. */
  35081. static Parse(parsedAnimation: any): Animation;
  35082. /**
  35083. * Appends the serialized animations from the source animations
  35084. * @param source Source containing the animations
  35085. * @param destination Target to store the animations
  35086. */
  35087. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  35088. /**
  35089. * Creates a new animation or an array of animations from a snippet saved in a remote file
  35090. * @param name defines the name of the animation to create (can be null or empty to use the one from the json data)
  35091. * @param url defines the url to load from
  35092. * @returns a promise that will resolve to the new animation or an array of animations
  35093. */
  35094. static ParseFromFileAsync(name: Nullable<string>, url: string): Promise<Animation | Array<Animation>>;
  35095. /**
  35096. * Creates an animation or an array of animations from a snippet saved by the Inspector
  35097. * @param snippetId defines the snippet to load
  35098. * @returns a promise that will resolve to the new animation or a new array of animations
  35099. */
  35100. static CreateFromSnippetAsync(snippetId: string): Promise<Animation | Array<Animation>>;
  35101. }
  35102. }
  35103. declare module "babylonjs/Animations/animatable.interface" {
  35104. import { Nullable } from "babylonjs/types";
  35105. import { Animation } from "babylonjs/Animations/animation";
  35106. /**
  35107. * Interface containing an array of animations
  35108. */
  35109. export interface IAnimatable {
  35110. /**
  35111. * Array of animations
  35112. */
  35113. animations: Nullable<Array<Animation>>;
  35114. }
  35115. }
  35116. declare module "babylonjs/Misc/decorators" {
  35117. import { Nullable } from "babylonjs/types";
  35118. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  35119. import { Scene } from "babylonjs/scene";
  35120. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  35121. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  35122. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  35123. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  35124. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  35125. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  35126. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  35127. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  35128. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  35129. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  35130. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  35131. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  35132. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  35133. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  35134. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  35135. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  35136. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  35137. /**
  35138. * Decorator used to define property that can be serialized as reference to a camera
  35139. * @param sourceName defines the name of the property to decorate
  35140. */
  35141. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  35142. /**
  35143. * Class used to help serialization objects
  35144. */
  35145. export class SerializationHelper {
  35146. /** @hidden */
  35147. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  35148. /** @hidden */
  35149. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  35150. /** @hidden */
  35151. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  35152. /** @hidden */
  35153. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  35154. /**
  35155. * Appends the serialized animations from the source animations
  35156. * @param source Source containing the animations
  35157. * @param destination Target to store the animations
  35158. */
  35159. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  35160. /**
  35161. * Static function used to serialized a specific entity
  35162. * @param entity defines the entity to serialize
  35163. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  35164. * @returns a JSON compatible object representing the serialization of the entity
  35165. */
  35166. static Serialize<T>(entity: T, serializationObject?: any): any;
  35167. /**
  35168. * Creates a new entity from a serialization data object
  35169. * @param creationFunction defines a function used to instanciated the new entity
  35170. * @param source defines the source serialization data
  35171. * @param scene defines the hosting scene
  35172. * @param rootUrl defines the root url for resources
  35173. * @returns a new entity
  35174. */
  35175. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  35176. /**
  35177. * Clones an object
  35178. * @param creationFunction defines the function used to instanciate the new object
  35179. * @param source defines the source object
  35180. * @returns the cloned object
  35181. */
  35182. static Clone<T>(creationFunction: () => T, source: T): T;
  35183. /**
  35184. * Instanciates a new object based on a source one (some data will be shared between both object)
  35185. * @param creationFunction defines the function used to instanciate the new object
  35186. * @param source defines the source object
  35187. * @returns the new object
  35188. */
  35189. static Instanciate<T>(creationFunction: () => T, source: T): T;
  35190. }
  35191. }
  35192. declare module "babylonjs/Materials/Textures/baseTexture" {
  35193. import { Observable } from "babylonjs/Misc/observable";
  35194. import { Nullable } from "babylonjs/types";
  35195. import { Scene } from "babylonjs/scene";
  35196. import { Matrix } from "babylonjs/Maths/math.vector";
  35197. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  35198. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  35199. import { ISize } from "babylonjs/Maths/math.size";
  35200. import "babylonjs/Misc/fileTools";
  35201. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  35202. /**
  35203. * Base class of all the textures in babylon.
  35204. * It groups all the common properties the materials, post process, lights... might need
  35205. * in order to make a correct use of the texture.
  35206. */
  35207. export class BaseTexture implements IAnimatable {
  35208. /**
  35209. * Default anisotropic filtering level for the application.
  35210. * It is set to 4 as a good tradeoff between perf and quality.
  35211. */
  35212. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  35213. /**
  35214. * Gets or sets the unique id of the texture
  35215. */
  35216. uniqueId: number;
  35217. /**
  35218. * Define the name of the texture.
  35219. */
  35220. name: string;
  35221. /**
  35222. * Gets or sets an object used to store user defined information.
  35223. */
  35224. metadata: any;
  35225. /**
  35226. * For internal use only. Please do not use.
  35227. */
  35228. reservedDataStore: any;
  35229. private _hasAlpha;
  35230. /**
  35231. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  35232. */
  35233. set hasAlpha(value: boolean);
  35234. get hasAlpha(): boolean;
  35235. /**
  35236. * Defines if the alpha value should be determined via the rgb values.
  35237. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  35238. */
  35239. getAlphaFromRGB: boolean;
  35240. /**
  35241. * Intensity or strength of the texture.
  35242. * It is commonly used by materials to fine tune the intensity of the texture
  35243. */
  35244. level: number;
  35245. /**
  35246. * Define the UV chanel to use starting from 0 and defaulting to 0.
  35247. * This is part of the texture as textures usually maps to one uv set.
  35248. */
  35249. coordinatesIndex: number;
  35250. protected _coordinatesMode: number;
  35251. /**
  35252. * How a texture is mapped.
  35253. *
  35254. * | Value | Type | Description |
  35255. * | ----- | ----------------------------------- | ----------- |
  35256. * | 0 | EXPLICIT_MODE | |
  35257. * | 1 | SPHERICAL_MODE | |
  35258. * | 2 | PLANAR_MODE | |
  35259. * | 3 | CUBIC_MODE | |
  35260. * | 4 | PROJECTION_MODE | |
  35261. * | 5 | SKYBOX_MODE | |
  35262. * | 6 | INVCUBIC_MODE | |
  35263. * | 7 | EQUIRECTANGULAR_MODE | |
  35264. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  35265. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  35266. */
  35267. set coordinatesMode(value: number);
  35268. get coordinatesMode(): number;
  35269. private _wrapU;
  35270. /**
  35271. * | Value | Type | Description |
  35272. * | ----- | ------------------ | ----------- |
  35273. * | 0 | CLAMP_ADDRESSMODE | |
  35274. * | 1 | WRAP_ADDRESSMODE | |
  35275. * | 2 | MIRROR_ADDRESSMODE | |
  35276. */
  35277. get wrapU(): number;
  35278. set wrapU(value: number);
  35279. private _wrapV;
  35280. /**
  35281. * | Value | Type | Description |
  35282. * | ----- | ------------------ | ----------- |
  35283. * | 0 | CLAMP_ADDRESSMODE | |
  35284. * | 1 | WRAP_ADDRESSMODE | |
  35285. * | 2 | MIRROR_ADDRESSMODE | |
  35286. */
  35287. get wrapV(): number;
  35288. set wrapV(value: number);
  35289. /**
  35290. * | Value | Type | Description |
  35291. * | ----- | ------------------ | ----------- |
  35292. * | 0 | CLAMP_ADDRESSMODE | |
  35293. * | 1 | WRAP_ADDRESSMODE | |
  35294. * | 2 | MIRROR_ADDRESSMODE | |
  35295. */
  35296. wrapR: number;
  35297. /**
  35298. * With compliant hardware and browser (supporting anisotropic filtering)
  35299. * this defines the level of anisotropic filtering in the texture.
  35300. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  35301. */
  35302. anisotropicFilteringLevel: number;
  35303. /**
  35304. * Define if the texture is a cube texture or if false a 2d texture.
  35305. */
  35306. get isCube(): boolean;
  35307. set isCube(value: boolean);
  35308. /**
  35309. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  35310. */
  35311. get is3D(): boolean;
  35312. set is3D(value: boolean);
  35313. /**
  35314. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  35315. */
  35316. get is2DArray(): boolean;
  35317. set is2DArray(value: boolean);
  35318. private _gammaSpace;
  35319. /**
  35320. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  35321. * HDR texture are usually stored in linear space.
  35322. * This only impacts the PBR and Background materials
  35323. */
  35324. get gammaSpace(): boolean;
  35325. set gammaSpace(gamma: boolean);
  35326. /**
  35327. * Gets or sets whether or not the texture contains RGBD data.
  35328. */
  35329. get isRGBD(): boolean;
  35330. set isRGBD(value: boolean);
  35331. /**
  35332. * Is Z inverted in the texture (useful in a cube texture).
  35333. */
  35334. invertZ: boolean;
  35335. /**
  35336. * Are mip maps generated for this texture or not.
  35337. */
  35338. get noMipmap(): boolean;
  35339. /**
  35340. * @hidden
  35341. */
  35342. lodLevelInAlpha: boolean;
  35343. /**
  35344. * With prefiltered texture, defined the offset used during the prefiltering steps.
  35345. */
  35346. get lodGenerationOffset(): number;
  35347. set lodGenerationOffset(value: number);
  35348. /**
  35349. * With prefiltered texture, defined the scale used during the prefiltering steps.
  35350. */
  35351. get lodGenerationScale(): number;
  35352. set lodGenerationScale(value: number);
  35353. /**
  35354. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  35355. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  35356. * average roughness values.
  35357. */
  35358. get linearSpecularLOD(): boolean;
  35359. set linearSpecularLOD(value: boolean);
  35360. /**
  35361. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  35362. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  35363. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  35364. */
  35365. get irradianceTexture(): Nullable<BaseTexture>;
  35366. set irradianceTexture(value: Nullable<BaseTexture>);
  35367. /**
  35368. * Define if the texture is a render target.
  35369. */
  35370. isRenderTarget: boolean;
  35371. /**
  35372. * Define the unique id of the texture in the scene.
  35373. */
  35374. get uid(): string;
  35375. /** @hidden */
  35376. _prefiltered: boolean;
  35377. /**
  35378. * Return a string representation of the texture.
  35379. * @returns the texture as a string
  35380. */
  35381. toString(): string;
  35382. /**
  35383. * Get the class name of the texture.
  35384. * @returns "BaseTexture"
  35385. */
  35386. getClassName(): string;
  35387. /**
  35388. * Define the list of animation attached to the texture.
  35389. */
  35390. animations: import("babylonjs/Animations/animation").Animation[];
  35391. /**
  35392. * An event triggered when the texture is disposed.
  35393. */
  35394. onDisposeObservable: Observable<BaseTexture>;
  35395. private _onDisposeObserver;
  35396. /**
  35397. * Callback triggered when the texture has been disposed.
  35398. * Kept for back compatibility, you can use the onDisposeObservable instead.
  35399. */
  35400. set onDispose(callback: () => void);
  35401. /**
  35402. * Define the current state of the loading sequence when in delayed load mode.
  35403. */
  35404. delayLoadState: number;
  35405. protected _scene: Nullable<Scene>;
  35406. protected _engine: Nullable<ThinEngine>;
  35407. /** @hidden */
  35408. _texture: Nullable<InternalTexture>;
  35409. private _uid;
  35410. /**
  35411. * Define if the texture is preventinga material to render or not.
  35412. * If not and the texture is not ready, the engine will use a default black texture instead.
  35413. */
  35414. get isBlocking(): boolean;
  35415. /**
  35416. * Instantiates a new BaseTexture.
  35417. * Base class of all the textures in babylon.
  35418. * It groups all the common properties the materials, post process, lights... might need
  35419. * in order to make a correct use of the texture.
  35420. * @param sceneOrEngine Define the scene or engine the texture blongs to
  35421. */
  35422. constructor(sceneOrEngine: Nullable<Scene | ThinEngine>);
  35423. /**
  35424. * Get the scene the texture belongs to.
  35425. * @returns the scene or null if undefined
  35426. */
  35427. getScene(): Nullable<Scene>;
  35428. /** @hidden */
  35429. protected _getEngine(): Nullable<ThinEngine>;
  35430. /**
  35431. * Get the texture transform matrix used to offset tile the texture for istance.
  35432. * @returns the transformation matrix
  35433. */
  35434. getTextureMatrix(): Matrix;
  35435. /**
  35436. * Get the texture reflection matrix used to rotate/transform the reflection.
  35437. * @returns the reflection matrix
  35438. */
  35439. getReflectionTextureMatrix(): Matrix;
  35440. /**
  35441. * Get the underlying lower level texture from Babylon.
  35442. * @returns the insternal texture
  35443. */
  35444. getInternalTexture(): Nullable<InternalTexture>;
  35445. /**
  35446. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  35447. * @returns true if ready or not blocking
  35448. */
  35449. isReadyOrNotBlocking(): boolean;
  35450. /**
  35451. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  35452. * @returns true if fully ready
  35453. */
  35454. isReady(): boolean;
  35455. private _cachedSize;
  35456. /**
  35457. * Get the size of the texture.
  35458. * @returns the texture size.
  35459. */
  35460. getSize(): ISize;
  35461. /**
  35462. * Get the base size of the texture.
  35463. * It can be different from the size if the texture has been resized for POT for instance
  35464. * @returns the base size
  35465. */
  35466. getBaseSize(): ISize;
  35467. /**
  35468. * Update the sampling mode of the texture.
  35469. * Default is Trilinear mode.
  35470. *
  35471. * | Value | Type | Description |
  35472. * | ----- | ------------------ | ----------- |
  35473. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  35474. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  35475. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  35476. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  35477. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  35478. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  35479. * | 7 | NEAREST_LINEAR | |
  35480. * | 8 | NEAREST_NEAREST | |
  35481. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  35482. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  35483. * | 11 | LINEAR_LINEAR | |
  35484. * | 12 | LINEAR_NEAREST | |
  35485. *
  35486. * > _mag_: magnification filter (close to the viewer)
  35487. * > _min_: minification filter (far from the viewer)
  35488. * > _mip_: filter used between mip map levels
  35489. *@param samplingMode Define the new sampling mode of the texture
  35490. */
  35491. updateSamplingMode(samplingMode: number): void;
  35492. /**
  35493. * Scales the texture if is `canRescale()`
  35494. * @param ratio the resize factor we want to use to rescale
  35495. */
  35496. scale(ratio: number): void;
  35497. /**
  35498. * Get if the texture can rescale.
  35499. */
  35500. get canRescale(): boolean;
  35501. /** @hidden */
  35502. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  35503. /** @hidden */
  35504. _rebuild(): void;
  35505. /**
  35506. * Triggers the load sequence in delayed load mode.
  35507. */
  35508. delayLoad(): void;
  35509. /**
  35510. * Clones the texture.
  35511. * @returns the cloned texture
  35512. */
  35513. clone(): Nullable<BaseTexture>;
  35514. /**
  35515. * Get the texture underlying type (INT, FLOAT...)
  35516. */
  35517. get textureType(): number;
  35518. /**
  35519. * Get the texture underlying format (RGB, RGBA...)
  35520. */
  35521. get textureFormat(): number;
  35522. /**
  35523. * Indicates that textures need to be re-calculated for all materials
  35524. */
  35525. protected _markAllSubMeshesAsTexturesDirty(): void;
  35526. /**
  35527. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  35528. * This will returns an RGBA array buffer containing either in values (0-255) or
  35529. * float values (0-1) depending of the underlying buffer type.
  35530. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  35531. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  35532. * @param buffer defines a user defined buffer to fill with data (can be null)
  35533. * @returns The Array buffer containing the pixels data.
  35534. */
  35535. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  35536. /**
  35537. * Release and destroy the underlying lower level texture aka internalTexture.
  35538. */
  35539. releaseInternalTexture(): void;
  35540. /** @hidden */
  35541. get _lodTextureHigh(): Nullable<BaseTexture>;
  35542. /** @hidden */
  35543. get _lodTextureMid(): Nullable<BaseTexture>;
  35544. /** @hidden */
  35545. get _lodTextureLow(): Nullable<BaseTexture>;
  35546. /**
  35547. * Dispose the texture and release its associated resources.
  35548. */
  35549. dispose(): void;
  35550. /**
  35551. * Serialize the texture into a JSON representation that can be parsed later on.
  35552. * @returns the JSON representation of the texture
  35553. */
  35554. serialize(): any;
  35555. /**
  35556. * Helper function to be called back once a list of texture contains only ready textures.
  35557. * @param textures Define the list of textures to wait for
  35558. * @param callback Define the callback triggered once the entire list will be ready
  35559. */
  35560. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  35561. private static _isScene;
  35562. }
  35563. }
  35564. declare module "babylonjs/Materials/effect" {
  35565. import { Observable } from "babylonjs/Misc/observable";
  35566. import { Nullable } from "babylonjs/types";
  35567. import { IDisposable } from "babylonjs/scene";
  35568. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  35569. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  35570. import { IMatrixLike, IVector2Like, IVector3Like, IVector4Like, IColor3Like, IColor4Like } from "babylonjs/Maths/math.like";
  35571. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  35572. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  35573. import { Engine } from "babylonjs/Engines/engine";
  35574. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  35575. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  35576. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  35577. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  35578. /**
  35579. * Options to be used when creating an effect.
  35580. */
  35581. export interface IEffectCreationOptions {
  35582. /**
  35583. * Atrributes that will be used in the shader.
  35584. */
  35585. attributes: string[];
  35586. /**
  35587. * Uniform varible names that will be set in the shader.
  35588. */
  35589. uniformsNames: string[];
  35590. /**
  35591. * Uniform buffer variable names that will be set in the shader.
  35592. */
  35593. uniformBuffersNames: string[];
  35594. /**
  35595. * Sampler texture variable names that will be set in the shader.
  35596. */
  35597. samplers: string[];
  35598. /**
  35599. * Define statements that will be set in the shader.
  35600. */
  35601. defines: any;
  35602. /**
  35603. * Possible fallbacks for this effect to improve performance when needed.
  35604. */
  35605. fallbacks: Nullable<IEffectFallbacks>;
  35606. /**
  35607. * Callback that will be called when the shader is compiled.
  35608. */
  35609. onCompiled: Nullable<(effect: Effect) => void>;
  35610. /**
  35611. * Callback that will be called if an error occurs during shader compilation.
  35612. */
  35613. onError: Nullable<(effect: Effect, errors: string) => void>;
  35614. /**
  35615. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  35616. */
  35617. indexParameters?: any;
  35618. /**
  35619. * Max number of lights that can be used in the shader.
  35620. */
  35621. maxSimultaneousLights?: number;
  35622. /**
  35623. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  35624. */
  35625. transformFeedbackVaryings?: Nullable<string[]>;
  35626. /**
  35627. * 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
  35628. */
  35629. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  35630. /**
  35631. * Is this effect rendering to several color attachments ?
  35632. */
  35633. multiTarget?: boolean;
  35634. }
  35635. /**
  35636. * Effect containing vertex and fragment shader that can be executed on an object.
  35637. */
  35638. export class Effect implements IDisposable {
  35639. /**
  35640. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  35641. */
  35642. static ShadersRepository: string;
  35643. /**
  35644. * Enable logging of the shader code when a compilation error occurs
  35645. */
  35646. static LogShaderCodeOnCompilationError: boolean;
  35647. /**
  35648. * Name of the effect.
  35649. */
  35650. name: any;
  35651. /**
  35652. * String container all the define statements that should be set on the shader.
  35653. */
  35654. defines: string;
  35655. /**
  35656. * Callback that will be called when the shader is compiled.
  35657. */
  35658. onCompiled: Nullable<(effect: Effect) => void>;
  35659. /**
  35660. * Callback that will be called if an error occurs during shader compilation.
  35661. */
  35662. onError: Nullable<(effect: Effect, errors: string) => void>;
  35663. /**
  35664. * Callback that will be called when effect is bound.
  35665. */
  35666. onBind: Nullable<(effect: Effect) => void>;
  35667. /**
  35668. * Unique ID of the effect.
  35669. */
  35670. uniqueId: number;
  35671. /**
  35672. * Observable that will be called when the shader is compiled.
  35673. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  35674. */
  35675. onCompileObservable: Observable<Effect>;
  35676. /**
  35677. * Observable that will be called if an error occurs during shader compilation.
  35678. */
  35679. onErrorObservable: Observable<Effect>;
  35680. /** @hidden */
  35681. _onBindObservable: Nullable<Observable<Effect>>;
  35682. /**
  35683. * @hidden
  35684. * Specifies if the effect was previously ready
  35685. */
  35686. _wasPreviouslyReady: boolean;
  35687. /**
  35688. * Observable that will be called when effect is bound.
  35689. */
  35690. get onBindObservable(): Observable<Effect>;
  35691. /** @hidden */
  35692. _bonesComputationForcedToCPU: boolean;
  35693. /** @hidden */
  35694. _multiTarget: boolean;
  35695. private static _uniqueIdSeed;
  35696. private _engine;
  35697. private _uniformBuffersNames;
  35698. private _uniformBuffersNamesList;
  35699. private _uniformsNames;
  35700. private _samplerList;
  35701. private _samplers;
  35702. private _isReady;
  35703. private _compilationError;
  35704. private _allFallbacksProcessed;
  35705. private _attributesNames;
  35706. private _attributes;
  35707. private _attributeLocationByName;
  35708. private _uniforms;
  35709. /**
  35710. * Key for the effect.
  35711. * @hidden
  35712. */
  35713. _key: string;
  35714. private _indexParameters;
  35715. private _fallbacks;
  35716. private _vertexSourceCode;
  35717. private _fragmentSourceCode;
  35718. private _vertexSourceCodeOverride;
  35719. private _fragmentSourceCodeOverride;
  35720. private _transformFeedbackVaryings;
  35721. /**
  35722. * Compiled shader to webGL program.
  35723. * @hidden
  35724. */
  35725. _pipelineContext: Nullable<IPipelineContext>;
  35726. private _valueCache;
  35727. private static _baseCache;
  35728. /**
  35729. * Instantiates an effect.
  35730. * An effect can be used to create/manage/execute vertex and fragment shaders.
  35731. * @param baseName Name of the effect.
  35732. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  35733. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  35734. * @param samplers List of sampler variables that will be passed to the shader.
  35735. * @param engine Engine to be used to render the effect
  35736. * @param defines Define statements to be added to the shader.
  35737. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  35738. * @param onCompiled Callback that will be called when the shader is compiled.
  35739. * @param onError Callback that will be called if an error occurs during shader compilation.
  35740. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  35741. */
  35742. 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);
  35743. private _useFinalCode;
  35744. /**
  35745. * Unique key for this effect
  35746. */
  35747. get key(): string;
  35748. /**
  35749. * If the effect has been compiled and prepared.
  35750. * @returns if the effect is compiled and prepared.
  35751. */
  35752. isReady(): boolean;
  35753. private _isReadyInternal;
  35754. /**
  35755. * The engine the effect was initialized with.
  35756. * @returns the engine.
  35757. */
  35758. getEngine(): Engine;
  35759. /**
  35760. * The pipeline context for this effect
  35761. * @returns the associated pipeline context
  35762. */
  35763. getPipelineContext(): Nullable<IPipelineContext>;
  35764. /**
  35765. * The set of names of attribute variables for the shader.
  35766. * @returns An array of attribute names.
  35767. */
  35768. getAttributesNames(): string[];
  35769. /**
  35770. * Returns the attribute at the given index.
  35771. * @param index The index of the attribute.
  35772. * @returns The location of the attribute.
  35773. */
  35774. getAttributeLocation(index: number): number;
  35775. /**
  35776. * Returns the attribute based on the name of the variable.
  35777. * @param name of the attribute to look up.
  35778. * @returns the attribute location.
  35779. */
  35780. getAttributeLocationByName(name: string): number;
  35781. /**
  35782. * The number of attributes.
  35783. * @returns the numnber of attributes.
  35784. */
  35785. getAttributesCount(): number;
  35786. /**
  35787. * Gets the index of a uniform variable.
  35788. * @param uniformName of the uniform to look up.
  35789. * @returns the index.
  35790. */
  35791. getUniformIndex(uniformName: string): number;
  35792. /**
  35793. * Returns the attribute based on the name of the variable.
  35794. * @param uniformName of the uniform to look up.
  35795. * @returns the location of the uniform.
  35796. */
  35797. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  35798. /**
  35799. * Returns an array of sampler variable names
  35800. * @returns The array of sampler variable names.
  35801. */
  35802. getSamplers(): string[];
  35803. /**
  35804. * Returns an array of uniform variable names
  35805. * @returns The array of uniform variable names.
  35806. */
  35807. getUniformNames(): string[];
  35808. /**
  35809. * Returns an array of uniform buffer variable names
  35810. * @returns The array of uniform buffer variable names.
  35811. */
  35812. getUniformBuffersNames(): string[];
  35813. /**
  35814. * Returns the index parameters used to create the effect
  35815. * @returns The index parameters object
  35816. */
  35817. getIndexParameters(): any;
  35818. /**
  35819. * The error from the last compilation.
  35820. * @returns the error string.
  35821. */
  35822. getCompilationError(): string;
  35823. /**
  35824. * Gets a boolean indicating that all fallbacks were used during compilation
  35825. * @returns true if all fallbacks were used
  35826. */
  35827. allFallbacksProcessed(): boolean;
  35828. /**
  35829. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  35830. * @param func The callback to be used.
  35831. */
  35832. executeWhenCompiled(func: (effect: Effect) => void): void;
  35833. private _checkIsReady;
  35834. private _loadShader;
  35835. /**
  35836. * Gets the vertex shader source code of this effect
  35837. */
  35838. get vertexSourceCode(): string;
  35839. /**
  35840. * Gets the fragment shader source code of this effect
  35841. */
  35842. get fragmentSourceCode(): string;
  35843. /**
  35844. * Recompiles the webGL program
  35845. * @param vertexSourceCode The source code for the vertex shader.
  35846. * @param fragmentSourceCode The source code for the fragment shader.
  35847. * @param onCompiled Callback called when completed.
  35848. * @param onError Callback called on error.
  35849. * @hidden
  35850. */
  35851. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  35852. /**
  35853. * Prepares the effect
  35854. * @hidden
  35855. */
  35856. _prepareEffect(): void;
  35857. private _getShaderCodeAndErrorLine;
  35858. private _processCompilationErrors;
  35859. /**
  35860. * Checks if the effect is supported. (Must be called after compilation)
  35861. */
  35862. get isSupported(): boolean;
  35863. /**
  35864. * Binds a texture to the engine to be used as output of the shader.
  35865. * @param channel Name of the output variable.
  35866. * @param texture Texture to bind.
  35867. * @hidden
  35868. */
  35869. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  35870. /**
  35871. * Sets a texture on the engine to be used in the shader.
  35872. * @param channel Name of the sampler variable.
  35873. * @param texture Texture to set.
  35874. */
  35875. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  35876. /**
  35877. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  35878. * @param channel Name of the sampler variable.
  35879. * @param texture Texture to set.
  35880. */
  35881. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  35882. /**
  35883. * Sets an array of textures on the engine to be used in the shader.
  35884. * @param channel Name of the variable.
  35885. * @param textures Textures to set.
  35886. */
  35887. setTextureArray(channel: string, textures: BaseTexture[]): void;
  35888. /**
  35889. * 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)
  35890. * @param channel Name of the sampler variable.
  35891. * @param postProcess Post process to get the input texture from.
  35892. */
  35893. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  35894. /**
  35895. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  35896. * 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)
  35897. * @param channel Name of the sampler variable.
  35898. * @param postProcess Post process to get the output texture from.
  35899. */
  35900. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  35901. /** @hidden */
  35902. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  35903. /** @hidden */
  35904. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  35905. /** @hidden */
  35906. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  35907. /** @hidden */
  35908. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  35909. /**
  35910. * Binds a buffer to a uniform.
  35911. * @param buffer Buffer to bind.
  35912. * @param name Name of the uniform variable to bind to.
  35913. */
  35914. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  35915. /**
  35916. * Binds block to a uniform.
  35917. * @param blockName Name of the block to bind.
  35918. * @param index Index to bind.
  35919. */
  35920. bindUniformBlock(blockName: string, index: number): void;
  35921. /**
  35922. * Sets an interger value on a uniform variable.
  35923. * @param uniformName Name of the variable.
  35924. * @param value Value to be set.
  35925. * @returns this effect.
  35926. */
  35927. setInt(uniformName: string, value: number): Effect;
  35928. /**
  35929. * Sets an int array on a uniform variable.
  35930. * @param uniformName Name of the variable.
  35931. * @param array array to be set.
  35932. * @returns this effect.
  35933. */
  35934. setIntArray(uniformName: string, array: Int32Array): Effect;
  35935. /**
  35936. * 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)
  35937. * @param uniformName Name of the variable.
  35938. * @param array array to be set.
  35939. * @returns this effect.
  35940. */
  35941. setIntArray2(uniformName: string, array: Int32Array): Effect;
  35942. /**
  35943. * 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)
  35944. * @param uniformName Name of the variable.
  35945. * @param array array to be set.
  35946. * @returns this effect.
  35947. */
  35948. setIntArray3(uniformName: string, array: Int32Array): Effect;
  35949. /**
  35950. * 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)
  35951. * @param uniformName Name of the variable.
  35952. * @param array array to be set.
  35953. * @returns this effect.
  35954. */
  35955. setIntArray4(uniformName: string, array: Int32Array): Effect;
  35956. /**
  35957. * Sets an float array on a uniform variable.
  35958. * @param uniformName Name of the variable.
  35959. * @param array array to be set.
  35960. * @returns this effect.
  35961. */
  35962. setFloatArray(uniformName: string, array: Float32Array): Effect;
  35963. /**
  35964. * 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)
  35965. * @param uniformName Name of the variable.
  35966. * @param array array to be set.
  35967. * @returns this effect.
  35968. */
  35969. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  35970. /**
  35971. * 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)
  35972. * @param uniformName Name of the variable.
  35973. * @param array array to be set.
  35974. * @returns this effect.
  35975. */
  35976. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  35977. /**
  35978. * 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)
  35979. * @param uniformName Name of the variable.
  35980. * @param array array to be set.
  35981. * @returns this effect.
  35982. */
  35983. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  35984. /**
  35985. * Sets an array on a uniform variable.
  35986. * @param uniformName Name of the variable.
  35987. * @param array array to be set.
  35988. * @returns this effect.
  35989. */
  35990. setArray(uniformName: string, array: number[]): Effect;
  35991. /**
  35992. * 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)
  35993. * @param uniformName Name of the variable.
  35994. * @param array array to be set.
  35995. * @returns this effect.
  35996. */
  35997. setArray2(uniformName: string, array: number[]): Effect;
  35998. /**
  35999. * 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)
  36000. * @param uniformName Name of the variable.
  36001. * @param array array to be set.
  36002. * @returns this effect.
  36003. */
  36004. setArray3(uniformName: string, array: number[]): Effect;
  36005. /**
  36006. * 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)
  36007. * @param uniformName Name of the variable.
  36008. * @param array array to be set.
  36009. * @returns this effect.
  36010. */
  36011. setArray4(uniformName: string, array: number[]): Effect;
  36012. /**
  36013. * Sets matrices on a uniform variable.
  36014. * @param uniformName Name of the variable.
  36015. * @param matrices matrices to be set.
  36016. * @returns this effect.
  36017. */
  36018. setMatrices(uniformName: string, matrices: Float32Array | Array<number>): Effect;
  36019. /**
  36020. * Sets matrix on a uniform variable.
  36021. * @param uniformName Name of the variable.
  36022. * @param matrix matrix to be set.
  36023. * @returns this effect.
  36024. */
  36025. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  36026. /**
  36027. * 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)
  36028. * @param uniformName Name of the variable.
  36029. * @param matrix matrix to be set.
  36030. * @returns this effect.
  36031. */
  36032. setMatrix3x3(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  36033. /**
  36034. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  36035. * @param uniformName Name of the variable.
  36036. * @param matrix matrix to be set.
  36037. * @returns this effect.
  36038. */
  36039. setMatrix2x2(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  36040. /**
  36041. * Sets a float on a uniform variable.
  36042. * @param uniformName Name of the variable.
  36043. * @param value value to be set.
  36044. * @returns this effect.
  36045. */
  36046. setFloat(uniformName: string, value: number): Effect;
  36047. /**
  36048. * Sets a boolean on a uniform variable.
  36049. * @param uniformName Name of the variable.
  36050. * @param bool value to be set.
  36051. * @returns this effect.
  36052. */
  36053. setBool(uniformName: string, bool: boolean): Effect;
  36054. /**
  36055. * Sets a Vector2 on a uniform variable.
  36056. * @param uniformName Name of the variable.
  36057. * @param vector2 vector2 to be set.
  36058. * @returns this effect.
  36059. */
  36060. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  36061. /**
  36062. * Sets a float2 on a uniform variable.
  36063. * @param uniformName Name of the variable.
  36064. * @param x First float in float2.
  36065. * @param y Second float in float2.
  36066. * @returns this effect.
  36067. */
  36068. setFloat2(uniformName: string, x: number, y: number): Effect;
  36069. /**
  36070. * Sets a Vector3 on a uniform variable.
  36071. * @param uniformName Name of the variable.
  36072. * @param vector3 Value to be set.
  36073. * @returns this effect.
  36074. */
  36075. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  36076. /**
  36077. * Sets a float3 on a uniform variable.
  36078. * @param uniformName Name of the variable.
  36079. * @param x First float in float3.
  36080. * @param y Second float in float3.
  36081. * @param z Third float in float3.
  36082. * @returns this effect.
  36083. */
  36084. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  36085. /**
  36086. * Sets a Vector4 on a uniform variable.
  36087. * @param uniformName Name of the variable.
  36088. * @param vector4 Value to be set.
  36089. * @returns this effect.
  36090. */
  36091. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  36092. /**
  36093. * Sets a float4 on a uniform variable.
  36094. * @param uniformName Name of the variable.
  36095. * @param x First float in float4.
  36096. * @param y Second float in float4.
  36097. * @param z Third float in float4.
  36098. * @param w Fourth float in float4.
  36099. * @returns this effect.
  36100. */
  36101. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  36102. /**
  36103. * Sets a Color3 on a uniform variable.
  36104. * @param uniformName Name of the variable.
  36105. * @param color3 Value to be set.
  36106. * @returns this effect.
  36107. */
  36108. setColor3(uniformName: string, color3: IColor3Like): Effect;
  36109. /**
  36110. * Sets a Color4 on a uniform variable.
  36111. * @param uniformName Name of the variable.
  36112. * @param color3 Value to be set.
  36113. * @param alpha Alpha value to be set.
  36114. * @returns this effect.
  36115. */
  36116. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  36117. /**
  36118. * Sets a Color4 on a uniform variable
  36119. * @param uniformName defines the name of the variable
  36120. * @param color4 defines the value to be set
  36121. * @returns this effect.
  36122. */
  36123. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  36124. /** Release all associated resources */
  36125. dispose(): void;
  36126. /**
  36127. * This function will add a new shader to the shader store
  36128. * @param name the name of the shader
  36129. * @param pixelShader optional pixel shader content
  36130. * @param vertexShader optional vertex shader content
  36131. */
  36132. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  36133. /**
  36134. * Store of each shader (The can be looked up using effect.key)
  36135. */
  36136. static ShadersStore: {
  36137. [key: string]: string;
  36138. };
  36139. /**
  36140. * Store of each included file for a shader (The can be looked up using effect.key)
  36141. */
  36142. static IncludesShadersStore: {
  36143. [key: string]: string;
  36144. };
  36145. /**
  36146. * Resets the cache of effects.
  36147. */
  36148. static ResetCache(): void;
  36149. }
  36150. }
  36151. declare module "babylonjs/Engines/engineCapabilities" {
  36152. /**
  36153. * Interface used to describe the capabilities of the engine relatively to the current browser
  36154. */
  36155. export interface EngineCapabilities {
  36156. /** Maximum textures units per fragment shader */
  36157. maxTexturesImageUnits: number;
  36158. /** Maximum texture units per vertex shader */
  36159. maxVertexTextureImageUnits: number;
  36160. /** Maximum textures units in the entire pipeline */
  36161. maxCombinedTexturesImageUnits: number;
  36162. /** Maximum texture size */
  36163. maxTextureSize: number;
  36164. /** Maximum texture samples */
  36165. maxSamples?: number;
  36166. /** Maximum cube texture size */
  36167. maxCubemapTextureSize: number;
  36168. /** Maximum render texture size */
  36169. maxRenderTextureSize: number;
  36170. /** Maximum number of vertex attributes */
  36171. maxVertexAttribs: number;
  36172. /** Maximum number of varyings */
  36173. maxVaryingVectors: number;
  36174. /** Maximum number of uniforms per vertex shader */
  36175. maxVertexUniformVectors: number;
  36176. /** Maximum number of uniforms per fragment shader */
  36177. maxFragmentUniformVectors: number;
  36178. /** Defines if standard derivates (dx/dy) are supported */
  36179. standardDerivatives: boolean;
  36180. /** Defines if s3tc texture compression is supported */
  36181. s3tc?: WEBGL_compressed_texture_s3tc;
  36182. /** Defines if pvrtc texture compression is supported */
  36183. pvrtc: any;
  36184. /** Defines if etc1 texture compression is supported */
  36185. etc1: any;
  36186. /** Defines if etc2 texture compression is supported */
  36187. etc2: any;
  36188. /** Defines if astc texture compression is supported */
  36189. astc: any;
  36190. /** Defines if bptc texture compression is supported */
  36191. bptc: any;
  36192. /** Defines if float textures are supported */
  36193. textureFloat: boolean;
  36194. /** Defines if vertex array objects are supported */
  36195. vertexArrayObject: boolean;
  36196. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  36197. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  36198. /** Gets the maximum level of anisotropy supported */
  36199. maxAnisotropy: number;
  36200. /** Defines if instancing is supported */
  36201. instancedArrays: boolean;
  36202. /** Defines if 32 bits indices are supported */
  36203. uintIndices: boolean;
  36204. /** Defines if high precision shaders are supported */
  36205. highPrecisionShaderSupported: boolean;
  36206. /** Defines if depth reading in the fragment shader is supported */
  36207. fragmentDepthSupported: boolean;
  36208. /** Defines if float texture linear filtering is supported*/
  36209. textureFloatLinearFiltering: boolean;
  36210. /** Defines if rendering to float textures is supported */
  36211. textureFloatRender: boolean;
  36212. /** Defines if half float textures are supported*/
  36213. textureHalfFloat: boolean;
  36214. /** Defines if half float texture linear filtering is supported*/
  36215. textureHalfFloatLinearFiltering: boolean;
  36216. /** Defines if rendering to half float textures is supported */
  36217. textureHalfFloatRender: boolean;
  36218. /** Defines if textureLOD shader command is supported */
  36219. textureLOD: boolean;
  36220. /** Defines if draw buffers extension is supported */
  36221. drawBuffersExtension: boolean;
  36222. /** Defines if depth textures are supported */
  36223. depthTextureExtension: boolean;
  36224. /** Defines if float color buffer are supported */
  36225. colorBufferFloat: boolean;
  36226. /** Gets disjoint timer query extension (null if not supported) */
  36227. timerQuery?: EXT_disjoint_timer_query;
  36228. /** Defines if timestamp can be used with timer query */
  36229. canUseTimestampForTimerQuery: boolean;
  36230. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  36231. multiview?: any;
  36232. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  36233. oculusMultiview?: any;
  36234. /** Function used to let the system compiles shaders in background */
  36235. parallelShaderCompile?: {
  36236. COMPLETION_STATUS_KHR: number;
  36237. };
  36238. /** Max number of texture samples for MSAA */
  36239. maxMSAASamples: number;
  36240. /** Defines if the blend min max extension is supported */
  36241. blendMinMax: boolean;
  36242. }
  36243. }
  36244. declare module "babylonjs/States/depthCullingState" {
  36245. import { Nullable } from "babylonjs/types";
  36246. /**
  36247. * @hidden
  36248. **/
  36249. export class DepthCullingState {
  36250. private _isDepthTestDirty;
  36251. private _isDepthMaskDirty;
  36252. private _isDepthFuncDirty;
  36253. private _isCullFaceDirty;
  36254. private _isCullDirty;
  36255. private _isZOffsetDirty;
  36256. private _isFrontFaceDirty;
  36257. private _depthTest;
  36258. private _depthMask;
  36259. private _depthFunc;
  36260. private _cull;
  36261. private _cullFace;
  36262. private _zOffset;
  36263. private _frontFace;
  36264. /**
  36265. * Initializes the state.
  36266. */
  36267. constructor();
  36268. get isDirty(): boolean;
  36269. get zOffset(): number;
  36270. set zOffset(value: number);
  36271. get cullFace(): Nullable<number>;
  36272. set cullFace(value: Nullable<number>);
  36273. get cull(): Nullable<boolean>;
  36274. set cull(value: Nullable<boolean>);
  36275. get depthFunc(): Nullable<number>;
  36276. set depthFunc(value: Nullable<number>);
  36277. get depthMask(): boolean;
  36278. set depthMask(value: boolean);
  36279. get depthTest(): boolean;
  36280. set depthTest(value: boolean);
  36281. get frontFace(): Nullable<number>;
  36282. set frontFace(value: Nullable<number>);
  36283. reset(): void;
  36284. apply(gl: WebGLRenderingContext): void;
  36285. }
  36286. }
  36287. declare module "babylonjs/States/stencilState" {
  36288. /**
  36289. * @hidden
  36290. **/
  36291. export class StencilState {
  36292. /** 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 */
  36293. static readonly ALWAYS: number;
  36294. /** Passed to stencilOperation to specify that stencil value must be kept */
  36295. static readonly KEEP: number;
  36296. /** Passed to stencilOperation to specify that stencil value must be replaced */
  36297. static readonly REPLACE: number;
  36298. private _isStencilTestDirty;
  36299. private _isStencilMaskDirty;
  36300. private _isStencilFuncDirty;
  36301. private _isStencilOpDirty;
  36302. private _stencilTest;
  36303. private _stencilMask;
  36304. private _stencilFunc;
  36305. private _stencilFuncRef;
  36306. private _stencilFuncMask;
  36307. private _stencilOpStencilFail;
  36308. private _stencilOpDepthFail;
  36309. private _stencilOpStencilDepthPass;
  36310. get isDirty(): boolean;
  36311. get stencilFunc(): number;
  36312. set stencilFunc(value: number);
  36313. get stencilFuncRef(): number;
  36314. set stencilFuncRef(value: number);
  36315. get stencilFuncMask(): number;
  36316. set stencilFuncMask(value: number);
  36317. get stencilOpStencilFail(): number;
  36318. set stencilOpStencilFail(value: number);
  36319. get stencilOpDepthFail(): number;
  36320. set stencilOpDepthFail(value: number);
  36321. get stencilOpStencilDepthPass(): number;
  36322. set stencilOpStencilDepthPass(value: number);
  36323. get stencilMask(): number;
  36324. set stencilMask(value: number);
  36325. get stencilTest(): boolean;
  36326. set stencilTest(value: boolean);
  36327. constructor();
  36328. reset(): void;
  36329. apply(gl: WebGLRenderingContext): void;
  36330. }
  36331. }
  36332. declare module "babylonjs/States/alphaCullingState" {
  36333. /**
  36334. * @hidden
  36335. **/
  36336. export class AlphaState {
  36337. private _isAlphaBlendDirty;
  36338. private _isBlendFunctionParametersDirty;
  36339. private _isBlendEquationParametersDirty;
  36340. private _isBlendConstantsDirty;
  36341. private _alphaBlend;
  36342. private _blendFunctionParameters;
  36343. private _blendEquationParameters;
  36344. private _blendConstants;
  36345. /**
  36346. * Initializes the state.
  36347. */
  36348. constructor();
  36349. get isDirty(): boolean;
  36350. get alphaBlend(): boolean;
  36351. set alphaBlend(value: boolean);
  36352. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  36353. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  36354. setAlphaEquationParameters(rgb: number, alpha: number): void;
  36355. reset(): void;
  36356. apply(gl: WebGLRenderingContext): void;
  36357. }
  36358. }
  36359. declare module "babylonjs/Engines/WebGL/webGL2ShaderProcessors" {
  36360. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  36361. /** @hidden */
  36362. export class WebGL2ShaderProcessor implements IShaderProcessor {
  36363. attributeProcessor(attribute: string): string;
  36364. varyingProcessor(varying: string, isFragment: boolean): string;
  36365. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  36366. }
  36367. }
  36368. declare module "babylonjs/Engines/instancingAttributeInfo" {
  36369. /**
  36370. * Interface for attribute information associated with buffer instanciation
  36371. */
  36372. export interface InstancingAttributeInfo {
  36373. /**
  36374. * Name of the GLSL attribute
  36375. * if attribute index is not specified, this is used to retrieve the index from the effect
  36376. */
  36377. attributeName: string;
  36378. /**
  36379. * Index/offset of the attribute in the vertex shader
  36380. * if not specified, this will be computes from the name.
  36381. */
  36382. index?: number;
  36383. /**
  36384. * size of the attribute, 1, 2, 3 or 4
  36385. */
  36386. attributeSize: number;
  36387. /**
  36388. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  36389. */
  36390. offset: number;
  36391. /**
  36392. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  36393. * default to 1
  36394. */
  36395. divisor?: number;
  36396. /**
  36397. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  36398. * default is FLOAT
  36399. */
  36400. attributeType?: number;
  36401. /**
  36402. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  36403. */
  36404. normalized?: boolean;
  36405. }
  36406. }
  36407. declare module "babylonjs/Engines/Extensions/engine.videoTexture" {
  36408. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  36409. import { Nullable } from "babylonjs/types";
  36410. module "babylonjs/Engines/thinEngine" {
  36411. interface ThinEngine {
  36412. /**
  36413. * Update a video texture
  36414. * @param texture defines the texture to update
  36415. * @param video defines the video element to use
  36416. * @param invertY defines if data must be stored with Y axis inverted
  36417. */
  36418. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  36419. }
  36420. }
  36421. }
  36422. declare module "babylonjs/Engines/Extensions/engine.dynamicTexture" {
  36423. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  36424. import { Nullable } from "babylonjs/types";
  36425. module "babylonjs/Engines/thinEngine" {
  36426. interface ThinEngine {
  36427. /**
  36428. * Creates a dynamic texture
  36429. * @param width defines the width of the texture
  36430. * @param height defines the height of the texture
  36431. * @param generateMipMaps defines if the engine should generate the mip levels
  36432. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  36433. * @returns the dynamic texture inside an InternalTexture
  36434. */
  36435. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  36436. /**
  36437. * Update the content of a dynamic texture
  36438. * @param texture defines the texture to update
  36439. * @param canvas defines the canvas containing the source
  36440. * @param invertY defines if data must be stored with Y axis inverted
  36441. * @param premulAlpha defines if alpha is stored as premultiplied
  36442. * @param format defines the format of the data
  36443. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  36444. */
  36445. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  36446. }
  36447. }
  36448. }
  36449. declare module "babylonjs/Materials/Textures/videoTexture" {
  36450. import { Observable } from "babylonjs/Misc/observable";
  36451. import { Nullable } from "babylonjs/types";
  36452. import { Scene } from "babylonjs/scene";
  36453. import { Texture } from "babylonjs/Materials/Textures/texture";
  36454. import "babylonjs/Engines/Extensions/engine.videoTexture";
  36455. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  36456. /**
  36457. * Settings for finer control over video usage
  36458. */
  36459. export interface VideoTextureSettings {
  36460. /**
  36461. * Applies `autoplay` to video, if specified
  36462. */
  36463. autoPlay?: boolean;
  36464. /**
  36465. * Applies `loop` to video, if specified
  36466. */
  36467. loop?: boolean;
  36468. /**
  36469. * Automatically updates internal texture from video at every frame in the render loop
  36470. */
  36471. autoUpdateTexture: boolean;
  36472. /**
  36473. * Image src displayed during the video loading or until the user interacts with the video.
  36474. */
  36475. poster?: string;
  36476. }
  36477. /**
  36478. * If you want to display a video in your scene, this is the special texture for that.
  36479. * This special texture works similar to other textures, with the exception of a few parameters.
  36480. * @see https://doc.babylonjs.com/how_to/video_texture
  36481. */
  36482. export class VideoTexture extends Texture {
  36483. /**
  36484. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  36485. */
  36486. readonly autoUpdateTexture: boolean;
  36487. /**
  36488. * The video instance used by the texture internally
  36489. */
  36490. readonly video: HTMLVideoElement;
  36491. private _onUserActionRequestedObservable;
  36492. /**
  36493. * Event triggerd when a dom action is required by the user to play the video.
  36494. * This happens due to recent changes in browser policies preventing video to auto start.
  36495. */
  36496. get onUserActionRequestedObservable(): Observable<Texture>;
  36497. private _generateMipMaps;
  36498. private _stillImageCaptured;
  36499. private _displayingPosterTexture;
  36500. private _settings;
  36501. private _createInternalTextureOnEvent;
  36502. private _frameId;
  36503. private _currentSrc;
  36504. /**
  36505. * Creates a video texture.
  36506. * If you want to display a video in your scene, this is the special texture for that.
  36507. * This special texture works similar to other textures, with the exception of a few parameters.
  36508. * @see https://doc.babylonjs.com/how_to/video_texture
  36509. * @param name optional name, will detect from video source, if not defined
  36510. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  36511. * @param scene is obviously the current scene.
  36512. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  36513. * @param invertY is false by default but can be used to invert video on Y axis
  36514. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  36515. * @param settings allows finer control over video usage
  36516. */
  36517. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  36518. private _getName;
  36519. private _getVideo;
  36520. private _createInternalTexture;
  36521. private reset;
  36522. /**
  36523. * @hidden Internal method to initiate `update`.
  36524. */
  36525. _rebuild(): void;
  36526. /**
  36527. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  36528. */
  36529. update(): void;
  36530. /**
  36531. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  36532. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  36533. */
  36534. updateTexture(isVisible: boolean): void;
  36535. protected _updateInternalTexture: () => void;
  36536. /**
  36537. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  36538. * @param url New url.
  36539. */
  36540. updateURL(url: string): void;
  36541. /**
  36542. * Clones the texture.
  36543. * @returns the cloned texture
  36544. */
  36545. clone(): VideoTexture;
  36546. /**
  36547. * Dispose the texture and release its associated resources.
  36548. */
  36549. dispose(): void;
  36550. /**
  36551. * Creates a video texture straight from a stream.
  36552. * @param scene Define the scene the texture should be created in
  36553. * @param stream Define the stream the texture should be created from
  36554. * @returns The created video texture as a promise
  36555. */
  36556. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  36557. /**
  36558. * Creates a video texture straight from your WebCam video feed.
  36559. * @param scene Define the scene the texture should be created in
  36560. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  36561. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  36562. * @returns The created video texture as a promise
  36563. */
  36564. static CreateFromWebCamAsync(scene: Scene, constraints: {
  36565. minWidth: number;
  36566. maxWidth: number;
  36567. minHeight: number;
  36568. maxHeight: number;
  36569. deviceId: string;
  36570. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  36571. /**
  36572. * Creates a video texture straight from your WebCam video feed.
  36573. * @param scene Define the scene the texture should be created in
  36574. * @param onReady Define a callback to triggered once the texture will be ready
  36575. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  36576. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  36577. */
  36578. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  36579. minWidth: number;
  36580. maxWidth: number;
  36581. minHeight: number;
  36582. maxHeight: number;
  36583. deviceId: string;
  36584. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  36585. }
  36586. }
  36587. declare module "babylonjs/Engines/thinEngine" {
  36588. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  36589. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  36590. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  36591. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  36592. import { Nullable, DataArray, IndicesArray } from "babylonjs/types";
  36593. import { EngineCapabilities } from "babylonjs/Engines/engineCapabilities";
  36594. import { Observable } from "babylonjs/Misc/observable";
  36595. import { DepthCullingState } from "babylonjs/States/depthCullingState";
  36596. import { StencilState } from "babylonjs/States/stencilState";
  36597. import { AlphaState } from "babylonjs/States/alphaCullingState";
  36598. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  36599. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  36600. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  36601. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  36602. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  36603. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  36604. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  36605. import { InstancingAttributeInfo } from "babylonjs/Engines/instancingAttributeInfo";
  36606. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  36607. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  36608. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  36609. import { IWebRequest } from "babylonjs/Misc/interfaces/iWebRequest";
  36610. import { WebRequest } from "babylonjs/Misc/webRequest";
  36611. import { LoadFileError } from "babylonjs/Misc/fileTools";
  36612. /**
  36613. * Defines the interface used by objects working like Scene
  36614. * @hidden
  36615. */
  36616. export interface ISceneLike {
  36617. _addPendingData(data: any): void;
  36618. _removePendingData(data: any): void;
  36619. offlineProvider: IOfflineProvider;
  36620. }
  36621. /**
  36622. * Information about the current host
  36623. */
  36624. export interface HostInformation {
  36625. /**
  36626. * Defines if the current host is a mobile
  36627. */
  36628. isMobile: boolean;
  36629. }
  36630. /** Interface defining initialization parameters for Engine class */
  36631. export interface EngineOptions extends WebGLContextAttributes {
  36632. /**
  36633. * Defines if the engine should no exceed a specified device ratio
  36634. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  36635. */
  36636. limitDeviceRatio?: number;
  36637. /**
  36638. * Defines if webvr should be enabled automatically
  36639. * @see https://doc.babylonjs.com/how_to/webvr_camera
  36640. */
  36641. autoEnableWebVR?: boolean;
  36642. /**
  36643. * Defines if webgl2 should be turned off even if supported
  36644. * @see https://doc.babylonjs.com/features/webgl2
  36645. */
  36646. disableWebGL2Support?: boolean;
  36647. /**
  36648. * Defines if webaudio should be initialized as well
  36649. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  36650. */
  36651. audioEngine?: boolean;
  36652. /**
  36653. * Defines if animations should run using a deterministic lock step
  36654. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36655. */
  36656. deterministicLockstep?: boolean;
  36657. /** Defines the maximum steps to use with deterministic lock step mode */
  36658. lockstepMaxSteps?: number;
  36659. /** Defines the seconds between each deterministic lock step */
  36660. timeStep?: number;
  36661. /**
  36662. * Defines that engine should ignore context lost events
  36663. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  36664. */
  36665. doNotHandleContextLost?: boolean;
  36666. /**
  36667. * Defines that engine should ignore modifying touch action attribute and style
  36668. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  36669. */
  36670. doNotHandleTouchAction?: boolean;
  36671. /**
  36672. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  36673. */
  36674. useHighPrecisionFloats?: boolean;
  36675. /**
  36676. * Make the canvas XR Compatible for XR sessions
  36677. */
  36678. xrCompatible?: boolean;
  36679. /**
  36680. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  36681. */
  36682. useHighPrecisionMatrix?: boolean;
  36683. }
  36684. /**
  36685. * The base engine class (root of all engines)
  36686. */
  36687. export class ThinEngine {
  36688. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  36689. static ExceptionList: ({
  36690. key: string;
  36691. capture: string;
  36692. captureConstraint: number;
  36693. targets: string[];
  36694. } | {
  36695. key: string;
  36696. capture: null;
  36697. captureConstraint: null;
  36698. targets: string[];
  36699. })[];
  36700. /** @hidden */
  36701. static _TextureLoaders: IInternalTextureLoader[];
  36702. /**
  36703. * Returns the current npm package of the sdk
  36704. */
  36705. static get NpmPackage(): string;
  36706. /**
  36707. * Returns the current version of the framework
  36708. */
  36709. static get Version(): string;
  36710. /**
  36711. * Returns a string describing the current engine
  36712. */
  36713. get description(): string;
  36714. /**
  36715. * Gets or sets the epsilon value used by collision engine
  36716. */
  36717. static CollisionsEpsilon: number;
  36718. /**
  36719. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  36720. */
  36721. static get ShadersRepository(): string;
  36722. static set ShadersRepository(value: string);
  36723. /** @hidden */
  36724. _shaderProcessor: IShaderProcessor;
  36725. /**
  36726. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  36727. */
  36728. forcePOTTextures: boolean;
  36729. /**
  36730. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  36731. */
  36732. isFullscreen: boolean;
  36733. /**
  36734. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  36735. */
  36736. cullBackFaces: boolean;
  36737. /**
  36738. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  36739. */
  36740. renderEvenInBackground: boolean;
  36741. /**
  36742. * Gets or sets a boolean indicating that cache can be kept between frames
  36743. */
  36744. preventCacheWipeBetweenFrames: boolean;
  36745. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  36746. validateShaderPrograms: boolean;
  36747. /**
  36748. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  36749. * This can provide greater z depth for distant objects.
  36750. */
  36751. useReverseDepthBuffer: boolean;
  36752. /**
  36753. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  36754. */
  36755. disableUniformBuffers: boolean;
  36756. /** @hidden */
  36757. _uniformBuffers: UniformBuffer[];
  36758. /**
  36759. * Gets a boolean indicating that the engine supports uniform buffers
  36760. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  36761. */
  36762. get supportsUniformBuffers(): boolean;
  36763. /** @hidden */
  36764. _gl: WebGLRenderingContext;
  36765. /** @hidden */
  36766. _webGLVersion: number;
  36767. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  36768. protected _windowIsBackground: boolean;
  36769. protected _creationOptions: EngineOptions;
  36770. protected _highPrecisionShadersAllowed: boolean;
  36771. /** @hidden */
  36772. get _shouldUseHighPrecisionShader(): boolean;
  36773. /**
  36774. * Gets a boolean indicating that only power of 2 textures are supported
  36775. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  36776. */
  36777. get needPOTTextures(): boolean;
  36778. /** @hidden */
  36779. _badOS: boolean;
  36780. /** @hidden */
  36781. _badDesktopOS: boolean;
  36782. private _hardwareScalingLevel;
  36783. /** @hidden */
  36784. _caps: EngineCapabilities;
  36785. private _isStencilEnable;
  36786. private _glVersion;
  36787. private _glRenderer;
  36788. private _glVendor;
  36789. /** @hidden */
  36790. _videoTextureSupported: boolean;
  36791. protected _renderingQueueLaunched: boolean;
  36792. protected _activeRenderLoops: (() => void)[];
  36793. /**
  36794. * Observable signaled when a context lost event is raised
  36795. */
  36796. onContextLostObservable: Observable<ThinEngine>;
  36797. /**
  36798. * Observable signaled when a context restored event is raised
  36799. */
  36800. onContextRestoredObservable: Observable<ThinEngine>;
  36801. private _onContextLost;
  36802. private _onContextRestored;
  36803. protected _contextWasLost: boolean;
  36804. /** @hidden */
  36805. _doNotHandleContextLost: boolean;
  36806. /**
  36807. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  36808. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  36809. */
  36810. get doNotHandleContextLost(): boolean;
  36811. set doNotHandleContextLost(value: boolean);
  36812. /**
  36813. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  36814. */
  36815. disableVertexArrayObjects: boolean;
  36816. /** @hidden */
  36817. protected _colorWrite: boolean;
  36818. /** @hidden */
  36819. protected _colorWriteChanged: boolean;
  36820. /** @hidden */
  36821. protected _depthCullingState: DepthCullingState;
  36822. /** @hidden */
  36823. protected _stencilState: StencilState;
  36824. /** @hidden */
  36825. _alphaState: AlphaState;
  36826. /** @hidden */
  36827. _alphaMode: number;
  36828. /** @hidden */
  36829. _alphaEquation: number;
  36830. /** @hidden */
  36831. _internalTexturesCache: InternalTexture[];
  36832. /** @hidden */
  36833. protected _activeChannel: number;
  36834. private _currentTextureChannel;
  36835. /** @hidden */
  36836. protected _boundTexturesCache: {
  36837. [key: string]: Nullable<InternalTexture>;
  36838. };
  36839. /** @hidden */
  36840. protected _currentEffect: Nullable<Effect>;
  36841. /** @hidden */
  36842. protected _currentProgram: Nullable<WebGLProgram>;
  36843. private _compiledEffects;
  36844. private _vertexAttribArraysEnabled;
  36845. /** @hidden */
  36846. protected _cachedViewport: Nullable<IViewportLike>;
  36847. private _cachedVertexArrayObject;
  36848. /** @hidden */
  36849. protected _cachedVertexBuffers: any;
  36850. /** @hidden */
  36851. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  36852. /** @hidden */
  36853. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  36854. /** @hidden */
  36855. _currentRenderTarget: Nullable<InternalTexture>;
  36856. private _uintIndicesCurrentlySet;
  36857. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  36858. /** @hidden */
  36859. _currentFramebuffer: Nullable<WebGLFramebuffer>;
  36860. /** @hidden */
  36861. _dummyFramebuffer: Nullable<WebGLFramebuffer>;
  36862. private _currentBufferPointers;
  36863. private _currentInstanceLocations;
  36864. private _currentInstanceBuffers;
  36865. private _textureUnits;
  36866. /** @hidden */
  36867. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  36868. /** @hidden */
  36869. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  36870. /** @hidden */
  36871. _boundRenderFunction: any;
  36872. private _vaoRecordInProgress;
  36873. private _mustWipeVertexAttributes;
  36874. private _emptyTexture;
  36875. private _emptyCubeTexture;
  36876. private _emptyTexture3D;
  36877. private _emptyTexture2DArray;
  36878. /** @hidden */
  36879. _frameHandler: number;
  36880. private _nextFreeTextureSlots;
  36881. private _maxSimultaneousTextures;
  36882. private _activeRequests;
  36883. /** @hidden */
  36884. _transformTextureUrl: Nullable<(url: string) => string>;
  36885. /**
  36886. * Gets information about the current host
  36887. */
  36888. hostInformation: HostInformation;
  36889. protected get _supportsHardwareTextureRescaling(): boolean;
  36890. private _framebufferDimensionsObject;
  36891. /**
  36892. * sets the object from which width and height will be taken from when getting render width and height
  36893. * Will fallback to the gl object
  36894. * @param dimensions the framebuffer width and height that will be used.
  36895. */
  36896. set framebufferDimensionsObject(dimensions: Nullable<{
  36897. framebufferWidth: number;
  36898. framebufferHeight: number;
  36899. }>);
  36900. /**
  36901. * Gets the current viewport
  36902. */
  36903. get currentViewport(): Nullable<IViewportLike>;
  36904. /**
  36905. * Gets the default empty texture
  36906. */
  36907. get emptyTexture(): InternalTexture;
  36908. /**
  36909. * Gets the default empty 3D texture
  36910. */
  36911. get emptyTexture3D(): InternalTexture;
  36912. /**
  36913. * Gets the default empty 2D array texture
  36914. */
  36915. get emptyTexture2DArray(): InternalTexture;
  36916. /**
  36917. * Gets the default empty cube texture
  36918. */
  36919. get emptyCubeTexture(): InternalTexture;
  36920. /**
  36921. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  36922. */
  36923. readonly premultipliedAlpha: boolean;
  36924. /**
  36925. * Observable event triggered before each texture is initialized
  36926. */
  36927. onBeforeTextureInitObservable: Observable<import("babylonjs/Materials/Textures/texture").Texture>;
  36928. /**
  36929. * Creates a new engine
  36930. * @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
  36931. * @param antialias defines enable antialiasing (default: false)
  36932. * @param options defines further options to be sent to the getContext() function
  36933. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  36934. */
  36935. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  36936. private _rebuildInternalTextures;
  36937. private _rebuildEffects;
  36938. /**
  36939. * Gets a boolean indicating if all created effects are ready
  36940. * @returns true if all effects are ready
  36941. */
  36942. areAllEffectsReady(): boolean;
  36943. protected _rebuildBuffers(): void;
  36944. protected _initGLContext(): void;
  36945. /**
  36946. * Gets version of the current webGL context
  36947. */
  36948. get webGLVersion(): number;
  36949. /**
  36950. * Gets a string identifying the name of the class
  36951. * @returns "Engine" string
  36952. */
  36953. getClassName(): string;
  36954. /**
  36955. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  36956. */
  36957. get isStencilEnable(): boolean;
  36958. /** @hidden */
  36959. _prepareWorkingCanvas(): void;
  36960. /**
  36961. * Reset the texture cache to empty state
  36962. */
  36963. resetTextureCache(): void;
  36964. /**
  36965. * Gets an object containing information about the current webGL context
  36966. * @returns an object containing the vender, the renderer and the version of the current webGL context
  36967. */
  36968. getGlInfo(): {
  36969. vendor: string;
  36970. renderer: string;
  36971. version: string;
  36972. };
  36973. /**
  36974. * Defines the hardware scaling level.
  36975. * By default the hardware scaling level is computed from the window device ratio.
  36976. * 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.
  36977. * @param level defines the level to use
  36978. */
  36979. setHardwareScalingLevel(level: number): void;
  36980. /**
  36981. * Gets the current hardware scaling level.
  36982. * By default the hardware scaling level is computed from the window device ratio.
  36983. * 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.
  36984. * @returns a number indicating the current hardware scaling level
  36985. */
  36986. getHardwareScalingLevel(): number;
  36987. /**
  36988. * Gets the list of loaded textures
  36989. * @returns an array containing all loaded textures
  36990. */
  36991. getLoadedTexturesCache(): InternalTexture[];
  36992. /**
  36993. * Gets the object containing all engine capabilities
  36994. * @returns the EngineCapabilities object
  36995. */
  36996. getCaps(): EngineCapabilities;
  36997. /**
  36998. * stop executing a render loop function and remove it from the execution array
  36999. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  37000. */
  37001. stopRenderLoop(renderFunction?: () => void): void;
  37002. /** @hidden */
  37003. _renderLoop(): void;
  37004. /**
  37005. * Gets the HTML canvas attached with the current webGL context
  37006. * @returns a HTML canvas
  37007. */
  37008. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  37009. /**
  37010. * Gets host window
  37011. * @returns the host window object
  37012. */
  37013. getHostWindow(): Nullable<Window>;
  37014. /**
  37015. * Gets the current render width
  37016. * @param useScreen defines if screen size must be used (or the current render target if any)
  37017. * @returns a number defining the current render width
  37018. */
  37019. getRenderWidth(useScreen?: boolean): number;
  37020. /**
  37021. * Gets the current render height
  37022. * @param useScreen defines if screen size must be used (or the current render target if any)
  37023. * @returns a number defining the current render height
  37024. */
  37025. getRenderHeight(useScreen?: boolean): number;
  37026. /**
  37027. * Can be used to override the current requestAnimationFrame requester.
  37028. * @hidden
  37029. */
  37030. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  37031. /**
  37032. * Register and execute a render loop. The engine can have more than one render function
  37033. * @param renderFunction defines the function to continuously execute
  37034. */
  37035. runRenderLoop(renderFunction: () => void): void;
  37036. /**
  37037. * Clear the current render buffer or the current render target (if any is set up)
  37038. * @param color defines the color to use
  37039. * @param backBuffer defines if the back buffer must be cleared
  37040. * @param depth defines if the depth buffer must be cleared
  37041. * @param stencil defines if the stencil buffer must be cleared
  37042. */
  37043. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  37044. private _viewportCached;
  37045. /** @hidden */
  37046. _viewport(x: number, y: number, width: number, height: number): void;
  37047. /**
  37048. * Set the WebGL's viewport
  37049. * @param viewport defines the viewport element to be used
  37050. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  37051. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  37052. */
  37053. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  37054. /**
  37055. * Begin a new frame
  37056. */
  37057. beginFrame(): void;
  37058. /**
  37059. * Enf the current frame
  37060. */
  37061. endFrame(): void;
  37062. /**
  37063. * Resize the view according to the canvas' size
  37064. */
  37065. resize(): void;
  37066. /**
  37067. * Force a specific size of the canvas
  37068. * @param width defines the new canvas' width
  37069. * @param height defines the new canvas' height
  37070. * @returns true if the size was changed
  37071. */
  37072. setSize(width: number, height: number): boolean;
  37073. /**
  37074. * Binds the frame buffer to the specified texture.
  37075. * @param texture The texture to render to or null for the default canvas
  37076. * @param faceIndex The face of the texture to render to in case of cube texture
  37077. * @param requiredWidth The width of the target to render to
  37078. * @param requiredHeight The height of the target to render to
  37079. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  37080. * @param lodLevel defines the lod level to bind to the frame buffer
  37081. * @param layer defines the 2d array index to bind to frame buffer to
  37082. */
  37083. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  37084. /** @hidden */
  37085. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  37086. /**
  37087. * Unbind the current render target texture from the webGL context
  37088. * @param texture defines the render target texture to unbind
  37089. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  37090. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  37091. */
  37092. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  37093. /**
  37094. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  37095. */
  37096. flushFramebuffer(): void;
  37097. /**
  37098. * Unbind the current render target and bind the default framebuffer
  37099. */
  37100. restoreDefaultFramebuffer(): void;
  37101. /** @hidden */
  37102. protected _resetVertexBufferBinding(): void;
  37103. /**
  37104. * Creates a vertex buffer
  37105. * @param data the data for the vertex buffer
  37106. * @returns the new WebGL static buffer
  37107. */
  37108. createVertexBuffer(data: DataArray): DataBuffer;
  37109. private _createVertexBuffer;
  37110. /**
  37111. * Creates a dynamic vertex buffer
  37112. * @param data the data for the dynamic vertex buffer
  37113. * @returns the new WebGL dynamic buffer
  37114. */
  37115. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  37116. protected _resetIndexBufferBinding(): void;
  37117. /**
  37118. * Creates a new index buffer
  37119. * @param indices defines the content of the index buffer
  37120. * @param updatable defines if the index buffer must be updatable
  37121. * @returns a new webGL buffer
  37122. */
  37123. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  37124. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  37125. /**
  37126. * Bind a webGL buffer to the webGL context
  37127. * @param buffer defines the buffer to bind
  37128. */
  37129. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  37130. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  37131. private bindBuffer;
  37132. /**
  37133. * update the bound buffer with the given data
  37134. * @param data defines the data to update
  37135. */
  37136. updateArrayBuffer(data: Float32Array): void;
  37137. private _vertexAttribPointer;
  37138. /** @hidden */
  37139. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  37140. private _bindVertexBuffersAttributes;
  37141. /**
  37142. * Records a vertex array object
  37143. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  37144. * @param vertexBuffers defines the list of vertex buffers to store
  37145. * @param indexBuffer defines the index buffer to store
  37146. * @param effect defines the effect to store
  37147. * @returns the new vertex array object
  37148. */
  37149. recordVertexArrayObject(vertexBuffers: {
  37150. [key: string]: VertexBuffer;
  37151. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  37152. /**
  37153. * Bind a specific vertex array object
  37154. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  37155. * @param vertexArrayObject defines the vertex array object to bind
  37156. * @param indexBuffer defines the index buffer to bind
  37157. */
  37158. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  37159. /**
  37160. * Bind webGl buffers directly to the webGL context
  37161. * @param vertexBuffer defines the vertex buffer to bind
  37162. * @param indexBuffer defines the index buffer to bind
  37163. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  37164. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  37165. * @param effect defines the effect associated with the vertex buffer
  37166. */
  37167. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  37168. private _unbindVertexArrayObject;
  37169. /**
  37170. * Bind a list of vertex buffers to the webGL context
  37171. * @param vertexBuffers defines the list of vertex buffers to bind
  37172. * @param indexBuffer defines the index buffer to bind
  37173. * @param effect defines the effect associated with the vertex buffers
  37174. */
  37175. bindBuffers(vertexBuffers: {
  37176. [key: string]: Nullable<VertexBuffer>;
  37177. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  37178. /**
  37179. * Unbind all instance attributes
  37180. */
  37181. unbindInstanceAttributes(): void;
  37182. /**
  37183. * Release and free the memory of a vertex array object
  37184. * @param vao defines the vertex array object to delete
  37185. */
  37186. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  37187. /** @hidden */
  37188. _releaseBuffer(buffer: DataBuffer): boolean;
  37189. protected _deleteBuffer(buffer: DataBuffer): void;
  37190. /**
  37191. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  37192. * @param instancesBuffer defines the webGL buffer to update and bind
  37193. * @param data defines the data to store in the buffer
  37194. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  37195. */
  37196. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  37197. /**
  37198. * Bind the content of a webGL buffer used with instantiation
  37199. * @param instancesBuffer defines the webGL buffer to bind
  37200. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  37201. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  37202. */
  37203. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  37204. /**
  37205. * Disable the instance attribute corresponding to the name in parameter
  37206. * @param name defines the name of the attribute to disable
  37207. */
  37208. disableInstanceAttributeByName(name: string): void;
  37209. /**
  37210. * Disable the instance attribute corresponding to the location in parameter
  37211. * @param attributeLocation defines the attribute location of the attribute to disable
  37212. */
  37213. disableInstanceAttribute(attributeLocation: number): void;
  37214. /**
  37215. * Disable the attribute corresponding to the location in parameter
  37216. * @param attributeLocation defines the attribute location of the attribute to disable
  37217. */
  37218. disableAttributeByIndex(attributeLocation: number): void;
  37219. /**
  37220. * Send a draw order
  37221. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  37222. * @param indexStart defines the starting index
  37223. * @param indexCount defines the number of index to draw
  37224. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  37225. */
  37226. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  37227. /**
  37228. * Draw a list of points
  37229. * @param verticesStart defines the index of first vertex to draw
  37230. * @param verticesCount defines the count of vertices to draw
  37231. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  37232. */
  37233. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  37234. /**
  37235. * Draw a list of unindexed primitives
  37236. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  37237. * @param verticesStart defines the index of first vertex to draw
  37238. * @param verticesCount defines the count of vertices to draw
  37239. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  37240. */
  37241. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  37242. /**
  37243. * Draw a list of indexed primitives
  37244. * @param fillMode defines the primitive to use
  37245. * @param indexStart defines the starting index
  37246. * @param indexCount defines the number of index to draw
  37247. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  37248. */
  37249. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  37250. /**
  37251. * Draw a list of unindexed primitives
  37252. * @param fillMode defines the primitive to use
  37253. * @param verticesStart defines the index of first vertex to draw
  37254. * @param verticesCount defines the count of vertices to draw
  37255. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  37256. */
  37257. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  37258. private _drawMode;
  37259. /** @hidden */
  37260. protected _reportDrawCall(): void;
  37261. /** @hidden */
  37262. _releaseEffect(effect: Effect): void;
  37263. /** @hidden */
  37264. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  37265. /**
  37266. * Create a new effect (used to store vertex/fragment shaders)
  37267. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  37268. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  37269. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  37270. * @param samplers defines an array of string used to represent textures
  37271. * @param defines defines the string containing the defines to use to compile the shaders
  37272. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  37273. * @param onCompiled defines a function to call when the effect creation is successful
  37274. * @param onError defines a function to call when the effect creation has failed
  37275. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  37276. * @returns the new Effect
  37277. */
  37278. 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;
  37279. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  37280. private _compileShader;
  37281. private _compileRawShader;
  37282. /** @hidden */
  37283. _getShaderSource(shader: WebGLShader): Nullable<string>;
  37284. /**
  37285. * Directly creates a webGL program
  37286. * @param pipelineContext defines the pipeline context to attach to
  37287. * @param vertexCode defines the vertex shader code to use
  37288. * @param fragmentCode defines the fragment shader code to use
  37289. * @param context defines the webGL context to use (if not set, the current one will be used)
  37290. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  37291. * @returns the new webGL program
  37292. */
  37293. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  37294. /**
  37295. * Creates a webGL program
  37296. * @param pipelineContext defines the pipeline context to attach to
  37297. * @param vertexCode defines the vertex shader code to use
  37298. * @param fragmentCode defines the fragment shader code to use
  37299. * @param defines defines the string containing the defines to use to compile the shaders
  37300. * @param context defines the webGL context to use (if not set, the current one will be used)
  37301. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  37302. * @returns the new webGL program
  37303. */
  37304. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  37305. /**
  37306. * Creates a new pipeline context
  37307. * @returns the new pipeline
  37308. */
  37309. createPipelineContext(): IPipelineContext;
  37310. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  37311. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  37312. /** @hidden */
  37313. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  37314. /** @hidden */
  37315. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  37316. /** @hidden */
  37317. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  37318. /**
  37319. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  37320. * @param pipelineContext defines the pipeline context to use
  37321. * @param uniformsNames defines the list of uniform names
  37322. * @returns an array of webGL uniform locations
  37323. */
  37324. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  37325. /**
  37326. * Gets the lsit of active attributes for a given webGL program
  37327. * @param pipelineContext defines the pipeline context to use
  37328. * @param attributesNames defines the list of attribute names to get
  37329. * @returns an array of indices indicating the offset of each attribute
  37330. */
  37331. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  37332. /**
  37333. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  37334. * @param effect defines the effect to activate
  37335. */
  37336. enableEffect(effect: Nullable<Effect>): void;
  37337. /**
  37338. * Set the value of an uniform to a number (int)
  37339. * @param uniform defines the webGL uniform location where to store the value
  37340. * @param value defines the int number to store
  37341. */
  37342. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  37343. /**
  37344. * Set the value of an uniform to an array of int32
  37345. * @param uniform defines the webGL uniform location where to store the value
  37346. * @param array defines the array of int32 to store
  37347. */
  37348. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  37349. /**
  37350. * Set the value of an uniform to an array of int32 (stored as vec2)
  37351. * @param uniform defines the webGL uniform location where to store the value
  37352. * @param array defines the array of int32 to store
  37353. */
  37354. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  37355. /**
  37356. * Set the value of an uniform to an array of int32 (stored as vec3)
  37357. * @param uniform defines the webGL uniform location where to store the value
  37358. * @param array defines the array of int32 to store
  37359. */
  37360. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  37361. /**
  37362. * Set the value of an uniform to an array of int32 (stored as vec4)
  37363. * @param uniform defines the webGL uniform location where to store the value
  37364. * @param array defines the array of int32 to store
  37365. */
  37366. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  37367. /**
  37368. * Set the value of an uniform to an array of number
  37369. * @param uniform defines the webGL uniform location where to store the value
  37370. * @param array defines the array of number to store
  37371. */
  37372. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  37373. /**
  37374. * Set the value of an uniform to an array of number (stored as vec2)
  37375. * @param uniform defines the webGL uniform location where to store the value
  37376. * @param array defines the array of number to store
  37377. */
  37378. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  37379. /**
  37380. * Set the value of an uniform to an array of number (stored as vec3)
  37381. * @param uniform defines the webGL uniform location where to store the value
  37382. * @param array defines the array of number to store
  37383. */
  37384. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  37385. /**
  37386. * Set the value of an uniform to an array of number (stored as vec4)
  37387. * @param uniform defines the webGL uniform location where to store the value
  37388. * @param array defines the array of number to store
  37389. */
  37390. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  37391. /**
  37392. * Set the value of an uniform to an array of float32 (stored as matrices)
  37393. * @param uniform defines the webGL uniform location where to store the value
  37394. * @param matrices defines the array of float32 to store
  37395. */
  37396. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  37397. /**
  37398. * Set the value of an uniform to a matrix (3x3)
  37399. * @param uniform defines the webGL uniform location where to store the value
  37400. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  37401. */
  37402. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  37403. /**
  37404. * Set the value of an uniform to a matrix (2x2)
  37405. * @param uniform defines the webGL uniform location where to store the value
  37406. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  37407. */
  37408. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  37409. /**
  37410. * Set the value of an uniform to a number (float)
  37411. * @param uniform defines the webGL uniform location where to store the value
  37412. * @param value defines the float number to store
  37413. */
  37414. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  37415. /**
  37416. * Set the value of an uniform to a vec2
  37417. * @param uniform defines the webGL uniform location where to store the value
  37418. * @param x defines the 1st component of the value
  37419. * @param y defines the 2nd component of the value
  37420. */
  37421. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  37422. /**
  37423. * Set the value of an uniform to a vec3
  37424. * @param uniform defines the webGL uniform location where to store the value
  37425. * @param x defines the 1st component of the value
  37426. * @param y defines the 2nd component of the value
  37427. * @param z defines the 3rd component of the value
  37428. */
  37429. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  37430. /**
  37431. * Set the value of an uniform to a vec4
  37432. * @param uniform defines the webGL uniform location where to store the value
  37433. * @param x defines the 1st component of the value
  37434. * @param y defines the 2nd component of the value
  37435. * @param z defines the 3rd component of the value
  37436. * @param w defines the 4th component of the value
  37437. */
  37438. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  37439. /**
  37440. * Apply all cached states (depth, culling, stencil and alpha)
  37441. */
  37442. applyStates(): void;
  37443. /**
  37444. * Enable or disable color writing
  37445. * @param enable defines the state to set
  37446. */
  37447. setColorWrite(enable: boolean): void;
  37448. /**
  37449. * Gets a boolean indicating if color writing is enabled
  37450. * @returns the current color writing state
  37451. */
  37452. getColorWrite(): boolean;
  37453. /**
  37454. * Gets the depth culling state manager
  37455. */
  37456. get depthCullingState(): DepthCullingState;
  37457. /**
  37458. * Gets the alpha state manager
  37459. */
  37460. get alphaState(): AlphaState;
  37461. /**
  37462. * Gets the stencil state manager
  37463. */
  37464. get stencilState(): StencilState;
  37465. /**
  37466. * Clears the list of texture accessible through engine.
  37467. * This can help preventing texture load conflict due to name collision.
  37468. */
  37469. clearInternalTexturesCache(): void;
  37470. /**
  37471. * Force the entire cache to be cleared
  37472. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  37473. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  37474. */
  37475. wipeCaches(bruteForce?: boolean): void;
  37476. /** @hidden */
  37477. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  37478. min: number;
  37479. mag: number;
  37480. };
  37481. /** @hidden */
  37482. _createTexture(): WebGLTexture;
  37483. /**
  37484. * Usually called from Texture.ts.
  37485. * Passed information to create a WebGLTexture
  37486. * @param url defines a value which contains one of the following:
  37487. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  37488. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  37489. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  37490. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  37491. * @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)
  37492. * @param scene needed for loading to the correct scene
  37493. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  37494. * @param onLoad optional callback to be called upon successful completion
  37495. * @param onError optional callback to be called upon failure
  37496. * @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
  37497. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  37498. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  37499. * @param forcedExtension defines the extension to use to pick the right loader
  37500. * @param mimeType defines an optional mime type
  37501. * @returns a InternalTexture for assignment back into BABYLON.Texture
  37502. */
  37503. 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;
  37504. /**
  37505. * Loads an image as an HTMLImageElement.
  37506. * @param input url string, ArrayBuffer, or Blob to load
  37507. * @param onLoad callback called when the image successfully loads
  37508. * @param onError callback called when the image fails to load
  37509. * @param offlineProvider offline provider for caching
  37510. * @param mimeType optional mime type
  37511. * @returns the HTMLImageElement of the loaded image
  37512. * @hidden
  37513. */
  37514. 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>;
  37515. /**
  37516. * @hidden
  37517. */
  37518. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  37519. private _unpackFlipYCached;
  37520. /**
  37521. * In case you are sharing the context with other applications, it might
  37522. * be interested to not cache the unpack flip y state to ensure a consistent
  37523. * value would be set.
  37524. */
  37525. enableUnpackFlipYCached: boolean;
  37526. /** @hidden */
  37527. _unpackFlipY(value: boolean): void;
  37528. /** @hidden */
  37529. _getUnpackAlignement(): number;
  37530. private _getTextureTarget;
  37531. /**
  37532. * Update the sampling mode of a given texture
  37533. * @param samplingMode defines the required sampling mode
  37534. * @param texture defines the texture to update
  37535. * @param generateMipMaps defines whether to generate mipmaps for the texture
  37536. */
  37537. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  37538. /**
  37539. * Update the sampling mode of a given texture
  37540. * @param texture defines the texture to update
  37541. * @param wrapU defines the texture wrap mode of the u coordinates
  37542. * @param wrapV defines the texture wrap mode of the v coordinates
  37543. * @param wrapR defines the texture wrap mode of the r coordinates
  37544. */
  37545. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  37546. /** @hidden */
  37547. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  37548. width: number;
  37549. height: number;
  37550. layers?: number;
  37551. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  37552. /** @hidden */
  37553. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  37554. /** @hidden */
  37555. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  37556. /**
  37557. * Update a portion of an internal texture
  37558. * @param texture defines the texture to update
  37559. * @param imageData defines the data to store into the texture
  37560. * @param xOffset defines the x coordinates of the update rectangle
  37561. * @param yOffset defines the y coordinates of the update rectangle
  37562. * @param width defines the width of the update rectangle
  37563. * @param height defines the height of the update rectangle
  37564. * @param faceIndex defines the face index if texture is a cube (0 by default)
  37565. * @param lod defines the lod level to update (0 by default)
  37566. */
  37567. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  37568. /** @hidden */
  37569. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  37570. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  37571. private _prepareWebGLTexture;
  37572. /** @hidden */
  37573. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  37574. private _getDepthStencilBuffer;
  37575. /** @hidden */
  37576. _releaseFramebufferObjects(texture: InternalTexture): void;
  37577. /** @hidden */
  37578. _releaseTexture(texture: InternalTexture): void;
  37579. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  37580. protected _setProgram(program: WebGLProgram): void;
  37581. protected _boundUniforms: {
  37582. [key: number]: WebGLUniformLocation;
  37583. };
  37584. /**
  37585. * Binds an effect to the webGL context
  37586. * @param effect defines the effect to bind
  37587. */
  37588. bindSamplers(effect: Effect): void;
  37589. private _activateCurrentTexture;
  37590. /** @hidden */
  37591. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  37592. /** @hidden */
  37593. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  37594. /**
  37595. * Unbind all textures from the webGL context
  37596. */
  37597. unbindAllTextures(): void;
  37598. /**
  37599. * Sets a texture to the according uniform.
  37600. * @param channel The texture channel
  37601. * @param uniform The uniform to set
  37602. * @param texture The texture to apply
  37603. */
  37604. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  37605. private _bindSamplerUniformToChannel;
  37606. private _getTextureWrapMode;
  37607. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  37608. /**
  37609. * Sets an array of texture to the webGL context
  37610. * @param channel defines the channel where the texture array must be set
  37611. * @param uniform defines the associated uniform location
  37612. * @param textures defines the array of textures to bind
  37613. */
  37614. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  37615. /** @hidden */
  37616. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  37617. private _setTextureParameterFloat;
  37618. private _setTextureParameterInteger;
  37619. /**
  37620. * Unbind all vertex attributes from the webGL context
  37621. */
  37622. unbindAllAttributes(): void;
  37623. /**
  37624. * 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
  37625. */
  37626. releaseEffects(): void;
  37627. /**
  37628. * Dispose and release all associated resources
  37629. */
  37630. dispose(): void;
  37631. /**
  37632. * Attach a new callback raised when context lost event is fired
  37633. * @param callback defines the callback to call
  37634. */
  37635. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  37636. /**
  37637. * Attach a new callback raised when context restored event is fired
  37638. * @param callback defines the callback to call
  37639. */
  37640. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  37641. /**
  37642. * Get the current error code of the webGL context
  37643. * @returns the error code
  37644. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  37645. */
  37646. getError(): number;
  37647. private _canRenderToFloatFramebuffer;
  37648. private _canRenderToHalfFloatFramebuffer;
  37649. private _canRenderToFramebuffer;
  37650. /** @hidden */
  37651. _getWebGLTextureType(type: number): number;
  37652. /** @hidden */
  37653. _getInternalFormat(format: number): number;
  37654. /** @hidden */
  37655. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  37656. /** @hidden */
  37657. _getRGBAMultiSampleBufferFormat(type: number): number;
  37658. /** @hidden */
  37659. _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;
  37660. /**
  37661. * Loads a file from a url
  37662. * @param url url to load
  37663. * @param onSuccess callback called when the file successfully loads
  37664. * @param onProgress callback called while file is loading (if the server supports this mode)
  37665. * @param offlineProvider defines the offline provider for caching
  37666. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  37667. * @param onError callback called when the file fails to load
  37668. * @returns a file request object
  37669. * @hidden
  37670. */
  37671. 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;
  37672. /**
  37673. * Reads pixels from the current frame buffer. Please note that this function can be slow
  37674. * @param x defines the x coordinate of the rectangle where pixels must be read
  37675. * @param y defines the y coordinate of the rectangle where pixels must be read
  37676. * @param width defines the width of the rectangle where pixels must be read
  37677. * @param height defines the height of the rectangle where pixels must be read
  37678. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  37679. * @returns a Uint8Array containing RGBA colors
  37680. */
  37681. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  37682. private static _isSupported;
  37683. /**
  37684. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  37685. * @returns true if the engine can be created
  37686. * @ignorenaming
  37687. */
  37688. static isSupported(): boolean;
  37689. /**
  37690. * Find the next highest power of two.
  37691. * @param x Number to start search from.
  37692. * @return Next highest power of two.
  37693. */
  37694. static CeilingPOT(x: number): number;
  37695. /**
  37696. * Find the next lowest power of two.
  37697. * @param x Number to start search from.
  37698. * @return Next lowest power of two.
  37699. */
  37700. static FloorPOT(x: number): number;
  37701. /**
  37702. * Find the nearest power of two.
  37703. * @param x Number to start search from.
  37704. * @return Next nearest power of two.
  37705. */
  37706. static NearestPOT(x: number): number;
  37707. /**
  37708. * Get the closest exponent of two
  37709. * @param value defines the value to approximate
  37710. * @param max defines the maximum value to return
  37711. * @param mode defines how to define the closest value
  37712. * @returns closest exponent of two of the given value
  37713. */
  37714. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  37715. /**
  37716. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  37717. * @param func - the function to be called
  37718. * @param requester - the object that will request the next frame. Falls back to window.
  37719. * @returns frame number
  37720. */
  37721. static QueueNewFrame(func: () => void, requester?: any): number;
  37722. /**
  37723. * Gets host document
  37724. * @returns the host document object
  37725. */
  37726. getHostDocument(): Nullable<Document>;
  37727. }
  37728. }
  37729. declare module "babylonjs/Maths/sphericalPolynomial" {
  37730. import { Vector3 } from "babylonjs/Maths/math.vector";
  37731. import { Color3 } from "babylonjs/Maths/math.color";
  37732. /**
  37733. * Class representing spherical harmonics coefficients to the 3rd degree
  37734. */
  37735. export class SphericalHarmonics {
  37736. /**
  37737. * Defines whether or not the harmonics have been prescaled for rendering.
  37738. */
  37739. preScaled: boolean;
  37740. /**
  37741. * The l0,0 coefficients of the spherical harmonics
  37742. */
  37743. l00: Vector3;
  37744. /**
  37745. * The l1,-1 coefficients of the spherical harmonics
  37746. */
  37747. l1_1: Vector3;
  37748. /**
  37749. * The l1,0 coefficients of the spherical harmonics
  37750. */
  37751. l10: Vector3;
  37752. /**
  37753. * The l1,1 coefficients of the spherical harmonics
  37754. */
  37755. l11: Vector3;
  37756. /**
  37757. * The l2,-2 coefficients of the spherical harmonics
  37758. */
  37759. l2_2: Vector3;
  37760. /**
  37761. * The l2,-1 coefficients of the spherical harmonics
  37762. */
  37763. l2_1: Vector3;
  37764. /**
  37765. * The l2,0 coefficients of the spherical harmonics
  37766. */
  37767. l20: Vector3;
  37768. /**
  37769. * The l2,1 coefficients of the spherical harmonics
  37770. */
  37771. l21: Vector3;
  37772. /**
  37773. * The l2,2 coefficients of the spherical harmonics
  37774. */
  37775. l22: Vector3;
  37776. /**
  37777. * Adds a light to the spherical harmonics
  37778. * @param direction the direction of the light
  37779. * @param color the color of the light
  37780. * @param deltaSolidAngle the delta solid angle of the light
  37781. */
  37782. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  37783. /**
  37784. * Scales the spherical harmonics by the given amount
  37785. * @param scale the amount to scale
  37786. */
  37787. scaleInPlace(scale: number): void;
  37788. /**
  37789. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  37790. *
  37791. * ```
  37792. * E_lm = A_l * L_lm
  37793. * ```
  37794. *
  37795. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  37796. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  37797. * the scaling factors are given in equation 9.
  37798. */
  37799. convertIncidentRadianceToIrradiance(): void;
  37800. /**
  37801. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  37802. *
  37803. * ```
  37804. * L = (1/pi) * E * rho
  37805. * ```
  37806. *
  37807. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  37808. */
  37809. convertIrradianceToLambertianRadiance(): void;
  37810. /**
  37811. * Integrates the reconstruction coefficients directly in to the SH preventing further
  37812. * required operations at run time.
  37813. *
  37814. * This is simply done by scaling back the SH with Ylm constants parameter.
  37815. * The trigonometric part being applied by the shader at run time.
  37816. */
  37817. preScaleForRendering(): void;
  37818. /**
  37819. * Constructs a spherical harmonics from an array.
  37820. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  37821. * @returns the spherical harmonics
  37822. */
  37823. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  37824. /**
  37825. * Gets the spherical harmonics from polynomial
  37826. * @param polynomial the spherical polynomial
  37827. * @returns the spherical harmonics
  37828. */
  37829. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  37830. }
  37831. /**
  37832. * Class representing spherical polynomial coefficients to the 3rd degree
  37833. */
  37834. export class SphericalPolynomial {
  37835. private _harmonics;
  37836. /**
  37837. * The spherical harmonics used to create the polynomials.
  37838. */
  37839. get preScaledHarmonics(): SphericalHarmonics;
  37840. /**
  37841. * The x coefficients of the spherical polynomial
  37842. */
  37843. x: Vector3;
  37844. /**
  37845. * The y coefficients of the spherical polynomial
  37846. */
  37847. y: Vector3;
  37848. /**
  37849. * The z coefficients of the spherical polynomial
  37850. */
  37851. z: Vector3;
  37852. /**
  37853. * The xx coefficients of the spherical polynomial
  37854. */
  37855. xx: Vector3;
  37856. /**
  37857. * The yy coefficients of the spherical polynomial
  37858. */
  37859. yy: Vector3;
  37860. /**
  37861. * The zz coefficients of the spherical polynomial
  37862. */
  37863. zz: Vector3;
  37864. /**
  37865. * The xy coefficients of the spherical polynomial
  37866. */
  37867. xy: Vector3;
  37868. /**
  37869. * The yz coefficients of the spherical polynomial
  37870. */
  37871. yz: Vector3;
  37872. /**
  37873. * The zx coefficients of the spherical polynomial
  37874. */
  37875. zx: Vector3;
  37876. /**
  37877. * Adds an ambient color to the spherical polynomial
  37878. * @param color the color to add
  37879. */
  37880. addAmbient(color: Color3): void;
  37881. /**
  37882. * Scales the spherical polynomial by the given amount
  37883. * @param scale the amount to scale
  37884. */
  37885. scaleInPlace(scale: number): void;
  37886. /**
  37887. * Gets the spherical polynomial from harmonics
  37888. * @param harmonics the spherical harmonics
  37889. * @returns the spherical polynomial
  37890. */
  37891. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  37892. /**
  37893. * Constructs a spherical polynomial from an array.
  37894. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  37895. * @returns the spherical polynomial
  37896. */
  37897. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  37898. }
  37899. }
  37900. declare module "babylonjs/Materials/Textures/internalTexture" {
  37901. import { Observable } from "babylonjs/Misc/observable";
  37902. import { Nullable, int } from "babylonjs/types";
  37903. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  37904. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  37905. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  37906. /**
  37907. * Defines the source of the internal texture
  37908. */
  37909. export enum InternalTextureSource {
  37910. /**
  37911. * The source of the texture data is unknown
  37912. */
  37913. Unknown = 0,
  37914. /**
  37915. * Texture data comes from an URL
  37916. */
  37917. Url = 1,
  37918. /**
  37919. * Texture data is only used for temporary storage
  37920. */
  37921. Temp = 2,
  37922. /**
  37923. * Texture data comes from raw data (ArrayBuffer)
  37924. */
  37925. Raw = 3,
  37926. /**
  37927. * Texture content is dynamic (video or dynamic texture)
  37928. */
  37929. Dynamic = 4,
  37930. /**
  37931. * Texture content is generated by rendering to it
  37932. */
  37933. RenderTarget = 5,
  37934. /**
  37935. * Texture content is part of a multi render target process
  37936. */
  37937. MultiRenderTarget = 6,
  37938. /**
  37939. * Texture data comes from a cube data file
  37940. */
  37941. Cube = 7,
  37942. /**
  37943. * Texture data comes from a raw cube data
  37944. */
  37945. CubeRaw = 8,
  37946. /**
  37947. * Texture data come from a prefiltered cube data file
  37948. */
  37949. CubePrefiltered = 9,
  37950. /**
  37951. * Texture content is raw 3D data
  37952. */
  37953. Raw3D = 10,
  37954. /**
  37955. * Texture content is raw 2D array data
  37956. */
  37957. Raw2DArray = 11,
  37958. /**
  37959. * Texture content is a depth texture
  37960. */
  37961. Depth = 12,
  37962. /**
  37963. * Texture data comes from a raw cube data encoded with RGBD
  37964. */
  37965. CubeRawRGBD = 13
  37966. }
  37967. /**
  37968. * Class used to store data associated with WebGL texture data for the engine
  37969. * This class should not be used directly
  37970. */
  37971. export class InternalTexture {
  37972. /** @hidden */
  37973. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  37974. /**
  37975. * Defines if the texture is ready
  37976. */
  37977. isReady: boolean;
  37978. /**
  37979. * Defines if the texture is a cube texture
  37980. */
  37981. isCube: boolean;
  37982. /**
  37983. * Defines if the texture contains 3D data
  37984. */
  37985. is3D: boolean;
  37986. /**
  37987. * Defines if the texture contains 2D array data
  37988. */
  37989. is2DArray: boolean;
  37990. /**
  37991. * Defines if the texture contains multiview data
  37992. */
  37993. isMultiview: boolean;
  37994. /**
  37995. * Gets the URL used to load this texture
  37996. */
  37997. url: string;
  37998. /**
  37999. * Gets the sampling mode of the texture
  38000. */
  38001. samplingMode: number;
  38002. /**
  38003. * Gets a boolean indicating if the texture needs mipmaps generation
  38004. */
  38005. generateMipMaps: boolean;
  38006. /**
  38007. * Gets the number of samples used by the texture (WebGL2+ only)
  38008. */
  38009. samples: number;
  38010. /**
  38011. * Gets the type of the texture (int, float...)
  38012. */
  38013. type: number;
  38014. /**
  38015. * Gets the format of the texture (RGB, RGBA...)
  38016. */
  38017. format: number;
  38018. /**
  38019. * Observable called when the texture is loaded
  38020. */
  38021. onLoadedObservable: Observable<InternalTexture>;
  38022. /**
  38023. * Gets the width of the texture
  38024. */
  38025. width: number;
  38026. /**
  38027. * Gets the height of the texture
  38028. */
  38029. height: number;
  38030. /**
  38031. * Gets the depth of the texture
  38032. */
  38033. depth: number;
  38034. /**
  38035. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  38036. */
  38037. baseWidth: number;
  38038. /**
  38039. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  38040. */
  38041. baseHeight: number;
  38042. /**
  38043. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  38044. */
  38045. baseDepth: number;
  38046. /**
  38047. * Gets a boolean indicating if the texture is inverted on Y axis
  38048. */
  38049. invertY: boolean;
  38050. /** @hidden */
  38051. _invertVScale: boolean;
  38052. /** @hidden */
  38053. _associatedChannel: number;
  38054. /** @hidden */
  38055. _source: InternalTextureSource;
  38056. /** @hidden */
  38057. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  38058. /** @hidden */
  38059. _bufferView: Nullable<ArrayBufferView>;
  38060. /** @hidden */
  38061. _bufferViewArray: Nullable<ArrayBufferView[]>;
  38062. /** @hidden */
  38063. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  38064. /** @hidden */
  38065. _size: number;
  38066. /** @hidden */
  38067. _extension: string;
  38068. /** @hidden */
  38069. _files: Nullable<string[]>;
  38070. /** @hidden */
  38071. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  38072. /** @hidden */
  38073. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  38074. /** @hidden */
  38075. _framebuffer: Nullable<WebGLFramebuffer>;
  38076. /** @hidden */
  38077. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  38078. /** @hidden */
  38079. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  38080. /** @hidden */
  38081. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  38082. /** @hidden */
  38083. _attachments: Nullable<number[]>;
  38084. /** @hidden */
  38085. _textureArray: Nullable<InternalTexture[]>;
  38086. /** @hidden */
  38087. _cachedCoordinatesMode: Nullable<number>;
  38088. /** @hidden */
  38089. _cachedWrapU: Nullable<number>;
  38090. /** @hidden */
  38091. _cachedWrapV: Nullable<number>;
  38092. /** @hidden */
  38093. _cachedWrapR: Nullable<number>;
  38094. /** @hidden */
  38095. _cachedAnisotropicFilteringLevel: Nullable<number>;
  38096. /** @hidden */
  38097. _isDisabled: boolean;
  38098. /** @hidden */
  38099. _compression: Nullable<string>;
  38100. /** @hidden */
  38101. _generateStencilBuffer: boolean;
  38102. /** @hidden */
  38103. _generateDepthBuffer: boolean;
  38104. /** @hidden */
  38105. _comparisonFunction: number;
  38106. /** @hidden */
  38107. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  38108. /** @hidden */
  38109. _lodGenerationScale: number;
  38110. /** @hidden */
  38111. _lodGenerationOffset: number;
  38112. /** @hidden */
  38113. _depthStencilTexture: Nullable<InternalTexture>;
  38114. /** @hidden */
  38115. _colorTextureArray: Nullable<WebGLTexture>;
  38116. /** @hidden */
  38117. _depthStencilTextureArray: Nullable<WebGLTexture>;
  38118. /** @hidden */
  38119. _lodTextureHigh: Nullable<BaseTexture>;
  38120. /** @hidden */
  38121. _lodTextureMid: Nullable<BaseTexture>;
  38122. /** @hidden */
  38123. _lodTextureLow: Nullable<BaseTexture>;
  38124. /** @hidden */
  38125. _isRGBD: boolean;
  38126. /** @hidden */
  38127. _linearSpecularLOD: boolean;
  38128. /** @hidden */
  38129. _irradianceTexture: Nullable<BaseTexture>;
  38130. /** @hidden */
  38131. _webGLTexture: Nullable<WebGLTexture>;
  38132. /** @hidden */
  38133. _references: number;
  38134. /** @hidden */
  38135. _gammaSpace: Nullable<boolean>;
  38136. private _engine;
  38137. /**
  38138. * Gets the Engine the texture belongs to.
  38139. * @returns The babylon engine
  38140. */
  38141. getEngine(): ThinEngine;
  38142. /**
  38143. * Gets the data source type of the texture
  38144. */
  38145. get source(): InternalTextureSource;
  38146. /**
  38147. * Creates a new InternalTexture
  38148. * @param engine defines the engine to use
  38149. * @param source defines the type of data that will be used
  38150. * @param delayAllocation if the texture allocation should be delayed (default: false)
  38151. */
  38152. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  38153. /**
  38154. * Increments the number of references (ie. the number of Texture that point to it)
  38155. */
  38156. incrementReferences(): void;
  38157. /**
  38158. * Change the size of the texture (not the size of the content)
  38159. * @param width defines the new width
  38160. * @param height defines the new height
  38161. * @param depth defines the new depth (1 by default)
  38162. */
  38163. updateSize(width: int, height: int, depth?: int): void;
  38164. /** @hidden */
  38165. _rebuild(): void;
  38166. /** @hidden */
  38167. _swapAndDie(target: InternalTexture): void;
  38168. /**
  38169. * Dispose the current allocated resources
  38170. */
  38171. dispose(): void;
  38172. }
  38173. }
  38174. declare module "babylonjs/Audio/analyser" {
  38175. import { Scene } from "babylonjs/scene";
  38176. /**
  38177. * Class used to work with sound analyzer using fast fourier transform (FFT)
  38178. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  38179. */
  38180. export class Analyser {
  38181. /**
  38182. * Gets or sets the smoothing
  38183. * @ignorenaming
  38184. */
  38185. SMOOTHING: number;
  38186. /**
  38187. * Gets or sets the FFT table size
  38188. * @ignorenaming
  38189. */
  38190. FFT_SIZE: number;
  38191. /**
  38192. * Gets or sets the bar graph amplitude
  38193. * @ignorenaming
  38194. */
  38195. BARGRAPHAMPLITUDE: number;
  38196. /**
  38197. * Gets or sets the position of the debug canvas
  38198. * @ignorenaming
  38199. */
  38200. DEBUGCANVASPOS: {
  38201. x: number;
  38202. y: number;
  38203. };
  38204. /**
  38205. * Gets or sets the debug canvas size
  38206. * @ignorenaming
  38207. */
  38208. DEBUGCANVASSIZE: {
  38209. width: number;
  38210. height: number;
  38211. };
  38212. private _byteFreqs;
  38213. private _byteTime;
  38214. private _floatFreqs;
  38215. private _webAudioAnalyser;
  38216. private _debugCanvas;
  38217. private _debugCanvasContext;
  38218. private _scene;
  38219. private _registerFunc;
  38220. private _audioEngine;
  38221. /**
  38222. * Creates a new analyser
  38223. * @param scene defines hosting scene
  38224. */
  38225. constructor(scene: Scene);
  38226. /**
  38227. * Get the number of data values you will have to play with for the visualization
  38228. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  38229. * @returns a number
  38230. */
  38231. getFrequencyBinCount(): number;
  38232. /**
  38233. * Gets the current frequency data as a byte array
  38234. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  38235. * @returns a Uint8Array
  38236. */
  38237. getByteFrequencyData(): Uint8Array;
  38238. /**
  38239. * Gets the current waveform as a byte array
  38240. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  38241. * @returns a Uint8Array
  38242. */
  38243. getByteTimeDomainData(): Uint8Array;
  38244. /**
  38245. * Gets the current frequency data as a float array
  38246. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  38247. * @returns a Float32Array
  38248. */
  38249. getFloatFrequencyData(): Float32Array;
  38250. /**
  38251. * Renders the debug canvas
  38252. */
  38253. drawDebugCanvas(): void;
  38254. /**
  38255. * Stops rendering the debug canvas and removes it
  38256. */
  38257. stopDebugCanvas(): void;
  38258. /**
  38259. * Connects two audio nodes
  38260. * @param inputAudioNode defines first node to connect
  38261. * @param outputAudioNode defines second node to connect
  38262. */
  38263. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  38264. /**
  38265. * Releases all associated resources
  38266. */
  38267. dispose(): void;
  38268. }
  38269. }
  38270. declare module "babylonjs/Audio/audioEngine" {
  38271. import { IDisposable } from "babylonjs/scene";
  38272. import { Analyser } from "babylonjs/Audio/analyser";
  38273. import { Nullable } from "babylonjs/types";
  38274. import { Observable } from "babylonjs/Misc/observable";
  38275. /**
  38276. * This represents an audio engine and it is responsible
  38277. * to play, synchronize and analyse sounds throughout the application.
  38278. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  38279. */
  38280. export interface IAudioEngine extends IDisposable {
  38281. /**
  38282. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  38283. */
  38284. readonly canUseWebAudio: boolean;
  38285. /**
  38286. * Gets the current AudioContext if available.
  38287. */
  38288. readonly audioContext: Nullable<AudioContext>;
  38289. /**
  38290. * The master gain node defines the global audio volume of your audio engine.
  38291. */
  38292. readonly masterGain: GainNode;
  38293. /**
  38294. * Gets whether or not mp3 are supported by your browser.
  38295. */
  38296. readonly isMP3supported: boolean;
  38297. /**
  38298. * Gets whether or not ogg are supported by your browser.
  38299. */
  38300. readonly isOGGsupported: boolean;
  38301. /**
  38302. * Defines if Babylon should emit a warning if WebAudio is not supported.
  38303. * @ignoreNaming
  38304. */
  38305. WarnedWebAudioUnsupported: boolean;
  38306. /**
  38307. * Defines if the audio engine relies on a custom unlocked button.
  38308. * In this case, the embedded button will not be displayed.
  38309. */
  38310. useCustomUnlockedButton: boolean;
  38311. /**
  38312. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  38313. */
  38314. readonly unlocked: boolean;
  38315. /**
  38316. * Event raised when audio has been unlocked on the browser.
  38317. */
  38318. onAudioUnlockedObservable: Observable<AudioEngine>;
  38319. /**
  38320. * Event raised when audio has been locked on the browser.
  38321. */
  38322. onAudioLockedObservable: Observable<AudioEngine>;
  38323. /**
  38324. * Flags the audio engine in Locked state.
  38325. * This happens due to new browser policies preventing audio to autoplay.
  38326. */
  38327. lock(): void;
  38328. /**
  38329. * Unlocks the audio engine once a user action has been done on the dom.
  38330. * This is helpful to resume play once browser policies have been satisfied.
  38331. */
  38332. unlock(): void;
  38333. /**
  38334. * Gets the global volume sets on the master gain.
  38335. * @returns the global volume if set or -1 otherwise
  38336. */
  38337. getGlobalVolume(): number;
  38338. /**
  38339. * Sets the global volume of your experience (sets on the master gain).
  38340. * @param newVolume Defines the new global volume of the application
  38341. */
  38342. setGlobalVolume(newVolume: number): void;
  38343. /**
  38344. * Connect the audio engine to an audio analyser allowing some amazing
  38345. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  38346. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  38347. * @param analyser The analyser to connect to the engine
  38348. */
  38349. connectToAnalyser(analyser: Analyser): void;
  38350. }
  38351. /**
  38352. * This represents the default audio engine used in babylon.
  38353. * It is responsible to play, synchronize and analyse sounds throughout the application.
  38354. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  38355. */
  38356. export class AudioEngine implements IAudioEngine {
  38357. private _audioContext;
  38358. private _audioContextInitialized;
  38359. private _muteButton;
  38360. private _hostElement;
  38361. /**
  38362. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  38363. */
  38364. canUseWebAudio: boolean;
  38365. /**
  38366. * The master gain node defines the global audio volume of your audio engine.
  38367. */
  38368. masterGain: GainNode;
  38369. /**
  38370. * Defines if Babylon should emit a warning if WebAudio is not supported.
  38371. * @ignoreNaming
  38372. */
  38373. WarnedWebAudioUnsupported: boolean;
  38374. /**
  38375. * Gets whether or not mp3 are supported by your browser.
  38376. */
  38377. isMP3supported: boolean;
  38378. /**
  38379. * Gets whether or not ogg are supported by your browser.
  38380. */
  38381. isOGGsupported: boolean;
  38382. /**
  38383. * Gets whether audio has been unlocked on the device.
  38384. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  38385. * a user interaction has happened.
  38386. */
  38387. unlocked: boolean;
  38388. /**
  38389. * Defines if the audio engine relies on a custom unlocked button.
  38390. * In this case, the embedded button will not be displayed.
  38391. */
  38392. useCustomUnlockedButton: boolean;
  38393. /**
  38394. * Event raised when audio has been unlocked on the browser.
  38395. */
  38396. onAudioUnlockedObservable: Observable<AudioEngine>;
  38397. /**
  38398. * Event raised when audio has been locked on the browser.
  38399. */
  38400. onAudioLockedObservable: Observable<AudioEngine>;
  38401. /**
  38402. * Gets the current AudioContext if available.
  38403. */
  38404. get audioContext(): Nullable<AudioContext>;
  38405. private _connectedAnalyser;
  38406. /**
  38407. * Instantiates a new audio engine.
  38408. *
  38409. * There should be only one per page as some browsers restrict the number
  38410. * of audio contexts you can create.
  38411. * @param hostElement defines the host element where to display the mute icon if necessary
  38412. */
  38413. constructor(hostElement?: Nullable<HTMLElement>);
  38414. /**
  38415. * Flags the audio engine in Locked state.
  38416. * This happens due to new browser policies preventing audio to autoplay.
  38417. */
  38418. lock(): void;
  38419. /**
  38420. * Unlocks the audio engine once a user action has been done on the dom.
  38421. * This is helpful to resume play once browser policies have been satisfied.
  38422. */
  38423. unlock(): void;
  38424. private _resumeAudioContext;
  38425. private _initializeAudioContext;
  38426. private _tryToRun;
  38427. private _triggerRunningState;
  38428. private _triggerSuspendedState;
  38429. private _displayMuteButton;
  38430. private _moveButtonToTopLeft;
  38431. private _onResize;
  38432. private _hideMuteButton;
  38433. /**
  38434. * Destroy and release the resources associated with the audio ccontext.
  38435. */
  38436. dispose(): void;
  38437. /**
  38438. * Gets the global volume sets on the master gain.
  38439. * @returns the global volume if set or -1 otherwise
  38440. */
  38441. getGlobalVolume(): number;
  38442. /**
  38443. * Sets the global volume of your experience (sets on the master gain).
  38444. * @param newVolume Defines the new global volume of the application
  38445. */
  38446. setGlobalVolume(newVolume: number): void;
  38447. /**
  38448. * Connect the audio engine to an audio analyser allowing some amazing
  38449. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  38450. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  38451. * @param analyser The analyser to connect to the engine
  38452. */
  38453. connectToAnalyser(analyser: Analyser): void;
  38454. }
  38455. }
  38456. declare module "babylonjs/Loading/loadingScreen" {
  38457. /**
  38458. * Interface used to present a loading screen while loading a scene
  38459. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  38460. */
  38461. export interface ILoadingScreen {
  38462. /**
  38463. * Function called to display the loading screen
  38464. */
  38465. displayLoadingUI: () => void;
  38466. /**
  38467. * Function called to hide the loading screen
  38468. */
  38469. hideLoadingUI: () => void;
  38470. /**
  38471. * Gets or sets the color to use for the background
  38472. */
  38473. loadingUIBackgroundColor: string;
  38474. /**
  38475. * Gets or sets the text to display while loading
  38476. */
  38477. loadingUIText: string;
  38478. }
  38479. /**
  38480. * Class used for the default loading screen
  38481. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  38482. */
  38483. export class DefaultLoadingScreen implements ILoadingScreen {
  38484. private _renderingCanvas;
  38485. private _loadingText;
  38486. private _loadingDivBackgroundColor;
  38487. private _loadingDiv;
  38488. private _loadingTextDiv;
  38489. /** Gets or sets the logo url to use for the default loading screen */
  38490. static DefaultLogoUrl: string;
  38491. /** Gets or sets the spinner url to use for the default loading screen */
  38492. static DefaultSpinnerUrl: string;
  38493. /**
  38494. * Creates a new default loading screen
  38495. * @param _renderingCanvas defines the canvas used to render the scene
  38496. * @param _loadingText defines the default text to display
  38497. * @param _loadingDivBackgroundColor defines the default background color
  38498. */
  38499. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  38500. /**
  38501. * Function called to display the loading screen
  38502. */
  38503. displayLoadingUI(): void;
  38504. /**
  38505. * Function called to hide the loading screen
  38506. */
  38507. hideLoadingUI(): void;
  38508. /**
  38509. * Gets or sets the text to display while loading
  38510. */
  38511. set loadingUIText(text: string);
  38512. get loadingUIText(): string;
  38513. /**
  38514. * Gets or sets the color to use for the background
  38515. */
  38516. get loadingUIBackgroundColor(): string;
  38517. set loadingUIBackgroundColor(color: string);
  38518. private _resizeLoadingUI;
  38519. }
  38520. }
  38521. declare module "babylonjs/Misc/customAnimationFrameRequester" {
  38522. /**
  38523. * Interface for any object that can request an animation frame
  38524. */
  38525. export interface ICustomAnimationFrameRequester {
  38526. /**
  38527. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  38528. */
  38529. renderFunction?: Function;
  38530. /**
  38531. * Called to request the next frame to render to
  38532. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  38533. */
  38534. requestAnimationFrame: Function;
  38535. /**
  38536. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  38537. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  38538. */
  38539. requestID?: number;
  38540. }
  38541. }
  38542. declare module "babylonjs/Misc/performanceMonitor" {
  38543. /**
  38544. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  38545. */
  38546. export class PerformanceMonitor {
  38547. private _enabled;
  38548. private _rollingFrameTime;
  38549. private _lastFrameTimeMs;
  38550. /**
  38551. * constructor
  38552. * @param frameSampleSize The number of samples required to saturate the sliding window
  38553. */
  38554. constructor(frameSampleSize?: number);
  38555. /**
  38556. * Samples current frame
  38557. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  38558. */
  38559. sampleFrame(timeMs?: number): void;
  38560. /**
  38561. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  38562. */
  38563. get averageFrameTime(): number;
  38564. /**
  38565. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  38566. */
  38567. get averageFrameTimeVariance(): number;
  38568. /**
  38569. * Returns the frame time of the most recent frame
  38570. */
  38571. get instantaneousFrameTime(): number;
  38572. /**
  38573. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  38574. */
  38575. get averageFPS(): number;
  38576. /**
  38577. * Returns the average framerate in frames per second using the most recent frame time
  38578. */
  38579. get instantaneousFPS(): number;
  38580. /**
  38581. * Returns true if enough samples have been taken to completely fill the sliding window
  38582. */
  38583. get isSaturated(): boolean;
  38584. /**
  38585. * Enables contributions to the sliding window sample set
  38586. */
  38587. enable(): void;
  38588. /**
  38589. * Disables contributions to the sliding window sample set
  38590. * Samples will not be interpolated over the disabled period
  38591. */
  38592. disable(): void;
  38593. /**
  38594. * Returns true if sampling is enabled
  38595. */
  38596. get isEnabled(): boolean;
  38597. /**
  38598. * Resets performance monitor
  38599. */
  38600. reset(): void;
  38601. }
  38602. /**
  38603. * RollingAverage
  38604. *
  38605. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  38606. */
  38607. export class RollingAverage {
  38608. /**
  38609. * Current average
  38610. */
  38611. average: number;
  38612. /**
  38613. * Current variance
  38614. */
  38615. variance: number;
  38616. protected _samples: Array<number>;
  38617. protected _sampleCount: number;
  38618. protected _pos: number;
  38619. protected _m2: number;
  38620. /**
  38621. * constructor
  38622. * @param length The number of samples required to saturate the sliding window
  38623. */
  38624. constructor(length: number);
  38625. /**
  38626. * Adds a sample to the sample set
  38627. * @param v The sample value
  38628. */
  38629. add(v: number): void;
  38630. /**
  38631. * Returns previously added values or null if outside of history or outside the sliding window domain
  38632. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  38633. * @return Value previously recorded with add() or null if outside of range
  38634. */
  38635. history(i: number): number;
  38636. /**
  38637. * Returns true if enough samples have been taken to completely fill the sliding window
  38638. * @return true if sample-set saturated
  38639. */
  38640. isSaturated(): boolean;
  38641. /**
  38642. * Resets the rolling average (equivalent to 0 samples taken so far)
  38643. */
  38644. reset(): void;
  38645. /**
  38646. * Wraps a value around the sample range boundaries
  38647. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  38648. * @return Wrapped position in sample range
  38649. */
  38650. protected _wrapPosition(i: number): number;
  38651. }
  38652. }
  38653. declare module "babylonjs/Misc/perfCounter" {
  38654. /**
  38655. * This class is used to track a performance counter which is number based.
  38656. * The user has access to many properties which give statistics of different nature.
  38657. *
  38658. * The implementer can track two kinds of Performance Counter: time and count.
  38659. * 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.
  38660. * 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.
  38661. */
  38662. export class PerfCounter {
  38663. /**
  38664. * Gets or sets a global boolean to turn on and off all the counters
  38665. */
  38666. static Enabled: boolean;
  38667. /**
  38668. * Returns the smallest value ever
  38669. */
  38670. get min(): number;
  38671. /**
  38672. * Returns the biggest value ever
  38673. */
  38674. get max(): number;
  38675. /**
  38676. * Returns the average value since the performance counter is running
  38677. */
  38678. get average(): number;
  38679. /**
  38680. * Returns the average value of the last second the counter was monitored
  38681. */
  38682. get lastSecAverage(): number;
  38683. /**
  38684. * Returns the current value
  38685. */
  38686. get current(): number;
  38687. /**
  38688. * Gets the accumulated total
  38689. */
  38690. get total(): number;
  38691. /**
  38692. * Gets the total value count
  38693. */
  38694. get count(): number;
  38695. /**
  38696. * Creates a new counter
  38697. */
  38698. constructor();
  38699. /**
  38700. * Call this method to start monitoring a new frame.
  38701. * 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.
  38702. */
  38703. fetchNewFrame(): void;
  38704. /**
  38705. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  38706. * @param newCount the count value to add to the monitored count
  38707. * @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.
  38708. */
  38709. addCount(newCount: number, fetchResult: boolean): void;
  38710. /**
  38711. * Start monitoring this performance counter
  38712. */
  38713. beginMonitoring(): void;
  38714. /**
  38715. * Compute the time lapsed since the previous beginMonitoring() call.
  38716. * @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
  38717. */
  38718. endMonitoring(newFrame?: boolean): void;
  38719. private _fetchResult;
  38720. private _startMonitoringTime;
  38721. private _min;
  38722. private _max;
  38723. private _average;
  38724. private _current;
  38725. private _totalValueCount;
  38726. private _totalAccumulated;
  38727. private _lastSecAverage;
  38728. private _lastSecAccumulated;
  38729. private _lastSecTime;
  38730. private _lastSecValueCount;
  38731. }
  38732. }
  38733. declare module "babylonjs/Engines/Extensions/engine.readTexture" {
  38734. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  38735. import { Nullable } from "babylonjs/types";
  38736. module "babylonjs/Engines/thinEngine" {
  38737. interface ThinEngine {
  38738. /** @hidden */
  38739. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  38740. }
  38741. }
  38742. }
  38743. declare module "babylonjs/Engines/engine" {
  38744. import { Observable } from "babylonjs/Misc/observable";
  38745. import { Nullable } from "babylonjs/types";
  38746. import { Scene } from "babylonjs/scene";
  38747. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  38748. import { IAudioEngine } from "babylonjs/Audio/audioEngine";
  38749. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  38750. import { ILoadingScreen } from "babylonjs/Loading/loadingScreen";
  38751. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  38752. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  38753. import { ICustomAnimationFrameRequester } from "babylonjs/Misc/customAnimationFrameRequester";
  38754. import { ThinEngine, EngineOptions } from "babylonjs/Engines/thinEngine";
  38755. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  38756. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  38757. import { PerformanceMonitor } from "babylonjs/Misc/performanceMonitor";
  38758. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  38759. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  38760. import "babylonjs/Engines/Extensions/engine.alpha";
  38761. import "babylonjs/Engines/Extensions/engine.readTexture";
  38762. import "babylonjs/Engines/Extensions/engine.dynamicBuffer";
  38763. import { Material } from "babylonjs/Materials/material";
  38764. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  38765. /**
  38766. * Defines the interface used by display changed events
  38767. */
  38768. export interface IDisplayChangedEventArgs {
  38769. /** Gets the vrDisplay object (if any) */
  38770. vrDisplay: Nullable<any>;
  38771. /** Gets a boolean indicating if webVR is supported */
  38772. vrSupported: boolean;
  38773. }
  38774. /**
  38775. * Defines the interface used by objects containing a viewport (like a camera)
  38776. */
  38777. interface IViewportOwnerLike {
  38778. /**
  38779. * Gets or sets the viewport
  38780. */
  38781. viewport: IViewportLike;
  38782. }
  38783. /**
  38784. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  38785. */
  38786. export class Engine extends ThinEngine {
  38787. /** Defines that alpha blending is disabled */
  38788. static readonly ALPHA_DISABLE: number;
  38789. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  38790. static readonly ALPHA_ADD: number;
  38791. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  38792. static readonly ALPHA_COMBINE: number;
  38793. /** Defines that alpha blending to DEST - SRC * DEST */
  38794. static readonly ALPHA_SUBTRACT: number;
  38795. /** Defines that alpha blending to SRC * DEST */
  38796. static readonly ALPHA_MULTIPLY: number;
  38797. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  38798. static readonly ALPHA_MAXIMIZED: number;
  38799. /** Defines that alpha blending to SRC + DEST */
  38800. static readonly ALPHA_ONEONE: number;
  38801. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  38802. static readonly ALPHA_PREMULTIPLIED: number;
  38803. /**
  38804. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  38805. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  38806. */
  38807. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  38808. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  38809. static readonly ALPHA_INTERPOLATE: number;
  38810. /**
  38811. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  38812. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  38813. */
  38814. static readonly ALPHA_SCREENMODE: number;
  38815. /** Defines that the ressource is not delayed*/
  38816. static readonly DELAYLOADSTATE_NONE: number;
  38817. /** Defines that the ressource was successfully delay loaded */
  38818. static readonly DELAYLOADSTATE_LOADED: number;
  38819. /** Defines that the ressource is currently delay loading */
  38820. static readonly DELAYLOADSTATE_LOADING: number;
  38821. /** Defines that the ressource is delayed and has not started loading */
  38822. static readonly DELAYLOADSTATE_NOTLOADED: number;
  38823. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  38824. static readonly NEVER: number;
  38825. /** 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 */
  38826. static readonly ALWAYS: number;
  38827. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  38828. static readonly LESS: number;
  38829. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  38830. static readonly EQUAL: number;
  38831. /** 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 */
  38832. static readonly LEQUAL: number;
  38833. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  38834. static readonly GREATER: number;
  38835. /** 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 */
  38836. static readonly GEQUAL: number;
  38837. /** 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 */
  38838. static readonly NOTEQUAL: number;
  38839. /** Passed to stencilOperation to specify that stencil value must be kept */
  38840. static readonly KEEP: number;
  38841. /** Passed to stencilOperation to specify that stencil value must be replaced */
  38842. static readonly REPLACE: number;
  38843. /** Passed to stencilOperation to specify that stencil value must be incremented */
  38844. static readonly INCR: number;
  38845. /** Passed to stencilOperation to specify that stencil value must be decremented */
  38846. static readonly DECR: number;
  38847. /** Passed to stencilOperation to specify that stencil value must be inverted */
  38848. static readonly INVERT: number;
  38849. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  38850. static readonly INCR_WRAP: number;
  38851. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  38852. static readonly DECR_WRAP: number;
  38853. /** Texture is not repeating outside of 0..1 UVs */
  38854. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  38855. /** Texture is repeating outside of 0..1 UVs */
  38856. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  38857. /** Texture is repeating and mirrored */
  38858. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  38859. /** ALPHA */
  38860. static readonly TEXTUREFORMAT_ALPHA: number;
  38861. /** LUMINANCE */
  38862. static readonly TEXTUREFORMAT_LUMINANCE: number;
  38863. /** LUMINANCE_ALPHA */
  38864. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  38865. /** RGB */
  38866. static readonly TEXTUREFORMAT_RGB: number;
  38867. /** RGBA */
  38868. static readonly TEXTUREFORMAT_RGBA: number;
  38869. /** RED */
  38870. static readonly TEXTUREFORMAT_RED: number;
  38871. /** RED (2nd reference) */
  38872. static readonly TEXTUREFORMAT_R: number;
  38873. /** RG */
  38874. static readonly TEXTUREFORMAT_RG: number;
  38875. /** RED_INTEGER */
  38876. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  38877. /** RED_INTEGER (2nd reference) */
  38878. static readonly TEXTUREFORMAT_R_INTEGER: number;
  38879. /** RG_INTEGER */
  38880. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  38881. /** RGB_INTEGER */
  38882. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  38883. /** RGBA_INTEGER */
  38884. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  38885. /** UNSIGNED_BYTE */
  38886. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  38887. /** UNSIGNED_BYTE (2nd reference) */
  38888. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  38889. /** FLOAT */
  38890. static readonly TEXTURETYPE_FLOAT: number;
  38891. /** HALF_FLOAT */
  38892. static readonly TEXTURETYPE_HALF_FLOAT: number;
  38893. /** BYTE */
  38894. static readonly TEXTURETYPE_BYTE: number;
  38895. /** SHORT */
  38896. static readonly TEXTURETYPE_SHORT: number;
  38897. /** UNSIGNED_SHORT */
  38898. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  38899. /** INT */
  38900. static readonly TEXTURETYPE_INT: number;
  38901. /** UNSIGNED_INT */
  38902. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  38903. /** UNSIGNED_SHORT_4_4_4_4 */
  38904. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  38905. /** UNSIGNED_SHORT_5_5_5_1 */
  38906. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  38907. /** UNSIGNED_SHORT_5_6_5 */
  38908. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  38909. /** UNSIGNED_INT_2_10_10_10_REV */
  38910. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  38911. /** UNSIGNED_INT_24_8 */
  38912. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  38913. /** UNSIGNED_INT_10F_11F_11F_REV */
  38914. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  38915. /** UNSIGNED_INT_5_9_9_9_REV */
  38916. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  38917. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  38918. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  38919. /** nearest is mag = nearest and min = nearest and mip = linear */
  38920. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  38921. /** Bilinear is mag = linear and min = linear and mip = nearest */
  38922. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  38923. /** Trilinear is mag = linear and min = linear and mip = linear */
  38924. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  38925. /** nearest is mag = nearest and min = nearest and mip = linear */
  38926. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  38927. /** Bilinear is mag = linear and min = linear and mip = nearest */
  38928. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  38929. /** Trilinear is mag = linear and min = linear and mip = linear */
  38930. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  38931. /** mag = nearest and min = nearest and mip = nearest */
  38932. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  38933. /** mag = nearest and min = linear and mip = nearest */
  38934. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  38935. /** mag = nearest and min = linear and mip = linear */
  38936. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  38937. /** mag = nearest and min = linear and mip = none */
  38938. static readonly TEXTURE_NEAREST_LINEAR: number;
  38939. /** mag = nearest and min = nearest and mip = none */
  38940. static readonly TEXTURE_NEAREST_NEAREST: number;
  38941. /** mag = linear and min = nearest and mip = nearest */
  38942. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  38943. /** mag = linear and min = nearest and mip = linear */
  38944. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  38945. /** mag = linear and min = linear and mip = none */
  38946. static readonly TEXTURE_LINEAR_LINEAR: number;
  38947. /** mag = linear and min = nearest and mip = none */
  38948. static readonly TEXTURE_LINEAR_NEAREST: number;
  38949. /** Explicit coordinates mode */
  38950. static readonly TEXTURE_EXPLICIT_MODE: number;
  38951. /** Spherical coordinates mode */
  38952. static readonly TEXTURE_SPHERICAL_MODE: number;
  38953. /** Planar coordinates mode */
  38954. static readonly TEXTURE_PLANAR_MODE: number;
  38955. /** Cubic coordinates mode */
  38956. static readonly TEXTURE_CUBIC_MODE: number;
  38957. /** Projection coordinates mode */
  38958. static readonly TEXTURE_PROJECTION_MODE: number;
  38959. /** Skybox coordinates mode */
  38960. static readonly TEXTURE_SKYBOX_MODE: number;
  38961. /** Inverse Cubic coordinates mode */
  38962. static readonly TEXTURE_INVCUBIC_MODE: number;
  38963. /** Equirectangular coordinates mode */
  38964. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  38965. /** Equirectangular Fixed coordinates mode */
  38966. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  38967. /** Equirectangular Fixed Mirrored coordinates mode */
  38968. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  38969. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  38970. static readonly SCALEMODE_FLOOR: number;
  38971. /** Defines that texture rescaling will look for the nearest power of 2 size */
  38972. static readonly SCALEMODE_NEAREST: number;
  38973. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  38974. static readonly SCALEMODE_CEILING: number;
  38975. /**
  38976. * Returns the current npm package of the sdk
  38977. */
  38978. static get NpmPackage(): string;
  38979. /**
  38980. * Returns the current version of the framework
  38981. */
  38982. static get Version(): string;
  38983. /** Gets the list of created engines */
  38984. static get Instances(): Engine[];
  38985. /**
  38986. * Gets the latest created engine
  38987. */
  38988. static get LastCreatedEngine(): Nullable<Engine>;
  38989. /**
  38990. * Gets the latest created scene
  38991. */
  38992. static get LastCreatedScene(): Nullable<Scene>;
  38993. /**
  38994. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  38995. * @param flag defines which part of the materials must be marked as dirty
  38996. * @param predicate defines a predicate used to filter which materials should be affected
  38997. */
  38998. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  38999. /**
  39000. * Method called to create the default loading screen.
  39001. * This can be overriden in your own app.
  39002. * @param canvas The rendering canvas element
  39003. * @returns The loading screen
  39004. */
  39005. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  39006. /**
  39007. * Method called to create the default rescale post process on each engine.
  39008. */
  39009. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  39010. /**
  39011. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  39012. **/
  39013. enableOfflineSupport: boolean;
  39014. /**
  39015. * 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)
  39016. **/
  39017. disableManifestCheck: boolean;
  39018. /**
  39019. * Gets the list of created scenes
  39020. */
  39021. scenes: Scene[];
  39022. /**
  39023. * Event raised when a new scene is created
  39024. */
  39025. onNewSceneAddedObservable: Observable<Scene>;
  39026. /**
  39027. * Gets the list of created postprocesses
  39028. */
  39029. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  39030. /**
  39031. * Gets a boolean indicating if the pointer is currently locked
  39032. */
  39033. isPointerLock: boolean;
  39034. /**
  39035. * Observable event triggered each time the rendering canvas is resized
  39036. */
  39037. onResizeObservable: Observable<Engine>;
  39038. /**
  39039. * Observable event triggered each time the canvas loses focus
  39040. */
  39041. onCanvasBlurObservable: Observable<Engine>;
  39042. /**
  39043. * Observable event triggered each time the canvas gains focus
  39044. */
  39045. onCanvasFocusObservable: Observable<Engine>;
  39046. /**
  39047. * Observable event triggered each time the canvas receives pointerout event
  39048. */
  39049. onCanvasPointerOutObservable: Observable<PointerEvent>;
  39050. /**
  39051. * Observable raised when the engine begins a new frame
  39052. */
  39053. onBeginFrameObservable: Observable<Engine>;
  39054. /**
  39055. * If set, will be used to request the next animation frame for the render loop
  39056. */
  39057. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  39058. /**
  39059. * Observable raised when the engine ends the current frame
  39060. */
  39061. onEndFrameObservable: Observable<Engine>;
  39062. /**
  39063. * Observable raised when the engine is about to compile a shader
  39064. */
  39065. onBeforeShaderCompilationObservable: Observable<Engine>;
  39066. /**
  39067. * Observable raised when the engine has jsut compiled a shader
  39068. */
  39069. onAfterShaderCompilationObservable: Observable<Engine>;
  39070. /**
  39071. * Gets the audio engine
  39072. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  39073. * @ignorenaming
  39074. */
  39075. static audioEngine: IAudioEngine;
  39076. /**
  39077. * Default AudioEngine factory responsible of creating the Audio Engine.
  39078. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  39079. */
  39080. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  39081. /**
  39082. * Default offline support factory responsible of creating a tool used to store data locally.
  39083. * By default, this will create a Database object if the workload has been embedded.
  39084. */
  39085. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  39086. private _loadingScreen;
  39087. private _pointerLockRequested;
  39088. private _rescalePostProcess;
  39089. private _deterministicLockstep;
  39090. private _lockstepMaxSteps;
  39091. private _timeStep;
  39092. protected get _supportsHardwareTextureRescaling(): boolean;
  39093. private _fps;
  39094. private _deltaTime;
  39095. /** @hidden */
  39096. _drawCalls: PerfCounter;
  39097. /** 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 */
  39098. canvasTabIndex: number;
  39099. /**
  39100. * Turn this value on if you want to pause FPS computation when in background
  39101. */
  39102. disablePerformanceMonitorInBackground: boolean;
  39103. private _performanceMonitor;
  39104. /**
  39105. * Gets the performance monitor attached to this engine
  39106. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  39107. */
  39108. get performanceMonitor(): PerformanceMonitor;
  39109. private _onFocus;
  39110. private _onBlur;
  39111. private _onCanvasPointerOut;
  39112. private _onCanvasBlur;
  39113. private _onCanvasFocus;
  39114. private _onFullscreenChange;
  39115. private _onPointerLockChange;
  39116. /**
  39117. * Gets the HTML element used to attach event listeners
  39118. * @returns a HTML element
  39119. */
  39120. getInputElement(): Nullable<HTMLElement>;
  39121. /**
  39122. * Creates a new engine
  39123. * @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
  39124. * @param antialias defines enable antialiasing (default: false)
  39125. * @param options defines further options to be sent to the getContext() function
  39126. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  39127. */
  39128. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  39129. /**
  39130. * Gets current aspect ratio
  39131. * @param viewportOwner defines the camera to use to get the aspect ratio
  39132. * @param useScreen defines if screen size must be used (or the current render target if any)
  39133. * @returns a number defining the aspect ratio
  39134. */
  39135. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  39136. /**
  39137. * Gets current screen aspect ratio
  39138. * @returns a number defining the aspect ratio
  39139. */
  39140. getScreenAspectRatio(): number;
  39141. /**
  39142. * Gets the client rect of the HTML canvas attached with the current webGL context
  39143. * @returns a client rectanglee
  39144. */
  39145. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  39146. /**
  39147. * Gets the client rect of the HTML element used for events
  39148. * @returns a client rectanglee
  39149. */
  39150. getInputElementClientRect(): Nullable<ClientRect>;
  39151. /**
  39152. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  39153. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  39154. * @returns true if engine is in deterministic lock step mode
  39155. */
  39156. isDeterministicLockStep(): boolean;
  39157. /**
  39158. * Gets the max steps when engine is running in deterministic lock step
  39159. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  39160. * @returns the max steps
  39161. */
  39162. getLockstepMaxSteps(): number;
  39163. /**
  39164. * Returns the time in ms between steps when using deterministic lock step.
  39165. * @returns time step in (ms)
  39166. */
  39167. getTimeStep(): number;
  39168. /**
  39169. * Force the mipmap generation for the given render target texture
  39170. * @param texture defines the render target texture to use
  39171. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  39172. */
  39173. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  39174. /** States */
  39175. /**
  39176. * Set various states to the webGL context
  39177. * @param culling defines backface culling state
  39178. * @param zOffset defines the value to apply to zOffset (0 by default)
  39179. * @param force defines if states must be applied even if cache is up to date
  39180. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  39181. */
  39182. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  39183. /**
  39184. * Set the z offset to apply to current rendering
  39185. * @param value defines the offset to apply
  39186. */
  39187. setZOffset(value: number): void;
  39188. /**
  39189. * Gets the current value of the zOffset
  39190. * @returns the current zOffset state
  39191. */
  39192. getZOffset(): number;
  39193. /**
  39194. * Enable or disable depth buffering
  39195. * @param enable defines the state to set
  39196. */
  39197. setDepthBuffer(enable: boolean): void;
  39198. /**
  39199. * Gets a boolean indicating if depth writing is enabled
  39200. * @returns the current depth writing state
  39201. */
  39202. getDepthWrite(): boolean;
  39203. /**
  39204. * Enable or disable depth writing
  39205. * @param enable defines the state to set
  39206. */
  39207. setDepthWrite(enable: boolean): void;
  39208. /**
  39209. * Gets a boolean indicating if stencil buffer is enabled
  39210. * @returns the current stencil buffer state
  39211. */
  39212. getStencilBuffer(): boolean;
  39213. /**
  39214. * Enable or disable the stencil buffer
  39215. * @param enable defines if the stencil buffer must be enabled or disabled
  39216. */
  39217. setStencilBuffer(enable: boolean): void;
  39218. /**
  39219. * Gets the current stencil mask
  39220. * @returns a number defining the new stencil mask to use
  39221. */
  39222. getStencilMask(): number;
  39223. /**
  39224. * Sets the current stencil mask
  39225. * @param mask defines the new stencil mask to use
  39226. */
  39227. setStencilMask(mask: number): void;
  39228. /**
  39229. * Gets the current stencil function
  39230. * @returns a number defining the stencil function to use
  39231. */
  39232. getStencilFunction(): number;
  39233. /**
  39234. * Gets the current stencil reference value
  39235. * @returns a number defining the stencil reference value to use
  39236. */
  39237. getStencilFunctionReference(): number;
  39238. /**
  39239. * Gets the current stencil mask
  39240. * @returns a number defining the stencil mask to use
  39241. */
  39242. getStencilFunctionMask(): number;
  39243. /**
  39244. * Sets the current stencil function
  39245. * @param stencilFunc defines the new stencil function to use
  39246. */
  39247. setStencilFunction(stencilFunc: number): void;
  39248. /**
  39249. * Sets the current stencil reference
  39250. * @param reference defines the new stencil reference to use
  39251. */
  39252. setStencilFunctionReference(reference: number): void;
  39253. /**
  39254. * Sets the current stencil mask
  39255. * @param mask defines the new stencil mask to use
  39256. */
  39257. setStencilFunctionMask(mask: number): void;
  39258. /**
  39259. * Gets the current stencil operation when stencil fails
  39260. * @returns a number defining stencil operation to use when stencil fails
  39261. */
  39262. getStencilOperationFail(): number;
  39263. /**
  39264. * Gets the current stencil operation when depth fails
  39265. * @returns a number defining stencil operation to use when depth fails
  39266. */
  39267. getStencilOperationDepthFail(): number;
  39268. /**
  39269. * Gets the current stencil operation when stencil passes
  39270. * @returns a number defining stencil operation to use when stencil passes
  39271. */
  39272. getStencilOperationPass(): number;
  39273. /**
  39274. * Sets the stencil operation to use when stencil fails
  39275. * @param operation defines the stencil operation to use when stencil fails
  39276. */
  39277. setStencilOperationFail(operation: number): void;
  39278. /**
  39279. * Sets the stencil operation to use when depth fails
  39280. * @param operation defines the stencil operation to use when depth fails
  39281. */
  39282. setStencilOperationDepthFail(operation: number): void;
  39283. /**
  39284. * Sets the stencil operation to use when stencil passes
  39285. * @param operation defines the stencil operation to use when stencil passes
  39286. */
  39287. setStencilOperationPass(operation: number): void;
  39288. /**
  39289. * Sets a boolean indicating if the dithering state is enabled or disabled
  39290. * @param value defines the dithering state
  39291. */
  39292. setDitheringState(value: boolean): void;
  39293. /**
  39294. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  39295. * @param value defines the rasterizer state
  39296. */
  39297. setRasterizerState(value: boolean): void;
  39298. /**
  39299. * Gets the current depth function
  39300. * @returns a number defining the depth function
  39301. */
  39302. getDepthFunction(): Nullable<number>;
  39303. /**
  39304. * Sets the current depth function
  39305. * @param depthFunc defines the function to use
  39306. */
  39307. setDepthFunction(depthFunc: number): void;
  39308. /**
  39309. * Sets the current depth function to GREATER
  39310. */
  39311. setDepthFunctionToGreater(): void;
  39312. /**
  39313. * Sets the current depth function to GEQUAL
  39314. */
  39315. setDepthFunctionToGreaterOrEqual(): void;
  39316. /**
  39317. * Sets the current depth function to LESS
  39318. */
  39319. setDepthFunctionToLess(): void;
  39320. /**
  39321. * Sets the current depth function to LEQUAL
  39322. */
  39323. setDepthFunctionToLessOrEqual(): void;
  39324. private _cachedStencilBuffer;
  39325. private _cachedStencilFunction;
  39326. private _cachedStencilMask;
  39327. private _cachedStencilOperationPass;
  39328. private _cachedStencilOperationFail;
  39329. private _cachedStencilOperationDepthFail;
  39330. private _cachedStencilReference;
  39331. /**
  39332. * Caches the the state of the stencil buffer
  39333. */
  39334. cacheStencilState(): void;
  39335. /**
  39336. * Restores the state of the stencil buffer
  39337. */
  39338. restoreStencilState(): void;
  39339. /**
  39340. * Directly set the WebGL Viewport
  39341. * @param x defines the x coordinate of the viewport (in screen space)
  39342. * @param y defines the y coordinate of the viewport (in screen space)
  39343. * @param width defines the width of the viewport (in screen space)
  39344. * @param height defines the height of the viewport (in screen space)
  39345. * @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
  39346. */
  39347. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  39348. /**
  39349. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  39350. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  39351. * @param y defines the y-coordinate of the corner of the clear rectangle
  39352. * @param width defines the width of the clear rectangle
  39353. * @param height defines the height of the clear rectangle
  39354. * @param clearColor defines the clear color
  39355. */
  39356. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  39357. /**
  39358. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  39359. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  39360. * @param y defines the y-coordinate of the corner of the clear rectangle
  39361. * @param width defines the width of the clear rectangle
  39362. * @param height defines the height of the clear rectangle
  39363. */
  39364. enableScissor(x: number, y: number, width: number, height: number): void;
  39365. /**
  39366. * Disable previously set scissor test rectangle
  39367. */
  39368. disableScissor(): void;
  39369. protected _reportDrawCall(): void;
  39370. /**
  39371. * Initializes a webVR display and starts listening to display change events
  39372. * The onVRDisplayChangedObservable will be notified upon these changes
  39373. * @returns The onVRDisplayChangedObservable
  39374. */
  39375. initWebVR(): Observable<IDisplayChangedEventArgs>;
  39376. /** @hidden */
  39377. _prepareVRComponent(): void;
  39378. /** @hidden */
  39379. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  39380. /** @hidden */
  39381. _submitVRFrame(): void;
  39382. /**
  39383. * Call this function to leave webVR mode
  39384. * Will do nothing if webVR is not supported or if there is no webVR device
  39385. * @see https://doc.babylonjs.com/how_to/webvr_camera
  39386. */
  39387. disableVR(): void;
  39388. /**
  39389. * Gets a boolean indicating that the system is in VR mode and is presenting
  39390. * @returns true if VR mode is engaged
  39391. */
  39392. isVRPresenting(): boolean;
  39393. /** @hidden */
  39394. _requestVRFrame(): void;
  39395. /** @hidden */
  39396. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  39397. /**
  39398. * Gets the source code of the vertex shader associated with a specific webGL program
  39399. * @param program defines the program to use
  39400. * @returns a string containing the source code of the vertex shader associated with the program
  39401. */
  39402. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  39403. /**
  39404. * Gets the source code of the fragment shader associated with a specific webGL program
  39405. * @param program defines the program to use
  39406. * @returns a string containing the source code of the fragment shader associated with the program
  39407. */
  39408. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  39409. /**
  39410. * Sets a depth stencil texture from a render target to the according uniform.
  39411. * @param channel The texture channel
  39412. * @param uniform The uniform to set
  39413. * @param texture The render target texture containing the depth stencil texture to apply
  39414. */
  39415. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  39416. /**
  39417. * Sets a texture to the webGL context from a postprocess
  39418. * @param channel defines the channel to use
  39419. * @param postProcess defines the source postprocess
  39420. */
  39421. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  39422. /**
  39423. * Binds the output of the passed in post process to the texture channel specified
  39424. * @param channel The channel the texture should be bound to
  39425. * @param postProcess The post process which's output should be bound
  39426. */
  39427. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  39428. protected _rebuildBuffers(): void;
  39429. /** @hidden */
  39430. _renderFrame(): void;
  39431. _renderLoop(): void;
  39432. /** @hidden */
  39433. _renderViews(): boolean;
  39434. /**
  39435. * Toggle full screen mode
  39436. * @param requestPointerLock defines if a pointer lock should be requested from the user
  39437. */
  39438. switchFullscreen(requestPointerLock: boolean): void;
  39439. /**
  39440. * Enters full screen mode
  39441. * @param requestPointerLock defines if a pointer lock should be requested from the user
  39442. */
  39443. enterFullscreen(requestPointerLock: boolean): void;
  39444. /**
  39445. * Exits full screen mode
  39446. */
  39447. exitFullscreen(): void;
  39448. /**
  39449. * Enters Pointerlock mode
  39450. */
  39451. enterPointerlock(): void;
  39452. /**
  39453. * Exits Pointerlock mode
  39454. */
  39455. exitPointerlock(): void;
  39456. /**
  39457. * Begin a new frame
  39458. */
  39459. beginFrame(): void;
  39460. /**
  39461. * Enf the current frame
  39462. */
  39463. endFrame(): void;
  39464. resize(): void;
  39465. /**
  39466. * Force a specific size of the canvas
  39467. * @param width defines the new canvas' width
  39468. * @param height defines the new canvas' height
  39469. * @returns true if the size was changed
  39470. */
  39471. setSize(width: number, height: number): boolean;
  39472. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  39473. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  39474. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  39475. _releaseTexture(texture: InternalTexture): void;
  39476. /**
  39477. * @hidden
  39478. * Rescales a texture
  39479. * @param source input texutre
  39480. * @param destination destination texture
  39481. * @param scene scene to use to render the resize
  39482. * @param internalFormat format to use when resizing
  39483. * @param onComplete callback to be called when resize has completed
  39484. */
  39485. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  39486. /**
  39487. * Gets the current framerate
  39488. * @returns a number representing the framerate
  39489. */
  39490. getFps(): number;
  39491. /**
  39492. * Gets the time spent between current and previous frame
  39493. * @returns a number representing the delta time in ms
  39494. */
  39495. getDeltaTime(): number;
  39496. private _measureFps;
  39497. /** @hidden */
  39498. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  39499. /**
  39500. * Updates the sample count of a render target texture
  39501. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  39502. * @param texture defines the texture to update
  39503. * @param samples defines the sample count to set
  39504. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  39505. */
  39506. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  39507. /**
  39508. * Updates a depth texture Comparison Mode and Function.
  39509. * If the comparison Function is equal to 0, the mode will be set to none.
  39510. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  39511. * @param texture The texture to set the comparison function for
  39512. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  39513. */
  39514. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  39515. /**
  39516. * Creates a webGL buffer to use with instanciation
  39517. * @param capacity defines the size of the buffer
  39518. * @returns the webGL buffer
  39519. */
  39520. createInstancesBuffer(capacity: number): DataBuffer;
  39521. /**
  39522. * Delete a webGL buffer used with instanciation
  39523. * @param buffer defines the webGL buffer to delete
  39524. */
  39525. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  39526. private _clientWaitAsync;
  39527. /** @hidden */
  39528. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  39529. dispose(): void;
  39530. private _disableTouchAction;
  39531. /**
  39532. * Display the loading screen
  39533. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  39534. */
  39535. displayLoadingUI(): void;
  39536. /**
  39537. * Hide the loading screen
  39538. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  39539. */
  39540. hideLoadingUI(): void;
  39541. /**
  39542. * Gets the current loading screen object
  39543. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  39544. */
  39545. get loadingScreen(): ILoadingScreen;
  39546. /**
  39547. * Sets the current loading screen object
  39548. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  39549. */
  39550. set loadingScreen(loadingScreen: ILoadingScreen);
  39551. /**
  39552. * Sets the current loading screen text
  39553. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  39554. */
  39555. set loadingUIText(text: string);
  39556. /**
  39557. * Sets the current loading screen background color
  39558. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  39559. */
  39560. set loadingUIBackgroundColor(color: string);
  39561. /** Pointerlock and fullscreen */
  39562. /**
  39563. * Ask the browser to promote the current element to pointerlock mode
  39564. * @param element defines the DOM element to promote
  39565. */
  39566. static _RequestPointerlock(element: HTMLElement): void;
  39567. /**
  39568. * Asks the browser to exit pointerlock mode
  39569. */
  39570. static _ExitPointerlock(): void;
  39571. /**
  39572. * Ask the browser to promote the current element to fullscreen rendering mode
  39573. * @param element defines the DOM element to promote
  39574. */
  39575. static _RequestFullscreen(element: HTMLElement): void;
  39576. /**
  39577. * Asks the browser to exit fullscreen mode
  39578. */
  39579. static _ExitFullscreen(): void;
  39580. }
  39581. }
  39582. declare module "babylonjs/Engines/engineStore" {
  39583. import { Nullable } from "babylonjs/types";
  39584. import { Engine } from "babylonjs/Engines/engine";
  39585. import { Scene } from "babylonjs/scene";
  39586. /**
  39587. * The engine store class is responsible to hold all the instances of Engine and Scene created
  39588. * during the life time of the application.
  39589. */
  39590. export class EngineStore {
  39591. /** Gets the list of created engines */
  39592. static Instances: import("babylonjs/Engines/engine").Engine[];
  39593. /** @hidden */
  39594. static _LastCreatedScene: Nullable<Scene>;
  39595. /**
  39596. * Gets the latest created engine
  39597. */
  39598. static get LastCreatedEngine(): Nullable<Engine>;
  39599. /**
  39600. * Gets the latest created scene
  39601. */
  39602. static get LastCreatedScene(): Nullable<Scene>;
  39603. /**
  39604. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  39605. * @ignorenaming
  39606. */
  39607. static UseFallbackTexture: boolean;
  39608. /**
  39609. * Texture content used if a texture cannot loaded
  39610. * @ignorenaming
  39611. */
  39612. static FallbackTexture: string;
  39613. }
  39614. }
  39615. declare module "babylonjs/Misc/promise" {
  39616. /**
  39617. * Helper class that provides a small promise polyfill
  39618. */
  39619. export class PromisePolyfill {
  39620. /**
  39621. * Static function used to check if the polyfill is required
  39622. * If this is the case then the function will inject the polyfill to window.Promise
  39623. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  39624. */
  39625. static Apply(force?: boolean): void;
  39626. }
  39627. }
  39628. declare module "babylonjs/Misc/interfaces/screenshotSize" {
  39629. /**
  39630. * Interface for screenshot methods with describe argument called `size` as object with options
  39631. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  39632. */
  39633. export interface IScreenshotSize {
  39634. /**
  39635. * number in pixels for canvas height
  39636. */
  39637. height?: number;
  39638. /**
  39639. * multiplier allowing render at a higher or lower resolution
  39640. * If value is defined then height and width will be ignored and taken from camera
  39641. */
  39642. precision?: number;
  39643. /**
  39644. * number in pixels for canvas width
  39645. */
  39646. width?: number;
  39647. }
  39648. }
  39649. declare module "babylonjs/Misc/tools" {
  39650. import { Nullable, float } from "babylonjs/types";
  39651. import { DomManagement } from "babylonjs/Misc/domManagement";
  39652. import { WebRequest } from "babylonjs/Misc/webRequest";
  39653. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  39654. import { ReadFileError } from "babylonjs/Misc/fileTools";
  39655. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  39656. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  39657. import { Camera } from "babylonjs/Cameras/camera";
  39658. import { Engine } from "babylonjs/Engines/engine";
  39659. interface IColor4Like {
  39660. r: float;
  39661. g: float;
  39662. b: float;
  39663. a: float;
  39664. }
  39665. /**
  39666. * Class containing a set of static utilities functions
  39667. */
  39668. export class Tools {
  39669. /**
  39670. * Gets or sets the base URL to use to load assets
  39671. */
  39672. static get BaseUrl(): string;
  39673. static set BaseUrl(value: string);
  39674. /**
  39675. * Enable/Disable Custom HTTP Request Headers globally.
  39676. * default = false
  39677. * @see CustomRequestHeaders
  39678. */
  39679. static UseCustomRequestHeaders: boolean;
  39680. /**
  39681. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  39682. * i.e. when loading files, where the server/service expects an Authorization header
  39683. */
  39684. static CustomRequestHeaders: {
  39685. [key: string]: string;
  39686. };
  39687. /**
  39688. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  39689. */
  39690. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  39691. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  39692. /**
  39693. * Default behaviour for cors in the application.
  39694. * It can be a string if the expected behavior is identical in the entire app.
  39695. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  39696. */
  39697. static get CorsBehavior(): string | ((url: string | string[]) => string);
  39698. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  39699. /**
  39700. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  39701. * @ignorenaming
  39702. */
  39703. static get UseFallbackTexture(): boolean;
  39704. static set UseFallbackTexture(value: boolean);
  39705. /**
  39706. * Use this object to register external classes like custom textures or material
  39707. * to allow the laoders to instantiate them
  39708. */
  39709. static get RegisteredExternalClasses(): {
  39710. [key: string]: Object;
  39711. };
  39712. static set RegisteredExternalClasses(classes: {
  39713. [key: string]: Object;
  39714. });
  39715. /**
  39716. * Texture content used if a texture cannot loaded
  39717. * @ignorenaming
  39718. */
  39719. static get fallbackTexture(): string;
  39720. static set fallbackTexture(value: string);
  39721. /**
  39722. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  39723. * @param u defines the coordinate on X axis
  39724. * @param v defines the coordinate on Y axis
  39725. * @param width defines the width of the source data
  39726. * @param height defines the height of the source data
  39727. * @param pixels defines the source byte array
  39728. * @param color defines the output color
  39729. */
  39730. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  39731. /**
  39732. * Interpolates between a and b via alpha
  39733. * @param a The lower value (returned when alpha = 0)
  39734. * @param b The upper value (returned when alpha = 1)
  39735. * @param alpha The interpolation-factor
  39736. * @return The mixed value
  39737. */
  39738. static Mix(a: number, b: number, alpha: number): number;
  39739. /**
  39740. * Tries to instantiate a new object from a given class name
  39741. * @param className defines the class name to instantiate
  39742. * @returns the new object or null if the system was not able to do the instantiation
  39743. */
  39744. static Instantiate(className: string): any;
  39745. /**
  39746. * Provides a slice function that will work even on IE
  39747. * @param data defines the array to slice
  39748. * @param start defines the start of the data (optional)
  39749. * @param end defines the end of the data (optional)
  39750. * @returns the new sliced array
  39751. */
  39752. static Slice<T>(data: T, start?: number, end?: number): T;
  39753. /**
  39754. * Polyfill for setImmediate
  39755. * @param action defines the action to execute after the current execution block
  39756. */
  39757. static SetImmediate(action: () => void): void;
  39758. /**
  39759. * Function indicating if a number is an exponent of 2
  39760. * @param value defines the value to test
  39761. * @returns true if the value is an exponent of 2
  39762. */
  39763. static IsExponentOfTwo(value: number): boolean;
  39764. private static _tmpFloatArray;
  39765. /**
  39766. * Returns the nearest 32-bit single precision float representation of a Number
  39767. * @param value A Number. If the parameter is of a different type, it will get converted
  39768. * to a number or to NaN if it cannot be converted
  39769. * @returns number
  39770. */
  39771. static FloatRound(value: number): number;
  39772. /**
  39773. * Extracts the filename from a path
  39774. * @param path defines the path to use
  39775. * @returns the filename
  39776. */
  39777. static GetFilename(path: string): string;
  39778. /**
  39779. * Extracts the "folder" part of a path (everything before the filename).
  39780. * @param uri The URI to extract the info from
  39781. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  39782. * @returns The "folder" part of the path
  39783. */
  39784. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  39785. /**
  39786. * Extracts text content from a DOM element hierarchy
  39787. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  39788. */
  39789. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  39790. /**
  39791. * Convert an angle in radians to degrees
  39792. * @param angle defines the angle to convert
  39793. * @returns the angle in degrees
  39794. */
  39795. static ToDegrees(angle: number): number;
  39796. /**
  39797. * Convert an angle in degrees to radians
  39798. * @param angle defines the angle to convert
  39799. * @returns the angle in radians
  39800. */
  39801. static ToRadians(angle: number): number;
  39802. /**
  39803. * Returns an array if obj is not an array
  39804. * @param obj defines the object to evaluate as an array
  39805. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  39806. * @returns either obj directly if obj is an array or a new array containing obj
  39807. */
  39808. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  39809. /**
  39810. * Gets the pointer prefix to use
  39811. * @param engine defines the engine we are finding the prefix for
  39812. * @returns "pointer" if touch is enabled. Else returns "mouse"
  39813. */
  39814. static GetPointerPrefix(engine: Engine): string;
  39815. /**
  39816. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  39817. * @param url define the url we are trying
  39818. * @param element define the dom element where to configure the cors policy
  39819. */
  39820. static SetCorsBehavior(url: string | string[], element: {
  39821. crossOrigin: string | null;
  39822. }): void;
  39823. /**
  39824. * Removes unwanted characters from an url
  39825. * @param url defines the url to clean
  39826. * @returns the cleaned url
  39827. */
  39828. static CleanUrl(url: string): string;
  39829. /**
  39830. * Gets or sets a function used to pre-process url before using them to load assets
  39831. */
  39832. static get PreprocessUrl(): (url: string) => string;
  39833. static set PreprocessUrl(processor: (url: string) => string);
  39834. /**
  39835. * Loads an image as an HTMLImageElement.
  39836. * @param input url string, ArrayBuffer, or Blob to load
  39837. * @param onLoad callback called when the image successfully loads
  39838. * @param onError callback called when the image fails to load
  39839. * @param offlineProvider offline provider for caching
  39840. * @param mimeType optional mime type
  39841. * @returns the HTMLImageElement of the loaded image
  39842. */
  39843. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  39844. /**
  39845. * Loads a file from a url
  39846. * @param url url string, ArrayBuffer, or Blob to load
  39847. * @param onSuccess callback called when the file successfully loads
  39848. * @param onProgress callback called while file is loading (if the server supports this mode)
  39849. * @param offlineProvider defines the offline provider for caching
  39850. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  39851. * @param onError callback called when the file fails to load
  39852. * @returns a file request object
  39853. */
  39854. 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;
  39855. /**
  39856. * Loads a file from a url
  39857. * @param url the file url to load
  39858. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  39859. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  39860. */
  39861. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  39862. /**
  39863. * Load a script (identified by an url). When the url returns, the
  39864. * content of this file is added into a new script element, attached to the DOM (body element)
  39865. * @param scriptUrl defines the url of the script to laod
  39866. * @param onSuccess defines the callback called when the script is loaded
  39867. * @param onError defines the callback to call if an error occurs
  39868. * @param scriptId defines the id of the script element
  39869. */
  39870. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  39871. /**
  39872. * Load an asynchronous script (identified by an url). When the url returns, the
  39873. * content of this file is added into a new script element, attached to the DOM (body element)
  39874. * @param scriptUrl defines the url of the script to laod
  39875. * @param scriptId defines the id of the script element
  39876. * @returns a promise request object
  39877. */
  39878. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  39879. /**
  39880. * Loads a file from a blob
  39881. * @param fileToLoad defines the blob to use
  39882. * @param callback defines the callback to call when data is loaded
  39883. * @param progressCallback defines the callback to call during loading process
  39884. * @returns a file request object
  39885. */
  39886. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  39887. /**
  39888. * Reads a file from a File object
  39889. * @param file defines the file to load
  39890. * @param onSuccess defines the callback to call when data is loaded
  39891. * @param onProgress defines the callback to call during loading process
  39892. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  39893. * @param onError defines the callback to call when an error occurs
  39894. * @returns a file request object
  39895. */
  39896. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  39897. /**
  39898. * Creates a data url from a given string content
  39899. * @param content defines the content to convert
  39900. * @returns the new data url link
  39901. */
  39902. static FileAsURL(content: string): string;
  39903. /**
  39904. * Format the given number to a specific decimal format
  39905. * @param value defines the number to format
  39906. * @param decimals defines the number of decimals to use
  39907. * @returns the formatted string
  39908. */
  39909. static Format(value: number, decimals?: number): string;
  39910. /**
  39911. * Tries to copy an object by duplicating every property
  39912. * @param source defines the source object
  39913. * @param destination defines the target object
  39914. * @param doNotCopyList defines a list of properties to avoid
  39915. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  39916. */
  39917. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  39918. /**
  39919. * Gets a boolean indicating if the given object has no own property
  39920. * @param obj defines the object to test
  39921. * @returns true if object has no own property
  39922. */
  39923. static IsEmpty(obj: any): boolean;
  39924. /**
  39925. * Function used to register events at window level
  39926. * @param windowElement defines the Window object to use
  39927. * @param events defines the events to register
  39928. */
  39929. static RegisterTopRootEvents(windowElement: Window, events: {
  39930. name: string;
  39931. handler: Nullable<(e: FocusEvent) => any>;
  39932. }[]): void;
  39933. /**
  39934. * Function used to unregister events from window level
  39935. * @param windowElement defines the Window object to use
  39936. * @param events defines the events to unregister
  39937. */
  39938. static UnregisterTopRootEvents(windowElement: Window, events: {
  39939. name: string;
  39940. handler: Nullable<(e: FocusEvent) => any>;
  39941. }[]): void;
  39942. /**
  39943. * @ignore
  39944. */
  39945. static _ScreenshotCanvas: HTMLCanvasElement;
  39946. /**
  39947. * Dumps the current bound framebuffer
  39948. * @param width defines the rendering width
  39949. * @param height defines the rendering height
  39950. * @param engine defines the hosting engine
  39951. * @param successCallback defines the callback triggered once the data are available
  39952. * @param mimeType defines the mime type of the result
  39953. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  39954. */
  39955. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  39956. /**
  39957. * Converts the canvas data to blob.
  39958. * This acts as a polyfill for browsers not supporting the to blob function.
  39959. * @param canvas Defines the canvas to extract the data from
  39960. * @param successCallback Defines the callback triggered once the data are available
  39961. * @param mimeType Defines the mime type of the result
  39962. */
  39963. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  39964. /**
  39965. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  39966. * @param successCallback defines the callback triggered once the data are available
  39967. * @param mimeType defines the mime type of the result
  39968. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  39969. */
  39970. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  39971. /**
  39972. * Downloads a blob in the browser
  39973. * @param blob defines the blob to download
  39974. * @param fileName defines the name of the downloaded file
  39975. */
  39976. static Download(blob: Blob, fileName: string): void;
  39977. /**
  39978. * Captures a screenshot of the current rendering
  39979. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  39980. * @param engine defines the rendering engine
  39981. * @param camera defines the source camera
  39982. * @param size This parameter can be set to a single number or to an object with the
  39983. * following (optional) properties: precision, width, height. If a single number is passed,
  39984. * it will be used for both width and height. If an object is passed, the screenshot size
  39985. * will be derived from the parameters. The precision property is a multiplier allowing
  39986. * rendering at a higher or lower resolution
  39987. * @param successCallback defines the callback receives a single parameter which contains the
  39988. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  39989. * src parameter of an <img> to display it
  39990. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  39991. * Check your browser for supported MIME types
  39992. */
  39993. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  39994. /**
  39995. * Captures a screenshot of the current rendering
  39996. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  39997. * @param engine defines the rendering engine
  39998. * @param camera defines the source camera
  39999. * @param size This parameter can be set to a single number or to an object with the
  40000. * following (optional) properties: precision, width, height. If a single number is passed,
  40001. * it will be used for both width and height. If an object is passed, the screenshot size
  40002. * will be derived from the parameters. The precision property is a multiplier allowing
  40003. * rendering at a higher or lower resolution
  40004. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  40005. * Check your browser for supported MIME types
  40006. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  40007. * to the src parameter of an <img> to display it
  40008. */
  40009. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  40010. /**
  40011. * Generates an image screenshot from the specified camera.
  40012. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  40013. * @param engine The engine to use for rendering
  40014. * @param camera The camera to use for rendering
  40015. * @param size This parameter can be set to a single number or to an object with the
  40016. * following (optional) properties: precision, width, height. If a single number is passed,
  40017. * it will be used for both width and height. If an object is passed, the screenshot size
  40018. * will be derived from the parameters. The precision property is a multiplier allowing
  40019. * rendering at a higher or lower resolution
  40020. * @param successCallback The callback receives a single parameter which contains the
  40021. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  40022. * src parameter of an <img> to display it
  40023. * @param mimeType The MIME type of the screenshot image (default: image/png).
  40024. * Check your browser for supported MIME types
  40025. * @param samples Texture samples (default: 1)
  40026. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  40027. * @param fileName A name for for the downloaded file.
  40028. */
  40029. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  40030. /**
  40031. * Generates an image screenshot from the specified camera.
  40032. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  40033. * @param engine The engine to use for rendering
  40034. * @param camera The camera to use for rendering
  40035. * @param size This parameter can be set to a single number or to an object with the
  40036. * following (optional) properties: precision, width, height. If a single number is passed,
  40037. * it will be used for both width and height. If an object is passed, the screenshot size
  40038. * will be derived from the parameters. The precision property is a multiplier allowing
  40039. * rendering at a higher or lower resolution
  40040. * @param mimeType The MIME type of the screenshot image (default: image/png).
  40041. * Check your browser for supported MIME types
  40042. * @param samples Texture samples (default: 1)
  40043. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  40044. * @param fileName A name for for the downloaded file.
  40045. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  40046. * to the src parameter of an <img> to display it
  40047. */
  40048. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  40049. /**
  40050. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  40051. * Be aware Math.random() could cause collisions, but:
  40052. * "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"
  40053. * @returns a pseudo random id
  40054. */
  40055. static RandomId(): string;
  40056. /**
  40057. * Test if the given uri is a base64 string
  40058. * @param uri The uri to test
  40059. * @return True if the uri is a base64 string or false otherwise
  40060. */
  40061. static IsBase64(uri: string): boolean;
  40062. /**
  40063. * Decode the given base64 uri.
  40064. * @param uri The uri to decode
  40065. * @return The decoded base64 data.
  40066. */
  40067. static DecodeBase64(uri: string): ArrayBuffer;
  40068. /**
  40069. * Gets the absolute url.
  40070. * @param url the input url
  40071. * @return the absolute url
  40072. */
  40073. static GetAbsoluteUrl(url: string): string;
  40074. /**
  40075. * No log
  40076. */
  40077. static readonly NoneLogLevel: number;
  40078. /**
  40079. * Only message logs
  40080. */
  40081. static readonly MessageLogLevel: number;
  40082. /**
  40083. * Only warning logs
  40084. */
  40085. static readonly WarningLogLevel: number;
  40086. /**
  40087. * Only error logs
  40088. */
  40089. static readonly ErrorLogLevel: number;
  40090. /**
  40091. * All logs
  40092. */
  40093. static readonly AllLogLevel: number;
  40094. /**
  40095. * Gets a value indicating the number of loading errors
  40096. * @ignorenaming
  40097. */
  40098. static get errorsCount(): number;
  40099. /**
  40100. * Callback called when a new log is added
  40101. */
  40102. static OnNewCacheEntry: (entry: string) => void;
  40103. /**
  40104. * Log a message to the console
  40105. * @param message defines the message to log
  40106. */
  40107. static Log(message: string): void;
  40108. /**
  40109. * Write a warning message to the console
  40110. * @param message defines the message to log
  40111. */
  40112. static Warn(message: string): void;
  40113. /**
  40114. * Write an error message to the console
  40115. * @param message defines the message to log
  40116. */
  40117. static Error(message: string): void;
  40118. /**
  40119. * Gets current log cache (list of logs)
  40120. */
  40121. static get LogCache(): string;
  40122. /**
  40123. * Clears the log cache
  40124. */
  40125. static ClearLogCache(): void;
  40126. /**
  40127. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  40128. */
  40129. static set LogLevels(level: number);
  40130. /**
  40131. * Checks if the window object exists
  40132. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  40133. */
  40134. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  40135. /**
  40136. * No performance log
  40137. */
  40138. static readonly PerformanceNoneLogLevel: number;
  40139. /**
  40140. * Use user marks to log performance
  40141. */
  40142. static readonly PerformanceUserMarkLogLevel: number;
  40143. /**
  40144. * Log performance to the console
  40145. */
  40146. static readonly PerformanceConsoleLogLevel: number;
  40147. private static _performance;
  40148. /**
  40149. * Sets the current performance log level
  40150. */
  40151. static set PerformanceLogLevel(level: number);
  40152. private static _StartPerformanceCounterDisabled;
  40153. private static _EndPerformanceCounterDisabled;
  40154. private static _StartUserMark;
  40155. private static _EndUserMark;
  40156. private static _StartPerformanceConsole;
  40157. private static _EndPerformanceConsole;
  40158. /**
  40159. * Starts a performance counter
  40160. */
  40161. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  40162. /**
  40163. * Ends a specific performance coutner
  40164. */
  40165. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  40166. /**
  40167. * Gets either window.performance.now() if supported or Date.now() else
  40168. */
  40169. static get Now(): number;
  40170. /**
  40171. * This method will return the name of the class used to create the instance of the given object.
  40172. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  40173. * @param object the object to get the class name from
  40174. * @param isType defines if the object is actually a type
  40175. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  40176. */
  40177. static GetClassName(object: any, isType?: boolean): string;
  40178. /**
  40179. * Gets the first element of an array satisfying a given predicate
  40180. * @param array defines the array to browse
  40181. * @param predicate defines the predicate to use
  40182. * @returns null if not found or the element
  40183. */
  40184. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  40185. /**
  40186. * This method will return the name of the full name of the class, including its owning module (if any).
  40187. * 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).
  40188. * @param object the object to get the class name from
  40189. * @param isType defines if the object is actually a type
  40190. * @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.
  40191. * @ignorenaming
  40192. */
  40193. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  40194. /**
  40195. * Returns a promise that resolves after the given amount of time.
  40196. * @param delay Number of milliseconds to delay
  40197. * @returns Promise that resolves after the given amount of time
  40198. */
  40199. static DelayAsync(delay: number): Promise<void>;
  40200. /**
  40201. * Utility function to detect if the current user agent is Safari
  40202. * @returns whether or not the current user agent is safari
  40203. */
  40204. static IsSafari(): boolean;
  40205. }
  40206. /**
  40207. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  40208. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  40209. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  40210. * @param name The name of the class, case should be preserved
  40211. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  40212. */
  40213. export function className(name: string, module?: string): (target: Object) => void;
  40214. /**
  40215. * An implementation of a loop for asynchronous functions.
  40216. */
  40217. export class AsyncLoop {
  40218. /**
  40219. * Defines the number of iterations for the loop
  40220. */
  40221. iterations: number;
  40222. /**
  40223. * Defines the current index of the loop.
  40224. */
  40225. index: number;
  40226. private _done;
  40227. private _fn;
  40228. private _successCallback;
  40229. /**
  40230. * Constructor.
  40231. * @param iterations the number of iterations.
  40232. * @param func the function to run each iteration
  40233. * @param successCallback the callback that will be called upon succesful execution
  40234. * @param offset starting offset.
  40235. */
  40236. constructor(
  40237. /**
  40238. * Defines the number of iterations for the loop
  40239. */
  40240. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  40241. /**
  40242. * Execute the next iteration. Must be called after the last iteration was finished.
  40243. */
  40244. executeNext(): void;
  40245. /**
  40246. * Break the loop and run the success callback.
  40247. */
  40248. breakLoop(): void;
  40249. /**
  40250. * Create and run an async loop.
  40251. * @param iterations the number of iterations.
  40252. * @param fn the function to run each iteration
  40253. * @param successCallback the callback that will be called upon succesful execution
  40254. * @param offset starting offset.
  40255. * @returns the created async loop object
  40256. */
  40257. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  40258. /**
  40259. * A for-loop that will run a given number of iterations synchronous and the rest async.
  40260. * @param iterations total number of iterations
  40261. * @param syncedIterations number of synchronous iterations in each async iteration.
  40262. * @param fn the function to call each iteration.
  40263. * @param callback a success call back that will be called when iterating stops.
  40264. * @param breakFunction a break condition (optional)
  40265. * @param timeout timeout settings for the setTimeout function. default - 0.
  40266. * @returns the created async loop object
  40267. */
  40268. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  40269. }
  40270. }
  40271. declare module "babylonjs/Misc/stringDictionary" {
  40272. import { Nullable } from "babylonjs/types";
  40273. /**
  40274. * This class implement a typical dictionary using a string as key and the generic type T as value.
  40275. * The underlying implementation relies on an associative array to ensure the best performances.
  40276. * The value can be anything including 'null' but except 'undefined'
  40277. */
  40278. export class StringDictionary<T> {
  40279. /**
  40280. * This will clear this dictionary and copy the content from the 'source' one.
  40281. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  40282. * @param source the dictionary to take the content from and copy to this dictionary
  40283. */
  40284. copyFrom(source: StringDictionary<T>): void;
  40285. /**
  40286. * Get a value based from its key
  40287. * @param key the given key to get the matching value from
  40288. * @return the value if found, otherwise undefined is returned
  40289. */
  40290. get(key: string): T | undefined;
  40291. /**
  40292. * Get a value from its key or add it if it doesn't exist.
  40293. * This method will ensure you that a given key/data will be present in the dictionary.
  40294. * @param key the given key to get the matching value from
  40295. * @param factory the factory that will create the value if the key is not present in the dictionary.
  40296. * The factory will only be invoked if there's no data for the given key.
  40297. * @return the value corresponding to the key.
  40298. */
  40299. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  40300. /**
  40301. * Get a value from its key if present in the dictionary otherwise add it
  40302. * @param key the key to get the value from
  40303. * @param val if there's no such key/value pair in the dictionary add it with this value
  40304. * @return the value corresponding to the key
  40305. */
  40306. getOrAdd(key: string, val: T): T;
  40307. /**
  40308. * Check if there's a given key in the dictionary
  40309. * @param key the key to check for
  40310. * @return true if the key is present, false otherwise
  40311. */
  40312. contains(key: string): boolean;
  40313. /**
  40314. * Add a new key and its corresponding value
  40315. * @param key the key to add
  40316. * @param value the value corresponding to the key
  40317. * @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
  40318. */
  40319. add(key: string, value: T): boolean;
  40320. /**
  40321. * Update a specific value associated to a key
  40322. * @param key defines the key to use
  40323. * @param value defines the value to store
  40324. * @returns true if the value was updated (or false if the key was not found)
  40325. */
  40326. set(key: string, value: T): boolean;
  40327. /**
  40328. * Get the element of the given key and remove it from the dictionary
  40329. * @param key defines the key to search
  40330. * @returns the value associated with the key or null if not found
  40331. */
  40332. getAndRemove(key: string): Nullable<T>;
  40333. /**
  40334. * Remove a key/value from the dictionary.
  40335. * @param key the key to remove
  40336. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  40337. */
  40338. remove(key: string): boolean;
  40339. /**
  40340. * Clear the whole content of the dictionary
  40341. */
  40342. clear(): void;
  40343. /**
  40344. * Gets the current count
  40345. */
  40346. get count(): number;
  40347. /**
  40348. * Execute a callback on each key/val of the dictionary.
  40349. * Note that you can remove any element in this dictionary in the callback implementation
  40350. * @param callback the callback to execute on a given key/value pair
  40351. */
  40352. forEach(callback: (key: string, val: T) => void): void;
  40353. /**
  40354. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  40355. * If the callback returns null or undefined the method will iterate to the next key/value pair
  40356. * Note that you can remove any element in this dictionary in the callback implementation
  40357. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  40358. * @returns the first item
  40359. */
  40360. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  40361. private _count;
  40362. private _data;
  40363. }
  40364. }
  40365. declare module "babylonjs/Collisions/collisionCoordinator" {
  40366. import { Nullable } from "babylonjs/types";
  40367. import { Scene } from "babylonjs/scene";
  40368. import { Vector3 } from "babylonjs/Maths/math.vector";
  40369. import { Collider } from "babylonjs/Collisions/collider";
  40370. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40371. /** @hidden */
  40372. export interface ICollisionCoordinator {
  40373. createCollider(): Collider;
  40374. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  40375. init(scene: Scene): void;
  40376. }
  40377. /** @hidden */
  40378. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  40379. private _scene;
  40380. private _scaledPosition;
  40381. private _scaledVelocity;
  40382. private _finalPosition;
  40383. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  40384. createCollider(): Collider;
  40385. init(scene: Scene): void;
  40386. private _collideWithWorld;
  40387. }
  40388. }
  40389. declare module "babylonjs/Inputs/scene.inputManager" {
  40390. import { Nullable } from "babylonjs/types";
  40391. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  40392. import { Vector2 } from "babylonjs/Maths/math.vector";
  40393. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40394. import { Scene } from "babylonjs/scene";
  40395. /**
  40396. * Class used to manage all inputs for the scene.
  40397. */
  40398. export class InputManager {
  40399. /** The distance in pixel that you have to move to prevent some events */
  40400. static DragMovementThreshold: number;
  40401. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  40402. static LongPressDelay: number;
  40403. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  40404. static DoubleClickDelay: number;
  40405. /** If you need to check double click without raising a single click at first click, enable this flag */
  40406. static ExclusiveDoubleClickMode: boolean;
  40407. /** 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. */
  40408. private _alreadyAttached;
  40409. private _wheelEventName;
  40410. private _onPointerMove;
  40411. private _onPointerDown;
  40412. private _onPointerUp;
  40413. private _initClickEvent;
  40414. private _initActionManager;
  40415. private _delayedSimpleClick;
  40416. private _delayedSimpleClickTimeout;
  40417. private _previousDelayedSimpleClickTimeout;
  40418. private _meshPickProceed;
  40419. private _previousButtonPressed;
  40420. private _currentPickResult;
  40421. private _previousPickResult;
  40422. private _totalPointersPressed;
  40423. private _doubleClickOccured;
  40424. private _pointerOverMesh;
  40425. private _pickedDownMesh;
  40426. private _pickedUpMesh;
  40427. private _pointerX;
  40428. private _pointerY;
  40429. private _unTranslatedPointerX;
  40430. private _unTranslatedPointerY;
  40431. private _startingPointerPosition;
  40432. private _previousStartingPointerPosition;
  40433. private _startingPointerTime;
  40434. private _previousStartingPointerTime;
  40435. private _pointerCaptures;
  40436. private _meshUnderPointerId;
  40437. private _onKeyDown;
  40438. private _onKeyUp;
  40439. private _onCanvasFocusObserver;
  40440. private _onCanvasBlurObserver;
  40441. private _scene;
  40442. /**
  40443. * Creates a new InputManager
  40444. * @param scene defines the hosting scene
  40445. */
  40446. constructor(scene: Scene);
  40447. /**
  40448. * Gets the mesh that is currently under the pointer
  40449. */
  40450. get meshUnderPointer(): Nullable<AbstractMesh>;
  40451. /**
  40452. * When using more than one pointer (for example in XR) you can get the mesh under the specific pointer
  40453. * @param pointerId the pointer id to use
  40454. * @returns The mesh under this pointer id or null if not found
  40455. */
  40456. getMeshUnderPointerByPointerId(pointerId: number): Nullable<AbstractMesh>;
  40457. /**
  40458. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  40459. */
  40460. get unTranslatedPointer(): Vector2;
  40461. /**
  40462. * Gets or sets the current on-screen X position of the pointer
  40463. */
  40464. get pointerX(): number;
  40465. set pointerX(value: number);
  40466. /**
  40467. * Gets or sets the current on-screen Y position of the pointer
  40468. */
  40469. get pointerY(): number;
  40470. set pointerY(value: number);
  40471. private _updatePointerPosition;
  40472. private _processPointerMove;
  40473. private _setRayOnPointerInfo;
  40474. private _checkPrePointerObservable;
  40475. /**
  40476. * Use this method to simulate a pointer move on a mesh
  40477. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  40478. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  40479. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  40480. */
  40481. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  40482. /**
  40483. * Use this method to simulate a pointer down on a mesh
  40484. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  40485. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  40486. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  40487. */
  40488. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  40489. private _processPointerDown;
  40490. /** @hidden */
  40491. _isPointerSwiping(): boolean;
  40492. /**
  40493. * Use this method to simulate a pointer up on a mesh
  40494. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  40495. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  40496. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  40497. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  40498. */
  40499. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  40500. private _processPointerUp;
  40501. /**
  40502. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  40503. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  40504. * @returns true if the pointer was captured
  40505. */
  40506. isPointerCaptured(pointerId?: number): boolean;
  40507. /**
  40508. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  40509. * @param attachUp defines if you want to attach events to pointerup
  40510. * @param attachDown defines if you want to attach events to pointerdown
  40511. * @param attachMove defines if you want to attach events to pointermove
  40512. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  40513. */
  40514. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  40515. /**
  40516. * Detaches all event handlers
  40517. */
  40518. detachControl(): void;
  40519. /**
  40520. * Force the value of meshUnderPointer
  40521. * @param mesh defines the mesh to use
  40522. * @param pointerId optional pointer id when using more than one pointer. Defaults to 0
  40523. */
  40524. setPointerOverMesh(mesh: Nullable<AbstractMesh>, pointerId?: number): void;
  40525. /**
  40526. * Gets the mesh under the pointer
  40527. * @returns a Mesh or null if no mesh is under the pointer
  40528. */
  40529. getPointerOverMesh(): Nullable<AbstractMesh>;
  40530. }
  40531. }
  40532. declare module "babylonjs/Animations/animationGroup" {
  40533. import { Animatable } from "babylonjs/Animations/animatable";
  40534. import { Animation } from "babylonjs/Animations/animation";
  40535. import { Scene, IDisposable } from "babylonjs/scene";
  40536. import { Observable } from "babylonjs/Misc/observable";
  40537. import { Nullable } from "babylonjs/types";
  40538. import "babylonjs/Animations/animatable";
  40539. /**
  40540. * This class defines the direct association between an animation and a target
  40541. */
  40542. export class TargetedAnimation {
  40543. /**
  40544. * Animation to perform
  40545. */
  40546. animation: Animation;
  40547. /**
  40548. * Target to animate
  40549. */
  40550. target: any;
  40551. /**
  40552. * Returns the string "TargetedAnimation"
  40553. * @returns "TargetedAnimation"
  40554. */
  40555. getClassName(): string;
  40556. /**
  40557. * Serialize the object
  40558. * @returns the JSON object representing the current entity
  40559. */
  40560. serialize(): any;
  40561. }
  40562. /**
  40563. * Use this class to create coordinated animations on multiple targets
  40564. */
  40565. export class AnimationGroup implements IDisposable {
  40566. /** The name of the animation group */
  40567. name: string;
  40568. private _scene;
  40569. private _targetedAnimations;
  40570. private _animatables;
  40571. private _from;
  40572. private _to;
  40573. private _isStarted;
  40574. private _isPaused;
  40575. private _speedRatio;
  40576. private _loopAnimation;
  40577. private _isAdditive;
  40578. /**
  40579. * Gets or sets the unique id of the node
  40580. */
  40581. uniqueId: number;
  40582. /**
  40583. * This observable will notify when one animation have ended
  40584. */
  40585. onAnimationEndObservable: Observable<TargetedAnimation>;
  40586. /**
  40587. * Observer raised when one animation loops
  40588. */
  40589. onAnimationLoopObservable: Observable<TargetedAnimation>;
  40590. /**
  40591. * Observer raised when all animations have looped
  40592. */
  40593. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  40594. /**
  40595. * This observable will notify when all animations have ended.
  40596. */
  40597. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  40598. /**
  40599. * This observable will notify when all animations have paused.
  40600. */
  40601. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  40602. /**
  40603. * This observable will notify when all animations are playing.
  40604. */
  40605. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  40606. /**
  40607. * Gets the first frame
  40608. */
  40609. get from(): number;
  40610. /**
  40611. * Gets the last frame
  40612. */
  40613. get to(): number;
  40614. /**
  40615. * Define if the animations are started
  40616. */
  40617. get isStarted(): boolean;
  40618. /**
  40619. * Gets a value indicating that the current group is playing
  40620. */
  40621. get isPlaying(): boolean;
  40622. /**
  40623. * Gets or sets the speed ratio to use for all animations
  40624. */
  40625. get speedRatio(): number;
  40626. /**
  40627. * Gets or sets the speed ratio to use for all animations
  40628. */
  40629. set speedRatio(value: number);
  40630. /**
  40631. * Gets or sets if all animations should loop or not
  40632. */
  40633. get loopAnimation(): boolean;
  40634. set loopAnimation(value: boolean);
  40635. /**
  40636. * Gets or sets if all animations should be evaluated additively
  40637. */
  40638. get isAdditive(): boolean;
  40639. set isAdditive(value: boolean);
  40640. /**
  40641. * Gets the targeted animations for this animation group
  40642. */
  40643. get targetedAnimations(): Array<TargetedAnimation>;
  40644. /**
  40645. * returning the list of animatables controlled by this animation group.
  40646. */
  40647. get animatables(): Array<Animatable>;
  40648. /**
  40649. * Gets the list of target animations
  40650. */
  40651. get children(): TargetedAnimation[];
  40652. /**
  40653. * Instantiates a new Animation Group.
  40654. * This helps managing several animations at once.
  40655. * @see https://doc.babylonjs.com/how_to/group
  40656. * @param name Defines the name of the group
  40657. * @param scene Defines the scene the group belongs to
  40658. */
  40659. constructor(
  40660. /** The name of the animation group */
  40661. name: string, scene?: Nullable<Scene>);
  40662. /**
  40663. * Add an animation (with its target) in the group
  40664. * @param animation defines the animation we want to add
  40665. * @param target defines the target of the animation
  40666. * @returns the TargetedAnimation object
  40667. */
  40668. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  40669. /**
  40670. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  40671. * It can add constant keys at begin or end
  40672. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  40673. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  40674. * @returns the animation group
  40675. */
  40676. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  40677. private _animationLoopCount;
  40678. private _animationLoopFlags;
  40679. private _processLoop;
  40680. /**
  40681. * Start all animations on given targets
  40682. * @param loop defines if animations must loop
  40683. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  40684. * @param from defines the from key (optional)
  40685. * @param to defines the to key (optional)
  40686. * @param isAdditive defines the additive state for the resulting animatables (optional)
  40687. * @returns the current animation group
  40688. */
  40689. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  40690. /**
  40691. * Pause all animations
  40692. * @returns the animation group
  40693. */
  40694. pause(): AnimationGroup;
  40695. /**
  40696. * Play all animations to initial state
  40697. * This function will start() the animations if they were not started or will restart() them if they were paused
  40698. * @param loop defines if animations must loop
  40699. * @returns the animation group
  40700. */
  40701. play(loop?: boolean): AnimationGroup;
  40702. /**
  40703. * Reset all animations to initial state
  40704. * @returns the animation group
  40705. */
  40706. reset(): AnimationGroup;
  40707. /**
  40708. * Restart animations from key 0
  40709. * @returns the animation group
  40710. */
  40711. restart(): AnimationGroup;
  40712. /**
  40713. * Stop all animations
  40714. * @returns the animation group
  40715. */
  40716. stop(): AnimationGroup;
  40717. /**
  40718. * Set animation weight for all animatables
  40719. * @param weight defines the weight to use
  40720. * @return the animationGroup
  40721. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  40722. */
  40723. setWeightForAllAnimatables(weight: number): AnimationGroup;
  40724. /**
  40725. * Synchronize and normalize all animatables with a source animatable
  40726. * @param root defines the root animatable to synchronize with
  40727. * @return the animationGroup
  40728. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  40729. */
  40730. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  40731. /**
  40732. * Goes to a specific frame in this animation group
  40733. * @param frame the frame number to go to
  40734. * @return the animationGroup
  40735. */
  40736. goToFrame(frame: number): AnimationGroup;
  40737. /**
  40738. * Dispose all associated resources
  40739. */
  40740. dispose(): void;
  40741. private _checkAnimationGroupEnded;
  40742. /**
  40743. * Clone the current animation group and returns a copy
  40744. * @param newName defines the name of the new group
  40745. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  40746. * @returns the new aniamtion group
  40747. */
  40748. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  40749. /**
  40750. * Serializes the animationGroup to an object
  40751. * @returns Serialized object
  40752. */
  40753. serialize(): any;
  40754. /**
  40755. * Returns a new AnimationGroup object parsed from the source provided.
  40756. * @param parsedAnimationGroup defines the source
  40757. * @param scene defines the scene that will receive the animationGroup
  40758. * @returns a new AnimationGroup
  40759. */
  40760. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  40761. /**
  40762. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  40763. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  40764. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  40765. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  40766. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  40767. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  40768. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  40769. */
  40770. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  40771. /**
  40772. * Returns the string "AnimationGroup"
  40773. * @returns "AnimationGroup"
  40774. */
  40775. getClassName(): string;
  40776. /**
  40777. * Creates a detailled string about the object
  40778. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  40779. * @returns a string representing the object
  40780. */
  40781. toString(fullDetails?: boolean): string;
  40782. }
  40783. }
  40784. declare module "babylonjs/scene" {
  40785. import { Nullable } from "babylonjs/types";
  40786. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  40787. import { Observable } from "babylonjs/Misc/observable";
  40788. import { SmartArrayNoDuplicate, SmartArray, ISmartArrayLike } from "babylonjs/Misc/smartArray";
  40789. import { Vector2, Vector3, Matrix } from "babylonjs/Maths/math.vector";
  40790. import { Geometry } from "babylonjs/Meshes/geometry";
  40791. import { TransformNode } from "babylonjs/Meshes/transformNode";
  40792. import { SubMesh } from "babylonjs/Meshes/subMesh";
  40793. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40794. import { Mesh } from "babylonjs/Meshes/mesh";
  40795. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  40796. import { Bone } from "babylonjs/Bones/bone";
  40797. import { Skeleton } from "babylonjs/Bones/skeleton";
  40798. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  40799. import { Camera } from "babylonjs/Cameras/camera";
  40800. import { AbstractScene } from "babylonjs/abstractScene";
  40801. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  40802. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  40803. import { Material } from "babylonjs/Materials/material";
  40804. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  40805. import { Effect } from "babylonjs/Materials/effect";
  40806. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  40807. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  40808. import { Light } from "babylonjs/Lights/light";
  40809. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  40810. import { ICollisionCoordinator } from "babylonjs/Collisions/collisionCoordinator";
  40811. import { PointerEventTypes, PointerInfoPre, PointerInfo } from "babylonjs/Events/pointerEvents";
  40812. import { KeyboardInfoPre, KeyboardInfo } from "babylonjs/Events/keyboardEvents";
  40813. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  40814. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  40815. import { RenderingGroupInfo, IRenderingManagerAutoClearSetup } from "babylonjs/Rendering/renderingManager";
  40816. import { ISceneComponent, ISceneSerializableComponent, Stage, SimpleStageAction, RenderTargetsStageAction, RenderTargetStageAction, MeshStageAction, EvaluateSubMeshStageAction, ActiveMeshStageAction, CameraStageAction, RenderingGroupStageAction, RenderingMeshStageAction, PointerMoveStageAction, PointerUpDownStageAction, CameraStageFrameBufferAction } from "babylonjs/sceneComponent";
  40817. import { Engine } from "babylonjs/Engines/engine";
  40818. import { Node } from "babylonjs/node";
  40819. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  40820. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  40821. import { WebRequest } from "babylonjs/Misc/webRequest";
  40822. import { InputManager } from "babylonjs/Inputs/scene.inputManager";
  40823. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  40824. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  40825. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  40826. import { Plane } from "babylonjs/Maths/math.plane";
  40827. import { LoadFileError, RequestFileError, ReadFileError } from "babylonjs/Misc/fileTools";
  40828. import { IClipPlanesHolder } from "babylonjs/Misc/interfaces/iClipPlanesHolder";
  40829. import { Ray } from "babylonjs/Culling/ray";
  40830. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  40831. import { Animation } from "babylonjs/Animations/animation";
  40832. import { Animatable } from "babylonjs/Animations/animatable";
  40833. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  40834. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  40835. import { Collider } from "babylonjs/Collisions/collider";
  40836. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  40837. /**
  40838. * Define an interface for all classes that will hold resources
  40839. */
  40840. export interface IDisposable {
  40841. /**
  40842. * Releases all held resources
  40843. */
  40844. dispose(): void;
  40845. }
  40846. /** Interface defining initialization parameters for Scene class */
  40847. export interface SceneOptions {
  40848. /**
  40849. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  40850. * It will improve performance when the number of geometries becomes important.
  40851. */
  40852. useGeometryUniqueIdsMap?: boolean;
  40853. /**
  40854. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  40855. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  40856. */
  40857. useMaterialMeshMap?: boolean;
  40858. /**
  40859. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  40860. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  40861. */
  40862. useClonedMeshMap?: boolean;
  40863. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  40864. virtual?: boolean;
  40865. }
  40866. /**
  40867. * Represents a scene to be rendered by the engine.
  40868. * @see https://doc.babylonjs.com/features/scene
  40869. */
  40870. export class Scene extends AbstractScene implements IAnimatable, IClipPlanesHolder {
  40871. /** The fog is deactivated */
  40872. static readonly FOGMODE_NONE: number;
  40873. /** The fog density is following an exponential function */
  40874. static readonly FOGMODE_EXP: number;
  40875. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  40876. static readonly FOGMODE_EXP2: number;
  40877. /** The fog density is following a linear function. */
  40878. static readonly FOGMODE_LINEAR: number;
  40879. /**
  40880. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  40881. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  40882. */
  40883. static MinDeltaTime: number;
  40884. /**
  40885. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  40886. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  40887. */
  40888. static MaxDeltaTime: number;
  40889. /**
  40890. * Factory used to create the default material.
  40891. * @param name The name of the material to create
  40892. * @param scene The scene to create the material for
  40893. * @returns The default material
  40894. */
  40895. static DefaultMaterialFactory(scene: Scene): Material;
  40896. /**
  40897. * Factory used to create the a collision coordinator.
  40898. * @returns The collision coordinator
  40899. */
  40900. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  40901. /** @hidden */
  40902. _inputManager: InputManager;
  40903. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  40904. cameraToUseForPointers: Nullable<Camera>;
  40905. /** @hidden */
  40906. readonly _isScene: boolean;
  40907. /** @hidden */
  40908. _blockEntityCollection: boolean;
  40909. /**
  40910. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  40911. */
  40912. autoClear: boolean;
  40913. /**
  40914. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  40915. */
  40916. autoClearDepthAndStencil: boolean;
  40917. /**
  40918. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  40919. */
  40920. clearColor: Color4;
  40921. /**
  40922. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  40923. */
  40924. ambientColor: Color3;
  40925. /**
  40926. * This is use to store the default BRDF lookup for PBR materials in your scene.
  40927. * It should only be one of the following (if not the default embedded one):
  40928. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  40929. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  40930. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  40931. * The material properties need to be setup according to the type of texture in use.
  40932. */
  40933. environmentBRDFTexture: BaseTexture;
  40934. /**
  40935. * Texture used in all pbr material as the reflection texture.
  40936. * As in the majority of the scene they are the same (exception for multi room and so on),
  40937. * this is easier to reference from here than from all the materials.
  40938. */
  40939. get environmentTexture(): Nullable<BaseTexture>;
  40940. /**
  40941. * Texture used in all pbr material as the reflection texture.
  40942. * As in the majority of the scene they are the same (exception for multi room and so on),
  40943. * this is easier to set here than in all the materials.
  40944. */
  40945. set environmentTexture(value: Nullable<BaseTexture>);
  40946. /** @hidden */
  40947. protected _environmentIntensity: number;
  40948. /**
  40949. * Intensity of the environment in all pbr material.
  40950. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  40951. * As in the majority of the scene they are the same (exception for multi room and so on),
  40952. * this is easier to reference from here than from all the materials.
  40953. */
  40954. get environmentIntensity(): number;
  40955. /**
  40956. * Intensity of the environment in all pbr material.
  40957. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  40958. * As in the majority of the scene they are the same (exception for multi room and so on),
  40959. * this is easier to set here than in all the materials.
  40960. */
  40961. set environmentIntensity(value: number);
  40962. /** @hidden */
  40963. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  40964. /**
  40965. * Default image processing configuration used either in the rendering
  40966. * Forward main pass or through the imageProcessingPostProcess if present.
  40967. * As in the majority of the scene they are the same (exception for multi camera),
  40968. * this is easier to reference from here than from all the materials and post process.
  40969. *
  40970. * No setter as we it is a shared configuration, you can set the values instead.
  40971. */
  40972. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  40973. private _forceWireframe;
  40974. /**
  40975. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  40976. */
  40977. set forceWireframe(value: boolean);
  40978. get forceWireframe(): boolean;
  40979. private _skipFrustumClipping;
  40980. /**
  40981. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  40982. */
  40983. set skipFrustumClipping(value: boolean);
  40984. get skipFrustumClipping(): boolean;
  40985. private _forcePointsCloud;
  40986. /**
  40987. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  40988. */
  40989. set forcePointsCloud(value: boolean);
  40990. get forcePointsCloud(): boolean;
  40991. /**
  40992. * Gets or sets the active clipplane 1
  40993. */
  40994. clipPlane: Nullable<Plane>;
  40995. /**
  40996. * Gets or sets the active clipplane 2
  40997. */
  40998. clipPlane2: Nullable<Plane>;
  40999. /**
  41000. * Gets or sets the active clipplane 3
  41001. */
  41002. clipPlane3: Nullable<Plane>;
  41003. /**
  41004. * Gets or sets the active clipplane 4
  41005. */
  41006. clipPlane4: Nullable<Plane>;
  41007. /**
  41008. * Gets or sets the active clipplane 5
  41009. */
  41010. clipPlane5: Nullable<Plane>;
  41011. /**
  41012. * Gets or sets the active clipplane 6
  41013. */
  41014. clipPlane6: Nullable<Plane>;
  41015. /**
  41016. * Gets or sets a boolean indicating if animations are enabled
  41017. */
  41018. animationsEnabled: boolean;
  41019. private _animationPropertiesOverride;
  41020. /**
  41021. * Gets or sets the animation properties override
  41022. */
  41023. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  41024. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  41025. /**
  41026. * Gets or sets a boolean indicating if a constant deltatime has to be used
  41027. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  41028. */
  41029. useConstantAnimationDeltaTime: boolean;
  41030. /**
  41031. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  41032. * Please note that it requires to run a ray cast through the scene on every frame
  41033. */
  41034. constantlyUpdateMeshUnderPointer: boolean;
  41035. /**
  41036. * Defines the HTML cursor to use when hovering over interactive elements
  41037. */
  41038. hoverCursor: string;
  41039. /**
  41040. * Defines the HTML default cursor to use (empty by default)
  41041. */
  41042. defaultCursor: string;
  41043. /**
  41044. * Defines whether cursors are handled by the scene.
  41045. */
  41046. doNotHandleCursors: boolean;
  41047. /**
  41048. * This is used to call preventDefault() on pointer down
  41049. * in order to block unwanted artifacts like system double clicks
  41050. */
  41051. preventDefaultOnPointerDown: boolean;
  41052. /**
  41053. * This is used to call preventDefault() on pointer up
  41054. * in order to block unwanted artifacts like system double clicks
  41055. */
  41056. preventDefaultOnPointerUp: boolean;
  41057. /**
  41058. * Gets or sets user defined metadata
  41059. */
  41060. metadata: any;
  41061. /**
  41062. * For internal use only. Please do not use.
  41063. */
  41064. reservedDataStore: any;
  41065. /**
  41066. * Gets the name of the plugin used to load this scene (null by default)
  41067. */
  41068. loadingPluginName: string;
  41069. /**
  41070. * Use this array to add regular expressions used to disable offline support for specific urls
  41071. */
  41072. disableOfflineSupportExceptionRules: RegExp[];
  41073. /**
  41074. * An event triggered when the scene is disposed.
  41075. */
  41076. onDisposeObservable: Observable<Scene>;
  41077. private _onDisposeObserver;
  41078. /** Sets a function to be executed when this scene is disposed. */
  41079. set onDispose(callback: () => void);
  41080. /**
  41081. * An event triggered before rendering the scene (right after animations and physics)
  41082. */
  41083. onBeforeRenderObservable: Observable<Scene>;
  41084. private _onBeforeRenderObserver;
  41085. /** Sets a function to be executed before rendering this scene */
  41086. set beforeRender(callback: Nullable<() => void>);
  41087. /**
  41088. * An event triggered after rendering the scene
  41089. */
  41090. onAfterRenderObservable: Observable<Scene>;
  41091. /**
  41092. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  41093. */
  41094. onAfterRenderCameraObservable: Observable<Camera>;
  41095. private _onAfterRenderObserver;
  41096. /** Sets a function to be executed after rendering this scene */
  41097. set afterRender(callback: Nullable<() => void>);
  41098. /**
  41099. * An event triggered before animating the scene
  41100. */
  41101. onBeforeAnimationsObservable: Observable<Scene>;
  41102. /**
  41103. * An event triggered after animations processing
  41104. */
  41105. onAfterAnimationsObservable: Observable<Scene>;
  41106. /**
  41107. * An event triggered before draw calls are ready to be sent
  41108. */
  41109. onBeforeDrawPhaseObservable: Observable<Scene>;
  41110. /**
  41111. * An event triggered after draw calls have been sent
  41112. */
  41113. onAfterDrawPhaseObservable: Observable<Scene>;
  41114. /**
  41115. * An event triggered when the scene is ready
  41116. */
  41117. onReadyObservable: Observable<Scene>;
  41118. /**
  41119. * An event triggered before rendering a camera
  41120. */
  41121. onBeforeCameraRenderObservable: Observable<Camera>;
  41122. private _onBeforeCameraRenderObserver;
  41123. /** Sets a function to be executed before rendering a camera*/
  41124. set beforeCameraRender(callback: () => void);
  41125. /**
  41126. * An event triggered after rendering a camera
  41127. */
  41128. onAfterCameraRenderObservable: Observable<Camera>;
  41129. private _onAfterCameraRenderObserver;
  41130. /** Sets a function to be executed after rendering a camera*/
  41131. set afterCameraRender(callback: () => void);
  41132. /**
  41133. * An event triggered when active meshes evaluation is about to start
  41134. */
  41135. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  41136. /**
  41137. * An event triggered when active meshes evaluation is done
  41138. */
  41139. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  41140. /**
  41141. * An event triggered when particles rendering is about to start
  41142. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  41143. */
  41144. onBeforeParticlesRenderingObservable: Observable<Scene>;
  41145. /**
  41146. * An event triggered when particles rendering is done
  41147. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  41148. */
  41149. onAfterParticlesRenderingObservable: Observable<Scene>;
  41150. /**
  41151. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  41152. */
  41153. onDataLoadedObservable: Observable<Scene>;
  41154. /**
  41155. * An event triggered when a camera is created
  41156. */
  41157. onNewCameraAddedObservable: Observable<Camera>;
  41158. /**
  41159. * An event triggered when a camera is removed
  41160. */
  41161. onCameraRemovedObservable: Observable<Camera>;
  41162. /**
  41163. * An event triggered when a light is created
  41164. */
  41165. onNewLightAddedObservable: Observable<Light>;
  41166. /**
  41167. * An event triggered when a light is removed
  41168. */
  41169. onLightRemovedObservable: Observable<Light>;
  41170. /**
  41171. * An event triggered when a geometry is created
  41172. */
  41173. onNewGeometryAddedObservable: Observable<Geometry>;
  41174. /**
  41175. * An event triggered when a geometry is removed
  41176. */
  41177. onGeometryRemovedObservable: Observable<Geometry>;
  41178. /**
  41179. * An event triggered when a transform node is created
  41180. */
  41181. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  41182. /**
  41183. * An event triggered when a transform node is removed
  41184. */
  41185. onTransformNodeRemovedObservable: Observable<TransformNode>;
  41186. /**
  41187. * An event triggered when a mesh is created
  41188. */
  41189. onNewMeshAddedObservable: Observable<AbstractMesh>;
  41190. /**
  41191. * An event triggered when a mesh is removed
  41192. */
  41193. onMeshRemovedObservable: Observable<AbstractMesh>;
  41194. /**
  41195. * An event triggered when a skeleton is created
  41196. */
  41197. onNewSkeletonAddedObservable: Observable<Skeleton>;
  41198. /**
  41199. * An event triggered when a skeleton is removed
  41200. */
  41201. onSkeletonRemovedObservable: Observable<Skeleton>;
  41202. /**
  41203. * An event triggered when a material is created
  41204. */
  41205. onNewMaterialAddedObservable: Observable<Material>;
  41206. /**
  41207. * An event triggered when a material is removed
  41208. */
  41209. onMaterialRemovedObservable: Observable<Material>;
  41210. /**
  41211. * An event triggered when a texture is created
  41212. */
  41213. onNewTextureAddedObservable: Observable<BaseTexture>;
  41214. /**
  41215. * An event triggered when a texture is removed
  41216. */
  41217. onTextureRemovedObservable: Observable<BaseTexture>;
  41218. /**
  41219. * An event triggered when render targets are about to be rendered
  41220. * Can happen multiple times per frame.
  41221. */
  41222. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  41223. /**
  41224. * An event triggered when render targets were rendered.
  41225. * Can happen multiple times per frame.
  41226. */
  41227. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  41228. /**
  41229. * An event triggered before calculating deterministic simulation step
  41230. */
  41231. onBeforeStepObservable: Observable<Scene>;
  41232. /**
  41233. * An event triggered after calculating deterministic simulation step
  41234. */
  41235. onAfterStepObservable: Observable<Scene>;
  41236. /**
  41237. * An event triggered when the activeCamera property is updated
  41238. */
  41239. onActiveCameraChanged: Observable<Scene>;
  41240. /**
  41241. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  41242. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  41243. * 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)
  41244. */
  41245. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  41246. /**
  41247. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  41248. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  41249. * 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)
  41250. */
  41251. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  41252. /**
  41253. * This Observable will when a mesh has been imported into the scene.
  41254. */
  41255. onMeshImportedObservable: Observable<AbstractMesh>;
  41256. /**
  41257. * This Observable will when an animation file has been imported into the scene.
  41258. */
  41259. onAnimationFileImportedObservable: Observable<Scene>;
  41260. /**
  41261. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  41262. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  41263. */
  41264. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  41265. /** @hidden */
  41266. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  41267. /**
  41268. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  41269. */
  41270. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  41271. /**
  41272. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  41273. */
  41274. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  41275. /**
  41276. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  41277. */
  41278. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  41279. /** Callback called when a pointer move is detected */
  41280. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  41281. /** Callback called when a pointer down is detected */
  41282. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  41283. /** Callback called when a pointer up is detected */
  41284. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  41285. /** Callback called when a pointer pick is detected */
  41286. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  41287. /**
  41288. * 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).
  41289. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  41290. */
  41291. onPrePointerObservable: Observable<PointerInfoPre>;
  41292. /**
  41293. * Observable event triggered each time an input event is received from the rendering canvas
  41294. */
  41295. onPointerObservable: Observable<PointerInfo>;
  41296. /**
  41297. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  41298. */
  41299. get unTranslatedPointer(): Vector2;
  41300. /**
  41301. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  41302. */
  41303. static get DragMovementThreshold(): number;
  41304. static set DragMovementThreshold(value: number);
  41305. /**
  41306. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  41307. */
  41308. static get LongPressDelay(): number;
  41309. static set LongPressDelay(value: number);
  41310. /**
  41311. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  41312. */
  41313. static get DoubleClickDelay(): number;
  41314. static set DoubleClickDelay(value: number);
  41315. /** If you need to check double click without raising a single click at first click, enable this flag */
  41316. static get ExclusiveDoubleClickMode(): boolean;
  41317. static set ExclusiveDoubleClickMode(value: boolean);
  41318. /** @hidden */
  41319. _mirroredCameraPosition: Nullable<Vector3>;
  41320. /**
  41321. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  41322. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  41323. */
  41324. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  41325. /**
  41326. * Observable event triggered each time an keyboard event is received from the hosting window
  41327. */
  41328. onKeyboardObservable: Observable<KeyboardInfo>;
  41329. private _useRightHandedSystem;
  41330. /**
  41331. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  41332. */
  41333. set useRightHandedSystem(value: boolean);
  41334. get useRightHandedSystem(): boolean;
  41335. private _timeAccumulator;
  41336. private _currentStepId;
  41337. private _currentInternalStep;
  41338. /**
  41339. * Sets the step Id used by deterministic lock step
  41340. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  41341. * @param newStepId defines the step Id
  41342. */
  41343. setStepId(newStepId: number): void;
  41344. /**
  41345. * Gets the step Id used by deterministic lock step
  41346. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  41347. * @returns the step Id
  41348. */
  41349. getStepId(): number;
  41350. /**
  41351. * Gets the internal step used by deterministic lock step
  41352. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  41353. * @returns the internal step
  41354. */
  41355. getInternalStep(): number;
  41356. private _fogEnabled;
  41357. /**
  41358. * Gets or sets a boolean indicating if fog is enabled on this scene
  41359. * @see https://doc.babylonjs.com/babylon101/environment#fog
  41360. * (Default is true)
  41361. */
  41362. set fogEnabled(value: boolean);
  41363. get fogEnabled(): boolean;
  41364. private _fogMode;
  41365. /**
  41366. * Gets or sets the fog mode to use
  41367. * @see https://doc.babylonjs.com/babylon101/environment#fog
  41368. * | mode | value |
  41369. * | --- | --- |
  41370. * | FOGMODE_NONE | 0 |
  41371. * | FOGMODE_EXP | 1 |
  41372. * | FOGMODE_EXP2 | 2 |
  41373. * | FOGMODE_LINEAR | 3 |
  41374. */
  41375. set fogMode(value: number);
  41376. get fogMode(): number;
  41377. /**
  41378. * Gets or sets the fog color to use
  41379. * @see https://doc.babylonjs.com/babylon101/environment#fog
  41380. * (Default is Color3(0.2, 0.2, 0.3))
  41381. */
  41382. fogColor: Color3;
  41383. /**
  41384. * Gets or sets the fog density to use
  41385. * @see https://doc.babylonjs.com/babylon101/environment#fog
  41386. * (Default is 0.1)
  41387. */
  41388. fogDensity: number;
  41389. /**
  41390. * Gets or sets the fog start distance to use
  41391. * @see https://doc.babylonjs.com/babylon101/environment#fog
  41392. * (Default is 0)
  41393. */
  41394. fogStart: number;
  41395. /**
  41396. * Gets or sets the fog end distance to use
  41397. * @see https://doc.babylonjs.com/babylon101/environment#fog
  41398. * (Default is 1000)
  41399. */
  41400. fogEnd: number;
  41401. /**
  41402. * Flag indicating that the frame buffer binding is handled by another component
  41403. */
  41404. prePass: boolean;
  41405. private _shadowsEnabled;
  41406. /**
  41407. * Gets or sets a boolean indicating if shadows are enabled on this scene
  41408. */
  41409. set shadowsEnabled(value: boolean);
  41410. get shadowsEnabled(): boolean;
  41411. private _lightsEnabled;
  41412. /**
  41413. * Gets or sets a boolean indicating if lights are enabled on this scene
  41414. */
  41415. set lightsEnabled(value: boolean);
  41416. get lightsEnabled(): boolean;
  41417. /** All of the active cameras added to this scene. */
  41418. activeCameras: Camera[];
  41419. /** @hidden */
  41420. _activeCamera: Nullable<Camera>;
  41421. /** Gets or sets the current active camera */
  41422. get activeCamera(): Nullable<Camera>;
  41423. set activeCamera(value: Nullable<Camera>);
  41424. private _defaultMaterial;
  41425. /** The default material used on meshes when no material is affected */
  41426. get defaultMaterial(): Material;
  41427. /** The default material used on meshes when no material is affected */
  41428. set defaultMaterial(value: Material);
  41429. private _texturesEnabled;
  41430. /**
  41431. * Gets or sets a boolean indicating if textures are enabled on this scene
  41432. */
  41433. set texturesEnabled(value: boolean);
  41434. get texturesEnabled(): boolean;
  41435. /**
  41436. * Gets or sets a boolean indicating if physic engines are enabled on this scene
  41437. */
  41438. physicsEnabled: boolean;
  41439. /**
  41440. * Gets or sets a boolean indicating if particles are enabled on this scene
  41441. */
  41442. particlesEnabled: boolean;
  41443. /**
  41444. * Gets or sets a boolean indicating if sprites are enabled on this scene
  41445. */
  41446. spritesEnabled: boolean;
  41447. private _skeletonsEnabled;
  41448. /**
  41449. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  41450. */
  41451. set skeletonsEnabled(value: boolean);
  41452. get skeletonsEnabled(): boolean;
  41453. /**
  41454. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  41455. */
  41456. lensFlaresEnabled: boolean;
  41457. /**
  41458. * Gets or sets a boolean indicating if collisions are enabled on this scene
  41459. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  41460. */
  41461. collisionsEnabled: boolean;
  41462. private _collisionCoordinator;
  41463. /** @hidden */
  41464. get collisionCoordinator(): ICollisionCoordinator;
  41465. /**
  41466. * Defines the gravity applied to this scene (used only for collisions)
  41467. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  41468. */
  41469. gravity: Vector3;
  41470. /**
  41471. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  41472. */
  41473. postProcessesEnabled: boolean;
  41474. /**
  41475. * Gets the current postprocess manager
  41476. */
  41477. postProcessManager: PostProcessManager;
  41478. /**
  41479. * Gets or sets a boolean indicating if render targets are enabled on this scene
  41480. */
  41481. renderTargetsEnabled: boolean;
  41482. /**
  41483. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  41484. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  41485. */
  41486. dumpNextRenderTargets: boolean;
  41487. /**
  41488. * The list of user defined render targets added to the scene
  41489. */
  41490. customRenderTargets: RenderTargetTexture[];
  41491. /**
  41492. * Defines if texture loading must be delayed
  41493. * If true, textures will only be loaded when they need to be rendered
  41494. */
  41495. useDelayedTextureLoading: boolean;
  41496. /**
  41497. * Gets the list of meshes imported to the scene through SceneLoader
  41498. */
  41499. importedMeshesFiles: String[];
  41500. /**
  41501. * Gets or sets a boolean indicating if probes are enabled on this scene
  41502. */
  41503. probesEnabled: boolean;
  41504. /**
  41505. * Gets or sets the current offline provider to use to store scene data
  41506. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  41507. */
  41508. offlineProvider: IOfflineProvider;
  41509. /**
  41510. * Gets or sets the action manager associated with the scene
  41511. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  41512. */
  41513. actionManager: AbstractActionManager;
  41514. private _meshesForIntersections;
  41515. /**
  41516. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  41517. */
  41518. proceduralTexturesEnabled: boolean;
  41519. private _engine;
  41520. private _totalVertices;
  41521. /** @hidden */
  41522. _activeIndices: PerfCounter;
  41523. /** @hidden */
  41524. _activeParticles: PerfCounter;
  41525. /** @hidden */
  41526. _activeBones: PerfCounter;
  41527. private _animationRatio;
  41528. /** @hidden */
  41529. _animationTimeLast: number;
  41530. /** @hidden */
  41531. _animationTime: number;
  41532. /**
  41533. * Gets or sets a general scale for animation speed
  41534. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  41535. */
  41536. animationTimeScale: number;
  41537. /** @hidden */
  41538. _cachedMaterial: Nullable<Material>;
  41539. /** @hidden */
  41540. _cachedEffect: Nullable<Effect>;
  41541. /** @hidden */
  41542. _cachedVisibility: Nullable<number>;
  41543. private _renderId;
  41544. private _frameId;
  41545. private _executeWhenReadyTimeoutId;
  41546. private _intermediateRendering;
  41547. private _viewUpdateFlag;
  41548. private _projectionUpdateFlag;
  41549. /** @hidden */
  41550. _toBeDisposed: Nullable<IDisposable>[];
  41551. private _activeRequests;
  41552. /** @hidden */
  41553. _pendingData: any[];
  41554. private _isDisposed;
  41555. /**
  41556. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  41557. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  41558. */
  41559. dispatchAllSubMeshesOfActiveMeshes: boolean;
  41560. private _activeMeshes;
  41561. private _processedMaterials;
  41562. private _renderTargets;
  41563. /** @hidden */
  41564. _activeParticleSystems: SmartArray<IParticleSystem>;
  41565. private _activeSkeletons;
  41566. private _softwareSkinnedMeshes;
  41567. private _renderingManager;
  41568. /** @hidden */
  41569. _activeAnimatables: import("babylonjs/Animations/animatable").Animatable[];
  41570. private _transformMatrix;
  41571. private _sceneUbo;
  41572. /** @hidden */
  41573. _viewMatrix: Matrix;
  41574. private _projectionMatrix;
  41575. /** @hidden */
  41576. _forcedViewPosition: Nullable<Vector3>;
  41577. /** @hidden */
  41578. _frustumPlanes: Plane[];
  41579. /**
  41580. * Gets the list of frustum planes (built from the active camera)
  41581. */
  41582. get frustumPlanes(): Plane[];
  41583. /**
  41584. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  41585. * This is useful if there are more lights that the maximum simulteanous authorized
  41586. */
  41587. requireLightSorting: boolean;
  41588. /** @hidden */
  41589. readonly useMaterialMeshMap: boolean;
  41590. /** @hidden */
  41591. readonly useClonedMeshMap: boolean;
  41592. private _externalData;
  41593. private _uid;
  41594. /**
  41595. * @hidden
  41596. * Backing store of defined scene components.
  41597. */
  41598. _components: ISceneComponent[];
  41599. /**
  41600. * @hidden
  41601. * Backing store of defined scene components.
  41602. */
  41603. _serializableComponents: ISceneSerializableComponent[];
  41604. /**
  41605. * List of components to register on the next registration step.
  41606. */
  41607. private _transientComponents;
  41608. /**
  41609. * Registers the transient components if needed.
  41610. */
  41611. private _registerTransientComponents;
  41612. /**
  41613. * @hidden
  41614. * Add a component to the scene.
  41615. * Note that the ccomponent could be registered on th next frame if this is called after
  41616. * the register component stage.
  41617. * @param component Defines the component to add to the scene
  41618. */
  41619. _addComponent(component: ISceneComponent): void;
  41620. /**
  41621. * @hidden
  41622. * Gets a component from the scene.
  41623. * @param name defines the name of the component to retrieve
  41624. * @returns the component or null if not present
  41625. */
  41626. _getComponent(name: string): Nullable<ISceneComponent>;
  41627. /**
  41628. * @hidden
  41629. * Defines the actions happening before camera updates.
  41630. */
  41631. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  41632. /**
  41633. * @hidden
  41634. * Defines the actions happening before clear the canvas.
  41635. */
  41636. _beforeClearStage: Stage<SimpleStageAction>;
  41637. /**
  41638. * @hidden
  41639. * Defines the actions when collecting render targets for the frame.
  41640. */
  41641. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  41642. /**
  41643. * @hidden
  41644. * Defines the actions happening for one camera in the frame.
  41645. */
  41646. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  41647. /**
  41648. * @hidden
  41649. * Defines the actions happening during the per mesh ready checks.
  41650. */
  41651. _isReadyForMeshStage: Stage<MeshStageAction>;
  41652. /**
  41653. * @hidden
  41654. * Defines the actions happening before evaluate active mesh checks.
  41655. */
  41656. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  41657. /**
  41658. * @hidden
  41659. * Defines the actions happening during the evaluate sub mesh checks.
  41660. */
  41661. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  41662. /**
  41663. * @hidden
  41664. * Defines the actions happening during the active mesh stage.
  41665. */
  41666. _activeMeshStage: Stage<ActiveMeshStageAction>;
  41667. /**
  41668. * @hidden
  41669. * Defines the actions happening during the per camera render target step.
  41670. */
  41671. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  41672. /**
  41673. * @hidden
  41674. * Defines the actions happening just before the active camera is drawing.
  41675. */
  41676. _beforeCameraDrawStage: Stage<CameraStageAction>;
  41677. /**
  41678. * @hidden
  41679. * Defines the actions happening just before a render target is drawing.
  41680. */
  41681. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  41682. /**
  41683. * @hidden
  41684. * Defines the actions happening just before a rendering group is drawing.
  41685. */
  41686. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  41687. /**
  41688. * @hidden
  41689. * Defines the actions happening just before a mesh is drawing.
  41690. */
  41691. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  41692. /**
  41693. * @hidden
  41694. * Defines the actions happening just after a mesh has been drawn.
  41695. */
  41696. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  41697. /**
  41698. * @hidden
  41699. * Defines the actions happening just after a rendering group has been drawn.
  41700. */
  41701. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  41702. /**
  41703. * @hidden
  41704. * Defines the actions happening just after the active camera has been drawn.
  41705. */
  41706. _afterCameraDrawStage: Stage<CameraStageAction>;
  41707. /**
  41708. * @hidden
  41709. * Defines the actions happening just after a render target has been drawn.
  41710. */
  41711. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  41712. /**
  41713. * @hidden
  41714. * Defines the actions happening just after rendering all cameras and computing intersections.
  41715. */
  41716. _afterRenderStage: Stage<SimpleStageAction>;
  41717. /**
  41718. * @hidden
  41719. * Defines the actions happening when a pointer move event happens.
  41720. */
  41721. _pointerMoveStage: Stage<PointerMoveStageAction>;
  41722. /**
  41723. * @hidden
  41724. * Defines the actions happening when a pointer down event happens.
  41725. */
  41726. _pointerDownStage: Stage<PointerUpDownStageAction>;
  41727. /**
  41728. * @hidden
  41729. * Defines the actions happening when a pointer up event happens.
  41730. */
  41731. _pointerUpStage: Stage<PointerUpDownStageAction>;
  41732. /**
  41733. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  41734. */
  41735. private geometriesByUniqueId;
  41736. /**
  41737. * Creates a new Scene
  41738. * @param engine defines the engine to use to render this scene
  41739. * @param options defines the scene options
  41740. */
  41741. constructor(engine: Engine, options?: SceneOptions);
  41742. /**
  41743. * Gets a string identifying the name of the class
  41744. * @returns "Scene" string
  41745. */
  41746. getClassName(): string;
  41747. private _defaultMeshCandidates;
  41748. /**
  41749. * @hidden
  41750. */
  41751. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  41752. private _defaultSubMeshCandidates;
  41753. /**
  41754. * @hidden
  41755. */
  41756. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  41757. /**
  41758. * Sets the default candidate providers for the scene.
  41759. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  41760. * and getCollidingSubMeshCandidates to their default function
  41761. */
  41762. setDefaultCandidateProviders(): void;
  41763. /**
  41764. * Gets the mesh that is currently under the pointer
  41765. */
  41766. get meshUnderPointer(): Nullable<AbstractMesh>;
  41767. /**
  41768. * Gets or sets the current on-screen X position of the pointer
  41769. */
  41770. get pointerX(): number;
  41771. set pointerX(value: number);
  41772. /**
  41773. * Gets or sets the current on-screen Y position of the pointer
  41774. */
  41775. get pointerY(): number;
  41776. set pointerY(value: number);
  41777. /**
  41778. * Gets the cached material (ie. the latest rendered one)
  41779. * @returns the cached material
  41780. */
  41781. getCachedMaterial(): Nullable<Material>;
  41782. /**
  41783. * Gets the cached effect (ie. the latest rendered one)
  41784. * @returns the cached effect
  41785. */
  41786. getCachedEffect(): Nullable<Effect>;
  41787. /**
  41788. * Gets the cached visibility state (ie. the latest rendered one)
  41789. * @returns the cached visibility state
  41790. */
  41791. getCachedVisibility(): Nullable<number>;
  41792. /**
  41793. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  41794. * @param material defines the current material
  41795. * @param effect defines the current effect
  41796. * @param visibility defines the current visibility state
  41797. * @returns true if one parameter is not cached
  41798. */
  41799. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  41800. /**
  41801. * Gets the engine associated with the scene
  41802. * @returns an Engine
  41803. */
  41804. getEngine(): Engine;
  41805. /**
  41806. * Gets the total number of vertices rendered per frame
  41807. * @returns the total number of vertices rendered per frame
  41808. */
  41809. getTotalVertices(): number;
  41810. /**
  41811. * Gets the performance counter for total vertices
  41812. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  41813. */
  41814. get totalVerticesPerfCounter(): PerfCounter;
  41815. /**
  41816. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  41817. * @returns the total number of active indices rendered per frame
  41818. */
  41819. getActiveIndices(): number;
  41820. /**
  41821. * Gets the performance counter for active indices
  41822. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  41823. */
  41824. get totalActiveIndicesPerfCounter(): PerfCounter;
  41825. /**
  41826. * Gets the total number of active particles rendered per frame
  41827. * @returns the total number of active particles rendered per frame
  41828. */
  41829. getActiveParticles(): number;
  41830. /**
  41831. * Gets the performance counter for active particles
  41832. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  41833. */
  41834. get activeParticlesPerfCounter(): PerfCounter;
  41835. /**
  41836. * Gets the total number of active bones rendered per frame
  41837. * @returns the total number of active bones rendered per frame
  41838. */
  41839. getActiveBones(): number;
  41840. /**
  41841. * Gets the performance counter for active bones
  41842. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  41843. */
  41844. get activeBonesPerfCounter(): PerfCounter;
  41845. /**
  41846. * Gets the array of active meshes
  41847. * @returns an array of AbstractMesh
  41848. */
  41849. getActiveMeshes(): SmartArray<AbstractMesh>;
  41850. /**
  41851. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  41852. * @returns a number
  41853. */
  41854. getAnimationRatio(): number;
  41855. /**
  41856. * Gets an unique Id for the current render phase
  41857. * @returns a number
  41858. */
  41859. getRenderId(): number;
  41860. /**
  41861. * Gets an unique Id for the current frame
  41862. * @returns a number
  41863. */
  41864. getFrameId(): number;
  41865. /** Call this function if you want to manually increment the render Id*/
  41866. incrementRenderId(): void;
  41867. private _createUbo;
  41868. /**
  41869. * Use this method to simulate a pointer move on a mesh
  41870. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  41871. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  41872. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  41873. * @returns the current scene
  41874. */
  41875. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  41876. /**
  41877. * Use this method to simulate a pointer down on a mesh
  41878. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  41879. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  41880. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  41881. * @returns the current scene
  41882. */
  41883. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  41884. /**
  41885. * Use this method to simulate a pointer up on a mesh
  41886. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  41887. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  41888. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  41889. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  41890. * @returns the current scene
  41891. */
  41892. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  41893. /**
  41894. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  41895. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  41896. * @returns true if the pointer was captured
  41897. */
  41898. isPointerCaptured(pointerId?: number): boolean;
  41899. /**
  41900. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  41901. * @param attachUp defines if you want to attach events to pointerup
  41902. * @param attachDown defines if you want to attach events to pointerdown
  41903. * @param attachMove defines if you want to attach events to pointermove
  41904. */
  41905. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  41906. /** Detaches all event handlers*/
  41907. detachControl(): void;
  41908. /**
  41909. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  41910. * Delay loaded resources are not taking in account
  41911. * @return true if all required resources are ready
  41912. */
  41913. isReady(): boolean;
  41914. /** Resets all cached information relative to material (including effect and visibility) */
  41915. resetCachedMaterial(): void;
  41916. /**
  41917. * Registers a function to be called before every frame render
  41918. * @param func defines the function to register
  41919. */
  41920. registerBeforeRender(func: () => void): void;
  41921. /**
  41922. * Unregisters a function called before every frame render
  41923. * @param func defines the function to unregister
  41924. */
  41925. unregisterBeforeRender(func: () => void): void;
  41926. /**
  41927. * Registers a function to be called after every frame render
  41928. * @param func defines the function to register
  41929. */
  41930. registerAfterRender(func: () => void): void;
  41931. /**
  41932. * Unregisters a function called after every frame render
  41933. * @param func defines the function to unregister
  41934. */
  41935. unregisterAfterRender(func: () => void): void;
  41936. private _executeOnceBeforeRender;
  41937. /**
  41938. * The provided function will run before render once and will be disposed afterwards.
  41939. * A timeout delay can be provided so that the function will be executed in N ms.
  41940. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  41941. * @param func The function to be executed.
  41942. * @param timeout optional delay in ms
  41943. */
  41944. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  41945. /** @hidden */
  41946. _addPendingData(data: any): void;
  41947. /** @hidden */
  41948. _removePendingData(data: any): void;
  41949. /**
  41950. * Returns the number of items waiting to be loaded
  41951. * @returns the number of items waiting to be loaded
  41952. */
  41953. getWaitingItemsCount(): number;
  41954. /**
  41955. * Returns a boolean indicating if the scene is still loading data
  41956. */
  41957. get isLoading(): boolean;
  41958. /**
  41959. * Registers a function to be executed when the scene is ready
  41960. * @param {Function} func - the function to be executed
  41961. */
  41962. executeWhenReady(func: () => void): void;
  41963. /**
  41964. * Returns a promise that resolves when the scene is ready
  41965. * @returns A promise that resolves when the scene is ready
  41966. */
  41967. whenReadyAsync(): Promise<void>;
  41968. /** @hidden */
  41969. _checkIsReady(): void;
  41970. /**
  41971. * Gets all animatable attached to the scene
  41972. */
  41973. get animatables(): Animatable[];
  41974. /**
  41975. * Resets the last animation time frame.
  41976. * Useful to override when animations start running when loading a scene for the first time.
  41977. */
  41978. resetLastAnimationTimeFrame(): void;
  41979. /**
  41980. * Gets the current view matrix
  41981. * @returns a Matrix
  41982. */
  41983. getViewMatrix(): Matrix;
  41984. /**
  41985. * Gets the current projection matrix
  41986. * @returns a Matrix
  41987. */
  41988. getProjectionMatrix(): Matrix;
  41989. /**
  41990. * Gets the current transform matrix
  41991. * @returns a Matrix made of View * Projection
  41992. */
  41993. getTransformMatrix(): Matrix;
  41994. /**
  41995. * Sets the current transform matrix
  41996. * @param viewL defines the View matrix to use
  41997. * @param projectionL defines the Projection matrix to use
  41998. * @param viewR defines the right View matrix to use (if provided)
  41999. * @param projectionR defines the right Projection matrix to use (if provided)
  42000. */
  42001. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  42002. /**
  42003. * Gets the uniform buffer used to store scene data
  42004. * @returns a UniformBuffer
  42005. */
  42006. getSceneUniformBuffer(): UniformBuffer;
  42007. /**
  42008. * Gets an unique (relatively to the current scene) Id
  42009. * @returns an unique number for the scene
  42010. */
  42011. getUniqueId(): number;
  42012. /**
  42013. * Add a mesh to the list of scene's meshes
  42014. * @param newMesh defines the mesh to add
  42015. * @param recursive if all child meshes should also be added to the scene
  42016. */
  42017. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  42018. /**
  42019. * Remove a mesh for the list of scene's meshes
  42020. * @param toRemove defines the mesh to remove
  42021. * @param recursive if all child meshes should also be removed from the scene
  42022. * @returns the index where the mesh was in the mesh list
  42023. */
  42024. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  42025. /**
  42026. * Add a transform node to the list of scene's transform nodes
  42027. * @param newTransformNode defines the transform node to add
  42028. */
  42029. addTransformNode(newTransformNode: TransformNode): void;
  42030. /**
  42031. * Remove a transform node for the list of scene's transform nodes
  42032. * @param toRemove defines the transform node to remove
  42033. * @returns the index where the transform node was in the transform node list
  42034. */
  42035. removeTransformNode(toRemove: TransformNode): number;
  42036. /**
  42037. * Remove a skeleton for the list of scene's skeletons
  42038. * @param toRemove defines the skeleton to remove
  42039. * @returns the index where the skeleton was in the skeleton list
  42040. */
  42041. removeSkeleton(toRemove: Skeleton): number;
  42042. /**
  42043. * Remove a morph target for the list of scene's morph targets
  42044. * @param toRemove defines the morph target to remove
  42045. * @returns the index where the morph target was in the morph target list
  42046. */
  42047. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  42048. /**
  42049. * Remove a light for the list of scene's lights
  42050. * @param toRemove defines the light to remove
  42051. * @returns the index where the light was in the light list
  42052. */
  42053. removeLight(toRemove: Light): number;
  42054. /**
  42055. * Remove a camera for the list of scene's cameras
  42056. * @param toRemove defines the camera to remove
  42057. * @returns the index where the camera was in the camera list
  42058. */
  42059. removeCamera(toRemove: Camera): number;
  42060. /**
  42061. * Remove a particle system for the list of scene's particle systems
  42062. * @param toRemove defines the particle system to remove
  42063. * @returns the index where the particle system was in the particle system list
  42064. */
  42065. removeParticleSystem(toRemove: IParticleSystem): number;
  42066. /**
  42067. * Remove a animation for the list of scene's animations
  42068. * @param toRemove defines the animation to remove
  42069. * @returns the index where the animation was in the animation list
  42070. */
  42071. removeAnimation(toRemove: Animation): number;
  42072. /**
  42073. * Will stop the animation of the given target
  42074. * @param target - the target
  42075. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  42076. * @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)
  42077. */
  42078. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  42079. /**
  42080. * Removes the given animation group from this scene.
  42081. * @param toRemove The animation group to remove
  42082. * @returns The index of the removed animation group
  42083. */
  42084. removeAnimationGroup(toRemove: AnimationGroup): number;
  42085. /**
  42086. * Removes the given multi-material from this scene.
  42087. * @param toRemove The multi-material to remove
  42088. * @returns The index of the removed multi-material
  42089. */
  42090. removeMultiMaterial(toRemove: MultiMaterial): number;
  42091. /**
  42092. * Removes the given material from this scene.
  42093. * @param toRemove The material to remove
  42094. * @returns The index of the removed material
  42095. */
  42096. removeMaterial(toRemove: Material): number;
  42097. /**
  42098. * Removes the given action manager from this scene.
  42099. * @param toRemove The action manager to remove
  42100. * @returns The index of the removed action manager
  42101. */
  42102. removeActionManager(toRemove: AbstractActionManager): number;
  42103. /**
  42104. * Removes the given texture from this scene.
  42105. * @param toRemove The texture to remove
  42106. * @returns The index of the removed texture
  42107. */
  42108. removeTexture(toRemove: BaseTexture): number;
  42109. /**
  42110. * Adds the given light to this scene
  42111. * @param newLight The light to add
  42112. */
  42113. addLight(newLight: Light): void;
  42114. /**
  42115. * Sorts the list list based on light priorities
  42116. */
  42117. sortLightsByPriority(): void;
  42118. /**
  42119. * Adds the given camera to this scene
  42120. * @param newCamera The camera to add
  42121. */
  42122. addCamera(newCamera: Camera): void;
  42123. /**
  42124. * Adds the given skeleton to this scene
  42125. * @param newSkeleton The skeleton to add
  42126. */
  42127. addSkeleton(newSkeleton: Skeleton): void;
  42128. /**
  42129. * Adds the given particle system to this scene
  42130. * @param newParticleSystem The particle system to add
  42131. */
  42132. addParticleSystem(newParticleSystem: IParticleSystem): void;
  42133. /**
  42134. * Adds the given animation to this scene
  42135. * @param newAnimation The animation to add
  42136. */
  42137. addAnimation(newAnimation: Animation): void;
  42138. /**
  42139. * Adds the given animation group to this scene.
  42140. * @param newAnimationGroup The animation group to add
  42141. */
  42142. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  42143. /**
  42144. * Adds the given multi-material to this scene
  42145. * @param newMultiMaterial The multi-material to add
  42146. */
  42147. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  42148. /**
  42149. * Adds the given material to this scene
  42150. * @param newMaterial The material to add
  42151. */
  42152. addMaterial(newMaterial: Material): void;
  42153. /**
  42154. * Adds the given morph target to this scene
  42155. * @param newMorphTargetManager The morph target to add
  42156. */
  42157. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  42158. /**
  42159. * Adds the given geometry to this scene
  42160. * @param newGeometry The geometry to add
  42161. */
  42162. addGeometry(newGeometry: Geometry): void;
  42163. /**
  42164. * Adds the given action manager to this scene
  42165. * @param newActionManager The action manager to add
  42166. */
  42167. addActionManager(newActionManager: AbstractActionManager): void;
  42168. /**
  42169. * Adds the given texture to this scene.
  42170. * @param newTexture The texture to add
  42171. */
  42172. addTexture(newTexture: BaseTexture): void;
  42173. /**
  42174. * Switch active camera
  42175. * @param newCamera defines the new active camera
  42176. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  42177. */
  42178. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  42179. /**
  42180. * sets the active camera of the scene using its ID
  42181. * @param id defines the camera's ID
  42182. * @return the new active camera or null if none found.
  42183. */
  42184. setActiveCameraByID(id: string): Nullable<Camera>;
  42185. /**
  42186. * sets the active camera of the scene using its name
  42187. * @param name defines the camera's name
  42188. * @returns the new active camera or null if none found.
  42189. */
  42190. setActiveCameraByName(name: string): Nullable<Camera>;
  42191. /**
  42192. * get an animation group using its name
  42193. * @param name defines the material's name
  42194. * @return the animation group or null if none found.
  42195. */
  42196. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  42197. /**
  42198. * Get a material using its unique id
  42199. * @param uniqueId defines the material's unique id
  42200. * @return the material or null if none found.
  42201. */
  42202. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  42203. /**
  42204. * get a material using its id
  42205. * @param id defines the material's ID
  42206. * @return the material or null if none found.
  42207. */
  42208. getMaterialByID(id: string): Nullable<Material>;
  42209. /**
  42210. * Gets a the last added material using a given id
  42211. * @param id defines the material's ID
  42212. * @return the last material with the given id or null if none found.
  42213. */
  42214. getLastMaterialByID(id: string): Nullable<Material>;
  42215. /**
  42216. * Gets a material using its name
  42217. * @param name defines the material's name
  42218. * @return the material or null if none found.
  42219. */
  42220. getMaterialByName(name: string): Nullable<Material>;
  42221. /**
  42222. * Get a texture using its unique id
  42223. * @param uniqueId defines the texture's unique id
  42224. * @return the texture or null if none found.
  42225. */
  42226. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  42227. /**
  42228. * Gets a camera using its id
  42229. * @param id defines the id to look for
  42230. * @returns the camera or null if not found
  42231. */
  42232. getCameraByID(id: string): Nullable<Camera>;
  42233. /**
  42234. * Gets a camera using its unique id
  42235. * @param uniqueId defines the unique id to look for
  42236. * @returns the camera or null if not found
  42237. */
  42238. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  42239. /**
  42240. * Gets a camera using its name
  42241. * @param name defines the camera's name
  42242. * @return the camera or null if none found.
  42243. */
  42244. getCameraByName(name: string): Nullable<Camera>;
  42245. /**
  42246. * Gets a bone using its id
  42247. * @param id defines the bone's id
  42248. * @return the bone or null if not found
  42249. */
  42250. getBoneByID(id: string): Nullable<Bone>;
  42251. /**
  42252. * Gets a bone using its id
  42253. * @param name defines the bone's name
  42254. * @return the bone or null if not found
  42255. */
  42256. getBoneByName(name: string): Nullable<Bone>;
  42257. /**
  42258. * Gets a light node using its name
  42259. * @param name defines the the light's name
  42260. * @return the light or null if none found.
  42261. */
  42262. getLightByName(name: string): Nullable<Light>;
  42263. /**
  42264. * Gets a light node using its id
  42265. * @param id defines the light's id
  42266. * @return the light or null if none found.
  42267. */
  42268. getLightByID(id: string): Nullable<Light>;
  42269. /**
  42270. * Gets a light node using its scene-generated unique ID
  42271. * @param uniqueId defines the light's unique id
  42272. * @return the light or null if none found.
  42273. */
  42274. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  42275. /**
  42276. * Gets a particle system by id
  42277. * @param id defines the particle system id
  42278. * @return the corresponding system or null if none found
  42279. */
  42280. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  42281. /**
  42282. * Gets a geometry using its ID
  42283. * @param id defines the geometry's id
  42284. * @return the geometry or null if none found.
  42285. */
  42286. getGeometryByID(id: string): Nullable<Geometry>;
  42287. private _getGeometryByUniqueID;
  42288. /**
  42289. * Add a new geometry to this scene
  42290. * @param geometry defines the geometry to be added to the scene.
  42291. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  42292. * @return a boolean defining if the geometry was added or not
  42293. */
  42294. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  42295. /**
  42296. * Removes an existing geometry
  42297. * @param geometry defines the geometry to be removed from the scene
  42298. * @return a boolean defining if the geometry was removed or not
  42299. */
  42300. removeGeometry(geometry: Geometry): boolean;
  42301. /**
  42302. * Gets the list of geometries attached to the scene
  42303. * @returns an array of Geometry
  42304. */
  42305. getGeometries(): Geometry[];
  42306. /**
  42307. * Gets the first added mesh found of a given ID
  42308. * @param id defines the id to search for
  42309. * @return the mesh found or null if not found at all
  42310. */
  42311. getMeshByID(id: string): Nullable<AbstractMesh>;
  42312. /**
  42313. * Gets a list of meshes using their id
  42314. * @param id defines the id to search for
  42315. * @returns a list of meshes
  42316. */
  42317. getMeshesByID(id: string): Array<AbstractMesh>;
  42318. /**
  42319. * Gets the first added transform node found of a given ID
  42320. * @param id defines the id to search for
  42321. * @return the found transform node or null if not found at all.
  42322. */
  42323. getTransformNodeByID(id: string): Nullable<TransformNode>;
  42324. /**
  42325. * Gets a transform node with its auto-generated unique id
  42326. * @param uniqueId efines the unique id to search for
  42327. * @return the found transform node or null if not found at all.
  42328. */
  42329. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  42330. /**
  42331. * Gets a list of transform nodes using their id
  42332. * @param id defines the id to search for
  42333. * @returns a list of transform nodes
  42334. */
  42335. getTransformNodesByID(id: string): Array<TransformNode>;
  42336. /**
  42337. * Gets a mesh with its auto-generated unique id
  42338. * @param uniqueId defines the unique id to search for
  42339. * @return the found mesh or null if not found at all.
  42340. */
  42341. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  42342. /**
  42343. * Gets a the last added mesh using a given id
  42344. * @param id defines the id to search for
  42345. * @return the found mesh or null if not found at all.
  42346. */
  42347. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  42348. /**
  42349. * Gets a the last added node (Mesh, Camera, Light) using a given id
  42350. * @param id defines the id to search for
  42351. * @return the found node or null if not found at all
  42352. */
  42353. getLastEntryByID(id: string): Nullable<Node>;
  42354. /**
  42355. * Gets a node (Mesh, Camera, Light) using a given id
  42356. * @param id defines the id to search for
  42357. * @return the found node or null if not found at all
  42358. */
  42359. getNodeByID(id: string): Nullable<Node>;
  42360. /**
  42361. * Gets a node (Mesh, Camera, Light) using a given name
  42362. * @param name defines the name to search for
  42363. * @return the found node or null if not found at all.
  42364. */
  42365. getNodeByName(name: string): Nullable<Node>;
  42366. /**
  42367. * Gets a mesh using a given name
  42368. * @param name defines the name to search for
  42369. * @return the found mesh or null if not found at all.
  42370. */
  42371. getMeshByName(name: string): Nullable<AbstractMesh>;
  42372. /**
  42373. * Gets a transform node using a given name
  42374. * @param name defines the name to search for
  42375. * @return the found transform node or null if not found at all.
  42376. */
  42377. getTransformNodeByName(name: string): Nullable<TransformNode>;
  42378. /**
  42379. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  42380. * @param id defines the id to search for
  42381. * @return the found skeleton or null if not found at all.
  42382. */
  42383. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  42384. /**
  42385. * Gets a skeleton using a given auto generated unique id
  42386. * @param uniqueId defines the unique id to search for
  42387. * @return the found skeleton or null if not found at all.
  42388. */
  42389. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  42390. /**
  42391. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  42392. * @param id defines the id to search for
  42393. * @return the found skeleton or null if not found at all.
  42394. */
  42395. getSkeletonById(id: string): Nullable<Skeleton>;
  42396. /**
  42397. * Gets a skeleton using a given name
  42398. * @param name defines the name to search for
  42399. * @return the found skeleton or null if not found at all.
  42400. */
  42401. getSkeletonByName(name: string): Nullable<Skeleton>;
  42402. /**
  42403. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  42404. * @param id defines the id to search for
  42405. * @return the found morph target manager or null if not found at all.
  42406. */
  42407. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  42408. /**
  42409. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  42410. * @param id defines the id to search for
  42411. * @return the found morph target or null if not found at all.
  42412. */
  42413. getMorphTargetById(id: string): Nullable<MorphTarget>;
  42414. /**
  42415. * Gets a morph target using a given name (if many are found, this function will pick the first one)
  42416. * @param name defines the name to search for
  42417. * @return the found morph target or null if not found at all.
  42418. */
  42419. getMorphTargetByName(name: string): Nullable<MorphTarget>;
  42420. /**
  42421. * Gets a post process using a given name (if many are found, this function will pick the first one)
  42422. * @param name defines the name to search for
  42423. * @return the found post process or null if not found at all.
  42424. */
  42425. getPostProcessByName(name: string): Nullable<PostProcess>;
  42426. /**
  42427. * Gets a boolean indicating if the given mesh is active
  42428. * @param mesh defines the mesh to look for
  42429. * @returns true if the mesh is in the active list
  42430. */
  42431. isActiveMesh(mesh: AbstractMesh): boolean;
  42432. /**
  42433. * Return a unique id as a string which can serve as an identifier for the scene
  42434. */
  42435. get uid(): string;
  42436. /**
  42437. * Add an externaly attached data from its key.
  42438. * This method call will fail and return false, if such key already exists.
  42439. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  42440. * @param key the unique key that identifies the data
  42441. * @param data the data object to associate to the key for this Engine instance
  42442. * @return true if no such key were already present and the data was added successfully, false otherwise
  42443. */
  42444. addExternalData<T>(key: string, data: T): boolean;
  42445. /**
  42446. * Get an externaly attached data from its key
  42447. * @param key the unique key that identifies the data
  42448. * @return the associated data, if present (can be null), or undefined if not present
  42449. */
  42450. getExternalData<T>(key: string): Nullable<T>;
  42451. /**
  42452. * Get an externaly attached data from its key, create it using a factory if it's not already present
  42453. * @param key the unique key that identifies the data
  42454. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  42455. * @return the associated data, can be null if the factory returned null.
  42456. */
  42457. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  42458. /**
  42459. * Remove an externaly attached data from the Engine instance
  42460. * @param key the unique key that identifies the data
  42461. * @return true if the data was successfully removed, false if it doesn't exist
  42462. */
  42463. removeExternalData(key: string): boolean;
  42464. private _evaluateSubMesh;
  42465. /**
  42466. * Clear the processed materials smart array preventing retention point in material dispose.
  42467. */
  42468. freeProcessedMaterials(): void;
  42469. private _preventFreeActiveMeshesAndRenderingGroups;
  42470. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  42471. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  42472. * when disposing several meshes in a row or a hierarchy of meshes.
  42473. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  42474. */
  42475. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  42476. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  42477. /**
  42478. * Clear the active meshes smart array preventing retention point in mesh dispose.
  42479. */
  42480. freeActiveMeshes(): void;
  42481. /**
  42482. * Clear the info related to rendering groups preventing retention points during dispose.
  42483. */
  42484. freeRenderingGroups(): void;
  42485. /** @hidden */
  42486. _isInIntermediateRendering(): boolean;
  42487. /**
  42488. * Lambda returning the list of potentially active meshes.
  42489. */
  42490. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  42491. /**
  42492. * Lambda returning the list of potentially active sub meshes.
  42493. */
  42494. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  42495. /**
  42496. * Lambda returning the list of potentially intersecting sub meshes.
  42497. */
  42498. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  42499. /**
  42500. * Lambda returning the list of potentially colliding sub meshes.
  42501. */
  42502. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  42503. private _activeMeshesFrozen;
  42504. private _skipEvaluateActiveMeshesCompletely;
  42505. /**
  42506. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  42507. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  42508. * @returns the current scene
  42509. */
  42510. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  42511. /**
  42512. * Use this function to restart evaluating active meshes on every frame
  42513. * @returns the current scene
  42514. */
  42515. unfreezeActiveMeshes(): Scene;
  42516. private _evaluateActiveMeshes;
  42517. private _activeMesh;
  42518. /**
  42519. * Update the transform matrix to update from the current active camera
  42520. * @param force defines a boolean used to force the update even if cache is up to date
  42521. */
  42522. updateTransformMatrix(force?: boolean): void;
  42523. private _bindFrameBuffer;
  42524. /** @hidden */
  42525. _allowPostProcessClearColor: boolean;
  42526. /** @hidden */
  42527. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  42528. private _processSubCameras;
  42529. private _checkIntersections;
  42530. /** @hidden */
  42531. _advancePhysicsEngineStep(step: number): void;
  42532. /**
  42533. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  42534. */
  42535. getDeterministicFrameTime: () => number;
  42536. /** @hidden */
  42537. _animate(): void;
  42538. /** Execute all animations (for a frame) */
  42539. animate(): void;
  42540. /**
  42541. * Render the scene
  42542. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  42543. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  42544. */
  42545. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  42546. /**
  42547. * Freeze all materials
  42548. * A frozen material will not be updatable but should be faster to render
  42549. */
  42550. freezeMaterials(): void;
  42551. /**
  42552. * Unfreeze all materials
  42553. * A frozen material will not be updatable but should be faster to render
  42554. */
  42555. unfreezeMaterials(): void;
  42556. /**
  42557. * Releases all held ressources
  42558. */
  42559. dispose(): void;
  42560. /**
  42561. * Gets if the scene is already disposed
  42562. */
  42563. get isDisposed(): boolean;
  42564. /**
  42565. * Call this function to reduce memory footprint of the scene.
  42566. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  42567. */
  42568. clearCachedVertexData(): void;
  42569. /**
  42570. * This function will remove the local cached buffer data from texture.
  42571. * It will save memory but will prevent the texture from being rebuilt
  42572. */
  42573. cleanCachedTextureBuffer(): void;
  42574. /**
  42575. * Get the world extend vectors with an optional filter
  42576. *
  42577. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  42578. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  42579. */
  42580. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  42581. min: Vector3;
  42582. max: Vector3;
  42583. };
  42584. /**
  42585. * Creates a ray that can be used to pick in the scene
  42586. * @param x defines the x coordinate of the origin (on-screen)
  42587. * @param y defines the y coordinate of the origin (on-screen)
  42588. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  42589. * @param camera defines the camera to use for the picking
  42590. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  42591. * @returns a Ray
  42592. */
  42593. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  42594. /**
  42595. * Creates a ray that can be used to pick in the scene
  42596. * @param x defines the x coordinate of the origin (on-screen)
  42597. * @param y defines the y coordinate of the origin (on-screen)
  42598. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  42599. * @param result defines the ray where to store the picking ray
  42600. * @param camera defines the camera to use for the picking
  42601. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  42602. * @returns the current scene
  42603. */
  42604. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  42605. /**
  42606. * Creates a ray that can be used to pick in the scene
  42607. * @param x defines the x coordinate of the origin (on-screen)
  42608. * @param y defines the y coordinate of the origin (on-screen)
  42609. * @param camera defines the camera to use for the picking
  42610. * @returns a Ray
  42611. */
  42612. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  42613. /**
  42614. * Creates a ray that can be used to pick in the scene
  42615. * @param x defines the x coordinate of the origin (on-screen)
  42616. * @param y defines the y coordinate of the origin (on-screen)
  42617. * @param result defines the ray where to store the picking ray
  42618. * @param camera defines the camera to use for the picking
  42619. * @returns the current scene
  42620. */
  42621. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  42622. /** Launch a ray to try to pick a mesh in the scene
  42623. * @param x position on screen
  42624. * @param y position on screen
  42625. * @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
  42626. * @param fastCheck defines if the first intersection will be used (and not the closest)
  42627. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  42628. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  42629. * @returns a PickingInfo
  42630. */
  42631. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  42632. /** Launch a ray to try to pick a mesh in the scene using only bounding information of the main mesh (not using submeshes)
  42633. * @param x position on screen
  42634. * @param y position on screen
  42635. * @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
  42636. * @param fastCheck defines if the first intersection will be used (and not the closest)
  42637. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  42638. * @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)
  42639. */
  42640. pickWithBoundingInfo(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  42641. /** Use the given ray to pick a mesh in the scene
  42642. * @param ray The ray to use to pick meshes
  42643. * @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
  42644. * @param fastCheck defines if the first intersection will be used (and not the closest)
  42645. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  42646. * @returns a PickingInfo
  42647. */
  42648. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  42649. /**
  42650. * Launch a ray to try to pick a mesh in the scene
  42651. * @param x X position on screen
  42652. * @param y Y position on screen
  42653. * @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
  42654. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  42655. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  42656. * @returns an array of PickingInfo
  42657. */
  42658. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  42659. /**
  42660. * Launch a ray to try to pick a mesh in the scene
  42661. * @param ray Ray to use
  42662. * @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
  42663. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  42664. * @returns an array of PickingInfo
  42665. */
  42666. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  42667. /**
  42668. * Force the value of meshUnderPointer
  42669. * @param mesh defines the mesh to use
  42670. * @param pointerId optional pointer id when using more than one pointer
  42671. */
  42672. setPointerOverMesh(mesh: Nullable<AbstractMesh>, pointerId?: number): void;
  42673. /**
  42674. * Gets the mesh under the pointer
  42675. * @returns a Mesh or null if no mesh is under the pointer
  42676. */
  42677. getPointerOverMesh(): Nullable<AbstractMesh>;
  42678. /** @hidden */
  42679. _rebuildGeometries(): void;
  42680. /** @hidden */
  42681. _rebuildTextures(): void;
  42682. private _getByTags;
  42683. /**
  42684. * Get a list of meshes by tags
  42685. * @param tagsQuery defines the tags query to use
  42686. * @param forEach defines a predicate used to filter results
  42687. * @returns an array of Mesh
  42688. */
  42689. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  42690. /**
  42691. * Get a list of cameras by tags
  42692. * @param tagsQuery defines the tags query to use
  42693. * @param forEach defines a predicate used to filter results
  42694. * @returns an array of Camera
  42695. */
  42696. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  42697. /**
  42698. * Get a list of lights by tags
  42699. * @param tagsQuery defines the tags query to use
  42700. * @param forEach defines a predicate used to filter results
  42701. * @returns an array of Light
  42702. */
  42703. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  42704. /**
  42705. * Get a list of materials by tags
  42706. * @param tagsQuery defines the tags query to use
  42707. * @param forEach defines a predicate used to filter results
  42708. * @returns an array of Material
  42709. */
  42710. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  42711. /**
  42712. * Get a list of transform nodes by tags
  42713. * @param tagsQuery defines the tags query to use
  42714. * @param forEach defines a predicate used to filter results
  42715. * @returns an array of TransformNode
  42716. */
  42717. getTransformNodesByTags(tagsQuery: string, forEach?: (transform: TransformNode) => void): TransformNode[];
  42718. /**
  42719. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  42720. * This allowed control for front to back rendering or reversly depending of the special needs.
  42721. *
  42722. * @param renderingGroupId The rendering group id corresponding to its index
  42723. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  42724. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  42725. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  42726. */
  42727. 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;
  42728. /**
  42729. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  42730. *
  42731. * @param renderingGroupId The rendering group id corresponding to its index
  42732. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  42733. * @param depth Automatically clears depth between groups if true and autoClear is true.
  42734. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  42735. */
  42736. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  42737. /**
  42738. * Gets the current auto clear configuration for one rendering group of the rendering
  42739. * manager.
  42740. * @param index the rendering group index to get the information for
  42741. * @returns The auto clear setup for the requested rendering group
  42742. */
  42743. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  42744. private _blockMaterialDirtyMechanism;
  42745. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  42746. get blockMaterialDirtyMechanism(): boolean;
  42747. set blockMaterialDirtyMechanism(value: boolean);
  42748. /**
  42749. * Will flag all materials as dirty to trigger new shader compilation
  42750. * @param flag defines the flag used to specify which material part must be marked as dirty
  42751. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  42752. */
  42753. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  42754. /** @hidden */
  42755. _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;
  42756. /** @hidden */
  42757. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  42758. /** @hidden */
  42759. _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;
  42760. /** @hidden */
  42761. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  42762. /** @hidden */
  42763. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  42764. /** @hidden */
  42765. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  42766. }
  42767. }
  42768. declare module "babylonjs/assetContainer" {
  42769. import { AbstractScene } from "babylonjs/abstractScene";
  42770. import { Scene } from "babylonjs/scene";
  42771. import { Mesh } from "babylonjs/Meshes/mesh";
  42772. import { TransformNode } from "babylonjs/Meshes/transformNode";
  42773. import { Skeleton } from "babylonjs/Bones/skeleton";
  42774. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  42775. import { Animatable } from "babylonjs/Animations/animatable";
  42776. import { Nullable } from "babylonjs/types";
  42777. import { Node } from "babylonjs/node";
  42778. /**
  42779. * Set of assets to keep when moving a scene into an asset container.
  42780. */
  42781. export class KeepAssets extends AbstractScene {
  42782. }
  42783. /**
  42784. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  42785. */
  42786. export class InstantiatedEntries {
  42787. /**
  42788. * List of new root nodes (eg. nodes with no parent)
  42789. */
  42790. rootNodes: TransformNode[];
  42791. /**
  42792. * List of new skeletons
  42793. */
  42794. skeletons: Skeleton[];
  42795. /**
  42796. * List of new animation groups
  42797. */
  42798. animationGroups: AnimationGroup[];
  42799. }
  42800. /**
  42801. * Container with a set of assets that can be added or removed from a scene.
  42802. */
  42803. export class AssetContainer extends AbstractScene {
  42804. private _wasAddedToScene;
  42805. /**
  42806. * The scene the AssetContainer belongs to.
  42807. */
  42808. scene: Scene;
  42809. /**
  42810. * Instantiates an AssetContainer.
  42811. * @param scene The scene the AssetContainer belongs to.
  42812. */
  42813. constructor(scene: Scene);
  42814. /**
  42815. * Instantiate or clone all meshes and add the new ones to the scene.
  42816. * Skeletons and animation groups will all be cloned
  42817. * @param nameFunction defines an optional function used to get new names for clones
  42818. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  42819. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  42820. */
  42821. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  42822. /**
  42823. * Adds all the assets from the container to the scene.
  42824. */
  42825. addAllToScene(): void;
  42826. /**
  42827. * Removes all the assets in the container from the scene
  42828. */
  42829. removeAllFromScene(): void;
  42830. /**
  42831. * Disposes all the assets in the container
  42832. */
  42833. dispose(): void;
  42834. private _moveAssets;
  42835. /**
  42836. * Removes all the assets contained in the scene and adds them to the container.
  42837. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  42838. */
  42839. moveAllFromScene(keepAssets?: KeepAssets): void;
  42840. /**
  42841. * 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.
  42842. * @returns the root mesh
  42843. */
  42844. createRootMesh(): Mesh;
  42845. /**
  42846. * Merge animations (direct and animation groups) from this asset container into a scene
  42847. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  42848. * @param animatables set of animatables to retarget to a node from the scene
  42849. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  42850. * @returns an array of the new AnimationGroup added to the scene (empty array if none)
  42851. */
  42852. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): AnimationGroup[];
  42853. }
  42854. }
  42855. declare module "babylonjs/abstractScene" {
  42856. import { Scene } from "babylonjs/scene";
  42857. import { Nullable } from "babylonjs/types";
  42858. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42859. import { TransformNode } from "babylonjs/Meshes/transformNode";
  42860. import { Geometry } from "babylonjs/Meshes/geometry";
  42861. import { Skeleton } from "babylonjs/Bones/skeleton";
  42862. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  42863. import { AssetContainer } from "babylonjs/assetContainer";
  42864. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  42865. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  42866. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  42867. import { Material } from "babylonjs/Materials/material";
  42868. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  42869. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  42870. import { Camera } from "babylonjs/Cameras/camera";
  42871. import { Light } from "babylonjs/Lights/light";
  42872. import { Node } from "babylonjs/node";
  42873. import { Animation } from "babylonjs/Animations/animation";
  42874. /**
  42875. * Defines how the parser contract is defined.
  42876. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  42877. */
  42878. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  42879. /**
  42880. * Defines how the individual parser contract is defined.
  42881. * These parser can parse an individual asset
  42882. */
  42883. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  42884. /**
  42885. * Base class of the scene acting as a container for the different elements composing a scene.
  42886. * This class is dynamically extended by the different components of the scene increasing
  42887. * flexibility and reducing coupling
  42888. */
  42889. export abstract class AbstractScene {
  42890. /**
  42891. * Stores the list of available parsers in the application.
  42892. */
  42893. private static _BabylonFileParsers;
  42894. /**
  42895. * Stores the list of available individual parsers in the application.
  42896. */
  42897. private static _IndividualBabylonFileParsers;
  42898. /**
  42899. * Adds a parser in the list of available ones
  42900. * @param name Defines the name of the parser
  42901. * @param parser Defines the parser to add
  42902. */
  42903. static AddParser(name: string, parser: BabylonFileParser): void;
  42904. /**
  42905. * Gets a general parser from the list of avaialble ones
  42906. * @param name Defines the name of the parser
  42907. * @returns the requested parser or null
  42908. */
  42909. static GetParser(name: string): Nullable<BabylonFileParser>;
  42910. /**
  42911. * Adds n individual parser in the list of available ones
  42912. * @param name Defines the name of the parser
  42913. * @param parser Defines the parser to add
  42914. */
  42915. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  42916. /**
  42917. * Gets an individual parser from the list of avaialble ones
  42918. * @param name Defines the name of the parser
  42919. * @returns the requested parser or null
  42920. */
  42921. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  42922. /**
  42923. * Parser json data and populate both a scene and its associated container object
  42924. * @param jsonData Defines the data to parse
  42925. * @param scene Defines the scene to parse the data for
  42926. * @param container Defines the container attached to the parsing sequence
  42927. * @param rootUrl Defines the root url of the data
  42928. */
  42929. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  42930. /**
  42931. * Gets the list of root nodes (ie. nodes with no parent)
  42932. */
  42933. rootNodes: Node[];
  42934. /** All of the cameras added to this scene
  42935. * @see https://doc.babylonjs.com/babylon101/cameras
  42936. */
  42937. cameras: Camera[];
  42938. /**
  42939. * All of the lights added to this scene
  42940. * @see https://doc.babylonjs.com/babylon101/lights
  42941. */
  42942. lights: Light[];
  42943. /**
  42944. * All of the (abstract) meshes added to this scene
  42945. */
  42946. meshes: AbstractMesh[];
  42947. /**
  42948. * The list of skeletons added to the scene
  42949. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  42950. */
  42951. skeletons: Skeleton[];
  42952. /**
  42953. * All of the particle systems added to this scene
  42954. * @see https://doc.babylonjs.com/babylon101/particles
  42955. */
  42956. particleSystems: IParticleSystem[];
  42957. /**
  42958. * Gets a list of Animations associated with the scene
  42959. */
  42960. animations: Animation[];
  42961. /**
  42962. * All of the animation groups added to this scene
  42963. * @see https://doc.babylonjs.com/how_to/group
  42964. */
  42965. animationGroups: AnimationGroup[];
  42966. /**
  42967. * All of the multi-materials added to this scene
  42968. * @see https://doc.babylonjs.com/how_to/multi_materials
  42969. */
  42970. multiMaterials: MultiMaterial[];
  42971. /**
  42972. * All of the materials added to this scene
  42973. * In the context of a Scene, it is not supposed to be modified manually.
  42974. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  42975. * Note also that the order of the Material within the array is not significant and might change.
  42976. * @see https://doc.babylonjs.com/babylon101/materials
  42977. */
  42978. materials: Material[];
  42979. /**
  42980. * The list of morph target managers added to the scene
  42981. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  42982. */
  42983. morphTargetManagers: MorphTargetManager[];
  42984. /**
  42985. * The list of geometries used in the scene.
  42986. */
  42987. geometries: Geometry[];
  42988. /**
  42989. * All of the tranform nodes added to this scene
  42990. * In the context of a Scene, it is not supposed to be modified manually.
  42991. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  42992. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  42993. * @see https://doc.babylonjs.com/how_to/transformnode
  42994. */
  42995. transformNodes: TransformNode[];
  42996. /**
  42997. * ActionManagers available on the scene.
  42998. */
  42999. actionManagers: AbstractActionManager[];
  43000. /**
  43001. * Textures to keep.
  43002. */
  43003. textures: BaseTexture[];
  43004. /** @hidden */
  43005. protected _environmentTexture: Nullable<BaseTexture>;
  43006. /**
  43007. * Texture used in all pbr material as the reflection texture.
  43008. * As in the majority of the scene they are the same (exception for multi room and so on),
  43009. * this is easier to reference from here than from all the materials.
  43010. */
  43011. get environmentTexture(): Nullable<BaseTexture>;
  43012. set environmentTexture(value: Nullable<BaseTexture>);
  43013. /**
  43014. * The list of postprocesses added to the scene
  43015. */
  43016. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  43017. /**
  43018. * @returns all meshes, lights, cameras, transformNodes and bones
  43019. */
  43020. getNodes(): Array<Node>;
  43021. }
  43022. }
  43023. declare module "babylonjs/Audio/sound" {
  43024. import { Observable } from "babylonjs/Misc/observable";
  43025. import { Vector3 } from "babylonjs/Maths/math.vector";
  43026. import { Nullable } from "babylonjs/types";
  43027. import { Scene } from "babylonjs/scene";
  43028. import { TransformNode } from "babylonjs/Meshes/transformNode";
  43029. /**
  43030. * Interface used to define options for Sound class
  43031. */
  43032. export interface ISoundOptions {
  43033. /**
  43034. * Does the sound autoplay once loaded.
  43035. */
  43036. autoplay?: boolean;
  43037. /**
  43038. * Does the sound loop after it finishes playing once.
  43039. */
  43040. loop?: boolean;
  43041. /**
  43042. * Sound's volume
  43043. */
  43044. volume?: number;
  43045. /**
  43046. * Is it a spatial sound?
  43047. */
  43048. spatialSound?: boolean;
  43049. /**
  43050. * Maximum distance to hear that sound
  43051. */
  43052. maxDistance?: number;
  43053. /**
  43054. * Uses user defined attenuation function
  43055. */
  43056. useCustomAttenuation?: boolean;
  43057. /**
  43058. * Define the roll off factor of spatial sounds.
  43059. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  43060. */
  43061. rolloffFactor?: number;
  43062. /**
  43063. * Define the reference distance the sound should be heard perfectly.
  43064. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  43065. */
  43066. refDistance?: number;
  43067. /**
  43068. * Define the distance attenuation model the sound will follow.
  43069. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  43070. */
  43071. distanceModel?: string;
  43072. /**
  43073. * Defines the playback speed (1 by default)
  43074. */
  43075. playbackRate?: number;
  43076. /**
  43077. * Defines if the sound is from a streaming source
  43078. */
  43079. streaming?: boolean;
  43080. /**
  43081. * Defines an optional length (in seconds) inside the sound file
  43082. */
  43083. length?: number;
  43084. /**
  43085. * Defines an optional offset (in seconds) inside the sound file
  43086. */
  43087. offset?: number;
  43088. /**
  43089. * If true, URLs will not be required to state the audio file codec to use.
  43090. */
  43091. skipCodecCheck?: boolean;
  43092. }
  43093. /**
  43094. * Defines a sound that can be played in the application.
  43095. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  43096. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  43097. */
  43098. export class Sound {
  43099. /**
  43100. * The name of the sound in the scene.
  43101. */
  43102. name: string;
  43103. /**
  43104. * Does the sound autoplay once loaded.
  43105. */
  43106. autoplay: boolean;
  43107. /**
  43108. * Does the sound loop after it finishes playing once.
  43109. */
  43110. loop: boolean;
  43111. /**
  43112. * Does the sound use a custom attenuation curve to simulate the falloff
  43113. * happening when the source gets further away from the camera.
  43114. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  43115. */
  43116. useCustomAttenuation: boolean;
  43117. /**
  43118. * The sound track id this sound belongs to.
  43119. */
  43120. soundTrackId: number;
  43121. /**
  43122. * Is this sound currently played.
  43123. */
  43124. isPlaying: boolean;
  43125. /**
  43126. * Is this sound currently paused.
  43127. */
  43128. isPaused: boolean;
  43129. /**
  43130. * Does this sound enables spatial sound.
  43131. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  43132. */
  43133. spatialSound: boolean;
  43134. /**
  43135. * Define the reference distance the sound should be heard perfectly.
  43136. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  43137. */
  43138. refDistance: number;
  43139. /**
  43140. * Define the roll off factor of spatial sounds.
  43141. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  43142. */
  43143. rolloffFactor: number;
  43144. /**
  43145. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  43146. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  43147. */
  43148. maxDistance: number;
  43149. /**
  43150. * Define the distance attenuation model the sound will follow.
  43151. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  43152. */
  43153. distanceModel: string;
  43154. /**
  43155. * @hidden
  43156. * Back Compat
  43157. **/
  43158. onended: () => any;
  43159. /**
  43160. * Gets or sets an object used to store user defined information for the sound.
  43161. */
  43162. metadata: any;
  43163. /**
  43164. * Observable event when the current playing sound finishes.
  43165. */
  43166. onEndedObservable: Observable<Sound>;
  43167. private _panningModel;
  43168. private _playbackRate;
  43169. private _streaming;
  43170. private _startTime;
  43171. private _startOffset;
  43172. private _position;
  43173. /** @hidden */
  43174. _positionInEmitterSpace: boolean;
  43175. private _localDirection;
  43176. private _volume;
  43177. private _isReadyToPlay;
  43178. private _isDirectional;
  43179. private _readyToPlayCallback;
  43180. private _audioBuffer;
  43181. private _soundSource;
  43182. private _streamingSource;
  43183. private _soundPanner;
  43184. private _soundGain;
  43185. private _inputAudioNode;
  43186. private _outputAudioNode;
  43187. private _coneInnerAngle;
  43188. private _coneOuterAngle;
  43189. private _coneOuterGain;
  43190. private _scene;
  43191. private _connectedTransformNode;
  43192. private _customAttenuationFunction;
  43193. private _registerFunc;
  43194. private _isOutputConnected;
  43195. private _htmlAudioElement;
  43196. private _urlType;
  43197. private _length?;
  43198. private _offset?;
  43199. /** @hidden */
  43200. static _SceneComponentInitialization: (scene: Scene) => void;
  43201. /**
  43202. * Create a sound and attach it to a scene
  43203. * @param name Name of your sound
  43204. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  43205. * @param scene defines the scene the sound belongs to
  43206. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  43207. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  43208. */
  43209. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  43210. /**
  43211. * Release the sound and its associated resources
  43212. */
  43213. dispose(): void;
  43214. /**
  43215. * Gets if the sounds is ready to be played or not.
  43216. * @returns true if ready, otherwise false
  43217. */
  43218. isReady(): boolean;
  43219. private _soundLoaded;
  43220. /**
  43221. * Sets the data of the sound from an audiobuffer
  43222. * @param audioBuffer The audioBuffer containing the data
  43223. */
  43224. setAudioBuffer(audioBuffer: AudioBuffer): void;
  43225. /**
  43226. * Updates the current sounds options such as maxdistance, loop...
  43227. * @param options A JSON object containing values named as the object properties
  43228. */
  43229. updateOptions(options: ISoundOptions): void;
  43230. private _createSpatialParameters;
  43231. private _updateSpatialParameters;
  43232. /**
  43233. * Switch the panning model to HRTF:
  43234. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  43235. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  43236. */
  43237. switchPanningModelToHRTF(): void;
  43238. /**
  43239. * Switch the panning model to Equal Power:
  43240. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  43241. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  43242. */
  43243. switchPanningModelToEqualPower(): void;
  43244. private _switchPanningModel;
  43245. /**
  43246. * Connect this sound to a sound track audio node like gain...
  43247. * @param soundTrackAudioNode the sound track audio node to connect to
  43248. */
  43249. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  43250. /**
  43251. * Transform this sound into a directional source
  43252. * @param coneInnerAngle Size of the inner cone in degree
  43253. * @param coneOuterAngle Size of the outer cone in degree
  43254. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  43255. */
  43256. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  43257. /**
  43258. * Gets or sets the inner angle for the directional cone.
  43259. */
  43260. get directionalConeInnerAngle(): number;
  43261. /**
  43262. * Gets or sets the inner angle for the directional cone.
  43263. */
  43264. set directionalConeInnerAngle(value: number);
  43265. /**
  43266. * Gets or sets the outer angle for the directional cone.
  43267. */
  43268. get directionalConeOuterAngle(): number;
  43269. /**
  43270. * Gets or sets the outer angle for the directional cone.
  43271. */
  43272. set directionalConeOuterAngle(value: number);
  43273. /**
  43274. * Sets the position of the emitter if spatial sound is enabled
  43275. * @param newPosition Defines the new posisiton
  43276. */
  43277. setPosition(newPosition: Vector3): void;
  43278. /**
  43279. * Sets the local direction of the emitter if spatial sound is enabled
  43280. * @param newLocalDirection Defines the new local direction
  43281. */
  43282. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  43283. private _updateDirection;
  43284. /** @hidden */
  43285. updateDistanceFromListener(): void;
  43286. /**
  43287. * Sets a new custom attenuation function for the sound.
  43288. * @param callback Defines the function used for the attenuation
  43289. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  43290. */
  43291. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  43292. /**
  43293. * Play the sound
  43294. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  43295. * @param offset (optional) Start the sound at a specific time in seconds
  43296. * @param length (optional) Sound duration (in seconds)
  43297. */
  43298. play(time?: number, offset?: number, length?: number): void;
  43299. private _onended;
  43300. /**
  43301. * Stop the sound
  43302. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  43303. */
  43304. stop(time?: number): void;
  43305. /**
  43306. * Put the sound in pause
  43307. */
  43308. pause(): void;
  43309. /**
  43310. * Sets a dedicated volume for this sounds
  43311. * @param newVolume Define the new volume of the sound
  43312. * @param time Define time for gradual change to new volume
  43313. */
  43314. setVolume(newVolume: number, time?: number): void;
  43315. /**
  43316. * Set the sound play back rate
  43317. * @param newPlaybackRate Define the playback rate the sound should be played at
  43318. */
  43319. setPlaybackRate(newPlaybackRate: number): void;
  43320. /**
  43321. * Gets the volume of the sound.
  43322. * @returns the volume of the sound
  43323. */
  43324. getVolume(): number;
  43325. /**
  43326. * Attach the sound to a dedicated mesh
  43327. * @param transformNode The transform node to connect the sound with
  43328. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  43329. */
  43330. attachToMesh(transformNode: TransformNode): void;
  43331. /**
  43332. * Detach the sound from the previously attached mesh
  43333. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  43334. */
  43335. detachFromMesh(): void;
  43336. private _onRegisterAfterWorldMatrixUpdate;
  43337. /**
  43338. * Clone the current sound in the scene.
  43339. * @returns the new sound clone
  43340. */
  43341. clone(): Nullable<Sound>;
  43342. /**
  43343. * Gets the current underlying audio buffer containing the data
  43344. * @returns the audio buffer
  43345. */
  43346. getAudioBuffer(): Nullable<AudioBuffer>;
  43347. /**
  43348. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  43349. * @returns the source node
  43350. */
  43351. getSoundSource(): Nullable<AudioBufferSourceNode>;
  43352. /**
  43353. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  43354. * @returns the gain node
  43355. */
  43356. getSoundGain(): Nullable<GainNode>;
  43357. /**
  43358. * Serializes the Sound in a JSON representation
  43359. * @returns the JSON representation of the sound
  43360. */
  43361. serialize(): any;
  43362. /**
  43363. * Parse a JSON representation of a sound to innstantiate in a given scene
  43364. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  43365. * @param scene Define the scene the new parsed sound should be created in
  43366. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  43367. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  43368. * @returns the newly parsed sound
  43369. */
  43370. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  43371. }
  43372. }
  43373. declare module "babylonjs/Actions/directAudioActions" {
  43374. import { Action } from "babylonjs/Actions/action";
  43375. import { Condition } from "babylonjs/Actions/condition";
  43376. import { Sound } from "babylonjs/Audio/sound";
  43377. /**
  43378. * This defines an action helpful to play a defined sound on a triggered action.
  43379. */
  43380. export class PlaySoundAction extends Action {
  43381. private _sound;
  43382. /**
  43383. * Instantiate the action
  43384. * @param triggerOptions defines the trigger options
  43385. * @param sound defines the sound to play
  43386. * @param condition defines the trigger related conditions
  43387. */
  43388. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  43389. /** @hidden */
  43390. _prepare(): void;
  43391. /**
  43392. * Execute the action and play the sound.
  43393. */
  43394. execute(): void;
  43395. /**
  43396. * Serializes the actions and its related information.
  43397. * @param parent defines the object to serialize in
  43398. * @returns the serialized object
  43399. */
  43400. serialize(parent: any): any;
  43401. }
  43402. /**
  43403. * This defines an action helpful to stop a defined sound on a triggered action.
  43404. */
  43405. export class StopSoundAction extends Action {
  43406. private _sound;
  43407. /**
  43408. * Instantiate the action
  43409. * @param triggerOptions defines the trigger options
  43410. * @param sound defines the sound to stop
  43411. * @param condition defines the trigger related conditions
  43412. */
  43413. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  43414. /** @hidden */
  43415. _prepare(): void;
  43416. /**
  43417. * Execute the action and stop the sound.
  43418. */
  43419. execute(): void;
  43420. /**
  43421. * Serializes the actions and its related information.
  43422. * @param parent defines the object to serialize in
  43423. * @returns the serialized object
  43424. */
  43425. serialize(parent: any): any;
  43426. }
  43427. }
  43428. declare module "babylonjs/Actions/interpolateValueAction" {
  43429. import { Action } from "babylonjs/Actions/action";
  43430. import { Condition } from "babylonjs/Actions/condition";
  43431. import { Observable } from "babylonjs/Misc/observable";
  43432. /**
  43433. * This defines an action responsible to change the value of a property
  43434. * by interpolating between its current value and the newly set one once triggered.
  43435. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  43436. */
  43437. export class InterpolateValueAction extends Action {
  43438. /**
  43439. * Defines the path of the property where the value should be interpolated
  43440. */
  43441. propertyPath: string;
  43442. /**
  43443. * Defines the target value at the end of the interpolation.
  43444. */
  43445. value: any;
  43446. /**
  43447. * Defines the time it will take for the property to interpolate to the value.
  43448. */
  43449. duration: number;
  43450. /**
  43451. * Defines if the other scene animations should be stopped when the action has been triggered
  43452. */
  43453. stopOtherAnimations?: boolean;
  43454. /**
  43455. * Defines a callback raised once the interpolation animation has been done.
  43456. */
  43457. onInterpolationDone?: () => void;
  43458. /**
  43459. * Observable triggered once the interpolation animation has been done.
  43460. */
  43461. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  43462. private _target;
  43463. private _effectiveTarget;
  43464. private _property;
  43465. /**
  43466. * Instantiate the action
  43467. * @param triggerOptions defines the trigger options
  43468. * @param target defines the object containing the value to interpolate
  43469. * @param propertyPath defines the path to the property in the target object
  43470. * @param value defines the target value at the end of the interpolation
  43471. * @param duration deines the time it will take for the property to interpolate to the value.
  43472. * @param condition defines the trigger related conditions
  43473. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  43474. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  43475. */
  43476. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  43477. /** @hidden */
  43478. _prepare(): void;
  43479. /**
  43480. * Execute the action starts the value interpolation.
  43481. */
  43482. execute(): void;
  43483. /**
  43484. * Serializes the actions and its related information.
  43485. * @param parent defines the object to serialize in
  43486. * @returns the serialized object
  43487. */
  43488. serialize(parent: any): any;
  43489. }
  43490. }
  43491. declare module "babylonjs/Actions/index" {
  43492. export * from "babylonjs/Actions/abstractActionManager";
  43493. export * from "babylonjs/Actions/action";
  43494. export * from "babylonjs/Actions/actionEvent";
  43495. export * from "babylonjs/Actions/actionManager";
  43496. export * from "babylonjs/Actions/condition";
  43497. export * from "babylonjs/Actions/directActions";
  43498. export * from "babylonjs/Actions/directAudioActions";
  43499. export * from "babylonjs/Actions/interpolateValueAction";
  43500. }
  43501. declare module "babylonjs/Animations/index" {
  43502. export * from "babylonjs/Animations/animatable";
  43503. export * from "babylonjs/Animations/animation";
  43504. export * from "babylonjs/Animations/animationGroup";
  43505. export * from "babylonjs/Animations/animationPropertiesOverride";
  43506. export * from "babylonjs/Animations/easing";
  43507. export * from "babylonjs/Animations/runtimeAnimation";
  43508. export * from "babylonjs/Animations/animationEvent";
  43509. export * from "babylonjs/Animations/animationGroup";
  43510. export * from "babylonjs/Animations/animationKey";
  43511. export * from "babylonjs/Animations/animationRange";
  43512. export * from "babylonjs/Animations/animatable.interface";
  43513. }
  43514. declare module "babylonjs/Audio/soundTrack" {
  43515. import { Sound } from "babylonjs/Audio/sound";
  43516. import { Analyser } from "babylonjs/Audio/analyser";
  43517. import { Scene } from "babylonjs/scene";
  43518. /**
  43519. * Options allowed during the creation of a sound track.
  43520. */
  43521. export interface ISoundTrackOptions {
  43522. /**
  43523. * The volume the sound track should take during creation
  43524. */
  43525. volume?: number;
  43526. /**
  43527. * Define if the sound track is the main sound track of the scene
  43528. */
  43529. mainTrack?: boolean;
  43530. }
  43531. /**
  43532. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  43533. * It will be also used in a future release to apply effects on a specific track.
  43534. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  43535. */
  43536. export class SoundTrack {
  43537. /**
  43538. * The unique identifier of the sound track in the scene.
  43539. */
  43540. id: number;
  43541. /**
  43542. * The list of sounds included in the sound track.
  43543. */
  43544. soundCollection: Array<Sound>;
  43545. private _outputAudioNode;
  43546. private _scene;
  43547. private _connectedAnalyser;
  43548. private _options;
  43549. private _isInitialized;
  43550. /**
  43551. * Creates a new sound track.
  43552. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  43553. * @param scene Define the scene the sound track belongs to
  43554. * @param options
  43555. */
  43556. constructor(scene: Scene, options?: ISoundTrackOptions);
  43557. private _initializeSoundTrackAudioGraph;
  43558. /**
  43559. * Release the sound track and its associated resources
  43560. */
  43561. dispose(): void;
  43562. /**
  43563. * Adds a sound to this sound track
  43564. * @param sound define the cound to add
  43565. * @ignoreNaming
  43566. */
  43567. AddSound(sound: Sound): void;
  43568. /**
  43569. * Removes a sound to this sound track
  43570. * @param sound define the cound to remove
  43571. * @ignoreNaming
  43572. */
  43573. RemoveSound(sound: Sound): void;
  43574. /**
  43575. * Set a global volume for the full sound track.
  43576. * @param newVolume Define the new volume of the sound track
  43577. */
  43578. setVolume(newVolume: number): void;
  43579. /**
  43580. * Switch the panning model to HRTF:
  43581. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  43582. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  43583. */
  43584. switchPanningModelToHRTF(): void;
  43585. /**
  43586. * Switch the panning model to Equal Power:
  43587. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  43588. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  43589. */
  43590. switchPanningModelToEqualPower(): void;
  43591. /**
  43592. * Connect the sound track to an audio analyser allowing some amazing
  43593. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  43594. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  43595. * @param analyser The analyser to connect to the engine
  43596. */
  43597. connectToAnalyser(analyser: Analyser): void;
  43598. }
  43599. }
  43600. declare module "babylonjs/Audio/audioSceneComponent" {
  43601. import { Sound } from "babylonjs/Audio/sound";
  43602. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  43603. import { Nullable } from "babylonjs/types";
  43604. import { Vector3 } from "babylonjs/Maths/math.vector";
  43605. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  43606. import { Scene } from "babylonjs/scene";
  43607. import { AbstractScene } from "babylonjs/abstractScene";
  43608. import "babylonjs/Audio/audioEngine";
  43609. module "babylonjs/abstractScene" {
  43610. interface AbstractScene {
  43611. /**
  43612. * The list of sounds used in the scene.
  43613. */
  43614. sounds: Nullable<Array<Sound>>;
  43615. }
  43616. }
  43617. module "babylonjs/scene" {
  43618. interface Scene {
  43619. /**
  43620. * @hidden
  43621. * Backing field
  43622. */
  43623. _mainSoundTrack: SoundTrack;
  43624. /**
  43625. * The main sound track played by the scene.
  43626. * It cotains your primary collection of sounds.
  43627. */
  43628. mainSoundTrack: SoundTrack;
  43629. /**
  43630. * The list of sound tracks added to the scene
  43631. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  43632. */
  43633. soundTracks: Nullable<Array<SoundTrack>>;
  43634. /**
  43635. * Gets a sound using a given name
  43636. * @param name defines the name to search for
  43637. * @return the found sound or null if not found at all.
  43638. */
  43639. getSoundByName(name: string): Nullable<Sound>;
  43640. /**
  43641. * Gets or sets if audio support is enabled
  43642. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  43643. */
  43644. audioEnabled: boolean;
  43645. /**
  43646. * Gets or sets if audio will be output to headphones
  43647. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  43648. */
  43649. headphone: boolean;
  43650. /**
  43651. * Gets or sets custom audio listener position provider
  43652. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  43653. */
  43654. audioListenerPositionProvider: Nullable<() => Vector3>;
  43655. /**
  43656. * Gets or sets a refresh rate when using 3D audio positioning
  43657. */
  43658. audioPositioningRefreshRate: number;
  43659. }
  43660. }
  43661. /**
  43662. * Defines the sound scene component responsible to manage any sounds
  43663. * in a given scene.
  43664. */
  43665. export class AudioSceneComponent implements ISceneSerializableComponent {
  43666. private static _CameraDirectionLH;
  43667. private static _CameraDirectionRH;
  43668. /**
  43669. * The component name helpfull to identify the component in the list of scene components.
  43670. */
  43671. readonly name: string;
  43672. /**
  43673. * The scene the component belongs to.
  43674. */
  43675. scene: Scene;
  43676. private _audioEnabled;
  43677. /**
  43678. * Gets whether audio is enabled or not.
  43679. * Please use related enable/disable method to switch state.
  43680. */
  43681. get audioEnabled(): boolean;
  43682. private _headphone;
  43683. /**
  43684. * Gets whether audio is outputing to headphone or not.
  43685. * Please use the according Switch methods to change output.
  43686. */
  43687. get headphone(): boolean;
  43688. /**
  43689. * Gets or sets a refresh rate when using 3D audio positioning
  43690. */
  43691. audioPositioningRefreshRate: number;
  43692. private _audioListenerPositionProvider;
  43693. /**
  43694. * Gets the current audio listener position provider
  43695. */
  43696. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  43697. /**
  43698. * Sets a custom listener position for all sounds in the scene
  43699. * By default, this is the position of the first active camera
  43700. */
  43701. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  43702. /**
  43703. * Creates a new instance of the component for the given scene
  43704. * @param scene Defines the scene to register the component in
  43705. */
  43706. constructor(scene: Scene);
  43707. /**
  43708. * Registers the component in a given scene
  43709. */
  43710. register(): void;
  43711. /**
  43712. * Rebuilds the elements related to this component in case of
  43713. * context lost for instance.
  43714. */
  43715. rebuild(): void;
  43716. /**
  43717. * Serializes the component data to the specified json object
  43718. * @param serializationObject The object to serialize to
  43719. */
  43720. serialize(serializationObject: any): void;
  43721. /**
  43722. * Adds all the elements from the container to the scene
  43723. * @param container the container holding the elements
  43724. */
  43725. addFromContainer(container: AbstractScene): void;
  43726. /**
  43727. * Removes all the elements in the container from the scene
  43728. * @param container contains the elements to remove
  43729. * @param dispose if the removed element should be disposed (default: false)
  43730. */
  43731. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  43732. /**
  43733. * Disposes the component and the associated ressources.
  43734. */
  43735. dispose(): void;
  43736. /**
  43737. * Disables audio in the associated scene.
  43738. */
  43739. disableAudio(): void;
  43740. /**
  43741. * Enables audio in the associated scene.
  43742. */
  43743. enableAudio(): void;
  43744. /**
  43745. * Switch audio to headphone output.
  43746. */
  43747. switchAudioModeForHeadphones(): void;
  43748. /**
  43749. * Switch audio to normal speakers.
  43750. */
  43751. switchAudioModeForNormalSpeakers(): void;
  43752. private _cachedCameraDirection;
  43753. private _cachedCameraPosition;
  43754. private _lastCheck;
  43755. private _afterRender;
  43756. }
  43757. }
  43758. declare module "babylonjs/Audio/weightedsound" {
  43759. import { Sound } from "babylonjs/Audio/sound";
  43760. /**
  43761. * Wraps one or more Sound objects and selects one with random weight for playback.
  43762. */
  43763. export class WeightedSound {
  43764. /** When true a Sound will be selected and played when the current playing Sound completes. */
  43765. loop: boolean;
  43766. private _coneInnerAngle;
  43767. private _coneOuterAngle;
  43768. private _volume;
  43769. /** A Sound is currently playing. */
  43770. isPlaying: boolean;
  43771. /** A Sound is currently paused. */
  43772. isPaused: boolean;
  43773. private _sounds;
  43774. private _weights;
  43775. private _currentIndex?;
  43776. /**
  43777. * Creates a new WeightedSound from the list of sounds given.
  43778. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  43779. * @param sounds Array of Sounds that will be selected from.
  43780. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  43781. */
  43782. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  43783. /**
  43784. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  43785. */
  43786. get directionalConeInnerAngle(): number;
  43787. /**
  43788. * The size of cone in degress for a directional sound in which there will be no attenuation.
  43789. */
  43790. set directionalConeInnerAngle(value: number);
  43791. /**
  43792. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  43793. * Listener angles between innerAngle and outerAngle will falloff linearly.
  43794. */
  43795. get directionalConeOuterAngle(): number;
  43796. /**
  43797. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  43798. * Listener angles between innerAngle and outerAngle will falloff linearly.
  43799. */
  43800. set directionalConeOuterAngle(value: number);
  43801. /**
  43802. * Playback volume.
  43803. */
  43804. get volume(): number;
  43805. /**
  43806. * Playback volume.
  43807. */
  43808. set volume(value: number);
  43809. private _onended;
  43810. /**
  43811. * Suspend playback
  43812. */
  43813. pause(): void;
  43814. /**
  43815. * Stop playback
  43816. */
  43817. stop(): void;
  43818. /**
  43819. * Start playback.
  43820. * @param startOffset Position the clip head at a specific time in seconds.
  43821. */
  43822. play(startOffset?: number): void;
  43823. }
  43824. }
  43825. declare module "babylonjs/Audio/index" {
  43826. export * from "babylonjs/Audio/analyser";
  43827. export * from "babylonjs/Audio/audioEngine";
  43828. export * from "babylonjs/Audio/audioSceneComponent";
  43829. export * from "babylonjs/Audio/sound";
  43830. export * from "babylonjs/Audio/soundTrack";
  43831. export * from "babylonjs/Audio/weightedsound";
  43832. }
  43833. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  43834. import { Behavior } from "babylonjs/Behaviors/behavior";
  43835. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  43836. import { BackEase } from "babylonjs/Animations/easing";
  43837. /**
  43838. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  43839. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  43840. */
  43841. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  43842. /**
  43843. * Gets the name of the behavior.
  43844. */
  43845. get name(): string;
  43846. /**
  43847. * The easing function used by animations
  43848. */
  43849. static EasingFunction: BackEase;
  43850. /**
  43851. * The easing mode used by animations
  43852. */
  43853. static EasingMode: number;
  43854. /**
  43855. * The duration of the animation, in milliseconds
  43856. */
  43857. transitionDuration: number;
  43858. /**
  43859. * Length of the distance animated by the transition when lower radius is reached
  43860. */
  43861. lowerRadiusTransitionRange: number;
  43862. /**
  43863. * Length of the distance animated by the transition when upper radius is reached
  43864. */
  43865. upperRadiusTransitionRange: number;
  43866. private _autoTransitionRange;
  43867. /**
  43868. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  43869. */
  43870. get autoTransitionRange(): boolean;
  43871. /**
  43872. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  43873. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  43874. */
  43875. set autoTransitionRange(value: boolean);
  43876. private _attachedCamera;
  43877. private _onAfterCheckInputsObserver;
  43878. private _onMeshTargetChangedObserver;
  43879. /**
  43880. * Initializes the behavior.
  43881. */
  43882. init(): void;
  43883. /**
  43884. * Attaches the behavior to its arc rotate camera.
  43885. * @param camera Defines the camera to attach the behavior to
  43886. */
  43887. attach(camera: ArcRotateCamera): void;
  43888. /**
  43889. * Detaches the behavior from its current arc rotate camera.
  43890. */
  43891. detach(): void;
  43892. private _radiusIsAnimating;
  43893. private _radiusBounceTransition;
  43894. private _animatables;
  43895. private _cachedWheelPrecision;
  43896. /**
  43897. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  43898. * @param radiusLimit The limit to check against.
  43899. * @return Bool to indicate if at limit.
  43900. */
  43901. private _isRadiusAtLimit;
  43902. /**
  43903. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  43904. * @param radiusDelta The delta by which to animate to. Can be negative.
  43905. */
  43906. private _applyBoundRadiusAnimation;
  43907. /**
  43908. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  43909. */
  43910. protected _clearAnimationLocks(): void;
  43911. /**
  43912. * Stops and removes all animations that have been applied to the camera
  43913. */
  43914. stopAllAnimations(): void;
  43915. }
  43916. }
  43917. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  43918. import { Behavior } from "babylonjs/Behaviors/behavior";
  43919. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  43920. import { ExponentialEase } from "babylonjs/Animations/easing";
  43921. import { Nullable } from "babylonjs/types";
  43922. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43923. import { Vector3 } from "babylonjs/Maths/math.vector";
  43924. /**
  43925. * 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.
  43926. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  43927. */
  43928. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  43929. /**
  43930. * Gets the name of the behavior.
  43931. */
  43932. get name(): string;
  43933. private _mode;
  43934. private _radiusScale;
  43935. private _positionScale;
  43936. private _defaultElevation;
  43937. private _elevationReturnTime;
  43938. private _elevationReturnWaitTime;
  43939. private _zoomStopsAnimation;
  43940. private _framingTime;
  43941. /**
  43942. * The easing function used by animations
  43943. */
  43944. static EasingFunction: ExponentialEase;
  43945. /**
  43946. * The easing mode used by animations
  43947. */
  43948. static EasingMode: number;
  43949. /**
  43950. * Sets the current mode used by the behavior
  43951. */
  43952. set mode(mode: number);
  43953. /**
  43954. * Gets current mode used by the behavior.
  43955. */
  43956. get mode(): number;
  43957. /**
  43958. * Sets the scale applied to the radius (1 by default)
  43959. */
  43960. set radiusScale(radius: number);
  43961. /**
  43962. * Gets the scale applied to the radius
  43963. */
  43964. get radiusScale(): number;
  43965. /**
  43966. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  43967. */
  43968. set positionScale(scale: number);
  43969. /**
  43970. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  43971. */
  43972. get positionScale(): number;
  43973. /**
  43974. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  43975. * behaviour is triggered, in radians.
  43976. */
  43977. set defaultElevation(elevation: number);
  43978. /**
  43979. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  43980. * behaviour is triggered, in radians.
  43981. */
  43982. get defaultElevation(): number;
  43983. /**
  43984. * Sets the time (in milliseconds) taken to return to the default beta position.
  43985. * Negative value indicates camera should not return to default.
  43986. */
  43987. set elevationReturnTime(speed: number);
  43988. /**
  43989. * Gets the time (in milliseconds) taken to return to the default beta position.
  43990. * Negative value indicates camera should not return to default.
  43991. */
  43992. get elevationReturnTime(): number;
  43993. /**
  43994. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  43995. */
  43996. set elevationReturnWaitTime(time: number);
  43997. /**
  43998. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  43999. */
  44000. get elevationReturnWaitTime(): number;
  44001. /**
  44002. * Sets the flag that indicates if user zooming should stop animation.
  44003. */
  44004. set zoomStopsAnimation(flag: boolean);
  44005. /**
  44006. * Gets the flag that indicates if user zooming should stop animation.
  44007. */
  44008. get zoomStopsAnimation(): boolean;
  44009. /**
  44010. * Sets the transition time when framing the mesh, in milliseconds
  44011. */
  44012. set framingTime(time: number);
  44013. /**
  44014. * Gets the transition time when framing the mesh, in milliseconds
  44015. */
  44016. get framingTime(): number;
  44017. /**
  44018. * Define if the behavior should automatically change the configured
  44019. * camera limits and sensibilities.
  44020. */
  44021. autoCorrectCameraLimitsAndSensibility: boolean;
  44022. private _onPrePointerObservableObserver;
  44023. private _onAfterCheckInputsObserver;
  44024. private _onMeshTargetChangedObserver;
  44025. private _attachedCamera;
  44026. private _isPointerDown;
  44027. private _lastInteractionTime;
  44028. /**
  44029. * Initializes the behavior.
  44030. */
  44031. init(): void;
  44032. /**
  44033. * Attaches the behavior to its arc rotate camera.
  44034. * @param camera Defines the camera to attach the behavior to
  44035. */
  44036. attach(camera: ArcRotateCamera): void;
  44037. /**
  44038. * Detaches the behavior from its current arc rotate camera.
  44039. */
  44040. detach(): void;
  44041. private _animatables;
  44042. private _betaIsAnimating;
  44043. private _betaTransition;
  44044. private _radiusTransition;
  44045. private _vectorTransition;
  44046. /**
  44047. * Targets the given mesh and updates zoom level accordingly.
  44048. * @param mesh The mesh to target.
  44049. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  44050. * @param onAnimationEnd Callback triggered at the end of the framing animation
  44051. */
  44052. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  44053. /**
  44054. * Targets the given mesh with its children and updates zoom level accordingly.
  44055. * @param mesh The mesh to target.
  44056. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  44057. * @param onAnimationEnd Callback triggered at the end of the framing animation
  44058. */
  44059. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  44060. /**
  44061. * Targets the given meshes with their children and updates zoom level accordingly.
  44062. * @param meshes The mesh to target.
  44063. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  44064. * @param onAnimationEnd Callback triggered at the end of the framing animation
  44065. */
  44066. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  44067. /**
  44068. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  44069. * @param minimumWorld Determines the smaller position of the bounding box extend
  44070. * @param maximumWorld Determines the bigger position of the bounding box extend
  44071. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  44072. * @param onAnimationEnd Callback triggered at the end of the framing animation
  44073. */
  44074. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  44075. /**
  44076. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  44077. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  44078. * frustum width.
  44079. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  44080. * to fully enclose the mesh in the viewing frustum.
  44081. */
  44082. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  44083. /**
  44084. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  44085. * is automatically returned to its default position (expected to be above ground plane).
  44086. */
  44087. private _maintainCameraAboveGround;
  44088. /**
  44089. * Returns the frustum slope based on the canvas ratio and camera FOV
  44090. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  44091. */
  44092. private _getFrustumSlope;
  44093. /**
  44094. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  44095. */
  44096. private _clearAnimationLocks;
  44097. /**
  44098. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  44099. */
  44100. private _applyUserInteraction;
  44101. /**
  44102. * Stops and removes all animations that have been applied to the camera
  44103. */
  44104. stopAllAnimations(): void;
  44105. /**
  44106. * Gets a value indicating if the user is moving the camera
  44107. */
  44108. get isUserIsMoving(): boolean;
  44109. /**
  44110. * The camera can move all the way towards the mesh.
  44111. */
  44112. static IgnoreBoundsSizeMode: number;
  44113. /**
  44114. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  44115. */
  44116. static FitFrustumSidesMode: number;
  44117. }
  44118. }
  44119. declare module "babylonjs/Cameras/Inputs/BaseCameraPointersInput" {
  44120. import { Nullable } from "babylonjs/types";
  44121. import { Camera } from "babylonjs/Cameras/camera";
  44122. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  44123. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  44124. /**
  44125. * Base class for Camera Pointer Inputs.
  44126. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  44127. * for example usage.
  44128. */
  44129. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  44130. /**
  44131. * Defines the camera the input is attached to.
  44132. */
  44133. abstract camera: Camera;
  44134. /**
  44135. * Whether keyboard modifier keys are pressed at time of last mouse event.
  44136. */
  44137. protected _altKey: boolean;
  44138. protected _ctrlKey: boolean;
  44139. protected _metaKey: boolean;
  44140. protected _shiftKey: boolean;
  44141. /**
  44142. * Which mouse buttons were pressed at time of last mouse event.
  44143. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  44144. */
  44145. protected _buttonsPressed: number;
  44146. /**
  44147. * Defines the buttons associated with the input to handle camera move.
  44148. */
  44149. buttons: number[];
  44150. /**
  44151. * Attach the input controls to a specific dom element to get the input from.
  44152. * @param element Defines the element the controls should be listened from
  44153. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44154. */
  44155. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44156. /**
  44157. * Detach the current controls from the specified dom element.
  44158. * @param element Defines the element to stop listening the inputs from
  44159. */
  44160. detachControl(element: Nullable<HTMLElement>): void;
  44161. /**
  44162. * Gets the class name of the current input.
  44163. * @returns the class name
  44164. */
  44165. getClassName(): string;
  44166. /**
  44167. * Get the friendly name associated with the input class.
  44168. * @returns the input friendly name
  44169. */
  44170. getSimpleName(): string;
  44171. /**
  44172. * Called on pointer POINTERDOUBLETAP event.
  44173. * Override this method to provide functionality on POINTERDOUBLETAP event.
  44174. */
  44175. protected onDoubleTap(type: string): void;
  44176. /**
  44177. * Called on pointer POINTERMOVE event if only a single touch is active.
  44178. * Override this method to provide functionality.
  44179. */
  44180. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  44181. /**
  44182. * Called on pointer POINTERMOVE event if multiple touches are active.
  44183. * Override this method to provide functionality.
  44184. */
  44185. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  44186. /**
  44187. * Called on JS contextmenu event.
  44188. * Override this method to provide functionality.
  44189. */
  44190. protected onContextMenu(evt: PointerEvent): void;
  44191. /**
  44192. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  44193. * press.
  44194. * Override this method to provide functionality.
  44195. */
  44196. protected onButtonDown(evt: PointerEvent): void;
  44197. /**
  44198. * Called each time a new POINTERUP event occurs. Ie, for each button
  44199. * release.
  44200. * Override this method to provide functionality.
  44201. */
  44202. protected onButtonUp(evt: PointerEvent): void;
  44203. /**
  44204. * Called when window becomes inactive.
  44205. * Override this method to provide functionality.
  44206. */
  44207. protected onLostFocus(): void;
  44208. private _pointerInput;
  44209. private _observer;
  44210. private _onLostFocus;
  44211. private pointA;
  44212. private pointB;
  44213. }
  44214. }
  44215. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  44216. import { Nullable } from "babylonjs/types";
  44217. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  44218. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  44219. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  44220. /**
  44221. * Manage the pointers inputs to control an arc rotate camera.
  44222. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44223. */
  44224. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  44225. /**
  44226. * Defines the camera the input is attached to.
  44227. */
  44228. camera: ArcRotateCamera;
  44229. /**
  44230. * Gets the class name of the current input.
  44231. * @returns the class name
  44232. */
  44233. getClassName(): string;
  44234. /**
  44235. * Defines the buttons associated with the input to handle camera move.
  44236. */
  44237. buttons: number[];
  44238. /**
  44239. * Defines the pointer angular sensibility along the X axis or how fast is
  44240. * the camera rotating.
  44241. */
  44242. angularSensibilityX: number;
  44243. /**
  44244. * Defines the pointer angular sensibility along the Y axis or how fast is
  44245. * the camera rotating.
  44246. */
  44247. angularSensibilityY: number;
  44248. /**
  44249. * Defines the pointer pinch precision or how fast is the camera zooming.
  44250. */
  44251. pinchPrecision: number;
  44252. /**
  44253. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  44254. * from 0.
  44255. * It defines the percentage of current camera.radius to use as delta when
  44256. * pinch zoom is used.
  44257. */
  44258. pinchDeltaPercentage: number;
  44259. /**
  44260. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  44261. * that any object in the plane at the camera's target point will scale
  44262. * perfectly with finger motion.
  44263. * Overrides pinchDeltaPercentage and pinchPrecision.
  44264. */
  44265. useNaturalPinchZoom: boolean;
  44266. /**
  44267. * Defines the pointer panning sensibility or how fast is the camera moving.
  44268. */
  44269. panningSensibility: number;
  44270. /**
  44271. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  44272. */
  44273. multiTouchPanning: boolean;
  44274. /**
  44275. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  44276. * zoom (pinch) through multitouch.
  44277. */
  44278. multiTouchPanAndZoom: boolean;
  44279. /**
  44280. * Revers pinch action direction.
  44281. */
  44282. pinchInwards: boolean;
  44283. private _isPanClick;
  44284. private _twoFingerActivityCount;
  44285. private _isPinching;
  44286. /**
  44287. * Called on pointer POINTERMOVE event if only a single touch is active.
  44288. */
  44289. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  44290. /**
  44291. * Called on pointer POINTERDOUBLETAP event.
  44292. */
  44293. protected onDoubleTap(type: string): void;
  44294. /**
  44295. * Called on pointer POINTERMOVE event if multiple touches are active.
  44296. */
  44297. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  44298. /**
  44299. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  44300. * press.
  44301. */
  44302. protected onButtonDown(evt: PointerEvent): void;
  44303. /**
  44304. * Called each time a new POINTERUP event occurs. Ie, for each button
  44305. * release.
  44306. */
  44307. protected onButtonUp(evt: PointerEvent): void;
  44308. /**
  44309. * Called when window becomes inactive.
  44310. */
  44311. protected onLostFocus(): void;
  44312. }
  44313. }
  44314. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  44315. import { Nullable } from "babylonjs/types";
  44316. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  44317. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  44318. /**
  44319. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  44320. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44321. */
  44322. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  44323. /**
  44324. * Defines the camera the input is attached to.
  44325. */
  44326. camera: ArcRotateCamera;
  44327. /**
  44328. * Defines the list of key codes associated with the up action (increase alpha)
  44329. */
  44330. keysUp: number[];
  44331. /**
  44332. * Defines the list of key codes associated with the down action (decrease alpha)
  44333. */
  44334. keysDown: number[];
  44335. /**
  44336. * Defines the list of key codes associated with the left action (increase beta)
  44337. */
  44338. keysLeft: number[];
  44339. /**
  44340. * Defines the list of key codes associated with the right action (decrease beta)
  44341. */
  44342. keysRight: number[];
  44343. /**
  44344. * Defines the list of key codes associated with the reset action.
  44345. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  44346. */
  44347. keysReset: number[];
  44348. /**
  44349. * Defines the panning sensibility of the inputs.
  44350. * (How fast is the camera panning)
  44351. */
  44352. panningSensibility: number;
  44353. /**
  44354. * Defines the zooming sensibility of the inputs.
  44355. * (How fast is the camera zooming)
  44356. */
  44357. zoomingSensibility: number;
  44358. /**
  44359. * Defines whether maintaining the alt key down switch the movement mode from
  44360. * orientation to zoom.
  44361. */
  44362. useAltToZoom: boolean;
  44363. /**
  44364. * Rotation speed of the camera
  44365. */
  44366. angularSpeed: number;
  44367. private _keys;
  44368. private _ctrlPressed;
  44369. private _altPressed;
  44370. private _onCanvasBlurObserver;
  44371. private _onKeyboardObserver;
  44372. private _engine;
  44373. private _scene;
  44374. /**
  44375. * Attach the input controls to a specific dom element to get the input from.
  44376. * @param element Defines the element the controls should be listened from
  44377. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44378. */
  44379. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44380. /**
  44381. * Detach the current controls from the specified dom element.
  44382. * @param element Defines the element to stop listening the inputs from
  44383. */
  44384. detachControl(element: Nullable<HTMLElement>): void;
  44385. /**
  44386. * Update the current camera state depending on the inputs that have been used this frame.
  44387. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  44388. */
  44389. checkInputs(): void;
  44390. /**
  44391. * Gets the class name of the current intput.
  44392. * @returns the class name
  44393. */
  44394. getClassName(): string;
  44395. /**
  44396. * Get the friendly name associated with the input class.
  44397. * @returns the input friendly name
  44398. */
  44399. getSimpleName(): string;
  44400. }
  44401. }
  44402. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  44403. import { Nullable } from "babylonjs/types";
  44404. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  44405. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  44406. /**
  44407. * Manage the mouse wheel inputs to control an arc rotate camera.
  44408. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44409. */
  44410. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  44411. /**
  44412. * Defines the camera the input is attached to.
  44413. */
  44414. camera: ArcRotateCamera;
  44415. /**
  44416. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  44417. */
  44418. wheelPrecision: number;
  44419. /**
  44420. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  44421. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  44422. */
  44423. wheelDeltaPercentage: number;
  44424. private _wheel;
  44425. private _observer;
  44426. private computeDeltaFromMouseWheelLegacyEvent;
  44427. /**
  44428. * Attach the input controls to a specific dom element to get the input from.
  44429. * @param element Defines the element the controls should be listened from
  44430. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44431. */
  44432. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44433. /**
  44434. * Detach the current controls from the specified dom element.
  44435. * @param element Defines the element to stop listening the inputs from
  44436. */
  44437. detachControl(element: Nullable<HTMLElement>): void;
  44438. /**
  44439. * Gets the class name of the current intput.
  44440. * @returns the class name
  44441. */
  44442. getClassName(): string;
  44443. /**
  44444. * Get the friendly name associated with the input class.
  44445. * @returns the input friendly name
  44446. */
  44447. getSimpleName(): string;
  44448. }
  44449. }
  44450. declare module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  44451. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  44452. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  44453. /**
  44454. * Default Inputs manager for the ArcRotateCamera.
  44455. * It groups all the default supported inputs for ease of use.
  44456. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44457. */
  44458. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  44459. /**
  44460. * Instantiates a new ArcRotateCameraInputsManager.
  44461. * @param camera Defines the camera the inputs belong to
  44462. */
  44463. constructor(camera: ArcRotateCamera);
  44464. /**
  44465. * Add mouse wheel input support to the input manager.
  44466. * @returns the current input manager
  44467. */
  44468. addMouseWheel(): ArcRotateCameraInputsManager;
  44469. /**
  44470. * Add pointers input support to the input manager.
  44471. * @returns the current input manager
  44472. */
  44473. addPointers(): ArcRotateCameraInputsManager;
  44474. /**
  44475. * Add keyboard input support to the input manager.
  44476. * @returns the current input manager
  44477. */
  44478. addKeyboard(): ArcRotateCameraInputsManager;
  44479. }
  44480. }
  44481. declare module "babylonjs/Cameras/arcRotateCamera" {
  44482. import { Observable } from "babylonjs/Misc/observable";
  44483. import { Nullable } from "babylonjs/types";
  44484. import { Scene } from "babylonjs/scene";
  44485. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  44486. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44487. import { AutoRotationBehavior } from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  44488. import { BouncingBehavior } from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  44489. import { FramingBehavior } from "babylonjs/Behaviors/Cameras/framingBehavior";
  44490. import { Camera } from "babylonjs/Cameras/camera";
  44491. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  44492. import { ArcRotateCameraInputsManager } from "babylonjs/Cameras/arcRotateCameraInputsManager";
  44493. import { Collider } from "babylonjs/Collisions/collider";
  44494. /**
  44495. * This represents an orbital type of camera.
  44496. *
  44497. * 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.
  44498. * 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.
  44499. * @see https://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  44500. */
  44501. export class ArcRotateCamera extends TargetCamera {
  44502. /**
  44503. * Defines the rotation angle of the camera along the longitudinal axis.
  44504. */
  44505. alpha: number;
  44506. /**
  44507. * Defines the rotation angle of the camera along the latitudinal axis.
  44508. */
  44509. beta: number;
  44510. /**
  44511. * Defines the radius of the camera from it s target point.
  44512. */
  44513. radius: number;
  44514. protected _target: Vector3;
  44515. protected _targetHost: Nullable<AbstractMesh>;
  44516. /**
  44517. * Defines the target point of the camera.
  44518. * The camera looks towards it form the radius distance.
  44519. * Please note that you can set the target to a mesh and thus the target will be copied from mesh.position
  44520. */
  44521. get target(): Vector3;
  44522. set target(value: Vector3);
  44523. /**
  44524. * Define the current local position of the camera in the scene
  44525. */
  44526. get position(): Vector3;
  44527. set position(newPosition: Vector3);
  44528. protected _upToYMatrix: Matrix;
  44529. protected _YToUpMatrix: Matrix;
  44530. /**
  44531. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  44532. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  44533. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  44534. */
  44535. set upVector(vec: Vector3);
  44536. get upVector(): Vector3;
  44537. /**
  44538. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  44539. */
  44540. setMatUp(): void;
  44541. /**
  44542. * Current inertia value on the longitudinal axis.
  44543. * The bigger this number the longer it will take for the camera to stop.
  44544. */
  44545. inertialAlphaOffset: number;
  44546. /**
  44547. * Current inertia value on the latitudinal axis.
  44548. * The bigger this number the longer it will take for the camera to stop.
  44549. */
  44550. inertialBetaOffset: number;
  44551. /**
  44552. * Current inertia value on the radius axis.
  44553. * The bigger this number the longer it will take for the camera to stop.
  44554. */
  44555. inertialRadiusOffset: number;
  44556. /**
  44557. * Minimum allowed angle on the longitudinal axis.
  44558. * This can help limiting how the Camera is able to move in the scene.
  44559. */
  44560. lowerAlphaLimit: Nullable<number>;
  44561. /**
  44562. * Maximum allowed angle on the longitudinal axis.
  44563. * This can help limiting how the Camera is able to move in the scene.
  44564. */
  44565. upperAlphaLimit: Nullable<number>;
  44566. /**
  44567. * Minimum allowed angle on the latitudinal axis.
  44568. * This can help limiting how the Camera is able to move in the scene.
  44569. */
  44570. lowerBetaLimit: number;
  44571. /**
  44572. * Maximum allowed angle on the latitudinal axis.
  44573. * This can help limiting how the Camera is able to move in the scene.
  44574. */
  44575. upperBetaLimit: number;
  44576. /**
  44577. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  44578. * This can help limiting how the Camera is able to move in the scene.
  44579. */
  44580. lowerRadiusLimit: Nullable<number>;
  44581. /**
  44582. * Maximum allowed distance of the camera to the target (The camera can not get further).
  44583. * This can help limiting how the Camera is able to move in the scene.
  44584. */
  44585. upperRadiusLimit: Nullable<number>;
  44586. /**
  44587. * Defines the current inertia value used during panning of the camera along the X axis.
  44588. */
  44589. inertialPanningX: number;
  44590. /**
  44591. * Defines the current inertia value used during panning of the camera along the Y axis.
  44592. */
  44593. inertialPanningY: number;
  44594. /**
  44595. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  44596. * Basically if your fingers moves away from more than this distance you will be considered
  44597. * in pinch mode.
  44598. */
  44599. pinchToPanMaxDistance: number;
  44600. /**
  44601. * Defines the maximum distance the camera can pan.
  44602. * This could help keeping the cammera always in your scene.
  44603. */
  44604. panningDistanceLimit: Nullable<number>;
  44605. /**
  44606. * Defines the target of the camera before paning.
  44607. */
  44608. panningOriginTarget: Vector3;
  44609. /**
  44610. * Defines the value of the inertia used during panning.
  44611. * 0 would mean stop inertia and one would mean no decelleration at all.
  44612. */
  44613. panningInertia: number;
  44614. /**
  44615. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  44616. */
  44617. get angularSensibilityX(): number;
  44618. set angularSensibilityX(value: number);
  44619. /**
  44620. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  44621. */
  44622. get angularSensibilityY(): number;
  44623. set angularSensibilityY(value: number);
  44624. /**
  44625. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  44626. */
  44627. get pinchPrecision(): number;
  44628. set pinchPrecision(value: number);
  44629. /**
  44630. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  44631. * It will be used instead of pinchDeltaPrecision if different from 0.
  44632. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  44633. */
  44634. get pinchDeltaPercentage(): number;
  44635. set pinchDeltaPercentage(value: number);
  44636. /**
  44637. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  44638. * and pinch delta percentage.
  44639. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  44640. * that any object in the plane at the camera's target point will scale
  44641. * perfectly with finger motion.
  44642. */
  44643. get useNaturalPinchZoom(): boolean;
  44644. set useNaturalPinchZoom(value: boolean);
  44645. /**
  44646. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  44647. */
  44648. get panningSensibility(): number;
  44649. set panningSensibility(value: number);
  44650. /**
  44651. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  44652. */
  44653. get keysUp(): number[];
  44654. set keysUp(value: number[]);
  44655. /**
  44656. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  44657. */
  44658. get keysDown(): number[];
  44659. set keysDown(value: number[]);
  44660. /**
  44661. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  44662. */
  44663. get keysLeft(): number[];
  44664. set keysLeft(value: number[]);
  44665. /**
  44666. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  44667. */
  44668. get keysRight(): number[];
  44669. set keysRight(value: number[]);
  44670. /**
  44671. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  44672. */
  44673. get wheelPrecision(): number;
  44674. set wheelPrecision(value: number);
  44675. /**
  44676. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  44677. * It will be used instead of pinchDeltaPrecision if different from 0.
  44678. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  44679. */
  44680. get wheelDeltaPercentage(): number;
  44681. set wheelDeltaPercentage(value: number);
  44682. /**
  44683. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  44684. */
  44685. zoomOnFactor: number;
  44686. /**
  44687. * Defines a screen offset for the camera position.
  44688. */
  44689. targetScreenOffset: Vector2;
  44690. /**
  44691. * Allows the camera to be completely reversed.
  44692. * If false the camera can not arrive upside down.
  44693. */
  44694. allowUpsideDown: boolean;
  44695. /**
  44696. * Define if double tap/click is used to restore the previously saved state of the camera.
  44697. */
  44698. useInputToRestoreState: boolean;
  44699. /** @hidden */
  44700. _viewMatrix: Matrix;
  44701. /** @hidden */
  44702. _useCtrlForPanning: boolean;
  44703. /** @hidden */
  44704. _panningMouseButton: number;
  44705. /**
  44706. * Defines the input associated to the camera.
  44707. */
  44708. inputs: ArcRotateCameraInputsManager;
  44709. /** @hidden */
  44710. _reset: () => void;
  44711. /**
  44712. * Defines the allowed panning axis.
  44713. */
  44714. panningAxis: Vector3;
  44715. protected _localDirection: Vector3;
  44716. protected _transformedDirection: Vector3;
  44717. private _bouncingBehavior;
  44718. /**
  44719. * Gets the bouncing behavior of the camera if it has been enabled.
  44720. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  44721. */
  44722. get bouncingBehavior(): Nullable<BouncingBehavior>;
  44723. /**
  44724. * Defines if the bouncing behavior of the camera is enabled on the camera.
  44725. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  44726. */
  44727. get useBouncingBehavior(): boolean;
  44728. set useBouncingBehavior(value: boolean);
  44729. private _framingBehavior;
  44730. /**
  44731. * Gets the framing behavior of the camera if it has been enabled.
  44732. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  44733. */
  44734. get framingBehavior(): Nullable<FramingBehavior>;
  44735. /**
  44736. * Defines if the framing behavior of the camera is enabled on the camera.
  44737. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  44738. */
  44739. get useFramingBehavior(): boolean;
  44740. set useFramingBehavior(value: boolean);
  44741. private _autoRotationBehavior;
  44742. /**
  44743. * Gets the auto rotation behavior of the camera if it has been enabled.
  44744. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  44745. */
  44746. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  44747. /**
  44748. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  44749. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  44750. */
  44751. get useAutoRotationBehavior(): boolean;
  44752. set useAutoRotationBehavior(value: boolean);
  44753. /**
  44754. * Observable triggered when the mesh target has been changed on the camera.
  44755. */
  44756. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  44757. /**
  44758. * Event raised when the camera is colliding with a mesh.
  44759. */
  44760. onCollide: (collidedMesh: AbstractMesh) => void;
  44761. /**
  44762. * Defines whether the camera should check collision with the objects oh the scene.
  44763. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  44764. */
  44765. checkCollisions: boolean;
  44766. /**
  44767. * Defines the collision radius of the camera.
  44768. * This simulates a sphere around the camera.
  44769. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  44770. */
  44771. collisionRadius: Vector3;
  44772. protected _collider: Collider;
  44773. protected _previousPosition: Vector3;
  44774. protected _collisionVelocity: Vector3;
  44775. protected _newPosition: Vector3;
  44776. protected _previousAlpha: number;
  44777. protected _previousBeta: number;
  44778. protected _previousRadius: number;
  44779. protected _collisionTriggered: boolean;
  44780. protected _targetBoundingCenter: Nullable<Vector3>;
  44781. private _computationVector;
  44782. /**
  44783. * Instantiates a new ArcRotateCamera in a given scene
  44784. * @param name Defines the name of the camera
  44785. * @param alpha Defines the camera rotation along the logitudinal axis
  44786. * @param beta Defines the camera rotation along the latitudinal axis
  44787. * @param radius Defines the camera distance from its target
  44788. * @param target Defines the camera target
  44789. * @param scene Defines the scene the camera belongs to
  44790. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  44791. */
  44792. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  44793. /** @hidden */
  44794. _initCache(): void;
  44795. /** @hidden */
  44796. _updateCache(ignoreParentClass?: boolean): void;
  44797. protected _getTargetPosition(): Vector3;
  44798. private _storedAlpha;
  44799. private _storedBeta;
  44800. private _storedRadius;
  44801. private _storedTarget;
  44802. private _storedTargetScreenOffset;
  44803. /**
  44804. * Stores the current state of the camera (alpha, beta, radius and target)
  44805. * @returns the camera itself
  44806. */
  44807. storeState(): Camera;
  44808. /**
  44809. * @hidden
  44810. * Restored camera state. You must call storeState() first
  44811. */
  44812. _restoreStateValues(): boolean;
  44813. /** @hidden */
  44814. _isSynchronizedViewMatrix(): boolean;
  44815. /**
  44816. * Attached controls to the current camera.
  44817. * @param element Defines the element the controls should be listened from
  44818. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44819. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  44820. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  44821. */
  44822. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  44823. /**
  44824. * Detach the current controls from the camera.
  44825. * The camera will stop reacting to inputs.
  44826. * @param element Defines the element to stop listening the inputs from
  44827. */
  44828. detachControl(element: HTMLElement): void;
  44829. /** @hidden */
  44830. _checkInputs(): void;
  44831. protected _checkLimits(): void;
  44832. /**
  44833. * Rebuilds angles (alpha, beta) and radius from the give position and target
  44834. */
  44835. rebuildAnglesAndRadius(): void;
  44836. /**
  44837. * Use a position to define the current camera related information like alpha, beta and radius
  44838. * @param position Defines the position to set the camera at
  44839. */
  44840. setPosition(position: Vector3): void;
  44841. /**
  44842. * Defines the target the camera should look at.
  44843. * This will automatically adapt alpha beta and radius to fit within the new target.
  44844. * @param target Defines the new target as a Vector or a mesh
  44845. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  44846. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  44847. */
  44848. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  44849. /** @hidden */
  44850. _getViewMatrix(): Matrix;
  44851. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  44852. /**
  44853. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  44854. * @param meshes Defines the mesh to zoom on
  44855. * @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)
  44856. */
  44857. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  44858. /**
  44859. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  44860. * The target will be changed but the radius
  44861. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  44862. * @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)
  44863. */
  44864. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  44865. min: Vector3;
  44866. max: Vector3;
  44867. distance: number;
  44868. }, doNotUpdateMaxZ?: boolean): void;
  44869. /**
  44870. * @override
  44871. * Override Camera.createRigCamera
  44872. */
  44873. createRigCamera(name: string, cameraIndex: number): Camera;
  44874. /**
  44875. * @hidden
  44876. * @override
  44877. * Override Camera._updateRigCameras
  44878. */
  44879. _updateRigCameras(): void;
  44880. /**
  44881. * Destroy the camera and release the current resources hold by it.
  44882. */
  44883. dispose(): void;
  44884. /**
  44885. * Gets the current object class name.
  44886. * @return the class name
  44887. */
  44888. getClassName(): string;
  44889. }
  44890. }
  44891. declare module "babylonjs/Behaviors/Cameras/autoRotationBehavior" {
  44892. import { Behavior } from "babylonjs/Behaviors/behavior";
  44893. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  44894. /**
  44895. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  44896. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  44897. */
  44898. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  44899. /**
  44900. * Gets the name of the behavior.
  44901. */
  44902. get name(): string;
  44903. private _zoomStopsAnimation;
  44904. private _idleRotationSpeed;
  44905. private _idleRotationWaitTime;
  44906. private _idleRotationSpinupTime;
  44907. /**
  44908. * Sets the flag that indicates if user zooming should stop animation.
  44909. */
  44910. set zoomStopsAnimation(flag: boolean);
  44911. /**
  44912. * Gets the flag that indicates if user zooming should stop animation.
  44913. */
  44914. get zoomStopsAnimation(): boolean;
  44915. /**
  44916. * Sets the default speed at which the camera rotates around the model.
  44917. */
  44918. set idleRotationSpeed(speed: number);
  44919. /**
  44920. * Gets the default speed at which the camera rotates around the model.
  44921. */
  44922. get idleRotationSpeed(): number;
  44923. /**
  44924. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  44925. */
  44926. set idleRotationWaitTime(time: number);
  44927. /**
  44928. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  44929. */
  44930. get idleRotationWaitTime(): number;
  44931. /**
  44932. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  44933. */
  44934. set idleRotationSpinupTime(time: number);
  44935. /**
  44936. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  44937. */
  44938. get idleRotationSpinupTime(): number;
  44939. /**
  44940. * Gets a value indicating if the camera is currently rotating because of this behavior
  44941. */
  44942. get rotationInProgress(): boolean;
  44943. private _onPrePointerObservableObserver;
  44944. private _onAfterCheckInputsObserver;
  44945. private _attachedCamera;
  44946. private _isPointerDown;
  44947. private _lastFrameTime;
  44948. private _lastInteractionTime;
  44949. private _cameraRotationSpeed;
  44950. /**
  44951. * Initializes the behavior.
  44952. */
  44953. init(): void;
  44954. /**
  44955. * Attaches the behavior to its arc rotate camera.
  44956. * @param camera Defines the camera to attach the behavior to
  44957. */
  44958. attach(camera: ArcRotateCamera): void;
  44959. /**
  44960. * Detaches the behavior from its current arc rotate camera.
  44961. */
  44962. detach(): void;
  44963. /**
  44964. * Returns true if user is scrolling.
  44965. * @return true if user is scrolling.
  44966. */
  44967. private _userIsZooming;
  44968. private _lastFrameRadius;
  44969. private _shouldAnimationStopForInteraction;
  44970. /**
  44971. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  44972. */
  44973. private _applyUserInteraction;
  44974. private _userIsMoving;
  44975. }
  44976. }
  44977. declare module "babylonjs/Behaviors/Cameras/index" {
  44978. export * from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  44979. export * from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  44980. export * from "babylonjs/Behaviors/Cameras/framingBehavior";
  44981. }
  44982. declare module "babylonjs/Behaviors/Meshes/attachToBoxBehavior" {
  44983. import { Mesh } from "babylonjs/Meshes/mesh";
  44984. import { TransformNode } from "babylonjs/Meshes/transformNode";
  44985. import { Behavior } from "babylonjs/Behaviors/behavior";
  44986. /**
  44987. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  44988. */
  44989. export class AttachToBoxBehavior implements Behavior<Mesh> {
  44990. private ui;
  44991. /**
  44992. * The name of the behavior
  44993. */
  44994. name: string;
  44995. /**
  44996. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  44997. */
  44998. distanceAwayFromFace: number;
  44999. /**
  45000. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  45001. */
  45002. distanceAwayFromBottomOfFace: number;
  45003. private _faceVectors;
  45004. private _target;
  45005. private _scene;
  45006. private _onRenderObserver;
  45007. private _tmpMatrix;
  45008. private _tmpVector;
  45009. /**
  45010. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  45011. * @param ui The transform node that should be attched to the mesh
  45012. */
  45013. constructor(ui: TransformNode);
  45014. /**
  45015. * Initializes the behavior
  45016. */
  45017. init(): void;
  45018. private _closestFace;
  45019. private _zeroVector;
  45020. private _lookAtTmpMatrix;
  45021. private _lookAtToRef;
  45022. /**
  45023. * Attaches the AttachToBoxBehavior to the passed in mesh
  45024. * @param target The mesh that the specified node will be attached to
  45025. */
  45026. attach(target: Mesh): void;
  45027. /**
  45028. * Detaches the behavior from the mesh
  45029. */
  45030. detach(): void;
  45031. }
  45032. }
  45033. declare module "babylonjs/Behaviors/Meshes/fadeInOutBehavior" {
  45034. import { Behavior } from "babylonjs/Behaviors/behavior";
  45035. import { Mesh } from "babylonjs/Meshes/mesh";
  45036. /**
  45037. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  45038. */
  45039. export class FadeInOutBehavior implements Behavior<Mesh> {
  45040. /**
  45041. * Time in milliseconds to delay before fading in (Default: 0)
  45042. */
  45043. delay: number;
  45044. /**
  45045. * Time in milliseconds for the mesh to fade in (Default: 300)
  45046. */
  45047. fadeInTime: number;
  45048. private _millisecondsPerFrame;
  45049. private _hovered;
  45050. private _hoverValue;
  45051. private _ownerNode;
  45052. /**
  45053. * Instatiates the FadeInOutBehavior
  45054. */
  45055. constructor();
  45056. /**
  45057. * The name of the behavior
  45058. */
  45059. get name(): string;
  45060. /**
  45061. * Initializes the behavior
  45062. */
  45063. init(): void;
  45064. /**
  45065. * Attaches the fade behavior on the passed in mesh
  45066. * @param ownerNode The mesh that will be faded in/out once attached
  45067. */
  45068. attach(ownerNode: Mesh): void;
  45069. /**
  45070. * Detaches the behavior from the mesh
  45071. */
  45072. detach(): void;
  45073. /**
  45074. * Triggers the mesh to begin fading in or out
  45075. * @param value if the object should fade in or out (true to fade in)
  45076. */
  45077. fadeIn(value: boolean): void;
  45078. private _update;
  45079. private _setAllVisibility;
  45080. }
  45081. }
  45082. declare module "babylonjs/Misc/pivotTools" {
  45083. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45084. /**
  45085. * Class containing a set of static utilities functions for managing Pivots
  45086. * @hidden
  45087. */
  45088. export class PivotTools {
  45089. private static _PivotCached;
  45090. private static _OldPivotPoint;
  45091. private static _PivotTranslation;
  45092. private static _PivotTmpVector;
  45093. private static _PivotPostMultiplyPivotMatrix;
  45094. /** @hidden */
  45095. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  45096. /** @hidden */
  45097. static _RestorePivotPoint(mesh: AbstractMesh): void;
  45098. }
  45099. }
  45100. declare module "babylonjs/Meshes/Builders/planeBuilder" {
  45101. import { Scene } from "babylonjs/scene";
  45102. import { Vector4 } from "babylonjs/Maths/math.vector";
  45103. import { Mesh } from "babylonjs/Meshes/mesh";
  45104. import { Nullable } from "babylonjs/types";
  45105. import { Plane } from "babylonjs/Maths/math.plane";
  45106. /**
  45107. * Class containing static functions to help procedurally build meshes
  45108. */
  45109. export class PlaneBuilder {
  45110. /**
  45111. * Creates a plane mesh
  45112. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  45113. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  45114. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  45115. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  45116. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  45117. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45118. * @param name defines the name of the mesh
  45119. * @param options defines the options used to create the mesh
  45120. * @param scene defines the hosting scene
  45121. * @returns the plane mesh
  45122. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  45123. */
  45124. static CreatePlane(name: string, options: {
  45125. size?: number;
  45126. width?: number;
  45127. height?: number;
  45128. sideOrientation?: number;
  45129. frontUVs?: Vector4;
  45130. backUVs?: Vector4;
  45131. updatable?: boolean;
  45132. sourcePlane?: Plane;
  45133. }, scene?: Nullable<Scene>): Mesh;
  45134. }
  45135. }
  45136. declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
  45137. import { Behavior } from "babylonjs/Behaviors/behavior";
  45138. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45139. import { Observable } from "babylonjs/Misc/observable";
  45140. import { Vector3 } from "babylonjs/Maths/math.vector";
  45141. import { Ray } from "babylonjs/Culling/ray";
  45142. import "babylonjs/Meshes/Builders/planeBuilder";
  45143. /**
  45144. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  45145. */
  45146. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  45147. private static _AnyMouseID;
  45148. /**
  45149. * Abstract mesh the behavior is set on
  45150. */
  45151. attachedNode: AbstractMesh;
  45152. private _dragPlane;
  45153. private _scene;
  45154. private _pointerObserver;
  45155. private _beforeRenderObserver;
  45156. private static _planeScene;
  45157. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  45158. /**
  45159. * 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)
  45160. */
  45161. maxDragAngle: number;
  45162. /**
  45163. * @hidden
  45164. */
  45165. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  45166. /**
  45167. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  45168. */
  45169. currentDraggingPointerID: number;
  45170. /**
  45171. * The last position where the pointer hit the drag plane in world space
  45172. */
  45173. lastDragPosition: Vector3;
  45174. /**
  45175. * If the behavior is currently in a dragging state
  45176. */
  45177. dragging: boolean;
  45178. /**
  45179. * 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)
  45180. */
  45181. dragDeltaRatio: number;
  45182. /**
  45183. * If the drag plane orientation should be updated during the dragging (Default: true)
  45184. */
  45185. updateDragPlane: boolean;
  45186. private _debugMode;
  45187. private _moving;
  45188. /**
  45189. * Fires each time the attached mesh is dragged with the pointer
  45190. * * delta between last drag position and current drag position in world space
  45191. * * dragDistance along the drag axis
  45192. * * dragPlaneNormal normal of the current drag plane used during the drag
  45193. * * dragPlanePoint in world space where the drag intersects the drag plane
  45194. */
  45195. onDragObservable: Observable<{
  45196. delta: Vector3;
  45197. dragPlanePoint: Vector3;
  45198. dragPlaneNormal: Vector3;
  45199. dragDistance: number;
  45200. pointerId: number;
  45201. }>;
  45202. /**
  45203. * Fires each time a drag begins (eg. mouse down on mesh)
  45204. */
  45205. onDragStartObservable: Observable<{
  45206. dragPlanePoint: Vector3;
  45207. pointerId: number;
  45208. }>;
  45209. /**
  45210. * Fires each time a drag ends (eg. mouse release after drag)
  45211. */
  45212. onDragEndObservable: Observable<{
  45213. dragPlanePoint: Vector3;
  45214. pointerId: number;
  45215. }>;
  45216. /**
  45217. * If the attached mesh should be moved when dragged
  45218. */
  45219. moveAttached: boolean;
  45220. /**
  45221. * If the drag behavior will react to drag events (Default: true)
  45222. */
  45223. enabled: boolean;
  45224. /**
  45225. * If pointer events should start and release the drag (Default: true)
  45226. */
  45227. startAndReleaseDragOnPointerEvents: boolean;
  45228. /**
  45229. * If camera controls should be detached during the drag
  45230. */
  45231. detachCameraControls: boolean;
  45232. /**
  45233. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  45234. */
  45235. useObjectOrientationForDragging: boolean;
  45236. private _options;
  45237. /**
  45238. * Gets the options used by the behavior
  45239. */
  45240. get options(): {
  45241. dragAxis?: Vector3;
  45242. dragPlaneNormal?: Vector3;
  45243. };
  45244. /**
  45245. * Sets the options used by the behavior
  45246. */
  45247. set options(options: {
  45248. dragAxis?: Vector3;
  45249. dragPlaneNormal?: Vector3;
  45250. });
  45251. /**
  45252. * Creates a pointer drag behavior that can be attached to a mesh
  45253. * @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)
  45254. */
  45255. constructor(options?: {
  45256. dragAxis?: Vector3;
  45257. dragPlaneNormal?: Vector3;
  45258. });
  45259. /**
  45260. * Predicate to determine if it is valid to move the object to a new position when it is moved
  45261. */
  45262. validateDrag: (targetPosition: Vector3) => boolean;
  45263. /**
  45264. * The name of the behavior
  45265. */
  45266. get name(): string;
  45267. /**
  45268. * Initializes the behavior
  45269. */
  45270. init(): void;
  45271. private _tmpVector;
  45272. private _alternatePickedPoint;
  45273. private _worldDragAxis;
  45274. private _targetPosition;
  45275. private _attachedElement;
  45276. /**
  45277. * Attaches the drag behavior the passed in mesh
  45278. * @param ownerNode The mesh that will be dragged around once attached
  45279. * @param predicate Predicate to use for pick filtering
  45280. */
  45281. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  45282. /**
  45283. * Force relase the drag action by code.
  45284. */
  45285. releaseDrag(): void;
  45286. private _startDragRay;
  45287. private _lastPointerRay;
  45288. /**
  45289. * Simulates the start of a pointer drag event on the behavior
  45290. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  45291. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  45292. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  45293. */
  45294. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  45295. protected _startDrag(pointerId: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  45296. private _dragDelta;
  45297. protected _moveDrag(ray: Ray): void;
  45298. private _pickWithRayOnDragPlane;
  45299. private _pointA;
  45300. private _pointC;
  45301. private _localAxis;
  45302. private _lookAt;
  45303. private _updateDragPlanePosition;
  45304. /**
  45305. * Detaches the behavior from the mesh
  45306. */
  45307. detach(): void;
  45308. }
  45309. }
  45310. declare module "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior" {
  45311. import { Mesh } from "babylonjs/Meshes/mesh";
  45312. import { Behavior } from "babylonjs/Behaviors/behavior";
  45313. /**
  45314. * A behavior that when attached to a mesh will allow the mesh to be scaled
  45315. */
  45316. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  45317. private _dragBehaviorA;
  45318. private _dragBehaviorB;
  45319. private _startDistance;
  45320. private _initialScale;
  45321. private _targetScale;
  45322. private _ownerNode;
  45323. private _sceneRenderObserver;
  45324. /**
  45325. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  45326. */
  45327. constructor();
  45328. /**
  45329. * The name of the behavior
  45330. */
  45331. get name(): string;
  45332. /**
  45333. * Initializes the behavior
  45334. */
  45335. init(): void;
  45336. private _getCurrentDistance;
  45337. /**
  45338. * Attaches the scale behavior the passed in mesh
  45339. * @param ownerNode The mesh that will be scaled around once attached
  45340. */
  45341. attach(ownerNode: Mesh): void;
  45342. /**
  45343. * Detaches the behavior from the mesh
  45344. */
  45345. detach(): void;
  45346. }
  45347. }
  45348. declare module "babylonjs/Behaviors/Meshes/sixDofDragBehavior" {
  45349. import { Behavior } from "babylonjs/Behaviors/behavior";
  45350. import { Mesh } from "babylonjs/Meshes/mesh";
  45351. import { Observable } from "babylonjs/Misc/observable";
  45352. /**
  45353. * 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
  45354. */
  45355. export class SixDofDragBehavior implements Behavior<Mesh> {
  45356. private static _virtualScene;
  45357. private _ownerNode;
  45358. private _sceneRenderObserver;
  45359. private _scene;
  45360. private _targetPosition;
  45361. private _virtualOriginMesh;
  45362. private _virtualDragMesh;
  45363. private _pointerObserver;
  45364. private _moving;
  45365. private _startingOrientation;
  45366. private _attachedElement;
  45367. /**
  45368. * 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)
  45369. */
  45370. private zDragFactor;
  45371. /**
  45372. * If the object should rotate to face the drag origin
  45373. */
  45374. rotateDraggedObject: boolean;
  45375. /**
  45376. * If the behavior is currently in a dragging state
  45377. */
  45378. dragging: boolean;
  45379. /**
  45380. * 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)
  45381. */
  45382. dragDeltaRatio: number;
  45383. /**
  45384. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  45385. */
  45386. currentDraggingPointerID: number;
  45387. /**
  45388. * If camera controls should be detached during the drag
  45389. */
  45390. detachCameraControls: boolean;
  45391. /**
  45392. * Fires each time a drag starts
  45393. */
  45394. onDragStartObservable: Observable<{}>;
  45395. /**
  45396. * Fires each time a drag ends (eg. mouse release after drag)
  45397. */
  45398. onDragEndObservable: Observable<{}>;
  45399. /**
  45400. * 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
  45401. */
  45402. constructor();
  45403. /**
  45404. * The name of the behavior
  45405. */
  45406. get name(): string;
  45407. /**
  45408. * Initializes the behavior
  45409. */
  45410. init(): void;
  45411. /**
  45412. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  45413. */
  45414. private get _pointerCamera();
  45415. /**
  45416. * Attaches the scale behavior the passed in mesh
  45417. * @param ownerNode The mesh that will be scaled around once attached
  45418. */
  45419. attach(ownerNode: Mesh): void;
  45420. /**
  45421. * Detaches the behavior from the mesh
  45422. */
  45423. detach(): void;
  45424. }
  45425. }
  45426. declare module "babylonjs/Behaviors/Meshes/index" {
  45427. export * from "babylonjs/Behaviors/Meshes/attachToBoxBehavior";
  45428. export * from "babylonjs/Behaviors/Meshes/fadeInOutBehavior";
  45429. export * from "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior";
  45430. export * from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  45431. export * from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  45432. }
  45433. declare module "babylonjs/Behaviors/index" {
  45434. export * from "babylonjs/Behaviors/behavior";
  45435. export * from "babylonjs/Behaviors/Cameras/index";
  45436. export * from "babylonjs/Behaviors/Meshes/index";
  45437. }
  45438. declare module "babylonjs/Bones/boneIKController" {
  45439. import { Bone } from "babylonjs/Bones/bone";
  45440. import { Vector3 } from "babylonjs/Maths/math.vector";
  45441. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45442. import { Nullable } from "babylonjs/types";
  45443. /**
  45444. * Class used to apply inverse kinematics to bones
  45445. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  45446. */
  45447. export class BoneIKController {
  45448. private static _tmpVecs;
  45449. private static _tmpQuat;
  45450. private static _tmpMats;
  45451. /**
  45452. * Gets or sets the target mesh
  45453. */
  45454. targetMesh: AbstractMesh;
  45455. /** Gets or sets the mesh used as pole */
  45456. poleTargetMesh: AbstractMesh;
  45457. /**
  45458. * Gets or sets the bone used as pole
  45459. */
  45460. poleTargetBone: Nullable<Bone>;
  45461. /**
  45462. * Gets or sets the target position
  45463. */
  45464. targetPosition: Vector3;
  45465. /**
  45466. * Gets or sets the pole target position
  45467. */
  45468. poleTargetPosition: Vector3;
  45469. /**
  45470. * Gets or sets the pole target local offset
  45471. */
  45472. poleTargetLocalOffset: Vector3;
  45473. /**
  45474. * Gets or sets the pole angle
  45475. */
  45476. poleAngle: number;
  45477. /**
  45478. * Gets or sets the mesh associated with the controller
  45479. */
  45480. mesh: AbstractMesh;
  45481. /**
  45482. * 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)
  45483. */
  45484. slerpAmount: number;
  45485. private _bone1Quat;
  45486. private _bone1Mat;
  45487. private _bone2Ang;
  45488. private _bone1;
  45489. private _bone2;
  45490. private _bone1Length;
  45491. private _bone2Length;
  45492. private _maxAngle;
  45493. private _maxReach;
  45494. private _rightHandedSystem;
  45495. private _bendAxis;
  45496. private _slerping;
  45497. private _adjustRoll;
  45498. /**
  45499. * Gets or sets maximum allowed angle
  45500. */
  45501. get maxAngle(): number;
  45502. set maxAngle(value: number);
  45503. /**
  45504. * Creates a new BoneIKController
  45505. * @param mesh defines the mesh to control
  45506. * @param bone defines the bone to control
  45507. * @param options defines options to set up the controller
  45508. */
  45509. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  45510. targetMesh?: AbstractMesh;
  45511. poleTargetMesh?: AbstractMesh;
  45512. poleTargetBone?: Bone;
  45513. poleTargetLocalOffset?: Vector3;
  45514. poleAngle?: number;
  45515. bendAxis?: Vector3;
  45516. maxAngle?: number;
  45517. slerpAmount?: number;
  45518. });
  45519. private _setMaxAngle;
  45520. /**
  45521. * Force the controller to update the bones
  45522. */
  45523. update(): void;
  45524. }
  45525. }
  45526. declare module "babylonjs/Bones/boneLookController" {
  45527. import { Vector3 } from "babylonjs/Maths/math.vector";
  45528. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45529. import { Bone } from "babylonjs/Bones/bone";
  45530. import { Space } from "babylonjs/Maths/math.axis";
  45531. /**
  45532. * Class used to make a bone look toward a point in space
  45533. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  45534. */
  45535. export class BoneLookController {
  45536. private static _tmpVecs;
  45537. private static _tmpQuat;
  45538. private static _tmpMats;
  45539. /**
  45540. * The target Vector3 that the bone will look at
  45541. */
  45542. target: Vector3;
  45543. /**
  45544. * The mesh that the bone is attached to
  45545. */
  45546. mesh: AbstractMesh;
  45547. /**
  45548. * The bone that will be looking to the target
  45549. */
  45550. bone: Bone;
  45551. /**
  45552. * The up axis of the coordinate system that is used when the bone is rotated
  45553. */
  45554. upAxis: Vector3;
  45555. /**
  45556. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  45557. */
  45558. upAxisSpace: Space;
  45559. /**
  45560. * Used to make an adjustment to the yaw of the bone
  45561. */
  45562. adjustYaw: number;
  45563. /**
  45564. * Used to make an adjustment to the pitch of the bone
  45565. */
  45566. adjustPitch: number;
  45567. /**
  45568. * Used to make an adjustment to the roll of the bone
  45569. */
  45570. adjustRoll: number;
  45571. /**
  45572. * 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)
  45573. */
  45574. slerpAmount: number;
  45575. private _minYaw;
  45576. private _maxYaw;
  45577. private _minPitch;
  45578. private _maxPitch;
  45579. private _minYawSin;
  45580. private _minYawCos;
  45581. private _maxYawSin;
  45582. private _maxYawCos;
  45583. private _midYawConstraint;
  45584. private _minPitchTan;
  45585. private _maxPitchTan;
  45586. private _boneQuat;
  45587. private _slerping;
  45588. private _transformYawPitch;
  45589. private _transformYawPitchInv;
  45590. private _firstFrameSkipped;
  45591. private _yawRange;
  45592. private _fowardAxis;
  45593. /**
  45594. * Gets or sets the minimum yaw angle that the bone can look to
  45595. */
  45596. get minYaw(): number;
  45597. set minYaw(value: number);
  45598. /**
  45599. * Gets or sets the maximum yaw angle that the bone can look to
  45600. */
  45601. get maxYaw(): number;
  45602. set maxYaw(value: number);
  45603. /**
  45604. * Gets or sets the minimum pitch angle that the bone can look to
  45605. */
  45606. get minPitch(): number;
  45607. set minPitch(value: number);
  45608. /**
  45609. * Gets or sets the maximum pitch angle that the bone can look to
  45610. */
  45611. get maxPitch(): number;
  45612. set maxPitch(value: number);
  45613. /**
  45614. * Create a BoneLookController
  45615. * @param mesh the mesh that the bone belongs to
  45616. * @param bone the bone that will be looking to the target
  45617. * @param target the target Vector3 to look at
  45618. * @param options optional settings:
  45619. * * maxYaw: the maximum angle the bone will yaw to
  45620. * * minYaw: the minimum angle the bone will yaw to
  45621. * * maxPitch: the maximum angle the bone will pitch to
  45622. * * minPitch: the minimum angle the bone will yaw to
  45623. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  45624. * * upAxis: the up axis of the coordinate system
  45625. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  45626. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  45627. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  45628. * * adjustYaw: used to make an adjustment to the yaw of the bone
  45629. * * adjustPitch: used to make an adjustment to the pitch of the bone
  45630. * * adjustRoll: used to make an adjustment to the roll of the bone
  45631. **/
  45632. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  45633. maxYaw?: number;
  45634. minYaw?: number;
  45635. maxPitch?: number;
  45636. minPitch?: number;
  45637. slerpAmount?: number;
  45638. upAxis?: Vector3;
  45639. upAxisSpace?: Space;
  45640. yawAxis?: Vector3;
  45641. pitchAxis?: Vector3;
  45642. adjustYaw?: number;
  45643. adjustPitch?: number;
  45644. adjustRoll?: number;
  45645. });
  45646. /**
  45647. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  45648. */
  45649. update(): void;
  45650. private _getAngleDiff;
  45651. private _getAngleBetween;
  45652. private _isAngleBetween;
  45653. }
  45654. }
  45655. declare module "babylonjs/Bones/index" {
  45656. export * from "babylonjs/Bones/bone";
  45657. export * from "babylonjs/Bones/boneIKController";
  45658. export * from "babylonjs/Bones/boneLookController";
  45659. export * from "babylonjs/Bones/skeleton";
  45660. }
  45661. declare module "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput" {
  45662. import { Nullable } from "babylonjs/types";
  45663. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  45664. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  45665. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  45666. /**
  45667. * Manage the gamepad inputs to control an arc rotate camera.
  45668. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45669. */
  45670. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  45671. /**
  45672. * Defines the camera the input is attached to.
  45673. */
  45674. camera: ArcRotateCamera;
  45675. /**
  45676. * Defines the gamepad the input is gathering event from.
  45677. */
  45678. gamepad: Nullable<Gamepad>;
  45679. /**
  45680. * Defines the gamepad rotation sensiblity.
  45681. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  45682. */
  45683. gamepadRotationSensibility: number;
  45684. /**
  45685. * Defines the gamepad move sensiblity.
  45686. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  45687. */
  45688. gamepadMoveSensibility: number;
  45689. private _yAxisScale;
  45690. /**
  45691. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  45692. */
  45693. get invertYAxis(): boolean;
  45694. set invertYAxis(value: boolean);
  45695. private _onGamepadConnectedObserver;
  45696. private _onGamepadDisconnectedObserver;
  45697. /**
  45698. * Attach the input controls to a specific dom element to get the input from.
  45699. * @param element Defines the element the controls should be listened from
  45700. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  45701. */
  45702. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45703. /**
  45704. * Detach the current controls from the specified dom element.
  45705. * @param element Defines the element to stop listening the inputs from
  45706. */
  45707. detachControl(element: Nullable<HTMLElement>): void;
  45708. /**
  45709. * Update the current camera state depending on the inputs that have been used this frame.
  45710. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  45711. */
  45712. checkInputs(): void;
  45713. /**
  45714. * Gets the class name of the current intput.
  45715. * @returns the class name
  45716. */
  45717. getClassName(): string;
  45718. /**
  45719. * Get the friendly name associated with the input class.
  45720. * @returns the input friendly name
  45721. */
  45722. getSimpleName(): string;
  45723. }
  45724. }
  45725. declare module "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput" {
  45726. import { Nullable } from "babylonjs/types";
  45727. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  45728. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  45729. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  45730. interface ArcRotateCameraInputsManager {
  45731. /**
  45732. * Add orientation input support to the input manager.
  45733. * @returns the current input manager
  45734. */
  45735. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  45736. }
  45737. }
  45738. /**
  45739. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  45740. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45741. */
  45742. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  45743. /**
  45744. * Defines the camera the input is attached to.
  45745. */
  45746. camera: ArcRotateCamera;
  45747. /**
  45748. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  45749. */
  45750. alphaCorrection: number;
  45751. /**
  45752. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  45753. */
  45754. gammaCorrection: number;
  45755. private _alpha;
  45756. private _gamma;
  45757. private _dirty;
  45758. private _deviceOrientationHandler;
  45759. /**
  45760. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  45761. */
  45762. constructor();
  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. /** @hidden */
  45770. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  45771. /**
  45772. * Update the current camera state depending on the inputs that have been used this frame.
  45773. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  45774. */
  45775. checkInputs(): void;
  45776. /**
  45777. * Detach the current controls from the specified dom element.
  45778. * @param element Defines the element to stop listening the inputs from
  45779. */
  45780. detachControl(element: Nullable<HTMLElement>): void;
  45781. /**
  45782. * Gets the class name of the current intput.
  45783. * @returns the class name
  45784. */
  45785. getClassName(): string;
  45786. /**
  45787. * Get the friendly name associated with the input class.
  45788. * @returns the input friendly name
  45789. */
  45790. getSimpleName(): string;
  45791. }
  45792. }
  45793. declare module "babylonjs/Cameras/Inputs/flyCameraMouseInput" {
  45794. import { Nullable } from "babylonjs/types";
  45795. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  45796. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  45797. /**
  45798. * Listen to mouse events to control the camera.
  45799. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45800. */
  45801. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  45802. /**
  45803. * Defines the camera the input is attached to.
  45804. */
  45805. camera: FlyCamera;
  45806. /**
  45807. * Defines if touch is enabled. (Default is true.)
  45808. */
  45809. touchEnabled: boolean;
  45810. /**
  45811. * Defines the buttons associated with the input to handle camera rotation.
  45812. */
  45813. buttons: number[];
  45814. /**
  45815. * Assign buttons for Yaw control.
  45816. */
  45817. buttonsYaw: number[];
  45818. /**
  45819. * Assign buttons for Pitch control.
  45820. */
  45821. buttonsPitch: number[];
  45822. /**
  45823. * Assign buttons for Roll control.
  45824. */
  45825. buttonsRoll: number[];
  45826. /**
  45827. * Detect if any button is being pressed while mouse is moved.
  45828. * -1 = Mouse locked.
  45829. * 0 = Left button.
  45830. * 1 = Middle Button.
  45831. * 2 = Right Button.
  45832. */
  45833. activeButton: number;
  45834. /**
  45835. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  45836. * Higher values reduce its sensitivity.
  45837. */
  45838. angularSensibility: number;
  45839. private _mousemoveCallback;
  45840. private _observer;
  45841. private _rollObserver;
  45842. private previousPosition;
  45843. private noPreventDefault;
  45844. private element;
  45845. /**
  45846. * Listen to mouse events to control the camera.
  45847. * @param touchEnabled Define if touch is enabled. (Default is true.)
  45848. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45849. */
  45850. constructor(touchEnabled?: boolean);
  45851. /**
  45852. * Attach the mouse control to the HTML DOM element.
  45853. * @param element Defines the element that listens to the input events.
  45854. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  45855. */
  45856. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45857. /**
  45858. * Detach the current controls from the specified dom element.
  45859. * @param element Defines the element to stop listening the inputs from
  45860. */
  45861. detachControl(element: Nullable<HTMLElement>): void;
  45862. /**
  45863. * Gets the class name of the current input.
  45864. * @returns the class name.
  45865. */
  45866. getClassName(): string;
  45867. /**
  45868. * Get the friendly name associated with the input class.
  45869. * @returns the input's friendly name.
  45870. */
  45871. getSimpleName(): string;
  45872. private _pointerInput;
  45873. private _onMouseMove;
  45874. /**
  45875. * Rotate camera by mouse offset.
  45876. */
  45877. private rotateCamera;
  45878. }
  45879. }
  45880. declare module "babylonjs/Cameras/flyCameraInputsManager" {
  45881. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  45882. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  45883. /**
  45884. * Default Inputs manager for the FlyCamera.
  45885. * It groups all the default supported inputs for ease of use.
  45886. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45887. */
  45888. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  45889. /**
  45890. * Instantiates a new FlyCameraInputsManager.
  45891. * @param camera Defines the camera the inputs belong to.
  45892. */
  45893. constructor(camera: FlyCamera);
  45894. /**
  45895. * Add keyboard input support to the input manager.
  45896. * @returns the new FlyCameraKeyboardMoveInput().
  45897. */
  45898. addKeyboard(): FlyCameraInputsManager;
  45899. /**
  45900. * Add mouse input support to the input manager.
  45901. * @param touchEnabled Enable touch screen support.
  45902. * @returns the new FlyCameraMouseInput().
  45903. */
  45904. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  45905. }
  45906. }
  45907. declare module "babylonjs/Cameras/flyCamera" {
  45908. import { Scene } from "babylonjs/scene";
  45909. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  45910. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45911. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  45912. import { FlyCameraInputsManager } from "babylonjs/Cameras/flyCameraInputsManager";
  45913. /**
  45914. * This is a flying camera, designed for 3D movement and rotation in all directions,
  45915. * such as in a 3D Space Shooter or a Flight Simulator.
  45916. */
  45917. export class FlyCamera extends TargetCamera {
  45918. /**
  45919. * Define the collision ellipsoid of the camera.
  45920. * This is helpful for simulating a camera body, like a player's body.
  45921. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  45922. */
  45923. ellipsoid: Vector3;
  45924. /**
  45925. * Define an offset for the position of the ellipsoid around the camera.
  45926. * This can be helpful if the camera is attached away from the player's body center,
  45927. * such as at its head.
  45928. */
  45929. ellipsoidOffset: Vector3;
  45930. /**
  45931. * Enable or disable collisions of the camera with the rest of the scene objects.
  45932. */
  45933. checkCollisions: boolean;
  45934. /**
  45935. * Enable or disable gravity on the camera.
  45936. */
  45937. applyGravity: boolean;
  45938. /**
  45939. * Define the current direction the camera is moving to.
  45940. */
  45941. cameraDirection: Vector3;
  45942. /**
  45943. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  45944. * This overrides and empties cameraRotation.
  45945. */
  45946. rotationQuaternion: Quaternion;
  45947. /**
  45948. * Track Roll to maintain the wanted Rolling when looking around.
  45949. */
  45950. _trackRoll: number;
  45951. /**
  45952. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  45953. */
  45954. rollCorrect: number;
  45955. /**
  45956. * Mimic a banked turn, Rolling the camera when Yawing.
  45957. * It's recommended to use rollCorrect = 10 for faster banking correction.
  45958. */
  45959. bankedTurn: boolean;
  45960. /**
  45961. * Limit in radians for how much Roll banking will add. (Default: 90°)
  45962. */
  45963. bankedTurnLimit: number;
  45964. /**
  45965. * Value of 0 disables the banked Roll.
  45966. * Value of 1 is equal to the Yaw angle in radians.
  45967. */
  45968. bankedTurnMultiplier: number;
  45969. /**
  45970. * The inputs manager loads all the input sources, such as keyboard and mouse.
  45971. */
  45972. inputs: FlyCameraInputsManager;
  45973. /**
  45974. * Gets the input sensibility for mouse input.
  45975. * Higher values reduce sensitivity.
  45976. */
  45977. get angularSensibility(): number;
  45978. /**
  45979. * Sets the input sensibility for a mouse input.
  45980. * Higher values reduce sensitivity.
  45981. */
  45982. set angularSensibility(value: number);
  45983. /**
  45984. * Get the keys for camera movement forward.
  45985. */
  45986. get keysForward(): number[];
  45987. /**
  45988. * Set the keys for camera movement forward.
  45989. */
  45990. set keysForward(value: number[]);
  45991. /**
  45992. * Get the keys for camera movement backward.
  45993. */
  45994. get keysBackward(): number[];
  45995. set keysBackward(value: number[]);
  45996. /**
  45997. * Get the keys for camera movement up.
  45998. */
  45999. get keysUp(): number[];
  46000. /**
  46001. * Set the keys for camera movement up.
  46002. */
  46003. set keysUp(value: number[]);
  46004. /**
  46005. * Get the keys for camera movement down.
  46006. */
  46007. get keysDown(): number[];
  46008. /**
  46009. * Set the keys for camera movement down.
  46010. */
  46011. set keysDown(value: number[]);
  46012. /**
  46013. * Get the keys for camera movement left.
  46014. */
  46015. get keysLeft(): number[];
  46016. /**
  46017. * Set the keys for camera movement left.
  46018. */
  46019. set keysLeft(value: number[]);
  46020. /**
  46021. * Set the keys for camera movement right.
  46022. */
  46023. get keysRight(): number[];
  46024. /**
  46025. * Set the keys for camera movement right.
  46026. */
  46027. set keysRight(value: number[]);
  46028. /**
  46029. * Event raised when the camera collides with a mesh in the scene.
  46030. */
  46031. onCollide: (collidedMesh: AbstractMesh) => void;
  46032. private _collider;
  46033. private _needMoveForGravity;
  46034. private _oldPosition;
  46035. private _diffPosition;
  46036. private _newPosition;
  46037. /** @hidden */
  46038. _localDirection: Vector3;
  46039. /** @hidden */
  46040. _transformedDirection: Vector3;
  46041. /**
  46042. * Instantiates a FlyCamera.
  46043. * This is a flying camera, designed for 3D movement and rotation in all directions,
  46044. * such as in a 3D Space Shooter or a Flight Simulator.
  46045. * @param name Define the name of the camera in the scene.
  46046. * @param position Define the starting position of the camera in the scene.
  46047. * @param scene Define the scene the camera belongs to.
  46048. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  46049. */
  46050. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  46051. /**
  46052. * Attach a control to the HTML DOM element.
  46053. * @param element Defines the element that listens to the input events.
  46054. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  46055. */
  46056. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  46057. /**
  46058. * Detach a control from the HTML DOM element.
  46059. * The camera will stop reacting to that input.
  46060. * @param element Defines the element that listens to the input events.
  46061. */
  46062. detachControl(element: HTMLElement): void;
  46063. private _collisionMask;
  46064. /**
  46065. * Get the mask that the camera ignores in collision events.
  46066. */
  46067. get collisionMask(): number;
  46068. /**
  46069. * Set the mask that the camera ignores in collision events.
  46070. */
  46071. set collisionMask(mask: number);
  46072. /** @hidden */
  46073. _collideWithWorld(displacement: Vector3): void;
  46074. /** @hidden */
  46075. private _onCollisionPositionChange;
  46076. /** @hidden */
  46077. _checkInputs(): void;
  46078. /** @hidden */
  46079. _decideIfNeedsToMove(): boolean;
  46080. /** @hidden */
  46081. _updatePosition(): void;
  46082. /**
  46083. * Restore the Roll to its target value at the rate specified.
  46084. * @param rate - Higher means slower restoring.
  46085. * @hidden
  46086. */
  46087. restoreRoll(rate: number): void;
  46088. /**
  46089. * Destroy the camera and release the current resources held by it.
  46090. */
  46091. dispose(): void;
  46092. /**
  46093. * Get the current object class name.
  46094. * @returns the class name.
  46095. */
  46096. getClassName(): string;
  46097. }
  46098. }
  46099. declare module "babylonjs/Cameras/Inputs/flyCameraKeyboardInput" {
  46100. import { Nullable } from "babylonjs/types";
  46101. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  46102. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  46103. /**
  46104. * Listen to keyboard events to control the camera.
  46105. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  46106. */
  46107. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  46108. /**
  46109. * Defines the camera the input is attached to.
  46110. */
  46111. camera: FlyCamera;
  46112. /**
  46113. * The list of keyboard keys used to control the forward move of the camera.
  46114. */
  46115. keysForward: number[];
  46116. /**
  46117. * The list of keyboard keys used to control the backward move of the camera.
  46118. */
  46119. keysBackward: number[];
  46120. /**
  46121. * The list of keyboard keys used to control the forward move of the camera.
  46122. */
  46123. keysUp: number[];
  46124. /**
  46125. * The list of keyboard keys used to control the backward move of the camera.
  46126. */
  46127. keysDown: number[];
  46128. /**
  46129. * The list of keyboard keys used to control the right strafe move of the camera.
  46130. */
  46131. keysRight: number[];
  46132. /**
  46133. * The list of keyboard keys used to control the left strafe move of the camera.
  46134. */
  46135. keysLeft: number[];
  46136. private _keys;
  46137. private _onCanvasBlurObserver;
  46138. private _onKeyboardObserver;
  46139. private _engine;
  46140. private _scene;
  46141. /**
  46142. * Attach the input controls to a specific dom element to get the input from.
  46143. * @param element Defines the element the controls should be listened from
  46144. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46145. */
  46146. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  46147. /**
  46148. * Detach the current controls from the specified dom element.
  46149. * @param element Defines the element to stop listening the inputs from
  46150. */
  46151. detachControl(element: Nullable<HTMLElement>): void;
  46152. /**
  46153. * Gets the class name of the current intput.
  46154. * @returns the class name
  46155. */
  46156. getClassName(): string;
  46157. /** @hidden */
  46158. _onLostFocus(e: FocusEvent): void;
  46159. /**
  46160. * Get the friendly name associated with the input class.
  46161. * @returns the input friendly name
  46162. */
  46163. getSimpleName(): string;
  46164. /**
  46165. * Update the current camera state depending on the inputs that have been used this frame.
  46166. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  46167. */
  46168. checkInputs(): void;
  46169. }
  46170. }
  46171. declare module "babylonjs/Cameras/Inputs/followCameraMouseWheelInput" {
  46172. import { Nullable } from "babylonjs/types";
  46173. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  46174. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  46175. /**
  46176. * Manage the mouse wheel inputs to control a follow camera.
  46177. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  46178. */
  46179. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  46180. /**
  46181. * Defines the camera the input is attached to.
  46182. */
  46183. camera: FollowCamera;
  46184. /**
  46185. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  46186. */
  46187. axisControlRadius: boolean;
  46188. /**
  46189. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  46190. */
  46191. axisControlHeight: boolean;
  46192. /**
  46193. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  46194. */
  46195. axisControlRotation: boolean;
  46196. /**
  46197. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  46198. * relation to mouseWheel events.
  46199. */
  46200. wheelPrecision: number;
  46201. /**
  46202. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  46203. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  46204. */
  46205. wheelDeltaPercentage: number;
  46206. private _wheel;
  46207. private _observer;
  46208. /**
  46209. * Attach the input controls to a specific dom element to get the input from.
  46210. * @param element Defines the element the controls should be listened from
  46211. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46212. */
  46213. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  46214. /**
  46215. * Detach the current controls from the specified dom element.
  46216. * @param element Defines the element to stop listening the inputs from
  46217. */
  46218. detachControl(element: Nullable<HTMLElement>): void;
  46219. /**
  46220. * Gets the class name of the current intput.
  46221. * @returns the class name
  46222. */
  46223. getClassName(): string;
  46224. /**
  46225. * Get the friendly name associated with the input class.
  46226. * @returns the input friendly name
  46227. */
  46228. getSimpleName(): string;
  46229. }
  46230. }
  46231. declare module "babylonjs/Cameras/Inputs/followCameraPointersInput" {
  46232. import { Nullable } from "babylonjs/types";
  46233. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  46234. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  46235. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  46236. /**
  46237. * Manage the pointers inputs to control an follow camera.
  46238. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  46239. */
  46240. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  46241. /**
  46242. * Defines the camera the input is attached to.
  46243. */
  46244. camera: FollowCamera;
  46245. /**
  46246. * Gets the class name of the current input.
  46247. * @returns the class name
  46248. */
  46249. getClassName(): string;
  46250. /**
  46251. * Defines the pointer angular sensibility along the X axis or how fast is
  46252. * the camera rotating.
  46253. * A negative number will reverse the axis direction.
  46254. */
  46255. angularSensibilityX: number;
  46256. /**
  46257. * Defines the pointer angular sensibility along the Y axis or how fast is
  46258. * the camera rotating.
  46259. * A negative number will reverse the axis direction.
  46260. */
  46261. angularSensibilityY: number;
  46262. /**
  46263. * Defines the pointer pinch precision or how fast is the camera zooming.
  46264. * A negative number will reverse the axis direction.
  46265. */
  46266. pinchPrecision: number;
  46267. /**
  46268. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  46269. * from 0.
  46270. * It defines the percentage of current camera.radius to use as delta when
  46271. * pinch zoom is used.
  46272. */
  46273. pinchDeltaPercentage: number;
  46274. /**
  46275. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  46276. */
  46277. axisXControlRadius: boolean;
  46278. /**
  46279. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  46280. */
  46281. axisXControlHeight: boolean;
  46282. /**
  46283. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  46284. */
  46285. axisXControlRotation: boolean;
  46286. /**
  46287. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  46288. */
  46289. axisYControlRadius: boolean;
  46290. /**
  46291. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  46292. */
  46293. axisYControlHeight: boolean;
  46294. /**
  46295. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  46296. */
  46297. axisYControlRotation: boolean;
  46298. /**
  46299. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  46300. */
  46301. axisPinchControlRadius: boolean;
  46302. /**
  46303. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  46304. */
  46305. axisPinchControlHeight: boolean;
  46306. /**
  46307. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  46308. */
  46309. axisPinchControlRotation: boolean;
  46310. /**
  46311. * Log error messages if basic misconfiguration has occurred.
  46312. */
  46313. warningEnable: boolean;
  46314. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  46315. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  46316. private _warningCounter;
  46317. private _warning;
  46318. }
  46319. }
  46320. declare module "babylonjs/Cameras/followCameraInputsManager" {
  46321. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  46322. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  46323. /**
  46324. * Default Inputs manager for the FollowCamera.
  46325. * It groups all the default supported inputs for ease of use.
  46326. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  46327. */
  46328. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  46329. /**
  46330. * Instantiates a new FollowCameraInputsManager.
  46331. * @param camera Defines the camera the inputs belong to
  46332. */
  46333. constructor(camera: FollowCamera);
  46334. /**
  46335. * Add keyboard input support to the input manager.
  46336. * @returns the current input manager
  46337. */
  46338. addKeyboard(): FollowCameraInputsManager;
  46339. /**
  46340. * Add mouse wheel input support to the input manager.
  46341. * @returns the current input manager
  46342. */
  46343. addMouseWheel(): FollowCameraInputsManager;
  46344. /**
  46345. * Add pointers input support to the input manager.
  46346. * @returns the current input manager
  46347. */
  46348. addPointers(): FollowCameraInputsManager;
  46349. /**
  46350. * Add orientation input support to the input manager.
  46351. * @returns the current input manager
  46352. */
  46353. addVRDeviceOrientation(): FollowCameraInputsManager;
  46354. }
  46355. }
  46356. declare module "babylonjs/Cameras/followCamera" {
  46357. import { Nullable } from "babylonjs/types";
  46358. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  46359. import { Scene } from "babylonjs/scene";
  46360. import { Vector3 } from "babylonjs/Maths/math.vector";
  46361. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46362. import { FollowCameraInputsManager } from "babylonjs/Cameras/followCameraInputsManager";
  46363. /**
  46364. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  46365. * an arc rotate version arcFollowCamera are available.
  46366. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  46367. */
  46368. export class FollowCamera extends TargetCamera {
  46369. /**
  46370. * Distance the follow camera should follow an object at
  46371. */
  46372. radius: number;
  46373. /**
  46374. * Minimum allowed distance of the camera to the axis of rotation
  46375. * (The camera can not get closer).
  46376. * This can help limiting how the Camera is able to move in the scene.
  46377. */
  46378. lowerRadiusLimit: Nullable<number>;
  46379. /**
  46380. * Maximum allowed distance of the camera to the axis of rotation
  46381. * (The camera can not get further).
  46382. * This can help limiting how the Camera is able to move in the scene.
  46383. */
  46384. upperRadiusLimit: Nullable<number>;
  46385. /**
  46386. * Define a rotation offset between the camera and the object it follows
  46387. */
  46388. rotationOffset: number;
  46389. /**
  46390. * Minimum allowed angle to camera position relative to target object.
  46391. * This can help limiting how the Camera is able to move in the scene.
  46392. */
  46393. lowerRotationOffsetLimit: Nullable<number>;
  46394. /**
  46395. * Maximum allowed angle to camera position relative to target object.
  46396. * This can help limiting how the Camera is able to move in the scene.
  46397. */
  46398. upperRotationOffsetLimit: Nullable<number>;
  46399. /**
  46400. * Define a height offset between the camera and the object it follows.
  46401. * It can help following an object from the top (like a car chaing a plane)
  46402. */
  46403. heightOffset: number;
  46404. /**
  46405. * Minimum allowed height of camera position relative to target object.
  46406. * This can help limiting how the Camera is able to move in the scene.
  46407. */
  46408. lowerHeightOffsetLimit: Nullable<number>;
  46409. /**
  46410. * Maximum allowed height of camera position relative to target object.
  46411. * This can help limiting how the Camera is able to move in the scene.
  46412. */
  46413. upperHeightOffsetLimit: Nullable<number>;
  46414. /**
  46415. * Define how fast the camera can accelerate to follow it s target.
  46416. */
  46417. cameraAcceleration: number;
  46418. /**
  46419. * Define the speed limit of the camera following an object.
  46420. */
  46421. maxCameraSpeed: number;
  46422. /**
  46423. * Define the target of the camera.
  46424. */
  46425. lockedTarget: Nullable<AbstractMesh>;
  46426. /**
  46427. * Defines the input associated with the camera.
  46428. */
  46429. inputs: FollowCameraInputsManager;
  46430. /**
  46431. * Instantiates the follow camera.
  46432. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  46433. * @param name Define the name of the camera in the scene
  46434. * @param position Define the position of the camera
  46435. * @param scene Define the scene the camera belong to
  46436. * @param lockedTarget Define the target of the camera
  46437. */
  46438. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  46439. private _follow;
  46440. /**
  46441. * Attached controls to the current camera.
  46442. * @param element Defines the element the controls should be listened from
  46443. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46444. */
  46445. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  46446. /**
  46447. * Detach the current controls from the camera.
  46448. * The camera will stop reacting to inputs.
  46449. * @param element Defines the element to stop listening the inputs from
  46450. */
  46451. detachControl(element: HTMLElement): void;
  46452. /** @hidden */
  46453. _checkInputs(): void;
  46454. private _checkLimits;
  46455. /**
  46456. * Gets the camera class name.
  46457. * @returns the class name
  46458. */
  46459. getClassName(): string;
  46460. }
  46461. /**
  46462. * Arc Rotate version of the follow camera.
  46463. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  46464. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  46465. */
  46466. export class ArcFollowCamera extends TargetCamera {
  46467. /** The longitudinal angle of the camera */
  46468. alpha: number;
  46469. /** The latitudinal angle of the camera */
  46470. beta: number;
  46471. /** The radius of the camera from its target */
  46472. radius: number;
  46473. private _cartesianCoordinates;
  46474. /** Define the camera target (the mesh it should follow) */
  46475. private _meshTarget;
  46476. /**
  46477. * Instantiates a new ArcFollowCamera
  46478. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  46479. * @param name Define the name of the camera
  46480. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  46481. * @param beta Define the rotation angle of the camera around the elevation axis
  46482. * @param radius Define the radius of the camera from its target point
  46483. * @param target Define the target of the camera
  46484. * @param scene Define the scene the camera belongs to
  46485. */
  46486. constructor(name: string,
  46487. /** The longitudinal angle of the camera */
  46488. alpha: number,
  46489. /** The latitudinal angle of the camera */
  46490. beta: number,
  46491. /** The radius of the camera from its target */
  46492. radius: number,
  46493. /** Define the camera target (the mesh it should follow) */
  46494. target: Nullable<AbstractMesh>, scene: Scene);
  46495. private _follow;
  46496. /** @hidden */
  46497. _checkInputs(): void;
  46498. /**
  46499. * Returns the class name of the object.
  46500. * It is mostly used internally for serialization purposes.
  46501. */
  46502. getClassName(): string;
  46503. }
  46504. }
  46505. declare module "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput" {
  46506. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  46507. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  46508. import { Nullable } from "babylonjs/types";
  46509. /**
  46510. * Manage the keyboard inputs to control the movement of a follow camera.
  46511. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  46512. */
  46513. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  46514. /**
  46515. * Defines the camera the input is attached to.
  46516. */
  46517. camera: FollowCamera;
  46518. /**
  46519. * Defines the list of key codes associated with the up action (increase heightOffset)
  46520. */
  46521. keysHeightOffsetIncr: number[];
  46522. /**
  46523. * Defines the list of key codes associated with the down action (decrease heightOffset)
  46524. */
  46525. keysHeightOffsetDecr: number[];
  46526. /**
  46527. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  46528. */
  46529. keysHeightOffsetModifierAlt: boolean;
  46530. /**
  46531. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  46532. */
  46533. keysHeightOffsetModifierCtrl: boolean;
  46534. /**
  46535. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  46536. */
  46537. keysHeightOffsetModifierShift: boolean;
  46538. /**
  46539. * Defines the list of key codes associated with the left action (increase rotationOffset)
  46540. */
  46541. keysRotationOffsetIncr: number[];
  46542. /**
  46543. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  46544. */
  46545. keysRotationOffsetDecr: number[];
  46546. /**
  46547. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  46548. */
  46549. keysRotationOffsetModifierAlt: boolean;
  46550. /**
  46551. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  46552. */
  46553. keysRotationOffsetModifierCtrl: boolean;
  46554. /**
  46555. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  46556. */
  46557. keysRotationOffsetModifierShift: boolean;
  46558. /**
  46559. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  46560. */
  46561. keysRadiusIncr: number[];
  46562. /**
  46563. * Defines the list of key codes associated with the zoom-out action (increase radius)
  46564. */
  46565. keysRadiusDecr: number[];
  46566. /**
  46567. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  46568. */
  46569. keysRadiusModifierAlt: boolean;
  46570. /**
  46571. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  46572. */
  46573. keysRadiusModifierCtrl: boolean;
  46574. /**
  46575. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  46576. */
  46577. keysRadiusModifierShift: boolean;
  46578. /**
  46579. * Defines the rate of change of heightOffset.
  46580. */
  46581. heightSensibility: number;
  46582. /**
  46583. * Defines the rate of change of rotationOffset.
  46584. */
  46585. rotationSensibility: number;
  46586. /**
  46587. * Defines the rate of change of radius.
  46588. */
  46589. radiusSensibility: number;
  46590. private _keys;
  46591. private _ctrlPressed;
  46592. private _altPressed;
  46593. private _shiftPressed;
  46594. private _onCanvasBlurObserver;
  46595. private _onKeyboardObserver;
  46596. private _engine;
  46597. private _scene;
  46598. /**
  46599. * Attach the input controls to a specific dom element to get the input from.
  46600. * @param element Defines the element the controls should be listened from
  46601. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46602. */
  46603. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  46604. /**
  46605. * Detach the current controls from the specified dom element.
  46606. * @param element Defines the element to stop listening the inputs from
  46607. */
  46608. detachControl(element: Nullable<HTMLElement>): void;
  46609. /**
  46610. * Update the current camera state depending on the inputs that have been used this frame.
  46611. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  46612. */
  46613. checkInputs(): void;
  46614. /**
  46615. * Gets the class name of the current input.
  46616. * @returns the class name
  46617. */
  46618. getClassName(): string;
  46619. /**
  46620. * Get the friendly name associated with the input class.
  46621. * @returns the input friendly name
  46622. */
  46623. getSimpleName(): string;
  46624. /**
  46625. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  46626. * allow modification of the heightOffset value.
  46627. */
  46628. private _modifierHeightOffset;
  46629. /**
  46630. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  46631. * allow modification of the rotationOffset value.
  46632. */
  46633. private _modifierRotationOffset;
  46634. /**
  46635. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  46636. * allow modification of the radius value.
  46637. */
  46638. private _modifierRadius;
  46639. }
  46640. }
  46641. declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
  46642. import { Nullable } from "babylonjs/types";
  46643. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  46644. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  46645. import { Observable } from "babylonjs/Misc/observable";
  46646. module "babylonjs/Cameras/freeCameraInputsManager" {
  46647. interface FreeCameraInputsManager {
  46648. /**
  46649. * @hidden
  46650. */
  46651. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  46652. /**
  46653. * Add orientation input support to the input manager.
  46654. * @returns the current input manager
  46655. */
  46656. addDeviceOrientation(): FreeCameraInputsManager;
  46657. }
  46658. }
  46659. /**
  46660. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  46661. * Screen rotation is taken into account.
  46662. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  46663. */
  46664. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  46665. private _camera;
  46666. private _screenOrientationAngle;
  46667. private _constantTranform;
  46668. private _screenQuaternion;
  46669. private _alpha;
  46670. private _beta;
  46671. private _gamma;
  46672. /**
  46673. * Can be used to detect if a device orientation sensor is available on a device
  46674. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  46675. * @returns a promise that will resolve on orientation change
  46676. */
  46677. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  46678. /**
  46679. * @hidden
  46680. */
  46681. _onDeviceOrientationChangedObservable: Observable<void>;
  46682. /**
  46683. * Instantiates a new input
  46684. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  46685. */
  46686. constructor();
  46687. /**
  46688. * Define the camera controlled by the input.
  46689. */
  46690. get camera(): FreeCamera;
  46691. set camera(camera: FreeCamera);
  46692. /**
  46693. * Attach the input controls to a specific dom element to get the input from.
  46694. * @param element Defines the element the controls should be listened from
  46695. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46696. */
  46697. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  46698. private _orientationChanged;
  46699. private _deviceOrientation;
  46700. /**
  46701. * Detach the current controls from the specified dom element.
  46702. * @param element Defines the element to stop listening the inputs from
  46703. */
  46704. detachControl(element: Nullable<HTMLElement>): void;
  46705. /**
  46706. * Update the current camera state depending on the inputs that have been used this frame.
  46707. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  46708. */
  46709. checkInputs(): void;
  46710. /**
  46711. * Gets the class name of the current intput.
  46712. * @returns the class name
  46713. */
  46714. getClassName(): string;
  46715. /**
  46716. * Get the friendly name associated with the input class.
  46717. * @returns the input friendly name
  46718. */
  46719. getSimpleName(): string;
  46720. }
  46721. }
  46722. declare module "babylonjs/Cameras/Inputs/freeCameraGamepadInput" {
  46723. import { Nullable } from "babylonjs/types";
  46724. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  46725. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  46726. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  46727. /**
  46728. * Manage the gamepad inputs to control a free camera.
  46729. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  46730. */
  46731. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  46732. /**
  46733. * Define the camera the input is attached to.
  46734. */
  46735. camera: FreeCamera;
  46736. /**
  46737. * Define the Gamepad controlling the input
  46738. */
  46739. gamepad: Nullable<Gamepad>;
  46740. /**
  46741. * Defines the gamepad rotation sensiblity.
  46742. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  46743. */
  46744. gamepadAngularSensibility: number;
  46745. /**
  46746. * Defines the gamepad move sensiblity.
  46747. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  46748. */
  46749. gamepadMoveSensibility: number;
  46750. private _yAxisScale;
  46751. /**
  46752. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  46753. */
  46754. get invertYAxis(): boolean;
  46755. set invertYAxis(value: boolean);
  46756. private _onGamepadConnectedObserver;
  46757. private _onGamepadDisconnectedObserver;
  46758. private _cameraTransform;
  46759. private _deltaTransform;
  46760. private _vector3;
  46761. private _vector2;
  46762. /**
  46763. * Attach the input controls to a specific dom element to get the input from.
  46764. * @param element Defines the element the controls should be listened from
  46765. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46766. */
  46767. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  46768. /**
  46769. * Detach the current controls from the specified dom element.
  46770. * @param element Defines the element to stop listening the inputs from
  46771. */
  46772. detachControl(element: Nullable<HTMLElement>): void;
  46773. /**
  46774. * Update the current camera state depending on the inputs that have been used this frame.
  46775. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  46776. */
  46777. checkInputs(): void;
  46778. /**
  46779. * Gets the class name of the current intput.
  46780. * @returns the class name
  46781. */
  46782. getClassName(): string;
  46783. /**
  46784. * Get the friendly name associated with the input class.
  46785. * @returns the input friendly name
  46786. */
  46787. getSimpleName(): string;
  46788. }
  46789. }
  46790. declare module "babylonjs/Misc/virtualJoystick" {
  46791. import { Nullable } from "babylonjs/types";
  46792. import { Vector3 } from "babylonjs/Maths/math.vector";
  46793. /**
  46794. * Defines the potential axis of a Joystick
  46795. */
  46796. export enum JoystickAxis {
  46797. /** X axis */
  46798. X = 0,
  46799. /** Y axis */
  46800. Y = 1,
  46801. /** Z axis */
  46802. Z = 2
  46803. }
  46804. /**
  46805. * Represents the different customization options available
  46806. * for VirtualJoystick
  46807. */
  46808. interface VirtualJoystickCustomizations {
  46809. /**
  46810. * Size of the joystick's puck
  46811. */
  46812. puckSize: number;
  46813. /**
  46814. * Size of the joystick's container
  46815. */
  46816. containerSize: number;
  46817. /**
  46818. * Color of the joystick && puck
  46819. */
  46820. color: string;
  46821. /**
  46822. * Image URL for the joystick's puck
  46823. */
  46824. puckImage?: string;
  46825. /**
  46826. * Image URL for the joystick's container
  46827. */
  46828. containerImage?: string;
  46829. /**
  46830. * Defines the unmoving position of the joystick container
  46831. */
  46832. position?: {
  46833. x: number;
  46834. y: number;
  46835. };
  46836. /**
  46837. * Defines whether or not the joystick container is always visible
  46838. */
  46839. alwaysVisible: boolean;
  46840. /**
  46841. * Defines whether or not to limit the movement of the puck to the joystick's container
  46842. */
  46843. limitToContainer: boolean;
  46844. }
  46845. /**
  46846. * Class used to define virtual joystick (used in touch mode)
  46847. */
  46848. export class VirtualJoystick {
  46849. /**
  46850. * Gets or sets a boolean indicating that left and right values must be inverted
  46851. */
  46852. reverseLeftRight: boolean;
  46853. /**
  46854. * Gets or sets a boolean indicating that up and down values must be inverted
  46855. */
  46856. reverseUpDown: boolean;
  46857. /**
  46858. * Gets the offset value for the position (ie. the change of the position value)
  46859. */
  46860. deltaPosition: Vector3;
  46861. /**
  46862. * Gets a boolean indicating if the virtual joystick was pressed
  46863. */
  46864. pressed: boolean;
  46865. /**
  46866. * Canvas the virtual joystick will render onto, default z-index of this is 5
  46867. */
  46868. static Canvas: Nullable<HTMLCanvasElement>;
  46869. /**
  46870. * boolean indicating whether or not the joystick's puck's movement should be limited to the joystick's container area
  46871. */
  46872. limitToContainer: boolean;
  46873. private static _globalJoystickIndex;
  46874. private static _alwaysVisibleSticks;
  46875. private static vjCanvasContext;
  46876. private static vjCanvasWidth;
  46877. private static vjCanvasHeight;
  46878. private static halfWidth;
  46879. private static _GetDefaultOptions;
  46880. private _action;
  46881. private _axisTargetedByLeftAndRight;
  46882. private _axisTargetedByUpAndDown;
  46883. private _joystickSensibility;
  46884. private _inversedSensibility;
  46885. private _joystickPointerID;
  46886. private _joystickColor;
  46887. private _joystickPointerPos;
  46888. private _joystickPreviousPointerPos;
  46889. private _joystickPointerStartPos;
  46890. private _deltaJoystickVector;
  46891. private _leftJoystick;
  46892. private _touches;
  46893. private _joystickPosition;
  46894. private _alwaysVisible;
  46895. private _puckImage;
  46896. private _containerImage;
  46897. private _joystickPuckSize;
  46898. private _joystickContainerSize;
  46899. private _clearPuckSize;
  46900. private _clearContainerSize;
  46901. private _clearPuckSizeOffset;
  46902. private _clearContainerSizeOffset;
  46903. private _onPointerDownHandlerRef;
  46904. private _onPointerMoveHandlerRef;
  46905. private _onPointerUpHandlerRef;
  46906. private _onResize;
  46907. /**
  46908. * Creates a new virtual joystick
  46909. * @param leftJoystick defines that the joystick is for left hand (false by default)
  46910. * @param customizations Defines the options we want to customize the VirtualJoystick
  46911. */
  46912. constructor(leftJoystick?: boolean, customizations?: Partial<VirtualJoystickCustomizations>);
  46913. /**
  46914. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  46915. * @param newJoystickSensibility defines the new sensibility
  46916. */
  46917. setJoystickSensibility(newJoystickSensibility: number): void;
  46918. private _onPointerDown;
  46919. private _onPointerMove;
  46920. private _onPointerUp;
  46921. /**
  46922. * Change the color of the virtual joystick
  46923. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  46924. */
  46925. setJoystickColor(newColor: string): void;
  46926. /**
  46927. * Size of the joystick's container
  46928. */
  46929. set containerSize(newSize: number);
  46930. get containerSize(): number;
  46931. /**
  46932. * Size of the joystick's puck
  46933. */
  46934. set puckSize(newSize: number);
  46935. get puckSize(): number;
  46936. /**
  46937. * Clears the set position of the joystick
  46938. */
  46939. clearPosition(): void;
  46940. /**
  46941. * Defines whether or not the joystick container is always visible
  46942. */
  46943. set alwaysVisible(value: boolean);
  46944. get alwaysVisible(): boolean;
  46945. /**
  46946. * Sets the constant position of the Joystick container
  46947. * @param x X axis coordinate
  46948. * @param y Y axis coordinate
  46949. */
  46950. setPosition(x: number, y: number): void;
  46951. /**
  46952. * Defines a callback to call when the joystick is touched
  46953. * @param action defines the callback
  46954. */
  46955. setActionOnTouch(action: () => any): void;
  46956. /**
  46957. * Defines which axis you'd like to control for left & right
  46958. * @param axis defines the axis to use
  46959. */
  46960. setAxisForLeftRight(axis: JoystickAxis): void;
  46961. /**
  46962. * Defines which axis you'd like to control for up & down
  46963. * @param axis defines the axis to use
  46964. */
  46965. setAxisForUpDown(axis: JoystickAxis): void;
  46966. /**
  46967. * Clears the canvas from the previous puck / container draw
  46968. */
  46969. private _clearPreviousDraw;
  46970. /**
  46971. * Loads `urlPath` to be used for the container's image
  46972. * @param urlPath defines the urlPath of an image to use
  46973. */
  46974. setContainerImage(urlPath: string): void;
  46975. /**
  46976. * Loads `urlPath` to be used for the puck's image
  46977. * @param urlPath defines the urlPath of an image to use
  46978. */
  46979. setPuckImage(urlPath: string): void;
  46980. /**
  46981. * Draws the Virtual Joystick's container
  46982. */
  46983. private _drawContainer;
  46984. /**
  46985. * Draws the Virtual Joystick's puck
  46986. */
  46987. private _drawPuck;
  46988. private _drawVirtualJoystick;
  46989. /**
  46990. * Release internal HTML canvas
  46991. */
  46992. releaseCanvas(): void;
  46993. }
  46994. }
  46995. declare module "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput" {
  46996. import { VirtualJoystick } from "babylonjs/Misc/virtualJoystick";
  46997. import { Nullable } from "babylonjs/types";
  46998. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  46999. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  47000. module "babylonjs/Cameras/freeCameraInputsManager" {
  47001. interface FreeCameraInputsManager {
  47002. /**
  47003. * Add virtual joystick input support to the input manager.
  47004. * @returns the current input manager
  47005. */
  47006. addVirtualJoystick(): FreeCameraInputsManager;
  47007. }
  47008. }
  47009. /**
  47010. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  47011. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  47012. */
  47013. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  47014. /**
  47015. * Defines the camera the input is attached to.
  47016. */
  47017. camera: FreeCamera;
  47018. private _leftjoystick;
  47019. private _rightjoystick;
  47020. /**
  47021. * Gets the left stick of the virtual joystick.
  47022. * @returns The virtual Joystick
  47023. */
  47024. getLeftJoystick(): VirtualJoystick;
  47025. /**
  47026. * Gets the right stick of the virtual joystick.
  47027. * @returns The virtual Joystick
  47028. */
  47029. getRightJoystick(): VirtualJoystick;
  47030. /**
  47031. * Update the current camera state depending on the inputs that have been used this frame.
  47032. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  47033. */
  47034. checkInputs(): void;
  47035. /**
  47036. * Attach the input controls to a specific dom element to get the input from.
  47037. * @param element Defines the element the controls should be listened from
  47038. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  47039. */
  47040. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  47041. /**
  47042. * Detach the current controls from the specified dom element.
  47043. * @param element Defines the element to stop listening the inputs from
  47044. */
  47045. detachControl(element: Nullable<HTMLElement>): void;
  47046. /**
  47047. * Gets the class name of the current intput.
  47048. * @returns the class name
  47049. */
  47050. getClassName(): string;
  47051. /**
  47052. * Get the friendly name associated with the input class.
  47053. * @returns the input friendly name
  47054. */
  47055. getSimpleName(): string;
  47056. }
  47057. }
  47058. declare module "babylonjs/Cameras/Inputs/index" {
  47059. export * from "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput";
  47060. export * from "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
  47061. export * from "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput";
  47062. export * from "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput";
  47063. export * from "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  47064. export * from "babylonjs/Cameras/Inputs/flyCameraKeyboardInput";
  47065. export * from "babylonjs/Cameras/Inputs/flyCameraMouseInput";
  47066. export * from "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput";
  47067. export * from "babylonjs/Cameras/Inputs/followCameraMouseWheelInput";
  47068. export * from "babylonjs/Cameras/Inputs/followCameraPointersInput";
  47069. export * from "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  47070. export * from "babylonjs/Cameras/Inputs/freeCameraGamepadInput";
  47071. export * from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  47072. export * from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  47073. export * from "babylonjs/Cameras/Inputs/freeCameraTouchInput";
  47074. export * from "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  47075. }
  47076. declare module "babylonjs/Cameras/touchCamera" {
  47077. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  47078. import { Scene } from "babylonjs/scene";
  47079. import { Vector3 } from "babylonjs/Maths/math.vector";
  47080. /**
  47081. * This represents a FPS type of camera controlled by touch.
  47082. * This is like a universal camera minus the Gamepad controls.
  47083. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  47084. */
  47085. export class TouchCamera extends FreeCamera {
  47086. /**
  47087. * Defines the touch sensibility for rotation.
  47088. * The higher the faster.
  47089. */
  47090. get touchAngularSensibility(): number;
  47091. set touchAngularSensibility(value: number);
  47092. /**
  47093. * Defines the touch sensibility for move.
  47094. * The higher the faster.
  47095. */
  47096. get touchMoveSensibility(): number;
  47097. set touchMoveSensibility(value: number);
  47098. /**
  47099. * Instantiates a new touch camera.
  47100. * This represents a FPS type of camera controlled by touch.
  47101. * This is like a universal camera minus the Gamepad controls.
  47102. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  47103. * @param name Define the name of the camera in the scene
  47104. * @param position Define the start position of the camera in the scene
  47105. * @param scene Define the scene the camera belongs to
  47106. */
  47107. constructor(name: string, position: Vector3, scene: Scene);
  47108. /**
  47109. * Gets the current object class name.
  47110. * @return the class name
  47111. */
  47112. getClassName(): string;
  47113. /** @hidden */
  47114. _setupInputs(): void;
  47115. }
  47116. }
  47117. declare module "babylonjs/Cameras/deviceOrientationCamera" {
  47118. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  47119. import { Scene } from "babylonjs/scene";
  47120. import { Vector3 } from "babylonjs/Maths/math.vector";
  47121. import "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  47122. import { Axis } from "babylonjs/Maths/math.axis";
  47123. /**
  47124. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  47125. * being tilted forward or back and left or right.
  47126. */
  47127. export class DeviceOrientationCamera extends FreeCamera {
  47128. private _initialQuaternion;
  47129. private _quaternionCache;
  47130. private _tmpDragQuaternion;
  47131. private _disablePointerInputWhenUsingDeviceOrientation;
  47132. /**
  47133. * Creates a new device orientation camera
  47134. * @param name The name of the camera
  47135. * @param position The start position camera
  47136. * @param scene The scene the camera belongs to
  47137. */
  47138. constructor(name: string, position: Vector3, scene: Scene);
  47139. /**
  47140. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  47141. */
  47142. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  47143. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  47144. private _dragFactor;
  47145. /**
  47146. * Enabled turning on the y axis when the orientation sensor is active
  47147. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  47148. */
  47149. enableHorizontalDragging(dragFactor?: number): void;
  47150. /**
  47151. * Gets the current instance class name ("DeviceOrientationCamera").
  47152. * This helps avoiding instanceof at run time.
  47153. * @returns the class name
  47154. */
  47155. getClassName(): string;
  47156. /**
  47157. * @hidden
  47158. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  47159. */
  47160. _checkInputs(): void;
  47161. /**
  47162. * Reset the camera to its default orientation on the specified axis only.
  47163. * @param axis The axis to reset
  47164. */
  47165. resetToCurrentRotation(axis?: Axis): void;
  47166. }
  47167. }
  47168. declare module "babylonjs/Gamepads/xboxGamepad" {
  47169. import { Observable } from "babylonjs/Misc/observable";
  47170. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  47171. /**
  47172. * Defines supported buttons for XBox360 compatible gamepads
  47173. */
  47174. export enum Xbox360Button {
  47175. /** A */
  47176. A = 0,
  47177. /** B */
  47178. B = 1,
  47179. /** X */
  47180. X = 2,
  47181. /** Y */
  47182. Y = 3,
  47183. /** Left button */
  47184. LB = 4,
  47185. /** Right button */
  47186. RB = 5,
  47187. /** Back */
  47188. Back = 8,
  47189. /** Start */
  47190. Start = 9,
  47191. /** Left stick */
  47192. LeftStick = 10,
  47193. /** Right stick */
  47194. RightStick = 11
  47195. }
  47196. /** Defines values for XBox360 DPad */
  47197. export enum Xbox360Dpad {
  47198. /** Up */
  47199. Up = 12,
  47200. /** Down */
  47201. Down = 13,
  47202. /** Left */
  47203. Left = 14,
  47204. /** Right */
  47205. Right = 15
  47206. }
  47207. /**
  47208. * Defines a XBox360 gamepad
  47209. */
  47210. export class Xbox360Pad extends Gamepad {
  47211. private _leftTrigger;
  47212. private _rightTrigger;
  47213. private _onlefttriggerchanged;
  47214. private _onrighttriggerchanged;
  47215. private _onbuttondown;
  47216. private _onbuttonup;
  47217. private _ondpaddown;
  47218. private _ondpadup;
  47219. /** Observable raised when a button is pressed */
  47220. onButtonDownObservable: Observable<Xbox360Button>;
  47221. /** Observable raised when a button is released */
  47222. onButtonUpObservable: Observable<Xbox360Button>;
  47223. /** Observable raised when a pad is pressed */
  47224. onPadDownObservable: Observable<Xbox360Dpad>;
  47225. /** Observable raised when a pad is released */
  47226. onPadUpObservable: Observable<Xbox360Dpad>;
  47227. private _buttonA;
  47228. private _buttonB;
  47229. private _buttonX;
  47230. private _buttonY;
  47231. private _buttonBack;
  47232. private _buttonStart;
  47233. private _buttonLB;
  47234. private _buttonRB;
  47235. private _buttonLeftStick;
  47236. private _buttonRightStick;
  47237. private _dPadUp;
  47238. private _dPadDown;
  47239. private _dPadLeft;
  47240. private _dPadRight;
  47241. private _isXboxOnePad;
  47242. /**
  47243. * Creates a new XBox360 gamepad object
  47244. * @param id defines the id of this gamepad
  47245. * @param index defines its index
  47246. * @param gamepad defines the internal HTML gamepad object
  47247. * @param xboxOne defines if it is a XBox One gamepad
  47248. */
  47249. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  47250. /**
  47251. * Defines the callback to call when left trigger is pressed
  47252. * @param callback defines the callback to use
  47253. */
  47254. onlefttriggerchanged(callback: (value: number) => void): void;
  47255. /**
  47256. * Defines the callback to call when right trigger is pressed
  47257. * @param callback defines the callback to use
  47258. */
  47259. onrighttriggerchanged(callback: (value: number) => void): void;
  47260. /**
  47261. * Gets the left trigger value
  47262. */
  47263. get leftTrigger(): number;
  47264. /**
  47265. * Sets the left trigger value
  47266. */
  47267. set leftTrigger(newValue: number);
  47268. /**
  47269. * Gets the right trigger value
  47270. */
  47271. get rightTrigger(): number;
  47272. /**
  47273. * Sets the right trigger value
  47274. */
  47275. set rightTrigger(newValue: number);
  47276. /**
  47277. * Defines the callback to call when a button is pressed
  47278. * @param callback defines the callback to use
  47279. */
  47280. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  47281. /**
  47282. * Defines the callback to call when a button is released
  47283. * @param callback defines the callback to use
  47284. */
  47285. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  47286. /**
  47287. * Defines the callback to call when a pad is pressed
  47288. * @param callback defines the callback to use
  47289. */
  47290. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  47291. /**
  47292. * Defines the callback to call when a pad is released
  47293. * @param callback defines the callback to use
  47294. */
  47295. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  47296. private _setButtonValue;
  47297. private _setDPadValue;
  47298. /**
  47299. * Gets the value of the `A` button
  47300. */
  47301. get buttonA(): number;
  47302. /**
  47303. * Sets the value of the `A` button
  47304. */
  47305. set buttonA(value: number);
  47306. /**
  47307. * Gets the value of the `B` button
  47308. */
  47309. get buttonB(): number;
  47310. /**
  47311. * Sets the value of the `B` button
  47312. */
  47313. set buttonB(value: number);
  47314. /**
  47315. * Gets the value of the `X` button
  47316. */
  47317. get buttonX(): number;
  47318. /**
  47319. * Sets the value of the `X` button
  47320. */
  47321. set buttonX(value: number);
  47322. /**
  47323. * Gets the value of the `Y` button
  47324. */
  47325. get buttonY(): number;
  47326. /**
  47327. * Sets the value of the `Y` button
  47328. */
  47329. set buttonY(value: number);
  47330. /**
  47331. * Gets the value of the `Start` button
  47332. */
  47333. get buttonStart(): number;
  47334. /**
  47335. * Sets the value of the `Start` button
  47336. */
  47337. set buttonStart(value: number);
  47338. /**
  47339. * Gets the value of the `Back` button
  47340. */
  47341. get buttonBack(): number;
  47342. /**
  47343. * Sets the value of the `Back` button
  47344. */
  47345. set buttonBack(value: number);
  47346. /**
  47347. * Gets the value of the `Left` button
  47348. */
  47349. get buttonLB(): number;
  47350. /**
  47351. * Sets the value of the `Left` button
  47352. */
  47353. set buttonLB(value: number);
  47354. /**
  47355. * Gets the value of the `Right` button
  47356. */
  47357. get buttonRB(): number;
  47358. /**
  47359. * Sets the value of the `Right` button
  47360. */
  47361. set buttonRB(value: number);
  47362. /**
  47363. * Gets the value of the Left joystick
  47364. */
  47365. get buttonLeftStick(): number;
  47366. /**
  47367. * Sets the value of the Left joystick
  47368. */
  47369. set buttonLeftStick(value: number);
  47370. /**
  47371. * Gets the value of the Right joystick
  47372. */
  47373. get buttonRightStick(): number;
  47374. /**
  47375. * Sets the value of the Right joystick
  47376. */
  47377. set buttonRightStick(value: number);
  47378. /**
  47379. * Gets the value of D-pad up
  47380. */
  47381. get dPadUp(): number;
  47382. /**
  47383. * Sets the value of D-pad up
  47384. */
  47385. set dPadUp(value: number);
  47386. /**
  47387. * Gets the value of D-pad down
  47388. */
  47389. get dPadDown(): number;
  47390. /**
  47391. * Sets the value of D-pad down
  47392. */
  47393. set dPadDown(value: number);
  47394. /**
  47395. * Gets the value of D-pad left
  47396. */
  47397. get dPadLeft(): number;
  47398. /**
  47399. * Sets the value of D-pad left
  47400. */
  47401. set dPadLeft(value: number);
  47402. /**
  47403. * Gets the value of D-pad right
  47404. */
  47405. get dPadRight(): number;
  47406. /**
  47407. * Sets the value of D-pad right
  47408. */
  47409. set dPadRight(value: number);
  47410. /**
  47411. * Force the gamepad to synchronize with device values
  47412. */
  47413. update(): void;
  47414. /**
  47415. * Disposes the gamepad
  47416. */
  47417. dispose(): void;
  47418. }
  47419. }
  47420. declare module "babylonjs/Gamepads/dualShockGamepad" {
  47421. import { Observable } from "babylonjs/Misc/observable";
  47422. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  47423. /**
  47424. * Defines supported buttons for DualShock compatible gamepads
  47425. */
  47426. export enum DualShockButton {
  47427. /** Cross */
  47428. Cross = 0,
  47429. /** Circle */
  47430. Circle = 1,
  47431. /** Square */
  47432. Square = 2,
  47433. /** Triangle */
  47434. Triangle = 3,
  47435. /** L1 */
  47436. L1 = 4,
  47437. /** R1 */
  47438. R1 = 5,
  47439. /** Share */
  47440. Share = 8,
  47441. /** Options */
  47442. Options = 9,
  47443. /** Left stick */
  47444. LeftStick = 10,
  47445. /** Right stick */
  47446. RightStick = 11
  47447. }
  47448. /** Defines values for DualShock DPad */
  47449. export enum DualShockDpad {
  47450. /** Up */
  47451. Up = 12,
  47452. /** Down */
  47453. Down = 13,
  47454. /** Left */
  47455. Left = 14,
  47456. /** Right */
  47457. Right = 15
  47458. }
  47459. /**
  47460. * Defines a DualShock gamepad
  47461. */
  47462. export class DualShockPad extends Gamepad {
  47463. private _leftTrigger;
  47464. private _rightTrigger;
  47465. private _onlefttriggerchanged;
  47466. private _onrighttriggerchanged;
  47467. private _onbuttondown;
  47468. private _onbuttonup;
  47469. private _ondpaddown;
  47470. private _ondpadup;
  47471. /** Observable raised when a button is pressed */
  47472. onButtonDownObservable: Observable<DualShockButton>;
  47473. /** Observable raised when a button is released */
  47474. onButtonUpObservable: Observable<DualShockButton>;
  47475. /** Observable raised when a pad is pressed */
  47476. onPadDownObservable: Observable<DualShockDpad>;
  47477. /** Observable raised when a pad is released */
  47478. onPadUpObservable: Observable<DualShockDpad>;
  47479. private _buttonCross;
  47480. private _buttonCircle;
  47481. private _buttonSquare;
  47482. private _buttonTriangle;
  47483. private _buttonShare;
  47484. private _buttonOptions;
  47485. private _buttonL1;
  47486. private _buttonR1;
  47487. private _buttonLeftStick;
  47488. private _buttonRightStick;
  47489. private _dPadUp;
  47490. private _dPadDown;
  47491. private _dPadLeft;
  47492. private _dPadRight;
  47493. /**
  47494. * Creates a new DualShock gamepad object
  47495. * @param id defines the id of this gamepad
  47496. * @param index defines its index
  47497. * @param gamepad defines the internal HTML gamepad object
  47498. */
  47499. constructor(id: string, index: number, gamepad: any);
  47500. /**
  47501. * Defines the callback to call when left trigger is pressed
  47502. * @param callback defines the callback to use
  47503. */
  47504. onlefttriggerchanged(callback: (value: number) => void): void;
  47505. /**
  47506. * Defines the callback to call when right trigger is pressed
  47507. * @param callback defines the callback to use
  47508. */
  47509. onrighttriggerchanged(callback: (value: number) => void): void;
  47510. /**
  47511. * Gets the left trigger value
  47512. */
  47513. get leftTrigger(): number;
  47514. /**
  47515. * Sets the left trigger value
  47516. */
  47517. set leftTrigger(newValue: number);
  47518. /**
  47519. * Gets the right trigger value
  47520. */
  47521. get rightTrigger(): number;
  47522. /**
  47523. * Sets the right trigger value
  47524. */
  47525. set rightTrigger(newValue: number);
  47526. /**
  47527. * Defines the callback to call when a button is pressed
  47528. * @param callback defines the callback to use
  47529. */
  47530. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  47531. /**
  47532. * Defines the callback to call when a button is released
  47533. * @param callback defines the callback to use
  47534. */
  47535. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  47536. /**
  47537. * Defines the callback to call when a pad is pressed
  47538. * @param callback defines the callback to use
  47539. */
  47540. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  47541. /**
  47542. * Defines the callback to call when a pad is released
  47543. * @param callback defines the callback to use
  47544. */
  47545. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  47546. private _setButtonValue;
  47547. private _setDPadValue;
  47548. /**
  47549. * Gets the value of the `Cross` button
  47550. */
  47551. get buttonCross(): number;
  47552. /**
  47553. * Sets the value of the `Cross` button
  47554. */
  47555. set buttonCross(value: number);
  47556. /**
  47557. * Gets the value of the `Circle` button
  47558. */
  47559. get buttonCircle(): number;
  47560. /**
  47561. * Sets the value of the `Circle` button
  47562. */
  47563. set buttonCircle(value: number);
  47564. /**
  47565. * Gets the value of the `Square` button
  47566. */
  47567. get buttonSquare(): number;
  47568. /**
  47569. * Sets the value of the `Square` button
  47570. */
  47571. set buttonSquare(value: number);
  47572. /**
  47573. * Gets the value of the `Triangle` button
  47574. */
  47575. get buttonTriangle(): number;
  47576. /**
  47577. * Sets the value of the `Triangle` button
  47578. */
  47579. set buttonTriangle(value: number);
  47580. /**
  47581. * Gets the value of the `Options` button
  47582. */
  47583. get buttonOptions(): number;
  47584. /**
  47585. * Sets the value of the `Options` button
  47586. */
  47587. set buttonOptions(value: number);
  47588. /**
  47589. * Gets the value of the `Share` button
  47590. */
  47591. get buttonShare(): number;
  47592. /**
  47593. * Sets the value of the `Share` button
  47594. */
  47595. set buttonShare(value: number);
  47596. /**
  47597. * Gets the value of the `L1` button
  47598. */
  47599. get buttonL1(): number;
  47600. /**
  47601. * Sets the value of the `L1` button
  47602. */
  47603. set buttonL1(value: number);
  47604. /**
  47605. * Gets the value of the `R1` button
  47606. */
  47607. get buttonR1(): number;
  47608. /**
  47609. * Sets the value of the `R1` button
  47610. */
  47611. set buttonR1(value: number);
  47612. /**
  47613. * Gets the value of the Left joystick
  47614. */
  47615. get buttonLeftStick(): number;
  47616. /**
  47617. * Sets the value of the Left joystick
  47618. */
  47619. set buttonLeftStick(value: number);
  47620. /**
  47621. * Gets the value of the Right joystick
  47622. */
  47623. get buttonRightStick(): number;
  47624. /**
  47625. * Sets the value of the Right joystick
  47626. */
  47627. set buttonRightStick(value: number);
  47628. /**
  47629. * Gets the value of D-pad up
  47630. */
  47631. get dPadUp(): number;
  47632. /**
  47633. * Sets the value of D-pad up
  47634. */
  47635. set dPadUp(value: number);
  47636. /**
  47637. * Gets the value of D-pad down
  47638. */
  47639. get dPadDown(): number;
  47640. /**
  47641. * Sets the value of D-pad down
  47642. */
  47643. set dPadDown(value: number);
  47644. /**
  47645. * Gets the value of D-pad left
  47646. */
  47647. get dPadLeft(): number;
  47648. /**
  47649. * Sets the value of D-pad left
  47650. */
  47651. set dPadLeft(value: number);
  47652. /**
  47653. * Gets the value of D-pad right
  47654. */
  47655. get dPadRight(): number;
  47656. /**
  47657. * Sets the value of D-pad right
  47658. */
  47659. set dPadRight(value: number);
  47660. /**
  47661. * Force the gamepad to synchronize with device values
  47662. */
  47663. update(): void;
  47664. /**
  47665. * Disposes the gamepad
  47666. */
  47667. dispose(): void;
  47668. }
  47669. }
  47670. declare module "babylonjs/Gamepads/gamepadManager" {
  47671. import { Observable } from "babylonjs/Misc/observable";
  47672. import { Nullable } from "babylonjs/types";
  47673. import { Scene } from "babylonjs/scene";
  47674. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  47675. /**
  47676. * Manager for handling gamepads
  47677. */
  47678. export class GamepadManager {
  47679. private _scene?;
  47680. private _babylonGamepads;
  47681. private _oneGamepadConnected;
  47682. /** @hidden */
  47683. _isMonitoring: boolean;
  47684. private _gamepadEventSupported;
  47685. private _gamepadSupport?;
  47686. /**
  47687. * observable to be triggered when the gamepad controller has been connected
  47688. */
  47689. onGamepadConnectedObservable: Observable<Gamepad>;
  47690. /**
  47691. * observable to be triggered when the gamepad controller has been disconnected
  47692. */
  47693. onGamepadDisconnectedObservable: Observable<Gamepad>;
  47694. private _onGamepadConnectedEvent;
  47695. private _onGamepadDisconnectedEvent;
  47696. /**
  47697. * Initializes the gamepad manager
  47698. * @param _scene BabylonJS scene
  47699. */
  47700. constructor(_scene?: Scene | undefined);
  47701. /**
  47702. * The gamepads in the game pad manager
  47703. */
  47704. get gamepads(): Gamepad[];
  47705. /**
  47706. * Get the gamepad controllers based on type
  47707. * @param type The type of gamepad controller
  47708. * @returns Nullable gamepad
  47709. */
  47710. getGamepadByType(type?: number): Nullable<Gamepad>;
  47711. /**
  47712. * Disposes the gamepad manager
  47713. */
  47714. dispose(): void;
  47715. private _addNewGamepad;
  47716. private _startMonitoringGamepads;
  47717. private _stopMonitoringGamepads;
  47718. /** @hidden */
  47719. _checkGamepadsStatus(): void;
  47720. private _updateGamepadObjects;
  47721. }
  47722. }
  47723. declare module "babylonjs/Gamepads/gamepadSceneComponent" {
  47724. import { Nullable } from "babylonjs/types";
  47725. import { Scene } from "babylonjs/scene";
  47726. import { ISceneComponent } from "babylonjs/sceneComponent";
  47727. import { GamepadManager } from "babylonjs/Gamepads/gamepadManager";
  47728. module "babylonjs/scene" {
  47729. interface Scene {
  47730. /** @hidden */
  47731. _gamepadManager: Nullable<GamepadManager>;
  47732. /**
  47733. * Gets the gamepad manager associated with the scene
  47734. * @see https://doc.babylonjs.com/how_to/how_to_use_gamepads
  47735. */
  47736. gamepadManager: GamepadManager;
  47737. }
  47738. }
  47739. module "babylonjs/Cameras/freeCameraInputsManager" {
  47740. /**
  47741. * Interface representing a free camera inputs manager
  47742. */
  47743. interface FreeCameraInputsManager {
  47744. /**
  47745. * Adds gamepad input support to the FreeCameraInputsManager.
  47746. * @returns the FreeCameraInputsManager
  47747. */
  47748. addGamepad(): FreeCameraInputsManager;
  47749. }
  47750. }
  47751. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  47752. /**
  47753. * Interface representing an arc rotate camera inputs manager
  47754. */
  47755. interface ArcRotateCameraInputsManager {
  47756. /**
  47757. * Adds gamepad input support to the ArcRotateCamera InputManager.
  47758. * @returns the camera inputs manager
  47759. */
  47760. addGamepad(): ArcRotateCameraInputsManager;
  47761. }
  47762. }
  47763. /**
  47764. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  47765. */
  47766. export class GamepadSystemSceneComponent implements ISceneComponent {
  47767. /**
  47768. * The component name helpfull to identify the component in the list of scene components.
  47769. */
  47770. readonly name: string;
  47771. /**
  47772. * The scene the component belongs to.
  47773. */
  47774. scene: Scene;
  47775. /**
  47776. * Creates a new instance of the component for the given scene
  47777. * @param scene Defines the scene to register the component in
  47778. */
  47779. constructor(scene: Scene);
  47780. /**
  47781. * Registers the component in a given scene
  47782. */
  47783. register(): void;
  47784. /**
  47785. * Rebuilds the elements related to this component in case of
  47786. * context lost for instance.
  47787. */
  47788. rebuild(): void;
  47789. /**
  47790. * Disposes the component and the associated ressources
  47791. */
  47792. dispose(): void;
  47793. private _beforeCameraUpdate;
  47794. }
  47795. }
  47796. declare module "babylonjs/Cameras/universalCamera" {
  47797. import { TouchCamera } from "babylonjs/Cameras/touchCamera";
  47798. import { Scene } from "babylonjs/scene";
  47799. import { Vector3 } from "babylonjs/Maths/math.vector";
  47800. import "babylonjs/Gamepads/gamepadSceneComponent";
  47801. /**
  47802. * 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,
  47803. * which still works and will still be found in many Playgrounds.
  47804. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  47805. */
  47806. export class UniversalCamera extends TouchCamera {
  47807. /**
  47808. * Defines the gamepad rotation sensiblity.
  47809. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  47810. */
  47811. get gamepadAngularSensibility(): number;
  47812. set gamepadAngularSensibility(value: number);
  47813. /**
  47814. * Defines the gamepad move sensiblity.
  47815. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  47816. */
  47817. get gamepadMoveSensibility(): number;
  47818. set gamepadMoveSensibility(value: number);
  47819. /**
  47820. * 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,
  47821. * which still works and will still be found in many Playgrounds.
  47822. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  47823. * @param name Define the name of the camera in the scene
  47824. * @param position Define the start position of the camera in the scene
  47825. * @param scene Define the scene the camera belongs to
  47826. */
  47827. constructor(name: string, position: Vector3, scene: Scene);
  47828. /**
  47829. * Gets the current object class name.
  47830. * @return the class name
  47831. */
  47832. getClassName(): string;
  47833. }
  47834. }
  47835. declare module "babylonjs/Cameras/gamepadCamera" {
  47836. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  47837. import { Scene } from "babylonjs/scene";
  47838. import { Vector3 } from "babylonjs/Maths/math.vector";
  47839. /**
  47840. * This represents a FPS type of camera. This is only here for back compat purpose.
  47841. * Please use the UniversalCamera instead as both are identical.
  47842. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  47843. */
  47844. export class GamepadCamera extends UniversalCamera {
  47845. /**
  47846. * Instantiates a new Gamepad Camera
  47847. * This represents a FPS type of camera. This is only here for back compat purpose.
  47848. * Please use the UniversalCamera instead as both are identical.
  47849. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  47850. * @param name Define the name of the camera in the scene
  47851. * @param position Define the start position of the camera in the scene
  47852. * @param scene Define the scene the camera belongs to
  47853. */
  47854. constructor(name: string, position: Vector3, scene: Scene);
  47855. /**
  47856. * Gets the current object class name.
  47857. * @return the class name
  47858. */
  47859. getClassName(): string;
  47860. }
  47861. }
  47862. declare module "babylonjs/Shaders/pass.fragment" {
  47863. /** @hidden */
  47864. export var passPixelShader: {
  47865. name: string;
  47866. shader: string;
  47867. };
  47868. }
  47869. declare module "babylonjs/Shaders/passCube.fragment" {
  47870. /** @hidden */
  47871. export var passCubePixelShader: {
  47872. name: string;
  47873. shader: string;
  47874. };
  47875. }
  47876. declare module "babylonjs/PostProcesses/passPostProcess" {
  47877. import { Nullable } from "babylonjs/types";
  47878. import { Camera } from "babylonjs/Cameras/camera";
  47879. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  47880. import { Engine } from "babylonjs/Engines/engine";
  47881. import "babylonjs/Shaders/pass.fragment";
  47882. import "babylonjs/Shaders/passCube.fragment";
  47883. import { Scene } from "babylonjs/scene";
  47884. /**
  47885. * PassPostProcess which produces an output the same as it's input
  47886. */
  47887. export class PassPostProcess extends PostProcess {
  47888. /**
  47889. * Gets a string identifying the name of the class
  47890. * @returns "PassPostProcess" string
  47891. */
  47892. getClassName(): string;
  47893. /**
  47894. * Creates the PassPostProcess
  47895. * @param name The name of the effect.
  47896. * @param options The required width/height ratio to downsize to before computing the render pass.
  47897. * @param camera The camera to apply the render pass to.
  47898. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  47899. * @param engine The engine which the post process will be applied. (default: current engine)
  47900. * @param reusable If the post process can be reused on the same frame. (default: false)
  47901. * @param textureType The type of texture to be used when performing the post processing.
  47902. * @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)
  47903. */
  47904. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  47905. /** @hidden */
  47906. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassPostProcess;
  47907. }
  47908. /**
  47909. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  47910. */
  47911. export class PassCubePostProcess extends PostProcess {
  47912. private _face;
  47913. /**
  47914. * Gets or sets the cube face to display.
  47915. * * 0 is +X
  47916. * * 1 is -X
  47917. * * 2 is +Y
  47918. * * 3 is -Y
  47919. * * 4 is +Z
  47920. * * 5 is -Z
  47921. */
  47922. get face(): number;
  47923. set face(value: number);
  47924. /**
  47925. * Gets a string identifying the name of the class
  47926. * @returns "PassCubePostProcess" string
  47927. */
  47928. getClassName(): string;
  47929. /**
  47930. * Creates the PassCubePostProcess
  47931. * @param name The name of the effect.
  47932. * @param options The required width/height ratio to downsize to before computing the render pass.
  47933. * @param camera The camera to apply the render pass to.
  47934. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  47935. * @param engine The engine which the post process will be applied. (default: current engine)
  47936. * @param reusable If the post process can be reused on the same frame. (default: false)
  47937. * @param textureType The type of texture to be used when performing the post processing.
  47938. * @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)
  47939. */
  47940. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  47941. /** @hidden */
  47942. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassCubePostProcess;
  47943. }
  47944. }
  47945. declare module "babylonjs/Shaders/anaglyph.fragment" {
  47946. /** @hidden */
  47947. export var anaglyphPixelShader: {
  47948. name: string;
  47949. shader: string;
  47950. };
  47951. }
  47952. declare module "babylonjs/PostProcesses/anaglyphPostProcess" {
  47953. import { Engine } from "babylonjs/Engines/engine";
  47954. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  47955. import { Camera } from "babylonjs/Cameras/camera";
  47956. import "babylonjs/Shaders/anaglyph.fragment";
  47957. /**
  47958. * Postprocess used to generate anaglyphic rendering
  47959. */
  47960. export class AnaglyphPostProcess extends PostProcess {
  47961. private _passedProcess;
  47962. /**
  47963. * Gets a string identifying the name of the class
  47964. * @returns "AnaglyphPostProcess" string
  47965. */
  47966. getClassName(): string;
  47967. /**
  47968. * Creates a new AnaglyphPostProcess
  47969. * @param name defines postprocess name
  47970. * @param options defines creation options or target ratio scale
  47971. * @param rigCameras defines cameras using this postprocess
  47972. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  47973. * @param engine defines hosting engine
  47974. * @param reusable defines if the postprocess will be reused multiple times per frame
  47975. */
  47976. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  47977. }
  47978. }
  47979. declare module "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode" { }
  47980. declare module "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera" {
  47981. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  47982. import { Scene } from "babylonjs/scene";
  47983. import { Vector3 } from "babylonjs/Maths/math.vector";
  47984. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  47985. /**
  47986. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  47987. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  47988. */
  47989. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  47990. /**
  47991. * Creates a new AnaglyphArcRotateCamera
  47992. * @param name defines camera name
  47993. * @param alpha defines alpha angle (in radians)
  47994. * @param beta defines beta angle (in radians)
  47995. * @param radius defines radius
  47996. * @param target defines camera target
  47997. * @param interaxialDistance defines distance between each color axis
  47998. * @param scene defines the hosting scene
  47999. */
  48000. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  48001. /**
  48002. * Gets camera class name
  48003. * @returns AnaglyphArcRotateCamera
  48004. */
  48005. getClassName(): string;
  48006. }
  48007. }
  48008. declare module "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera" {
  48009. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  48010. import { Scene } from "babylonjs/scene";
  48011. import { Vector3 } from "babylonjs/Maths/math.vector";
  48012. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  48013. /**
  48014. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  48015. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  48016. */
  48017. export class AnaglyphFreeCamera extends FreeCamera {
  48018. /**
  48019. * Creates a new AnaglyphFreeCamera
  48020. * @param name defines camera name
  48021. * @param position defines initial position
  48022. * @param interaxialDistance defines distance between each color axis
  48023. * @param scene defines the hosting scene
  48024. */
  48025. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  48026. /**
  48027. * Gets camera class name
  48028. * @returns AnaglyphFreeCamera
  48029. */
  48030. getClassName(): string;
  48031. }
  48032. }
  48033. declare module "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera" {
  48034. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  48035. import { Scene } from "babylonjs/scene";
  48036. import { Vector3 } from "babylonjs/Maths/math.vector";
  48037. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  48038. /**
  48039. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  48040. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  48041. */
  48042. export class AnaglyphGamepadCamera extends GamepadCamera {
  48043. /**
  48044. * Creates a new AnaglyphGamepadCamera
  48045. * @param name defines camera name
  48046. * @param position defines initial position
  48047. * @param interaxialDistance defines distance between each color axis
  48048. * @param scene defines the hosting scene
  48049. */
  48050. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  48051. /**
  48052. * Gets camera class name
  48053. * @returns AnaglyphGamepadCamera
  48054. */
  48055. getClassName(): string;
  48056. }
  48057. }
  48058. declare module "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera" {
  48059. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  48060. import { Scene } from "babylonjs/scene";
  48061. import { Vector3 } from "babylonjs/Maths/math.vector";
  48062. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  48063. /**
  48064. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  48065. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  48066. */
  48067. export class AnaglyphUniversalCamera extends UniversalCamera {
  48068. /**
  48069. * Creates a new AnaglyphUniversalCamera
  48070. * @param name defines camera name
  48071. * @param position defines initial position
  48072. * @param interaxialDistance defines distance between each color axis
  48073. * @param scene defines the hosting scene
  48074. */
  48075. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  48076. /**
  48077. * Gets camera class name
  48078. * @returns AnaglyphUniversalCamera
  48079. */
  48080. getClassName(): string;
  48081. }
  48082. }
  48083. declare module "babylonjs/Cameras/RigModes/stereoscopicRigMode" { }
  48084. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera" {
  48085. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  48086. import { Scene } from "babylonjs/scene";
  48087. import { Vector3 } from "babylonjs/Maths/math.vector";
  48088. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  48089. /**
  48090. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  48091. * @see https://doc.babylonjs.com/features/cameras
  48092. */
  48093. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  48094. /**
  48095. * Creates a new StereoscopicArcRotateCamera
  48096. * @param name defines camera name
  48097. * @param alpha defines alpha angle (in radians)
  48098. * @param beta defines beta angle (in radians)
  48099. * @param radius defines radius
  48100. * @param target defines camera target
  48101. * @param interaxialDistance defines distance between each color axis
  48102. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  48103. * @param scene defines the hosting scene
  48104. */
  48105. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  48106. /**
  48107. * Gets camera class name
  48108. * @returns StereoscopicArcRotateCamera
  48109. */
  48110. getClassName(): string;
  48111. }
  48112. }
  48113. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera" {
  48114. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  48115. import { Scene } from "babylonjs/scene";
  48116. import { Vector3 } from "babylonjs/Maths/math.vector";
  48117. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  48118. /**
  48119. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  48120. * @see https://doc.babylonjs.com/features/cameras
  48121. */
  48122. export class StereoscopicFreeCamera extends FreeCamera {
  48123. /**
  48124. * Creates a new StereoscopicFreeCamera
  48125. * @param name defines camera name
  48126. * @param position defines initial position
  48127. * @param interaxialDistance defines distance between each color axis
  48128. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  48129. * @param scene defines the hosting scene
  48130. */
  48131. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  48132. /**
  48133. * Gets camera class name
  48134. * @returns StereoscopicFreeCamera
  48135. */
  48136. getClassName(): string;
  48137. }
  48138. }
  48139. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera" {
  48140. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  48141. import { Scene } from "babylonjs/scene";
  48142. import { Vector3 } from "babylonjs/Maths/math.vector";
  48143. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  48144. /**
  48145. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  48146. * @see https://doc.babylonjs.com/features/cameras
  48147. */
  48148. export class StereoscopicGamepadCamera extends GamepadCamera {
  48149. /**
  48150. * Creates a new StereoscopicGamepadCamera
  48151. * @param name defines camera name
  48152. * @param position defines initial position
  48153. * @param interaxialDistance defines distance between each color axis
  48154. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  48155. * @param scene defines the hosting scene
  48156. */
  48157. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  48158. /**
  48159. * Gets camera class name
  48160. * @returns StereoscopicGamepadCamera
  48161. */
  48162. getClassName(): string;
  48163. }
  48164. }
  48165. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera" {
  48166. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  48167. import { Scene } from "babylonjs/scene";
  48168. import { Vector3 } from "babylonjs/Maths/math.vector";
  48169. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  48170. /**
  48171. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  48172. * @see https://doc.babylonjs.com/features/cameras
  48173. */
  48174. export class StereoscopicUniversalCamera extends UniversalCamera {
  48175. /**
  48176. * Creates a new StereoscopicUniversalCamera
  48177. * @param name defines camera name
  48178. * @param position defines initial position
  48179. * @param interaxialDistance defines distance between each color axis
  48180. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  48181. * @param scene defines the hosting scene
  48182. */
  48183. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  48184. /**
  48185. * Gets camera class name
  48186. * @returns StereoscopicUniversalCamera
  48187. */
  48188. getClassName(): string;
  48189. }
  48190. }
  48191. declare module "babylonjs/Cameras/Stereoscopic/index" {
  48192. export * from "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera";
  48193. export * from "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera";
  48194. export * from "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera";
  48195. export * from "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera";
  48196. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera";
  48197. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera";
  48198. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera";
  48199. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera";
  48200. }
  48201. declare module "babylonjs/Cameras/virtualJoysticksCamera" {
  48202. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  48203. import { Scene } from "babylonjs/scene";
  48204. import { Vector3 } from "babylonjs/Maths/math.vector";
  48205. import "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  48206. /**
  48207. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  48208. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  48209. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  48210. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  48211. */
  48212. export class VirtualJoysticksCamera extends FreeCamera {
  48213. /**
  48214. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  48215. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  48216. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  48217. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  48218. * @param name Define the name of the camera in the scene
  48219. * @param position Define the start position of the camera in the scene
  48220. * @param scene Define the scene the camera belongs to
  48221. */
  48222. constructor(name: string, position: Vector3, scene: Scene);
  48223. /**
  48224. * Gets the current object class name.
  48225. * @return the class name
  48226. */
  48227. getClassName(): string;
  48228. }
  48229. }
  48230. declare module "babylonjs/Cameras/VR/vrCameraMetrics" {
  48231. import { Matrix } from "babylonjs/Maths/math.vector";
  48232. /**
  48233. * This represents all the required metrics to create a VR camera.
  48234. * @see https://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  48235. */
  48236. export class VRCameraMetrics {
  48237. /**
  48238. * Define the horizontal resolution off the screen.
  48239. */
  48240. hResolution: number;
  48241. /**
  48242. * Define the vertical resolution off the screen.
  48243. */
  48244. vResolution: number;
  48245. /**
  48246. * Define the horizontal screen size.
  48247. */
  48248. hScreenSize: number;
  48249. /**
  48250. * Define the vertical screen size.
  48251. */
  48252. vScreenSize: number;
  48253. /**
  48254. * Define the vertical screen center position.
  48255. */
  48256. vScreenCenter: number;
  48257. /**
  48258. * Define the distance of the eyes to the screen.
  48259. */
  48260. eyeToScreenDistance: number;
  48261. /**
  48262. * Define the distance between both lenses
  48263. */
  48264. lensSeparationDistance: number;
  48265. /**
  48266. * Define the distance between both viewer's eyes.
  48267. */
  48268. interpupillaryDistance: number;
  48269. /**
  48270. * Define the distortion factor of the VR postprocess.
  48271. * Please, touch with care.
  48272. */
  48273. distortionK: number[];
  48274. /**
  48275. * Define the chromatic aberration correction factors for the VR post process.
  48276. */
  48277. chromaAbCorrection: number[];
  48278. /**
  48279. * Define the scale factor of the post process.
  48280. * The smaller the better but the slower.
  48281. */
  48282. postProcessScaleFactor: number;
  48283. /**
  48284. * Define an offset for the lens center.
  48285. */
  48286. lensCenterOffset: number;
  48287. /**
  48288. * Define if the current vr camera should compensate the distortion of the lense or not.
  48289. */
  48290. compensateDistortion: boolean;
  48291. /**
  48292. * Defines if multiview should be enabled when rendering (Default: false)
  48293. */
  48294. multiviewEnabled: boolean;
  48295. /**
  48296. * Gets the rendering aspect ratio based on the provided resolutions.
  48297. */
  48298. get aspectRatio(): number;
  48299. /**
  48300. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  48301. */
  48302. get aspectRatioFov(): number;
  48303. /**
  48304. * @hidden
  48305. */
  48306. get leftHMatrix(): Matrix;
  48307. /**
  48308. * @hidden
  48309. */
  48310. get rightHMatrix(): Matrix;
  48311. /**
  48312. * @hidden
  48313. */
  48314. get leftPreViewMatrix(): Matrix;
  48315. /**
  48316. * @hidden
  48317. */
  48318. get rightPreViewMatrix(): Matrix;
  48319. /**
  48320. * Get the default VRMetrics based on the most generic setup.
  48321. * @returns the default vr metrics
  48322. */
  48323. static GetDefault(): VRCameraMetrics;
  48324. }
  48325. }
  48326. declare module "babylonjs/Shaders/vrDistortionCorrection.fragment" {
  48327. /** @hidden */
  48328. export var vrDistortionCorrectionPixelShader: {
  48329. name: string;
  48330. shader: string;
  48331. };
  48332. }
  48333. declare module "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess" {
  48334. import { Camera } from "babylonjs/Cameras/camera";
  48335. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  48336. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  48337. import "babylonjs/Shaders/vrDistortionCorrection.fragment";
  48338. /**
  48339. * VRDistortionCorrectionPostProcess used for mobile VR
  48340. */
  48341. export class VRDistortionCorrectionPostProcess extends PostProcess {
  48342. private _isRightEye;
  48343. private _distortionFactors;
  48344. private _postProcessScaleFactor;
  48345. private _lensCenterOffset;
  48346. private _scaleIn;
  48347. private _scaleFactor;
  48348. private _lensCenter;
  48349. /**
  48350. * Gets a string identifying the name of the class
  48351. * @returns "VRDistortionCorrectionPostProcess" string
  48352. */
  48353. getClassName(): string;
  48354. /**
  48355. * Initializes the VRDistortionCorrectionPostProcess
  48356. * @param name The name of the effect.
  48357. * @param camera The camera to apply the render pass to.
  48358. * @param isRightEye If this is for the right eye distortion
  48359. * @param vrMetrics All the required metrics for the VR camera
  48360. */
  48361. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  48362. }
  48363. }
  48364. declare module "babylonjs/Cameras/RigModes/vrRigMode" { }
  48365. declare module "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera" {
  48366. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  48367. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  48368. import { Scene } from "babylonjs/scene";
  48369. import { Vector3 } from "babylonjs/Maths/math.vector";
  48370. import "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  48371. import "babylonjs/Cameras/RigModes/vrRigMode";
  48372. /**
  48373. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  48374. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  48375. */
  48376. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  48377. /**
  48378. * Creates a new VRDeviceOrientationArcRotateCamera
  48379. * @param name defines camera name
  48380. * @param alpha defines the camera rotation along the logitudinal axis
  48381. * @param beta defines the camera rotation along the latitudinal axis
  48382. * @param radius defines the camera distance from its target
  48383. * @param target defines the camera target
  48384. * @param scene defines the scene the camera belongs to
  48385. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  48386. * @param vrCameraMetrics defines the vr metrics associated to the camera
  48387. */
  48388. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  48389. /**
  48390. * Gets camera class name
  48391. * @returns VRDeviceOrientationArcRotateCamera
  48392. */
  48393. getClassName(): string;
  48394. }
  48395. }
  48396. declare module "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera" {
  48397. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  48398. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  48399. import { Scene } from "babylonjs/scene";
  48400. import { Vector3 } from "babylonjs/Maths/math.vector";
  48401. import "babylonjs/Cameras/RigModes/vrRigMode";
  48402. /**
  48403. * Camera used to simulate VR rendering (based on FreeCamera)
  48404. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  48405. */
  48406. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  48407. /**
  48408. * Creates a new VRDeviceOrientationFreeCamera
  48409. * @param name defines camera name
  48410. * @param position defines the start position of the camera
  48411. * @param scene defines the scene the camera belongs to
  48412. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  48413. * @param vrCameraMetrics defines the vr metrics associated to the camera
  48414. */
  48415. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  48416. /**
  48417. * Gets camera class name
  48418. * @returns VRDeviceOrientationFreeCamera
  48419. */
  48420. getClassName(): string;
  48421. }
  48422. }
  48423. declare module "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera" {
  48424. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  48425. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  48426. import { Scene } from "babylonjs/scene";
  48427. import { Vector3 } from "babylonjs/Maths/math.vector";
  48428. import "babylonjs/Gamepads/gamepadSceneComponent";
  48429. /**
  48430. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  48431. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  48432. */
  48433. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  48434. /**
  48435. * Creates a new VRDeviceOrientationGamepadCamera
  48436. * @param name defines camera name
  48437. * @param position defines the start position of the camera
  48438. * @param scene defines the scene the camera belongs to
  48439. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  48440. * @param vrCameraMetrics defines the vr metrics associated to the camera
  48441. */
  48442. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  48443. /**
  48444. * Gets camera class name
  48445. * @returns VRDeviceOrientationGamepadCamera
  48446. */
  48447. getClassName(): string;
  48448. }
  48449. }
  48450. declare module "babylonjs/Materials/Textures/dynamicTexture" {
  48451. import { Scene } from "babylonjs/scene";
  48452. import { Texture } from "babylonjs/Materials/Textures/texture";
  48453. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  48454. /**
  48455. * A class extending Texture allowing drawing on a texture
  48456. * @see https://doc.babylonjs.com/how_to/dynamictexture
  48457. */
  48458. export class DynamicTexture extends Texture {
  48459. private _generateMipMaps;
  48460. private _canvas;
  48461. private _context;
  48462. /**
  48463. * Creates a DynamicTexture
  48464. * @param name defines the name of the texture
  48465. * @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
  48466. * @param scene defines the scene where you want the texture
  48467. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  48468. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  48469. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  48470. */
  48471. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  48472. /**
  48473. * Get the current class name of the texture useful for serialization or dynamic coding.
  48474. * @returns "DynamicTexture"
  48475. */
  48476. getClassName(): string;
  48477. /**
  48478. * Gets the current state of canRescale
  48479. */
  48480. get canRescale(): boolean;
  48481. private _recreate;
  48482. /**
  48483. * Scales the texture
  48484. * @param ratio the scale factor to apply to both width and height
  48485. */
  48486. scale(ratio: number): void;
  48487. /**
  48488. * Resizes the texture
  48489. * @param width the new width
  48490. * @param height the new height
  48491. */
  48492. scaleTo(width: number, height: number): void;
  48493. /**
  48494. * Gets the context of the canvas used by the texture
  48495. * @returns the canvas context of the dynamic texture
  48496. */
  48497. getContext(): CanvasRenderingContext2D;
  48498. /**
  48499. * Clears the texture
  48500. */
  48501. clear(): void;
  48502. /**
  48503. * Updates the texture
  48504. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  48505. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  48506. */
  48507. update(invertY?: boolean, premulAlpha?: boolean): void;
  48508. /**
  48509. * Draws text onto the texture
  48510. * @param text defines the text to be drawn
  48511. * @param x defines the placement of the text from the left
  48512. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  48513. * @param font defines the font to be used with font-style, font-size, font-name
  48514. * @param color defines the color used for the text
  48515. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  48516. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  48517. * @param update defines whether texture is immediately update (default is true)
  48518. */
  48519. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string | null, clearColor: string, invertY?: boolean, update?: boolean): void;
  48520. /**
  48521. * Clones the texture
  48522. * @returns the clone of the texture.
  48523. */
  48524. clone(): DynamicTexture;
  48525. /**
  48526. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  48527. * @returns a serialized dynamic texture object
  48528. */
  48529. serialize(): any;
  48530. private _IsCanvasElement;
  48531. /** @hidden */
  48532. _rebuild(): void;
  48533. }
  48534. }
  48535. declare module "babylonjs/Meshes/Builders/groundBuilder" {
  48536. import { Scene } from "babylonjs/scene";
  48537. import { Color3 } from "babylonjs/Maths/math.color";
  48538. import { Mesh } from "babylonjs/Meshes/mesh";
  48539. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  48540. import { Nullable } from "babylonjs/types";
  48541. /**
  48542. * Class containing static functions to help procedurally build meshes
  48543. */
  48544. export class GroundBuilder {
  48545. /**
  48546. * Creates a ground mesh
  48547. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  48548. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  48549. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48550. * @param name defines the name of the mesh
  48551. * @param options defines the options used to create the mesh
  48552. * @param scene defines the hosting scene
  48553. * @returns the ground mesh
  48554. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  48555. */
  48556. static CreateGround(name: string, options: {
  48557. width?: number;
  48558. height?: number;
  48559. subdivisions?: number;
  48560. subdivisionsX?: number;
  48561. subdivisionsY?: number;
  48562. updatable?: boolean;
  48563. }, scene: any): Mesh;
  48564. /**
  48565. * Creates a tiled ground mesh
  48566. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  48567. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  48568. * * 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
  48569. * * 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
  48570. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  48571. * @param name defines the name of the mesh
  48572. * @param options defines the options used to create the mesh
  48573. * @param scene defines the hosting scene
  48574. * @returns the tiled ground mesh
  48575. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  48576. */
  48577. static CreateTiledGround(name: string, options: {
  48578. xmin: number;
  48579. zmin: number;
  48580. xmax: number;
  48581. zmax: number;
  48582. subdivisions?: {
  48583. w: number;
  48584. h: number;
  48585. };
  48586. precision?: {
  48587. w: number;
  48588. h: number;
  48589. };
  48590. updatable?: boolean;
  48591. }, scene?: Nullable<Scene>): Mesh;
  48592. /**
  48593. * Creates a ground mesh from a height map
  48594. * * The parameter `url` sets the URL of the height map image resource.
  48595. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  48596. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  48597. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  48598. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  48599. * * 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.
  48600. * * 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).
  48601. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  48602. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  48603. * @param name defines the name of the mesh
  48604. * @param url defines the url to the height map
  48605. * @param options defines the options used to create the mesh
  48606. * @param scene defines the hosting scene
  48607. * @returns the ground mesh
  48608. * @see https://doc.babylonjs.com/babylon101/height_map
  48609. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  48610. */
  48611. static CreateGroundFromHeightMap(name: string, url: string, options: {
  48612. width?: number;
  48613. height?: number;
  48614. subdivisions?: number;
  48615. minHeight?: number;
  48616. maxHeight?: number;
  48617. colorFilter?: Color3;
  48618. alphaFilter?: number;
  48619. updatable?: boolean;
  48620. onReady?: (mesh: GroundMesh) => void;
  48621. }, scene?: Nullable<Scene>): GroundMesh;
  48622. }
  48623. }
  48624. declare module "babylonjs/Meshes/Builders/torusBuilder" {
  48625. import { Vector4 } from "babylonjs/Maths/math.vector";
  48626. import { Mesh } from "babylonjs/Meshes/mesh";
  48627. /**
  48628. * Class containing static functions to help procedurally build meshes
  48629. */
  48630. export class TorusBuilder {
  48631. /**
  48632. * Creates a torus mesh
  48633. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  48634. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  48635. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  48636. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48637. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  48638. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  48639. * @param name defines the name of the mesh
  48640. * @param options defines the options used to create the mesh
  48641. * @param scene defines the hosting scene
  48642. * @returns the torus mesh
  48643. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  48644. */
  48645. static CreateTorus(name: string, options: {
  48646. diameter?: number;
  48647. thickness?: number;
  48648. tessellation?: number;
  48649. updatable?: boolean;
  48650. sideOrientation?: number;
  48651. frontUVs?: Vector4;
  48652. backUVs?: Vector4;
  48653. }, scene: any): Mesh;
  48654. }
  48655. }
  48656. declare module "babylonjs/Meshes/Builders/cylinderBuilder" {
  48657. import { Vector4 } from "babylonjs/Maths/math.vector";
  48658. import { Color4 } from "babylonjs/Maths/math.color";
  48659. import { Mesh } from "babylonjs/Meshes/mesh";
  48660. /**
  48661. * Class containing static functions to help procedurally build meshes
  48662. */
  48663. export class CylinderBuilder {
  48664. /**
  48665. * Creates a cylinder or a cone mesh
  48666. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  48667. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  48668. * * 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.
  48669. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  48670. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  48671. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  48672. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  48673. * * 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).
  48674. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  48675. * * 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).
  48676. * * 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
  48677. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  48678. * * 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
  48679. * * 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.
  48680. * * If `enclose` is false, a ring surface is one element.
  48681. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  48682. * * 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
  48683. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48684. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  48685. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  48686. * @param name defines the name of the mesh
  48687. * @param options defines the options used to create the mesh
  48688. * @param scene defines the hosting scene
  48689. * @returns the cylinder mesh
  48690. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  48691. */
  48692. static CreateCylinder(name: string, options: {
  48693. height?: number;
  48694. diameterTop?: number;
  48695. diameterBottom?: number;
  48696. diameter?: number;
  48697. tessellation?: number;
  48698. subdivisions?: number;
  48699. arc?: number;
  48700. faceColors?: Color4[];
  48701. faceUV?: Vector4[];
  48702. updatable?: boolean;
  48703. hasRings?: boolean;
  48704. enclose?: boolean;
  48705. cap?: number;
  48706. sideOrientation?: number;
  48707. frontUVs?: Vector4;
  48708. backUVs?: Vector4;
  48709. }, scene: any): Mesh;
  48710. }
  48711. }
  48712. declare module "babylonjs/XR/webXRTypes" {
  48713. import { Nullable } from "babylonjs/types";
  48714. import { IDisposable } from "babylonjs/scene";
  48715. /**
  48716. * States of the webXR experience
  48717. */
  48718. export enum WebXRState {
  48719. /**
  48720. * Transitioning to being in XR mode
  48721. */
  48722. ENTERING_XR = 0,
  48723. /**
  48724. * Transitioning to non XR mode
  48725. */
  48726. EXITING_XR = 1,
  48727. /**
  48728. * In XR mode and presenting
  48729. */
  48730. IN_XR = 2,
  48731. /**
  48732. * Not entered XR mode
  48733. */
  48734. NOT_IN_XR = 3
  48735. }
  48736. /**
  48737. * Abstraction of the XR render target
  48738. */
  48739. export interface WebXRRenderTarget extends IDisposable {
  48740. /**
  48741. * xrpresent context of the canvas which can be used to display/mirror xr content
  48742. */
  48743. canvasContext: WebGLRenderingContext;
  48744. /**
  48745. * xr layer for the canvas
  48746. */
  48747. xrLayer: Nullable<XRWebGLLayer>;
  48748. /**
  48749. * Initializes the xr layer for the session
  48750. * @param xrSession xr session
  48751. * @returns a promise that will resolve once the XR Layer has been created
  48752. */
  48753. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  48754. }
  48755. }
  48756. declare module "babylonjs/XR/webXRManagedOutputCanvas" {
  48757. import { Nullable } from "babylonjs/types";
  48758. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  48759. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  48760. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  48761. import { Observable } from "babylonjs/Misc/observable";
  48762. /**
  48763. * COnfiguration object for WebXR output canvas
  48764. */
  48765. export class WebXRManagedOutputCanvasOptions {
  48766. /**
  48767. * An optional canvas in case you wish to create it yourself and provide it here.
  48768. * If not provided, a new canvas will be created
  48769. */
  48770. canvasElement?: HTMLCanvasElement;
  48771. /**
  48772. * Options for this XR Layer output
  48773. */
  48774. canvasOptions?: XRWebGLLayerOptions;
  48775. /**
  48776. * CSS styling for a newly created canvas (if not provided)
  48777. */
  48778. newCanvasCssStyle?: string;
  48779. /**
  48780. * Get the default values of the configuration object
  48781. * @param engine defines the engine to use (can be null)
  48782. * @returns default values of this configuration object
  48783. */
  48784. static GetDefaults(engine?: ThinEngine): WebXRManagedOutputCanvasOptions;
  48785. }
  48786. /**
  48787. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  48788. */
  48789. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  48790. private _options;
  48791. private _canvas;
  48792. private _engine;
  48793. private _originalCanvasSize;
  48794. /**
  48795. * Rendering context of the canvas which can be used to display/mirror xr content
  48796. */
  48797. canvasContext: WebGLRenderingContext;
  48798. /**
  48799. * xr layer for the canvas
  48800. */
  48801. xrLayer: Nullable<XRWebGLLayer>;
  48802. /**
  48803. * Obseervers registered here will be triggered when the xr layer was initialized
  48804. */
  48805. onXRLayerInitObservable: Observable<XRWebGLLayer>;
  48806. /**
  48807. * Initializes the canvas to be added/removed upon entering/exiting xr
  48808. * @param _xrSessionManager The XR Session manager
  48809. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  48810. */
  48811. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  48812. /**
  48813. * Disposes of the object
  48814. */
  48815. dispose(): void;
  48816. /**
  48817. * Initializes the xr layer for the session
  48818. * @param xrSession xr session
  48819. * @returns a promise that will resolve once the XR Layer has been created
  48820. */
  48821. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  48822. private _addCanvas;
  48823. private _removeCanvas;
  48824. private _setCanvasSize;
  48825. private _setManagedOutputCanvas;
  48826. }
  48827. }
  48828. declare module "babylonjs/XR/webXRSessionManager" {
  48829. import { Observable } from "babylonjs/Misc/observable";
  48830. import { Nullable } from "babylonjs/types";
  48831. import { IDisposable, Scene } from "babylonjs/scene";
  48832. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  48833. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  48834. import { WebXRManagedOutputCanvasOptions } from "babylonjs/XR/webXRManagedOutputCanvas";
  48835. /**
  48836. * Manages an XRSession to work with Babylon's engine
  48837. * @see https://doc.babylonjs.com/how_to/webxr_session_manager
  48838. */
  48839. export class WebXRSessionManager implements IDisposable {
  48840. /** The scene which the session should be created for */
  48841. scene: Scene;
  48842. private _referenceSpace;
  48843. private _rttProvider;
  48844. private _sessionEnded;
  48845. private _xrNavigator;
  48846. private baseLayer;
  48847. /**
  48848. * The base reference space from which the session started. good if you want to reset your
  48849. * reference space
  48850. */
  48851. baseReferenceSpace: XRReferenceSpace;
  48852. /**
  48853. * Current XR frame
  48854. */
  48855. currentFrame: Nullable<XRFrame>;
  48856. /** WebXR timestamp updated every frame */
  48857. currentTimestamp: number;
  48858. /**
  48859. * Used just in case of a failure to initialize an immersive session.
  48860. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  48861. */
  48862. defaultHeightCompensation: number;
  48863. /**
  48864. * Fires every time a new xrFrame arrives which can be used to update the camera
  48865. */
  48866. onXRFrameObservable: Observable<XRFrame>;
  48867. /**
  48868. * Fires when the reference space changed
  48869. */
  48870. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  48871. /**
  48872. * Fires when the xr session is ended either by the device or manually done
  48873. */
  48874. onXRSessionEnded: Observable<any>;
  48875. /**
  48876. * Fires when the xr session is ended either by the device or manually done
  48877. */
  48878. onXRSessionInit: Observable<XRSession>;
  48879. /**
  48880. * Underlying xr session
  48881. */
  48882. session: XRSession;
  48883. /**
  48884. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  48885. * or get the offset the player is currently at.
  48886. */
  48887. viewerReferenceSpace: XRReferenceSpace;
  48888. /**
  48889. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  48890. * @param scene The scene which the session should be created for
  48891. */
  48892. constructor(
  48893. /** The scene which the session should be created for */
  48894. scene: Scene);
  48895. /**
  48896. * The current reference space used in this session. This reference space can constantly change!
  48897. * It is mainly used to offset the camera's position.
  48898. */
  48899. get referenceSpace(): XRReferenceSpace;
  48900. /**
  48901. * Set a new reference space and triggers the observable
  48902. */
  48903. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  48904. /**
  48905. * Disposes of the session manager
  48906. */
  48907. dispose(): void;
  48908. /**
  48909. * Stops the xrSession and restores the render loop
  48910. * @returns Promise which resolves after it exits XR
  48911. */
  48912. exitXRAsync(): Promise<void>;
  48913. /**
  48914. * Gets the correct render target texture to be rendered this frame for this eye
  48915. * @param eye the eye for which to get the render target
  48916. * @returns the render target for the specified eye
  48917. */
  48918. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  48919. /**
  48920. * Creates a WebXRRenderTarget object for the XR session
  48921. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  48922. * @param options optional options to provide when creating a new render target
  48923. * @returns a WebXR render target to which the session can render
  48924. */
  48925. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  48926. /**
  48927. * Initializes the manager
  48928. * After initialization enterXR can be called to start an XR session
  48929. * @returns Promise which resolves after it is initialized
  48930. */
  48931. initializeAsync(): Promise<void>;
  48932. /**
  48933. * Initializes an xr session
  48934. * @param xrSessionMode mode to initialize
  48935. * @param xrSessionInit defines optional and required values to pass to the session builder
  48936. * @returns a promise which will resolve once the session has been initialized
  48937. */
  48938. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  48939. /**
  48940. * Checks if a session would be supported for the creation options specified
  48941. * @param sessionMode session mode to check if supported eg. immersive-vr
  48942. * @returns A Promise that resolves to true if supported and false if not
  48943. */
  48944. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  48945. /**
  48946. * Resets the reference space to the one started the session
  48947. */
  48948. resetReferenceSpace(): void;
  48949. /**
  48950. * Starts rendering to the xr layer
  48951. */
  48952. runXRRenderLoop(): void;
  48953. /**
  48954. * Sets the reference space on the xr session
  48955. * @param referenceSpaceType space to set
  48956. * @returns a promise that will resolve once the reference space has been set
  48957. */
  48958. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  48959. /**
  48960. * Updates the render state of the session
  48961. * @param state state to set
  48962. * @returns a promise that resolves once the render state has been updated
  48963. */
  48964. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  48965. /**
  48966. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  48967. * @param sessionMode defines the session to test
  48968. * @returns a promise with boolean as final value
  48969. */
  48970. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  48971. private _createRenderTargetTexture;
  48972. }
  48973. }
  48974. declare module "babylonjs/XR/webXRCamera" {
  48975. import { Vector3 } from "babylonjs/Maths/math.vector";
  48976. import { Scene } from "babylonjs/scene";
  48977. import { Camera } from "babylonjs/Cameras/camera";
  48978. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  48979. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  48980. import { Observable } from "babylonjs/Misc/observable";
  48981. /**
  48982. * WebXR Camera which holds the views for the xrSession
  48983. * @see https://doc.babylonjs.com/how_to/webxr_camera
  48984. */
  48985. export class WebXRCamera extends FreeCamera {
  48986. private _xrSessionManager;
  48987. private _firstFrame;
  48988. private _referenceQuaternion;
  48989. private _referencedPosition;
  48990. private _xrInvPositionCache;
  48991. private _xrInvQuaternionCache;
  48992. /**
  48993. * Observable raised before camera teleportation
  48994. */
  48995. onBeforeCameraTeleport: Observable<Vector3>;
  48996. /**
  48997. * Observable raised after camera teleportation
  48998. */
  48999. onAfterCameraTeleport: Observable<Vector3>;
  49000. /**
  49001. * Should position compensation execute on first frame.
  49002. * This is used when copying the position from a native (non XR) camera
  49003. */
  49004. compensateOnFirstFrame: boolean;
  49005. /**
  49006. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  49007. * @param name the name of the camera
  49008. * @param scene the scene to add the camera to
  49009. * @param _xrSessionManager a constructed xr session manager
  49010. */
  49011. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  49012. /**
  49013. * Return the user's height, unrelated to the current ground.
  49014. * This will be the y position of this camera, when ground level is 0.
  49015. */
  49016. get realWorldHeight(): number;
  49017. /** @hidden */
  49018. _updateForDualEyeDebugging(): void;
  49019. /**
  49020. * Sets this camera's transformation based on a non-vr camera
  49021. * @param otherCamera the non-vr camera to copy the transformation from
  49022. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  49023. */
  49024. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  49025. /**
  49026. * Gets the current instance class name ("WebXRCamera").
  49027. * @returns the class name
  49028. */
  49029. getClassName(): string;
  49030. private _rotate180;
  49031. private _updateFromXRSession;
  49032. private _updateNumberOfRigCameras;
  49033. private _updateReferenceSpace;
  49034. private _updateReferenceSpaceOffset;
  49035. }
  49036. }
  49037. declare module "babylonjs/XR/webXRFeaturesManager" {
  49038. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  49039. import { IDisposable } from "babylonjs/scene";
  49040. /**
  49041. * Defining the interface required for a (webxr) feature
  49042. */
  49043. export interface IWebXRFeature extends IDisposable {
  49044. /**
  49045. * Is this feature attached
  49046. */
  49047. attached: boolean;
  49048. /**
  49049. * Should auto-attach be disabled?
  49050. */
  49051. disableAutoAttach: boolean;
  49052. /**
  49053. * Attach the feature to the session
  49054. * Will usually be called by the features manager
  49055. *
  49056. * @param force should attachment be forced (even when already attached)
  49057. * @returns true if successful.
  49058. */
  49059. attach(force?: boolean): boolean;
  49060. /**
  49061. * Detach the feature from the session
  49062. * Will usually be called by the features manager
  49063. *
  49064. * @returns true if successful.
  49065. */
  49066. detach(): boolean;
  49067. /**
  49068. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  49069. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  49070. *
  49071. * @returns whether or not the feature is compatible in this environment
  49072. */
  49073. isCompatible(): boolean;
  49074. /**
  49075. * Was this feature disposed;
  49076. */
  49077. isDisposed: boolean;
  49078. /**
  49079. * The name of the native xr feature name, if applicable (like anchor, hit-test, or hand-tracking)
  49080. */
  49081. xrNativeFeatureName?: string;
  49082. /**
  49083. * A list of (Babylon WebXR) features this feature depends on
  49084. */
  49085. dependsOn?: string[];
  49086. }
  49087. /**
  49088. * A list of the currently available features without referencing them
  49089. */
  49090. export class WebXRFeatureName {
  49091. /**
  49092. * The name of the anchor system feature
  49093. */
  49094. static readonly ANCHOR_SYSTEM: string;
  49095. /**
  49096. * The name of the background remover feature
  49097. */
  49098. static readonly BACKGROUND_REMOVER: string;
  49099. /**
  49100. * The name of the hit test feature
  49101. */
  49102. static readonly HIT_TEST: string;
  49103. /**
  49104. * physics impostors for xr controllers feature
  49105. */
  49106. static readonly PHYSICS_CONTROLLERS: string;
  49107. /**
  49108. * The name of the plane detection feature
  49109. */
  49110. static readonly PLANE_DETECTION: string;
  49111. /**
  49112. * The name of the pointer selection feature
  49113. */
  49114. static readonly POINTER_SELECTION: string;
  49115. /**
  49116. * The name of the teleportation feature
  49117. */
  49118. static readonly TELEPORTATION: string;
  49119. /**
  49120. * The name of the feature points feature.
  49121. */
  49122. static readonly FEATURE_POINTS: string;
  49123. /**
  49124. * The name of the hand tracking feature.
  49125. */
  49126. static readonly HAND_TRACKING: string;
  49127. }
  49128. /**
  49129. * Defining the constructor of a feature. Used to register the modules.
  49130. */
  49131. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => () => IWebXRFeature;
  49132. /**
  49133. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  49134. * It is mainly used in AR sessions.
  49135. *
  49136. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  49137. */
  49138. export class WebXRFeaturesManager implements IDisposable {
  49139. private _xrSessionManager;
  49140. private static readonly _AvailableFeatures;
  49141. private _features;
  49142. /**
  49143. * constructs a new features manages.
  49144. *
  49145. * @param _xrSessionManager an instance of WebXRSessionManager
  49146. */
  49147. constructor(_xrSessionManager: WebXRSessionManager);
  49148. /**
  49149. * Used to register a module. After calling this function a developer can use this feature in the scene.
  49150. * Mainly used internally.
  49151. *
  49152. * @param featureName the name of the feature to register
  49153. * @param constructorFunction the function used to construct the module
  49154. * @param version the (babylon) version of the module
  49155. * @param stable is that a stable version of this module
  49156. */
  49157. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  49158. /**
  49159. * Returns a constructor of a specific feature.
  49160. *
  49161. * @param featureName the name of the feature to construct
  49162. * @param version the version of the feature to load
  49163. * @param xrSessionManager the xrSessionManager. Used to construct the module
  49164. * @param options optional options provided to the module.
  49165. * @returns a function that, when called, will return a new instance of this feature
  49166. */
  49167. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): () => IWebXRFeature;
  49168. /**
  49169. * Can be used to return the list of features currently registered
  49170. *
  49171. * @returns an Array of available features
  49172. */
  49173. static GetAvailableFeatures(): string[];
  49174. /**
  49175. * Gets the versions available for a specific feature
  49176. * @param featureName the name of the feature
  49177. * @returns an array with the available versions
  49178. */
  49179. static GetAvailableVersions(featureName: string): string[];
  49180. /**
  49181. * Return the latest unstable version of this feature
  49182. * @param featureName the name of the feature to search
  49183. * @returns the version number. if not found will return -1
  49184. */
  49185. static GetLatestVersionOfFeature(featureName: string): number;
  49186. /**
  49187. * Return the latest stable version of this feature
  49188. * @param featureName the name of the feature to search
  49189. * @returns the version number. if not found will return -1
  49190. */
  49191. static GetStableVersionOfFeature(featureName: string): number;
  49192. /**
  49193. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  49194. * Can be used during a session to start a feature
  49195. * @param featureName the name of feature to attach
  49196. */
  49197. attachFeature(featureName: string): void;
  49198. /**
  49199. * Can be used inside a session or when the session ends to detach a specific feature
  49200. * @param featureName the name of the feature to detach
  49201. */
  49202. detachFeature(featureName: string): void;
  49203. /**
  49204. * Used to disable an already-enabled feature
  49205. * The feature will be disposed and will be recreated once enabled.
  49206. * @param featureName the feature to disable
  49207. * @returns true if disable was successful
  49208. */
  49209. disableFeature(featureName: string | {
  49210. Name: string;
  49211. }): boolean;
  49212. /**
  49213. * dispose this features manager
  49214. */
  49215. dispose(): void;
  49216. /**
  49217. * 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.
  49218. * 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.
  49219. *
  49220. * @param featureName the name of the feature to load or the class of the feature
  49221. * @param version optional version to load. if not provided the latest version will be enabled
  49222. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  49223. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  49224. * @param required is this feature required to the app. If set to true the session init will fail if the feature is not available.
  49225. * @returns a new constructed feature or throws an error if feature not found.
  49226. */
  49227. enableFeature(featureName: string | {
  49228. Name: string;
  49229. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean, required?: boolean): IWebXRFeature;
  49230. /**
  49231. * get the implementation of an enabled feature.
  49232. * @param featureName the name of the feature to load
  49233. * @returns the feature class, if found
  49234. */
  49235. getEnabledFeature(featureName: string): IWebXRFeature;
  49236. /**
  49237. * Get the list of enabled features
  49238. * @returns an array of enabled features
  49239. */
  49240. getEnabledFeatures(): string[];
  49241. /**
  49242. * This function will exten the session creation configuration object with enabled features.
  49243. * If, for example, the anchors feature is enabled, it will be automatically added to the optional or required features list,
  49244. * according to the defined "required" variable, provided during enableFeature call
  49245. * @param xrSessionInit the xr Session init object to extend
  49246. *
  49247. * @returns an extended XRSessionInit object
  49248. */
  49249. extendXRSessionInitObject(xrSessionInit: XRSessionInit): XRSessionInit;
  49250. }
  49251. }
  49252. declare module "babylonjs/XR/webXRExperienceHelper" {
  49253. import { Observable } from "babylonjs/Misc/observable";
  49254. import { IDisposable, Scene } from "babylonjs/scene";
  49255. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  49256. import { WebXRCamera } from "babylonjs/XR/webXRCamera";
  49257. import { WebXRState, WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  49258. import { WebXRFeaturesManager } from "babylonjs/XR/webXRFeaturesManager";
  49259. /**
  49260. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  49261. * @see https://doc.babylonjs.com/how_to/webxr_experience_helpers
  49262. */
  49263. export class WebXRExperienceHelper implements IDisposable {
  49264. private scene;
  49265. private _nonVRCamera;
  49266. private _originalSceneAutoClear;
  49267. private _supported;
  49268. /**
  49269. * Camera used to render xr content
  49270. */
  49271. camera: WebXRCamera;
  49272. /** A features manager for this xr session */
  49273. featuresManager: WebXRFeaturesManager;
  49274. /**
  49275. * Observers registered here will be triggered after the camera's initial transformation is set
  49276. * This can be used to set a different ground level or an extra rotation.
  49277. *
  49278. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  49279. * to the position set after this observable is done executing.
  49280. */
  49281. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  49282. /**
  49283. * Fires when the state of the experience helper has changed
  49284. */
  49285. onStateChangedObservable: Observable<WebXRState>;
  49286. /** Session manager used to keep track of xr session */
  49287. sessionManager: WebXRSessionManager;
  49288. /**
  49289. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  49290. */
  49291. state: WebXRState;
  49292. /**
  49293. * Creates a WebXRExperienceHelper
  49294. * @param scene The scene the helper should be created in
  49295. */
  49296. private constructor();
  49297. /**
  49298. * Creates the experience helper
  49299. * @param scene the scene to attach the experience helper to
  49300. * @returns a promise for the experience helper
  49301. */
  49302. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  49303. /**
  49304. * Disposes of the experience helper
  49305. */
  49306. dispose(): void;
  49307. /**
  49308. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  49309. * @param sessionMode options for the XR session
  49310. * @param referenceSpaceType frame of reference of the XR session
  49311. * @param renderTarget the output canvas that will be used to enter XR mode
  49312. * @param sessionCreationOptions optional XRSessionInit object to init the session with
  49313. * @returns promise that resolves after xr mode has entered
  49314. */
  49315. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget, sessionCreationOptions?: XRSessionInit): Promise<WebXRSessionManager>;
  49316. /**
  49317. * Exits XR mode and returns the scene to its original state
  49318. * @returns promise that resolves after xr mode has exited
  49319. */
  49320. exitXRAsync(): Promise<void>;
  49321. private _nonXRToXRCamera;
  49322. private _setState;
  49323. }
  49324. }
  49325. declare module "babylonjs/XR/motionController/webXRControllerComponent" {
  49326. import { IMinimalMotionControllerObject, MotionControllerComponentType } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  49327. import { Observable } from "babylonjs/Misc/observable";
  49328. import { IDisposable } from "babylonjs/scene";
  49329. /**
  49330. * X-Y values for axes in WebXR
  49331. */
  49332. export interface IWebXRMotionControllerAxesValue {
  49333. /**
  49334. * The value of the x axis
  49335. */
  49336. x: number;
  49337. /**
  49338. * The value of the y-axis
  49339. */
  49340. y: number;
  49341. }
  49342. /**
  49343. * changed / previous values for the values of this component
  49344. */
  49345. export interface IWebXRMotionControllerComponentChangesValues<T> {
  49346. /**
  49347. * current (this frame) value
  49348. */
  49349. current: T;
  49350. /**
  49351. * previous (last change) value
  49352. */
  49353. previous: T;
  49354. }
  49355. /**
  49356. * Represents changes in the component between current frame and last values recorded
  49357. */
  49358. export interface IWebXRMotionControllerComponentChanges {
  49359. /**
  49360. * will be populated with previous and current values if axes changed
  49361. */
  49362. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  49363. /**
  49364. * will be populated with previous and current values if pressed changed
  49365. */
  49366. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  49367. /**
  49368. * will be populated with previous and current values if touched changed
  49369. */
  49370. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  49371. /**
  49372. * will be populated with previous and current values if value changed
  49373. */
  49374. value?: IWebXRMotionControllerComponentChangesValues<number>;
  49375. }
  49376. /**
  49377. * This class represents a single component (for example button or thumbstick) of a motion controller
  49378. */
  49379. export class WebXRControllerComponent implements IDisposable {
  49380. /**
  49381. * the id of this component
  49382. */
  49383. id: string;
  49384. /**
  49385. * the type of the component
  49386. */
  49387. type: MotionControllerComponentType;
  49388. private _buttonIndex;
  49389. private _axesIndices;
  49390. private _axes;
  49391. private _changes;
  49392. private _currentValue;
  49393. private _hasChanges;
  49394. private _pressed;
  49395. private _touched;
  49396. /**
  49397. * button component type
  49398. */
  49399. static BUTTON_TYPE: MotionControllerComponentType;
  49400. /**
  49401. * squeeze component type
  49402. */
  49403. static SQUEEZE_TYPE: MotionControllerComponentType;
  49404. /**
  49405. * Thumbstick component type
  49406. */
  49407. static THUMBSTICK_TYPE: MotionControllerComponentType;
  49408. /**
  49409. * Touchpad component type
  49410. */
  49411. static TOUCHPAD_TYPE: MotionControllerComponentType;
  49412. /**
  49413. * trigger component type
  49414. */
  49415. static TRIGGER_TYPE: MotionControllerComponentType;
  49416. /**
  49417. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  49418. * the axes data changes
  49419. */
  49420. onAxisValueChangedObservable: Observable<{
  49421. x: number;
  49422. y: number;
  49423. }>;
  49424. /**
  49425. * Observers registered here will be triggered when the state of a button changes
  49426. * State change is either pressed / touched / value
  49427. */
  49428. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  49429. /**
  49430. * Creates a new component for a motion controller.
  49431. * It is created by the motion controller itself
  49432. *
  49433. * @param id the id of this component
  49434. * @param type the type of the component
  49435. * @param _buttonIndex index in the buttons array of the gamepad
  49436. * @param _axesIndices indices of the values in the axes array of the gamepad
  49437. */
  49438. constructor(
  49439. /**
  49440. * the id of this component
  49441. */
  49442. id: string,
  49443. /**
  49444. * the type of the component
  49445. */
  49446. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  49447. /**
  49448. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  49449. */
  49450. get axes(): IWebXRMotionControllerAxesValue;
  49451. /**
  49452. * Get the changes. Elements will be populated only if they changed with their previous and current value
  49453. */
  49454. get changes(): IWebXRMotionControllerComponentChanges;
  49455. /**
  49456. * Return whether or not the component changed the last frame
  49457. */
  49458. get hasChanges(): boolean;
  49459. /**
  49460. * is the button currently pressed
  49461. */
  49462. get pressed(): boolean;
  49463. /**
  49464. * is the button currently touched
  49465. */
  49466. get touched(): boolean;
  49467. /**
  49468. * Get the current value of this component
  49469. */
  49470. get value(): number;
  49471. /**
  49472. * Dispose this component
  49473. */
  49474. dispose(): void;
  49475. /**
  49476. * Are there axes correlating to this component
  49477. * @return true is axes data is available
  49478. */
  49479. isAxes(): boolean;
  49480. /**
  49481. * Is this component a button (hence - pressable)
  49482. * @returns true if can be pressed
  49483. */
  49484. isButton(): boolean;
  49485. /**
  49486. * update this component using the gamepad object it is in. Called on every frame
  49487. * @param nativeController the native gamepad controller object
  49488. */
  49489. update(nativeController: IMinimalMotionControllerObject): void;
  49490. }
  49491. }
  49492. declare module "babylonjs/Loading/sceneLoader" {
  49493. import { Observable } from "babylonjs/Misc/observable";
  49494. import { Nullable } from "babylonjs/types";
  49495. import { Scene } from "babylonjs/scene";
  49496. import { Engine } from "babylonjs/Engines/engine";
  49497. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49498. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  49499. import { AssetContainer } from "babylonjs/assetContainer";
  49500. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  49501. import { Skeleton } from "babylonjs/Bones/skeleton";
  49502. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  49503. import { WebRequest } from "babylonjs/Misc/webRequest";
  49504. /**
  49505. * Interface used to represent data loading progression
  49506. */
  49507. export interface ISceneLoaderProgressEvent {
  49508. /**
  49509. * Defines if data length to load can be evaluated
  49510. */
  49511. readonly lengthComputable: boolean;
  49512. /**
  49513. * Defines the loaded data length
  49514. */
  49515. readonly loaded: number;
  49516. /**
  49517. * Defines the data length to load
  49518. */
  49519. readonly total: number;
  49520. }
  49521. /**
  49522. * Interface used by SceneLoader plugins to define supported file extensions
  49523. */
  49524. export interface ISceneLoaderPluginExtensions {
  49525. /**
  49526. * Defines the list of supported extensions
  49527. */
  49528. [extension: string]: {
  49529. isBinary: boolean;
  49530. };
  49531. }
  49532. /**
  49533. * Interface used by SceneLoader plugin factory
  49534. */
  49535. export interface ISceneLoaderPluginFactory {
  49536. /**
  49537. * Defines the name of the factory
  49538. */
  49539. name: string;
  49540. /**
  49541. * Function called to create a new plugin
  49542. * @return the new plugin
  49543. */
  49544. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  49545. /**
  49546. * The callback that returns true if the data can be directly loaded.
  49547. * @param data string containing the file data
  49548. * @returns if the data can be loaded directly
  49549. */
  49550. canDirectLoad?(data: string): boolean;
  49551. }
  49552. /**
  49553. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  49554. */
  49555. export interface ISceneLoaderPluginBase {
  49556. /**
  49557. * The friendly name of this plugin.
  49558. */
  49559. name: string;
  49560. /**
  49561. * The file extensions supported by this plugin.
  49562. */
  49563. extensions: string | ISceneLoaderPluginExtensions;
  49564. /**
  49565. * The callback called when loading from a url.
  49566. * @param scene scene loading this url
  49567. * @param url url to load
  49568. * @param onSuccess callback called when the file successfully loads
  49569. * @param onProgress callback called while file is loading (if the server supports this mode)
  49570. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  49571. * @param onError callback called when the file fails to load
  49572. * @returns a file request object
  49573. */
  49574. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  49575. /**
  49576. * The callback called when loading from a file object.
  49577. * @param scene scene loading this file
  49578. * @param file defines the file to load
  49579. * @param onSuccess defines the callback to call when data is loaded
  49580. * @param onProgress defines the callback to call during loading process
  49581. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  49582. * @param onError defines the callback to call when an error occurs
  49583. * @returns a file request object
  49584. */
  49585. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  49586. /**
  49587. * The callback that returns true if the data can be directly loaded.
  49588. * @param data string containing the file data
  49589. * @returns if the data can be loaded directly
  49590. */
  49591. canDirectLoad?(data: string): boolean;
  49592. /**
  49593. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  49594. * @param scene scene loading this data
  49595. * @param data string containing the data
  49596. * @returns data to pass to the plugin
  49597. */
  49598. directLoad?(scene: Scene, data: string): any;
  49599. /**
  49600. * The callback that allows custom handling of the root url based on the response url.
  49601. * @param rootUrl the original root url
  49602. * @param responseURL the response url if available
  49603. * @returns the new root url
  49604. */
  49605. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  49606. }
  49607. /**
  49608. * Interface used to define a SceneLoader plugin
  49609. */
  49610. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  49611. /**
  49612. * Import meshes into a scene.
  49613. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  49614. * @param scene The scene to import into
  49615. * @param data The data to import
  49616. * @param rootUrl The root url for scene and resources
  49617. * @param meshes The meshes array to import into
  49618. * @param particleSystems The particle systems array to import into
  49619. * @param skeletons The skeletons array to import into
  49620. * @param onError The callback when import fails
  49621. * @returns True if successful or false otherwise
  49622. */
  49623. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  49624. /**
  49625. * Load into a scene.
  49626. * @param scene The scene to load into
  49627. * @param data The data to import
  49628. * @param rootUrl The root url for scene and resources
  49629. * @param onError The callback when import fails
  49630. * @returns True if successful or false otherwise
  49631. */
  49632. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  49633. /**
  49634. * Load into an asset container.
  49635. * @param scene The scene to load into
  49636. * @param data The data to import
  49637. * @param rootUrl The root url for scene and resources
  49638. * @param onError The callback when import fails
  49639. * @returns The loaded asset container
  49640. */
  49641. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  49642. }
  49643. /**
  49644. * Interface used to define an async SceneLoader plugin
  49645. */
  49646. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  49647. /**
  49648. * Import meshes into a scene.
  49649. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  49650. * @param scene The scene to import into
  49651. * @param data The data to import
  49652. * @param rootUrl The root url for scene and resources
  49653. * @param onProgress The callback when the load progresses
  49654. * @param fileName Defines the name of the file to load
  49655. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  49656. */
  49657. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  49658. meshes: AbstractMesh[];
  49659. particleSystems: IParticleSystem[];
  49660. skeletons: Skeleton[];
  49661. animationGroups: AnimationGroup[];
  49662. }>;
  49663. /**
  49664. * Load into a scene.
  49665. * @param scene The scene to load into
  49666. * @param data The data to import
  49667. * @param rootUrl The root url for scene and resources
  49668. * @param onProgress The callback when the load progresses
  49669. * @param fileName Defines the name of the file to load
  49670. * @returns Nothing
  49671. */
  49672. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  49673. /**
  49674. * Load into an asset container.
  49675. * @param scene The scene to load into
  49676. * @param data The data to import
  49677. * @param rootUrl The root url for scene and resources
  49678. * @param onProgress The callback when the load progresses
  49679. * @param fileName Defines the name of the file to load
  49680. * @returns The loaded asset container
  49681. */
  49682. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  49683. }
  49684. /**
  49685. * Mode that determines how to handle old animation groups before loading new ones.
  49686. */
  49687. export enum SceneLoaderAnimationGroupLoadingMode {
  49688. /**
  49689. * Reset all old animations to initial state then dispose them.
  49690. */
  49691. Clean = 0,
  49692. /**
  49693. * Stop all old animations.
  49694. */
  49695. Stop = 1,
  49696. /**
  49697. * Restart old animations from first frame.
  49698. */
  49699. Sync = 2,
  49700. /**
  49701. * Old animations remains untouched.
  49702. */
  49703. NoSync = 3
  49704. }
  49705. /**
  49706. * Defines a plugin registered by the SceneLoader
  49707. */
  49708. interface IRegisteredPlugin {
  49709. /**
  49710. * Defines the plugin to use
  49711. */
  49712. plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  49713. /**
  49714. * Defines if the plugin supports binary data
  49715. */
  49716. isBinary: boolean;
  49717. }
  49718. /**
  49719. * Class used to load scene from various file formats using registered plugins
  49720. * @see https://doc.babylonjs.com/how_to/load_from_any_file_type
  49721. */
  49722. export class SceneLoader {
  49723. /**
  49724. * No logging while loading
  49725. */
  49726. static readonly NO_LOGGING: number;
  49727. /**
  49728. * Minimal logging while loading
  49729. */
  49730. static readonly MINIMAL_LOGGING: number;
  49731. /**
  49732. * Summary logging while loading
  49733. */
  49734. static readonly SUMMARY_LOGGING: number;
  49735. /**
  49736. * Detailled logging while loading
  49737. */
  49738. static readonly DETAILED_LOGGING: number;
  49739. /**
  49740. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  49741. */
  49742. static get ForceFullSceneLoadingForIncremental(): boolean;
  49743. static set ForceFullSceneLoadingForIncremental(value: boolean);
  49744. /**
  49745. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  49746. */
  49747. static get ShowLoadingScreen(): boolean;
  49748. static set ShowLoadingScreen(value: boolean);
  49749. /**
  49750. * Defines the current logging level (while loading the scene)
  49751. * @ignorenaming
  49752. */
  49753. static get loggingLevel(): number;
  49754. static set loggingLevel(value: number);
  49755. /**
  49756. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  49757. */
  49758. static get CleanBoneMatrixWeights(): boolean;
  49759. static set CleanBoneMatrixWeights(value: boolean);
  49760. /**
  49761. * Event raised when a plugin is used to load a scene
  49762. */
  49763. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  49764. private static _registeredPlugins;
  49765. private static _showingLoadingScreen;
  49766. /**
  49767. * Gets the default plugin (used to load Babylon files)
  49768. * @returns the .babylon plugin
  49769. */
  49770. static GetDefaultPlugin(): IRegisteredPlugin;
  49771. private static _GetPluginForExtension;
  49772. private static _GetPluginForDirectLoad;
  49773. private static _GetPluginForFilename;
  49774. private static _GetDirectLoad;
  49775. private static _LoadData;
  49776. private static _GetFileInfo;
  49777. /**
  49778. * Gets a plugin that can load the given extension
  49779. * @param extension defines the extension to load
  49780. * @returns a plugin or null if none works
  49781. */
  49782. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  49783. /**
  49784. * Gets a boolean indicating that the given extension can be loaded
  49785. * @param extension defines the extension to load
  49786. * @returns true if the extension is supported
  49787. */
  49788. static IsPluginForExtensionAvailable(extension: string): boolean;
  49789. /**
  49790. * Adds a new plugin to the list of registered plugins
  49791. * @param plugin defines the plugin to add
  49792. */
  49793. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  49794. /**
  49795. * Import meshes into a scene
  49796. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  49797. * @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)
  49798. * @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)
  49799. * @param scene the instance of BABYLON.Scene to append to
  49800. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  49801. * @param onProgress a callback with a progress event for each file being loaded
  49802. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  49803. * @param pluginExtension the extension used to determine the plugin
  49804. * @returns The loaded plugin
  49805. */
  49806. 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>;
  49807. /**
  49808. * Import meshes into a scene
  49809. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  49810. * @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)
  49811. * @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)
  49812. * @param scene the instance of BABYLON.Scene to append to
  49813. * @param onProgress a callback with a progress event for each file being loaded
  49814. * @param pluginExtension the extension used to determine the plugin
  49815. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  49816. */
  49817. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  49818. meshes: AbstractMesh[];
  49819. particleSystems: IParticleSystem[];
  49820. skeletons: Skeleton[];
  49821. animationGroups: AnimationGroup[];
  49822. }>;
  49823. /**
  49824. * Load a scene
  49825. * @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)
  49826. * @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)
  49827. * @param engine is the instance of BABYLON.Engine to use to create the scene
  49828. * @param onSuccess a callback with the scene when import succeeds
  49829. * @param onProgress a callback with a progress event for each file being loaded
  49830. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  49831. * @param pluginExtension the extension used to determine the plugin
  49832. * @returns The loaded plugin
  49833. */
  49834. 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>;
  49835. /**
  49836. * Load a scene
  49837. * @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)
  49838. * @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)
  49839. * @param engine is the instance of BABYLON.Engine to use to create the scene
  49840. * @param onProgress a callback with a progress event for each file being loaded
  49841. * @param pluginExtension the extension used to determine the plugin
  49842. * @returns The loaded scene
  49843. */
  49844. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  49845. /**
  49846. * Append a scene
  49847. * @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)
  49848. * @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)
  49849. * @param scene is the instance of BABYLON.Scene to append to
  49850. * @param onSuccess a callback with the scene when import succeeds
  49851. * @param onProgress a callback with a progress event for each file being loaded
  49852. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  49853. * @param pluginExtension the extension used to determine the plugin
  49854. * @returns The loaded plugin
  49855. */
  49856. 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>;
  49857. /**
  49858. * Append a scene
  49859. * @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)
  49860. * @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)
  49861. * @param scene is the instance of BABYLON.Scene to append to
  49862. * @param onProgress a callback with a progress event for each file being loaded
  49863. * @param pluginExtension the extension used to determine the plugin
  49864. * @returns The given scene
  49865. */
  49866. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  49867. /**
  49868. * Load a scene into an asset container
  49869. * @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)
  49870. * @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)
  49871. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  49872. * @param onSuccess a callback with the scene when import succeeds
  49873. * @param onProgress a callback with a progress event for each file being loaded
  49874. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  49875. * @param pluginExtension the extension used to determine the plugin
  49876. * @returns The loaded plugin
  49877. */
  49878. 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>;
  49879. /**
  49880. * Load a scene into an asset container
  49881. * @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)
  49882. * @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)
  49883. * @param scene is the instance of Scene to append to
  49884. * @param onProgress a callback with a progress event for each file being loaded
  49885. * @param pluginExtension the extension used to determine the plugin
  49886. * @returns The loaded asset container
  49887. */
  49888. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  49889. /**
  49890. * Import animations from a file into a scene
  49891. * @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)
  49892. * @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)
  49893. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  49894. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  49895. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  49896. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  49897. * @param onSuccess a callback with the scene when import succeeds
  49898. * @param onProgress a callback with a progress event for each file being loaded
  49899. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  49900. * @param pluginExtension the extension used to determine the plugin
  49901. */
  49902. 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;
  49903. /**
  49904. * Import animations from a file into a scene
  49905. * @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)
  49906. * @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)
  49907. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  49908. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  49909. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  49910. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  49911. * @param onSuccess a callback with the scene when import succeeds
  49912. * @param onProgress a callback with a progress event for each file being loaded
  49913. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  49914. * @param pluginExtension the extension used to determine the plugin
  49915. * @returns the updated scene with imported animations
  49916. */
  49917. 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>;
  49918. }
  49919. }
  49920. declare module "babylonjs/XR/motionController/webXRAbstractMotionController" {
  49921. import { IDisposable, Scene } from "babylonjs/scene";
  49922. import { WebXRControllerComponent } from "babylonjs/XR/motionController/webXRControllerComponent";
  49923. import { Observable } from "babylonjs/Misc/observable";
  49924. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49925. import { Nullable } from "babylonjs/types";
  49926. /**
  49927. * Handedness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  49928. */
  49929. export type MotionControllerHandedness = "none" | "left" | "right";
  49930. /**
  49931. * The type of components available in motion controllers.
  49932. * This is not the name of the component.
  49933. */
  49934. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  49935. /**
  49936. * The state of a controller component
  49937. */
  49938. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  49939. /**
  49940. * The schema of motion controller layout.
  49941. * No object will be initialized using this interface
  49942. * This is used just to define the profile.
  49943. */
  49944. export interface IMotionControllerLayout {
  49945. /**
  49946. * Path to load the assets. Usually relative to the base path
  49947. */
  49948. assetPath: string;
  49949. /**
  49950. * Available components (unsorted)
  49951. */
  49952. components: {
  49953. /**
  49954. * A map of component Ids
  49955. */
  49956. [componentId: string]: {
  49957. /**
  49958. * The type of input the component outputs
  49959. */
  49960. type: MotionControllerComponentType;
  49961. /**
  49962. * The indices of this component in the gamepad object
  49963. */
  49964. gamepadIndices: {
  49965. /**
  49966. * Index of button
  49967. */
  49968. button?: number;
  49969. /**
  49970. * If available, index of x-axis
  49971. */
  49972. xAxis?: number;
  49973. /**
  49974. * If available, index of y-axis
  49975. */
  49976. yAxis?: number;
  49977. };
  49978. /**
  49979. * The mesh's root node name
  49980. */
  49981. rootNodeName: string;
  49982. /**
  49983. * Animation definitions for this model
  49984. */
  49985. visualResponses: {
  49986. [stateKey: string]: {
  49987. /**
  49988. * What property will be animated
  49989. */
  49990. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  49991. /**
  49992. * What states influence this visual response
  49993. */
  49994. states: MotionControllerComponentStateType[];
  49995. /**
  49996. * Type of animation - movement or visibility
  49997. */
  49998. valueNodeProperty: "transform" | "visibility";
  49999. /**
  50000. * Base node name to move. Its position will be calculated according to the min and max nodes
  50001. */
  50002. valueNodeName?: string;
  50003. /**
  50004. * Minimum movement node
  50005. */
  50006. minNodeName?: string;
  50007. /**
  50008. * Max movement node
  50009. */
  50010. maxNodeName?: string;
  50011. };
  50012. };
  50013. /**
  50014. * If touch enabled, what is the name of node to display user feedback
  50015. */
  50016. touchPointNodeName?: string;
  50017. };
  50018. };
  50019. /**
  50020. * Is it xr standard mapping or not
  50021. */
  50022. gamepadMapping: "" | "xr-standard";
  50023. /**
  50024. * Base root node of this entire model
  50025. */
  50026. rootNodeName: string;
  50027. /**
  50028. * Defines the main button component id
  50029. */
  50030. selectComponentId: string;
  50031. }
  50032. /**
  50033. * A definition for the layout map in the input profile
  50034. */
  50035. export interface IMotionControllerLayoutMap {
  50036. /**
  50037. * Layouts with handedness type as a key
  50038. */
  50039. [handedness: string]: IMotionControllerLayout;
  50040. }
  50041. /**
  50042. * The XR Input profile schema
  50043. * Profiles can be found here:
  50044. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  50045. */
  50046. export interface IMotionControllerProfile {
  50047. /**
  50048. * fallback profiles for this profileId
  50049. */
  50050. fallbackProfileIds: string[];
  50051. /**
  50052. * The layout map, with handedness as key
  50053. */
  50054. layouts: IMotionControllerLayoutMap;
  50055. /**
  50056. * The id of this profile
  50057. * correlates to the profile(s) in the xrInput.profiles array
  50058. */
  50059. profileId: string;
  50060. }
  50061. /**
  50062. * A helper-interface for the 3 meshes needed for controller button animation
  50063. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  50064. */
  50065. export interface IMotionControllerButtonMeshMap {
  50066. /**
  50067. * the mesh that defines the pressed value mesh position.
  50068. * This is used to find the max-position of this button
  50069. */
  50070. pressedMesh: AbstractMesh;
  50071. /**
  50072. * the mesh that defines the unpressed value mesh position.
  50073. * This is used to find the min (or initial) position of this button
  50074. */
  50075. unpressedMesh: AbstractMesh;
  50076. /**
  50077. * The mesh that will be changed when value changes
  50078. */
  50079. valueMesh: AbstractMesh;
  50080. }
  50081. /**
  50082. * A helper-interface for the 3 meshes needed for controller axis animation.
  50083. * This will be expanded when touchpad animations are fully supported
  50084. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  50085. */
  50086. export interface IMotionControllerMeshMap {
  50087. /**
  50088. * the mesh that defines the maximum value mesh position.
  50089. */
  50090. maxMesh?: AbstractMesh;
  50091. /**
  50092. * the mesh that defines the minimum value mesh position.
  50093. */
  50094. minMesh?: AbstractMesh;
  50095. /**
  50096. * The mesh that will be changed when axis value changes
  50097. */
  50098. valueMesh?: AbstractMesh;
  50099. }
  50100. /**
  50101. * The elements needed for change-detection of the gamepad objects in motion controllers
  50102. */
  50103. export interface IMinimalMotionControllerObject {
  50104. /**
  50105. * Available axes of this controller
  50106. */
  50107. axes: number[];
  50108. /**
  50109. * An array of available buttons
  50110. */
  50111. buttons: Array<{
  50112. /**
  50113. * Value of the button/trigger
  50114. */
  50115. value: number;
  50116. /**
  50117. * If the button/trigger is currently touched
  50118. */
  50119. touched: boolean;
  50120. /**
  50121. * If the button/trigger is currently pressed
  50122. */
  50123. pressed: boolean;
  50124. }>;
  50125. /**
  50126. * EXPERIMENTAL haptic support.
  50127. */
  50128. hapticActuators?: Array<{
  50129. pulse: (value: number, duration: number) => Promise<boolean>;
  50130. }>;
  50131. }
  50132. /**
  50133. * An Abstract Motion controller
  50134. * This class receives an xrInput and a profile layout and uses those to initialize the components
  50135. * Each component has an observable to check for changes in value and state
  50136. */
  50137. export abstract class WebXRAbstractMotionController implements IDisposable {
  50138. protected scene: Scene;
  50139. protected layout: IMotionControllerLayout;
  50140. /**
  50141. * The gamepad object correlating to this controller
  50142. */
  50143. gamepadObject: IMinimalMotionControllerObject;
  50144. /**
  50145. * handedness (left/right/none) of this controller
  50146. */
  50147. handedness: MotionControllerHandedness;
  50148. private _initComponent;
  50149. private _modelReady;
  50150. /**
  50151. * A map of components (WebXRControllerComponent) in this motion controller
  50152. * Components have a ComponentType and can also have both button and axis definitions
  50153. */
  50154. readonly components: {
  50155. [id: string]: WebXRControllerComponent;
  50156. };
  50157. /**
  50158. * Disable the model's animation. Can be set at any time.
  50159. */
  50160. disableAnimation: boolean;
  50161. /**
  50162. * Observers registered here will be triggered when the model of this controller is done loading
  50163. */
  50164. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  50165. /**
  50166. * The profile id of this motion controller
  50167. */
  50168. abstract profileId: string;
  50169. /**
  50170. * The root mesh of the model. It is null if the model was not yet initialized
  50171. */
  50172. rootMesh: Nullable<AbstractMesh>;
  50173. /**
  50174. * constructs a new abstract motion controller
  50175. * @param scene the scene to which the model of the controller will be added
  50176. * @param layout The profile layout to load
  50177. * @param gamepadObject The gamepad object correlating to this controller
  50178. * @param handedness handedness (left/right/none) of this controller
  50179. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  50180. */
  50181. constructor(scene: Scene, layout: IMotionControllerLayout,
  50182. /**
  50183. * The gamepad object correlating to this controller
  50184. */
  50185. gamepadObject: IMinimalMotionControllerObject,
  50186. /**
  50187. * handedness (left/right/none) of this controller
  50188. */
  50189. handedness: MotionControllerHandedness, _doNotLoadControllerMesh?: boolean);
  50190. /**
  50191. * Dispose this controller, the model mesh and all its components
  50192. */
  50193. dispose(): void;
  50194. /**
  50195. * Returns all components of specific type
  50196. * @param type the type to search for
  50197. * @return an array of components with this type
  50198. */
  50199. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  50200. /**
  50201. * get a component based an its component id as defined in layout.components
  50202. * @param id the id of the component
  50203. * @returns the component correlates to the id or undefined if not found
  50204. */
  50205. getComponent(id: string): WebXRControllerComponent;
  50206. /**
  50207. * Get the list of components available in this motion controller
  50208. * @returns an array of strings correlating to available components
  50209. */
  50210. getComponentIds(): string[];
  50211. /**
  50212. * Get the first component of specific type
  50213. * @param type type of component to find
  50214. * @return a controller component or null if not found
  50215. */
  50216. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  50217. /**
  50218. * Get the main (Select) component of this controller as defined in the layout
  50219. * @returns the main component of this controller
  50220. */
  50221. getMainComponent(): WebXRControllerComponent;
  50222. /**
  50223. * Loads the model correlating to this controller
  50224. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  50225. * @returns A promise fulfilled with the result of the model loading
  50226. */
  50227. loadModel(): Promise<boolean>;
  50228. /**
  50229. * Update this model using the current XRFrame
  50230. * @param xrFrame the current xr frame to use and update the model
  50231. */
  50232. updateFromXRFrame(xrFrame: XRFrame): void;
  50233. /**
  50234. * Backwards compatibility due to a deeply-integrated typo
  50235. */
  50236. get handness(): XREye;
  50237. /**
  50238. * Pulse (vibrate) this controller
  50239. * If the controller does not support pulses, this function will fail silently and return Promise<false> directly after called
  50240. * Consecutive calls to this function will cancel the last pulse call
  50241. *
  50242. * @param value the strength of the pulse in 0.0...1.0 range
  50243. * @param duration Duration of the pulse in milliseconds
  50244. * @param hapticActuatorIndex optional index of actuator (will usually be 0)
  50245. * @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
  50246. */
  50247. pulse(value: number, duration: number, hapticActuatorIndex?: number): Promise<boolean>;
  50248. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  50249. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  50250. /**
  50251. * Moves the axis on the controller mesh based on its current state
  50252. * @param axis the index of the axis
  50253. * @param axisValue the value of the axis which determines the meshes new position
  50254. * @hidden
  50255. */
  50256. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  50257. /**
  50258. * Update the model itself with the current frame data
  50259. * @param xrFrame the frame to use for updating the model mesh
  50260. */
  50261. protected updateModel(xrFrame: XRFrame): void;
  50262. /**
  50263. * Get the filename and path for this controller's model
  50264. * @returns a map of filename and path
  50265. */
  50266. protected abstract _getFilenameAndPath(): {
  50267. filename: string;
  50268. path: string;
  50269. };
  50270. /**
  50271. * This function is called before the mesh is loaded. It checks for loading constraints.
  50272. * For example, this function can check if the GLB loader is available
  50273. * If this function returns false, the generic controller will be loaded instead
  50274. * @returns Is the client ready to load the mesh
  50275. */
  50276. protected abstract _getModelLoadingConstraints(): boolean;
  50277. /**
  50278. * This function will be called after the model was successfully loaded and can be used
  50279. * for mesh transformations before it is available for the user
  50280. * @param meshes the loaded meshes
  50281. */
  50282. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  50283. /**
  50284. * Set the root mesh for this controller. Important for the WebXR controller class
  50285. * @param meshes the loaded meshes
  50286. */
  50287. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  50288. /**
  50289. * A function executed each frame that updates the mesh (if needed)
  50290. * @param xrFrame the current xrFrame
  50291. */
  50292. protected abstract _updateModel(xrFrame: XRFrame): void;
  50293. private _getGenericFilenameAndPath;
  50294. private _getGenericParentMesh;
  50295. }
  50296. }
  50297. declare module "babylonjs/XR/motionController/webXRGenericMotionController" {
  50298. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandedness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  50299. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50300. import { Scene } from "babylonjs/scene";
  50301. /**
  50302. * A generic trigger-only motion controller for WebXR
  50303. */
  50304. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  50305. /**
  50306. * Static version of the profile id of this controller
  50307. */
  50308. static ProfileId: string;
  50309. profileId: string;
  50310. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  50311. protected _getFilenameAndPath(): {
  50312. filename: string;
  50313. path: string;
  50314. };
  50315. protected _getModelLoadingConstraints(): boolean;
  50316. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  50317. protected _setRootMesh(meshes: AbstractMesh[]): void;
  50318. protected _updateModel(): void;
  50319. }
  50320. }
  50321. declare module "babylonjs/Meshes/Builders/sphereBuilder" {
  50322. import { Vector4 } from "babylonjs/Maths/math.vector";
  50323. import { Mesh } from "babylonjs/Meshes/mesh";
  50324. import { Scene } from "babylonjs/scene";
  50325. import { Nullable } from "babylonjs/types";
  50326. /**
  50327. * Class containing static functions to help procedurally build meshes
  50328. */
  50329. export class SphereBuilder {
  50330. /**
  50331. * Creates a sphere mesh
  50332. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  50333. * * 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`)
  50334. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  50335. * * 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
  50336. * * 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)
  50337. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50338. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50339. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50340. * @param name defines the name of the mesh
  50341. * @param options defines the options used to create the mesh
  50342. * @param scene defines the hosting scene
  50343. * @returns the sphere mesh
  50344. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  50345. */
  50346. static CreateSphere(name: string, options: {
  50347. segments?: number;
  50348. diameter?: number;
  50349. diameterX?: number;
  50350. diameterY?: number;
  50351. diameterZ?: number;
  50352. arc?: number;
  50353. slice?: number;
  50354. sideOrientation?: number;
  50355. frontUVs?: Vector4;
  50356. backUVs?: Vector4;
  50357. updatable?: boolean;
  50358. }, scene?: Nullable<Scene>): Mesh;
  50359. }
  50360. }
  50361. declare module "babylonjs/XR/motionController/webXRProfiledMotionController" {
  50362. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50363. import { WebXRAbstractMotionController, IMotionControllerProfile } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  50364. import { Scene } from "babylonjs/scene";
  50365. /**
  50366. * A profiled motion controller has its profile loaded from an online repository.
  50367. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  50368. */
  50369. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  50370. private _repositoryUrl;
  50371. private _buttonMeshMapping;
  50372. private _touchDots;
  50373. /**
  50374. * The profile ID of this controller. Will be populated when the controller initializes.
  50375. */
  50376. profileId: string;
  50377. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  50378. dispose(): void;
  50379. protected _getFilenameAndPath(): {
  50380. filename: string;
  50381. path: string;
  50382. };
  50383. protected _getModelLoadingConstraints(): boolean;
  50384. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  50385. protected _setRootMesh(meshes: AbstractMesh[]): void;
  50386. protected _updateModel(_xrFrame: XRFrame): void;
  50387. }
  50388. }
  50389. declare module "babylonjs/XR/motionController/webXRMotionControllerManager" {
  50390. import { WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  50391. import { Scene } from "babylonjs/scene";
  50392. /**
  50393. * A construction function type to create a new controller based on an xrInput object
  50394. */
  50395. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  50396. /**
  50397. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  50398. *
  50399. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  50400. * it should be replaced with auto-loaded controllers.
  50401. *
  50402. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  50403. */
  50404. export class WebXRMotionControllerManager {
  50405. private static _AvailableControllers;
  50406. private static _Fallbacks;
  50407. private static _ProfileLoadingPromises;
  50408. private static _ProfilesList;
  50409. /**
  50410. * The base URL of the online controller repository. Can be changed at any time.
  50411. */
  50412. static BaseRepositoryUrl: string;
  50413. /**
  50414. * Which repository gets priority - local or online
  50415. */
  50416. static PrioritizeOnlineRepository: boolean;
  50417. /**
  50418. * Use the online repository, or use only locally-defined controllers
  50419. */
  50420. static UseOnlineRepository: boolean;
  50421. /**
  50422. * Clear the cache used for profile loading and reload when requested again
  50423. */
  50424. static ClearProfilesCache(): void;
  50425. /**
  50426. * Register the default fallbacks.
  50427. * This function is called automatically when this file is imported.
  50428. */
  50429. static DefaultFallbacks(): void;
  50430. /**
  50431. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  50432. * @param profileId the profile to which a fallback needs to be found
  50433. * @return an array with corresponding fallback profiles
  50434. */
  50435. static FindFallbackWithProfileId(profileId: string): string[];
  50436. /**
  50437. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  50438. * The order of search:
  50439. *
  50440. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  50441. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  50442. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  50443. * 4) return the generic trigger controller if none were found
  50444. *
  50445. * @param xrInput the xrInput to which a new controller is initialized
  50446. * @param scene the scene to which the model will be added
  50447. * @param forceProfile force a certain profile for this controller
  50448. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  50449. */
  50450. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  50451. /**
  50452. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  50453. *
  50454. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  50455. *
  50456. * @param type the profile type to register
  50457. * @param constructFunction the function to be called when loading this profile
  50458. */
  50459. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  50460. /**
  50461. * Register a fallback to a specific profile.
  50462. * @param profileId the profileId that will receive the fallbacks
  50463. * @param fallbacks A list of fallback profiles
  50464. */
  50465. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  50466. /**
  50467. * Will update the list of profiles available in the repository
  50468. * @return a promise that resolves to a map of profiles available online
  50469. */
  50470. static UpdateProfilesList(): Promise<{
  50471. [profile: string]: string;
  50472. }>;
  50473. private static _LoadProfileFromRepository;
  50474. private static _LoadProfilesFromAvailableControllers;
  50475. }
  50476. }
  50477. declare module "babylonjs/XR/webXRInputSource" {
  50478. import { Observable } from "babylonjs/Misc/observable";
  50479. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50480. import { Ray } from "babylonjs/Culling/ray";
  50481. import { Scene } from "babylonjs/scene";
  50482. import { WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  50483. /**
  50484. * Configuration options for the WebXR controller creation
  50485. */
  50486. export interface IWebXRControllerOptions {
  50487. /**
  50488. * Should the controller mesh be animated when a user interacts with it
  50489. * The pressed buttons / thumbstick and touchpad animations will be disabled
  50490. */
  50491. disableMotionControllerAnimation?: boolean;
  50492. /**
  50493. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  50494. */
  50495. doNotLoadControllerMesh?: boolean;
  50496. /**
  50497. * Force a specific controller type for this controller.
  50498. * This can be used when creating your own profile or when testing different controllers
  50499. */
  50500. forceControllerProfile?: string;
  50501. /**
  50502. * Defines a rendering group ID for meshes that will be loaded.
  50503. * This is for the default controllers only.
  50504. */
  50505. renderingGroupId?: number;
  50506. }
  50507. /**
  50508. * Represents an XR controller
  50509. */
  50510. export class WebXRInputSource {
  50511. private _scene;
  50512. /** The underlying input source for the controller */
  50513. inputSource: XRInputSource;
  50514. private _options;
  50515. private _tmpVector;
  50516. private _uniqueId;
  50517. private _disposed;
  50518. /**
  50519. * 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
  50520. */
  50521. grip?: AbstractMesh;
  50522. /**
  50523. * If available, this is the gamepad object related to this controller.
  50524. * Using this object it is possible to get click events and trackpad changes of the
  50525. * webxr controller that is currently being used.
  50526. */
  50527. motionController?: WebXRAbstractMotionController;
  50528. /**
  50529. * Event that fires when the controller is removed/disposed.
  50530. * The object provided as event data is this controller, after associated assets were disposed.
  50531. * uniqueId is still available.
  50532. */
  50533. onDisposeObservable: Observable<WebXRInputSource>;
  50534. /**
  50535. * Will be triggered when the mesh associated with the motion controller is done loading.
  50536. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  50537. * A shortened version of controller -> motion controller -> on mesh loaded.
  50538. */
  50539. onMeshLoadedObservable: Observable<AbstractMesh>;
  50540. /**
  50541. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  50542. */
  50543. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  50544. /**
  50545. * Pointer which can be used to select objects or attach a visible laser to
  50546. */
  50547. pointer: AbstractMesh;
  50548. /**
  50549. * Creates the input source object
  50550. * @see https://doc.babylonjs.com/how_to/webxr_controllers_support
  50551. * @param _scene the scene which the controller should be associated to
  50552. * @param inputSource the underlying input source for the controller
  50553. * @param _options options for this controller creation
  50554. */
  50555. constructor(_scene: Scene,
  50556. /** The underlying input source for the controller */
  50557. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  50558. /**
  50559. * Get this controllers unique id
  50560. */
  50561. get uniqueId(): string;
  50562. /**
  50563. * Disposes of the object
  50564. */
  50565. dispose(): void;
  50566. /**
  50567. * Gets a world space ray coming from the pointer or grip
  50568. * @param result the resulting ray
  50569. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  50570. */
  50571. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  50572. /**
  50573. * Updates the controller pose based on the given XRFrame
  50574. * @param xrFrame xr frame to update the pose with
  50575. * @param referenceSpace reference space to use
  50576. */
  50577. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  50578. }
  50579. }
  50580. declare module "babylonjs/XR/webXRInput" {
  50581. import { Observable } from "babylonjs/Misc/observable";
  50582. import { IDisposable } from "babylonjs/scene";
  50583. import { WebXRInputSource, IWebXRControllerOptions } from "babylonjs/XR/webXRInputSource";
  50584. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  50585. import { WebXRCamera } from "babylonjs/XR/webXRCamera";
  50586. /**
  50587. * The schema for initialization options of the XR Input class
  50588. */
  50589. export interface IWebXRInputOptions {
  50590. /**
  50591. * If set to true no model will be automatically loaded
  50592. */
  50593. doNotLoadControllerMeshes?: boolean;
  50594. /**
  50595. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  50596. * If not found, the xr input profile data will be used.
  50597. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  50598. */
  50599. forceInputProfile?: string;
  50600. /**
  50601. * Do not send a request to the controller repository to load the profile.
  50602. *
  50603. * Instead, use the controllers available in babylon itself.
  50604. */
  50605. disableOnlineControllerRepository?: boolean;
  50606. /**
  50607. * A custom URL for the controllers repository
  50608. */
  50609. customControllersRepositoryURL?: string;
  50610. /**
  50611. * Should the controller model's components not move according to the user input
  50612. */
  50613. disableControllerAnimation?: boolean;
  50614. /**
  50615. * Optional options to pass to the controller. Will be overridden by the Input options where applicable
  50616. */
  50617. controllerOptions?: IWebXRControllerOptions;
  50618. }
  50619. /**
  50620. * XR input used to track XR inputs such as controllers/rays
  50621. */
  50622. export class WebXRInput implements IDisposable {
  50623. /**
  50624. * the xr session manager for this session
  50625. */
  50626. xrSessionManager: WebXRSessionManager;
  50627. /**
  50628. * the WebXR camera for this session. Mainly used for teleportation
  50629. */
  50630. xrCamera: WebXRCamera;
  50631. private readonly options;
  50632. /**
  50633. * XR controllers being tracked
  50634. */
  50635. controllers: Array<WebXRInputSource>;
  50636. private _frameObserver;
  50637. private _sessionEndedObserver;
  50638. private _sessionInitObserver;
  50639. /**
  50640. * Event when a controller has been connected/added
  50641. */
  50642. onControllerAddedObservable: Observable<WebXRInputSource>;
  50643. /**
  50644. * Event when a controller has been removed/disconnected
  50645. */
  50646. onControllerRemovedObservable: Observable<WebXRInputSource>;
  50647. /**
  50648. * Initializes the WebXRInput
  50649. * @param xrSessionManager the xr session manager for this session
  50650. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  50651. * @param options = initialization options for this xr input
  50652. */
  50653. constructor(
  50654. /**
  50655. * the xr session manager for this session
  50656. */
  50657. xrSessionManager: WebXRSessionManager,
  50658. /**
  50659. * the WebXR camera for this session. Mainly used for teleportation
  50660. */
  50661. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  50662. private _onInputSourcesChange;
  50663. private _addAndRemoveControllers;
  50664. /**
  50665. * Disposes of the object
  50666. */
  50667. dispose(): void;
  50668. }
  50669. }
  50670. declare module "babylonjs/XR/features/WebXRAbstractFeature" {
  50671. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  50672. import { Observable, EventState } from "babylonjs/Misc/observable";
  50673. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  50674. /**
  50675. * This is the base class for all WebXR features.
  50676. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  50677. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  50678. */
  50679. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  50680. protected _xrSessionManager: WebXRSessionManager;
  50681. private _attached;
  50682. private _removeOnDetach;
  50683. /**
  50684. * Is this feature disposed?
  50685. */
  50686. isDisposed: boolean;
  50687. /**
  50688. * Should auto-attach be disabled?
  50689. */
  50690. disableAutoAttach: boolean;
  50691. /**
  50692. * The name of the native xr feature name (like anchor, hit-test, or hand-tracking)
  50693. */
  50694. xrNativeFeatureName: string;
  50695. /**
  50696. * Construct a new (abstract) WebXR feature
  50697. * @param _xrSessionManager the xr session manager for this feature
  50698. */
  50699. constructor(_xrSessionManager: WebXRSessionManager);
  50700. /**
  50701. * Is this feature attached
  50702. */
  50703. get attached(): boolean;
  50704. /**
  50705. * attach this feature
  50706. *
  50707. * @param force should attachment be forced (even when already attached)
  50708. * @returns true if successful, false is failed or already attached
  50709. */
  50710. attach(force?: boolean): boolean;
  50711. /**
  50712. * detach this feature.
  50713. *
  50714. * @returns true if successful, false if failed or already detached
  50715. */
  50716. detach(): boolean;
  50717. /**
  50718. * Dispose this feature and all of the resources attached
  50719. */
  50720. dispose(): void;
  50721. /**
  50722. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  50723. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  50724. *
  50725. * @returns whether or not the feature is compatible in this environment
  50726. */
  50727. isCompatible(): boolean;
  50728. /**
  50729. * This is used to register callbacks that will automatically be removed when detach is called.
  50730. * @param observable the observable to which the observer will be attached
  50731. * @param callback the callback to register
  50732. */
  50733. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  50734. /**
  50735. * Code in this function will be executed on each xrFrame received from the browser.
  50736. * This function will not execute after the feature is detached.
  50737. * @param _xrFrame the current frame
  50738. */
  50739. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  50740. }
  50741. }
  50742. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  50743. import { IDisposable, Scene } from "babylonjs/scene";
  50744. import { Nullable } from "babylonjs/types";
  50745. import { Observable } from "babylonjs/Misc/observable";
  50746. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50747. import { HemisphericLight } from "babylonjs/Lights/hemisphericLight";
  50748. import { Camera } from "babylonjs/Cameras/camera";
  50749. /**
  50750. * Renders a layer on top of an existing scene
  50751. */
  50752. export class UtilityLayerRenderer implements IDisposable {
  50753. /** the original scene that will be rendered on top of */
  50754. originalScene: Scene;
  50755. private _pointerCaptures;
  50756. private _lastPointerEvents;
  50757. private static _DefaultUtilityLayer;
  50758. private static _DefaultKeepDepthUtilityLayer;
  50759. private _sharedGizmoLight;
  50760. private _renderCamera;
  50761. /**
  50762. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  50763. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  50764. * @returns the camera that is used when rendering the utility layer
  50765. */
  50766. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  50767. /**
  50768. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  50769. * @param cam the camera that should be used when rendering the utility layer
  50770. */
  50771. setRenderCamera(cam: Nullable<Camera>): void;
  50772. /**
  50773. * @hidden
  50774. * Light which used by gizmos to get light shading
  50775. */
  50776. _getSharedGizmoLight(): HemisphericLight;
  50777. /**
  50778. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  50779. */
  50780. pickUtilitySceneFirst: boolean;
  50781. /**
  50782. * 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)
  50783. */
  50784. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  50785. /**
  50786. * 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)
  50787. */
  50788. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  50789. /**
  50790. * The scene that is rendered on top of the original scene
  50791. */
  50792. utilityLayerScene: Scene;
  50793. /**
  50794. * If the utility layer should automatically be rendered on top of existing scene
  50795. */
  50796. shouldRender: boolean;
  50797. /**
  50798. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  50799. */
  50800. onlyCheckPointerDownEvents: boolean;
  50801. /**
  50802. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  50803. */
  50804. processAllEvents: boolean;
  50805. /**
  50806. * Observable raised when the pointer move from the utility layer scene to the main scene
  50807. */
  50808. onPointerOutObservable: Observable<number>;
  50809. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  50810. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  50811. private _afterRenderObserver;
  50812. private _sceneDisposeObserver;
  50813. private _originalPointerObserver;
  50814. /**
  50815. * Instantiates a UtilityLayerRenderer
  50816. * @param originalScene the original scene that will be rendered on top of
  50817. * @param handleEvents boolean indicating if the utility layer should handle events
  50818. */
  50819. constructor(
  50820. /** the original scene that will be rendered on top of */
  50821. originalScene: Scene, handleEvents?: boolean);
  50822. private _notifyObservers;
  50823. /**
  50824. * Renders the utility layers scene on top of the original scene
  50825. */
  50826. render(): void;
  50827. /**
  50828. * Disposes of the renderer
  50829. */
  50830. dispose(): void;
  50831. private _updateCamera;
  50832. }
  50833. }
  50834. declare module "babylonjs/XR/features/WebXRControllerPointerSelection" {
  50835. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  50836. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50837. import { WebXRInput } from "babylonjs/XR/webXRInput";
  50838. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  50839. import { Scene } from "babylonjs/scene";
  50840. import { Nullable } from "babylonjs/types";
  50841. import { Color3 } from "babylonjs/Maths/math.color";
  50842. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  50843. import { WebXRCamera } from "babylonjs/XR/webXRCamera";
  50844. /**
  50845. * Options interface for the pointer selection module
  50846. */
  50847. export interface IWebXRControllerPointerSelectionOptions {
  50848. /**
  50849. * if provided, this scene will be used to render meshes.
  50850. */
  50851. customUtilityLayerScene?: Scene;
  50852. /**
  50853. * 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)
  50854. * If not disabled, the last picked point will be used to execute a pointer up event
  50855. * If disabled, pointer up event will be triggered right after the pointer down event.
  50856. * Used in screen and gaze target ray mode only
  50857. */
  50858. disablePointerUpOnTouchOut: boolean;
  50859. /**
  50860. * For gaze mode for tracked-pointer / controllers (time to select instead of button press)
  50861. */
  50862. forceGazeMode: boolean;
  50863. /**
  50864. * 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
  50865. * to start a new countdown to the pointer down event.
  50866. * Defaults to 1.
  50867. */
  50868. gazeModePointerMovedFactor?: number;
  50869. /**
  50870. * Different button type to use instead of the main component
  50871. */
  50872. overrideButtonId?: string;
  50873. /**
  50874. * use this rendering group id for the meshes (optional)
  50875. */
  50876. renderingGroupId?: number;
  50877. /**
  50878. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  50879. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  50880. * 3000 means 3 seconds between pointing at something and selecting it
  50881. */
  50882. timeToSelect?: number;
  50883. /**
  50884. * Should meshes created here be added to a utility layer or the main scene
  50885. */
  50886. useUtilityLayer?: boolean;
  50887. /**
  50888. * Optional WebXR camera to be used for gaze selection
  50889. */
  50890. gazeCamera?: WebXRCamera;
  50891. /**
  50892. * the xr input to use with this pointer selection
  50893. */
  50894. xrInput: WebXRInput;
  50895. }
  50896. /**
  50897. * A module that will enable pointer selection for motion controllers of XR Input Sources
  50898. */
  50899. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  50900. private readonly _options;
  50901. private static _idCounter;
  50902. private _attachController;
  50903. private _controllers;
  50904. private _scene;
  50905. private _tmpVectorForPickCompare;
  50906. /**
  50907. * The module's name
  50908. */
  50909. static readonly Name: string;
  50910. /**
  50911. * The (Babylon) version of this module.
  50912. * This is an integer representing the implementation version.
  50913. * This number does not correspond to the WebXR specs version
  50914. */
  50915. static readonly Version: number;
  50916. /**
  50917. * Disable lighting on the laser pointer (so it will always be visible)
  50918. */
  50919. disablePointerLighting: boolean;
  50920. /**
  50921. * Disable lighting on the selection mesh (so it will always be visible)
  50922. */
  50923. disableSelectionMeshLighting: boolean;
  50924. /**
  50925. * Should the laser pointer be displayed
  50926. */
  50927. displayLaserPointer: boolean;
  50928. /**
  50929. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  50930. */
  50931. displaySelectionMesh: boolean;
  50932. /**
  50933. * This color will be set to the laser pointer when selection is triggered
  50934. */
  50935. laserPointerPickedColor: Color3;
  50936. /**
  50937. * Default color of the laser pointer
  50938. */
  50939. laserPointerDefaultColor: Color3;
  50940. /**
  50941. * default color of the selection ring
  50942. */
  50943. selectionMeshDefaultColor: Color3;
  50944. /**
  50945. * This color will be applied to the selection ring when selection is triggered
  50946. */
  50947. selectionMeshPickedColor: Color3;
  50948. /**
  50949. * Optional filter to be used for ray selection. This predicate shares behavior with
  50950. * scene.pointerMovePredicate which takes priority if it is also assigned.
  50951. */
  50952. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  50953. /**
  50954. * constructs a new background remover module
  50955. * @param _xrSessionManager the session manager for this module
  50956. * @param _options read-only options to be used in this module
  50957. */
  50958. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  50959. /**
  50960. * attach this feature
  50961. * Will usually be called by the features manager
  50962. *
  50963. * @returns true if successful.
  50964. */
  50965. attach(): boolean;
  50966. /**
  50967. * detach this feature.
  50968. * Will usually be called by the features manager
  50969. *
  50970. * @returns true if successful.
  50971. */
  50972. detach(): boolean;
  50973. /**
  50974. * Will get the mesh under a specific pointer.
  50975. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  50976. * @param controllerId the controllerId to check
  50977. * @returns The mesh under pointer or null if no mesh is under the pointer
  50978. */
  50979. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  50980. /**
  50981. * Get the xr controller that correlates to the pointer id in the pointer event
  50982. *
  50983. * @param id the pointer id to search for
  50984. * @returns the controller that correlates to this id or null if not found
  50985. */
  50986. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  50987. protected _onXRFrame(_xrFrame: XRFrame): void;
  50988. private _attachGazeMode;
  50989. private _attachScreenRayMode;
  50990. private _attachTrackedPointerRayMode;
  50991. private _convertNormalToDirectionOfRay;
  50992. private _detachController;
  50993. private _generateNewMeshPair;
  50994. private _pickingMoved;
  50995. private _updatePointerDistance;
  50996. /** @hidden */
  50997. get lasterPointerDefaultColor(): Color3;
  50998. }
  50999. }
  51000. declare module "babylonjs/XR/webXREnterExitUI" {
  51001. import { Nullable } from "babylonjs/types";
  51002. import { Observable } from "babylonjs/Misc/observable";
  51003. import { IDisposable, Scene } from "babylonjs/scene";
  51004. import { WebXRExperienceHelper } from "babylonjs/XR/webXRExperienceHelper";
  51005. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  51006. /**
  51007. * Button which can be used to enter a different mode of XR
  51008. */
  51009. export class WebXREnterExitUIButton {
  51010. /** button element */
  51011. element: HTMLElement;
  51012. /** XR initialization options for the button */
  51013. sessionMode: XRSessionMode;
  51014. /** Reference space type */
  51015. referenceSpaceType: XRReferenceSpaceType;
  51016. /**
  51017. * Creates a WebXREnterExitUIButton
  51018. * @param element button element
  51019. * @param sessionMode XR initialization session mode
  51020. * @param referenceSpaceType the type of reference space to be used
  51021. */
  51022. constructor(
  51023. /** button element */
  51024. element: HTMLElement,
  51025. /** XR initialization options for the button */
  51026. sessionMode: XRSessionMode,
  51027. /** Reference space type */
  51028. referenceSpaceType: XRReferenceSpaceType);
  51029. /**
  51030. * Extendable function which can be used to update the button's visuals when the state changes
  51031. * @param activeButton the current active button in the UI
  51032. */
  51033. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  51034. }
  51035. /**
  51036. * Options to create the webXR UI
  51037. */
  51038. export class WebXREnterExitUIOptions {
  51039. /**
  51040. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  51041. */
  51042. customButtons?: Array<WebXREnterExitUIButton>;
  51043. /**
  51044. * A reference space type to use when creating the default button.
  51045. * Default is local-floor
  51046. */
  51047. referenceSpaceType?: XRReferenceSpaceType;
  51048. /**
  51049. * Context to enter xr with
  51050. */
  51051. renderTarget?: Nullable<WebXRRenderTarget>;
  51052. /**
  51053. * A session mode to use when creating the default button.
  51054. * Default is immersive-vr
  51055. */
  51056. sessionMode?: XRSessionMode;
  51057. /**
  51058. * A list of optional features to init the session with
  51059. */
  51060. optionalFeatures?: string[];
  51061. /**
  51062. * A list of optional features to init the session with
  51063. */
  51064. requiredFeatures?: string[];
  51065. }
  51066. /**
  51067. * UI to allow the user to enter/exit XR mode
  51068. */
  51069. export class WebXREnterExitUI implements IDisposable {
  51070. private scene;
  51071. /** version of the options passed to this UI */
  51072. options: WebXREnterExitUIOptions;
  51073. private _activeButton;
  51074. private _buttons;
  51075. /**
  51076. * The HTML Div Element to which buttons are added.
  51077. */
  51078. readonly overlay: HTMLDivElement;
  51079. /**
  51080. * Fired every time the active button is changed.
  51081. *
  51082. * When xr is entered via a button that launches xr that button will be the callback parameter
  51083. *
  51084. * When exiting xr the callback parameter will be null)
  51085. */
  51086. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  51087. /**
  51088. *
  51089. * @param scene babylon scene object to use
  51090. * @param options (read-only) version of the options passed to this UI
  51091. */
  51092. private constructor();
  51093. /**
  51094. * Creates UI to allow the user to enter/exit XR mode
  51095. * @param scene the scene to add the ui to
  51096. * @param helper the xr experience helper to enter/exit xr with
  51097. * @param options options to configure the UI
  51098. * @returns the created ui
  51099. */
  51100. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  51101. /**
  51102. * Disposes of the XR UI component
  51103. */
  51104. dispose(): void;
  51105. private _updateButtons;
  51106. }
  51107. }
  51108. declare module "babylonjs/Meshes/Builders/linesBuilder" {
  51109. import { Vector3 } from "babylonjs/Maths/math.vector";
  51110. import { Color4 } from "babylonjs/Maths/math.color";
  51111. import { Nullable } from "babylonjs/types";
  51112. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  51113. import { Scene } from "babylonjs/scene";
  51114. /**
  51115. * Class containing static functions to help procedurally build meshes
  51116. */
  51117. export class LinesBuilder {
  51118. /**
  51119. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  51120. * * 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
  51121. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  51122. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  51123. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  51124. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  51125. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  51126. * * 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
  51127. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  51128. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51129. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  51130. * @param name defines the name of the new line system
  51131. * @param options defines the options used to create the line system
  51132. * @param scene defines the hosting scene
  51133. * @returns a new line system mesh
  51134. */
  51135. static CreateLineSystem(name: string, options: {
  51136. lines: Vector3[][];
  51137. updatable?: boolean;
  51138. instance?: Nullable<LinesMesh>;
  51139. colors?: Nullable<Color4[][]>;
  51140. useVertexAlpha?: boolean;
  51141. }, scene: Nullable<Scene>): LinesMesh;
  51142. /**
  51143. * Creates a line mesh
  51144. * 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
  51145. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  51146. * * The parameter `points` is an array successive Vector3
  51147. * * 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
  51148. * * The optional parameter `colors` is an array of successive Color4, one per line point
  51149. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  51150. * * When updating an instance, remember that only point positions can change, not the number of points
  51151. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51152. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  51153. * @param name defines the name of the new line system
  51154. * @param options defines the options used to create the line system
  51155. * @param scene defines the hosting scene
  51156. * @returns a new line mesh
  51157. */
  51158. static CreateLines(name: string, options: {
  51159. points: Vector3[];
  51160. updatable?: boolean;
  51161. instance?: Nullable<LinesMesh>;
  51162. colors?: Color4[];
  51163. useVertexAlpha?: boolean;
  51164. }, scene?: Nullable<Scene>): LinesMesh;
  51165. /**
  51166. * Creates a dashed line mesh
  51167. * * 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
  51168. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  51169. * * The parameter `points` is an array successive Vector3
  51170. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  51171. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  51172. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  51173. * * 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
  51174. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  51175. * * When updating an instance, remember that only point positions can change, not the number of points
  51176. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51177. * @param name defines the name of the mesh
  51178. * @param options defines the options used to create the mesh
  51179. * @param scene defines the hosting scene
  51180. * @returns the dashed line mesh
  51181. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  51182. */
  51183. static CreateDashedLines(name: string, options: {
  51184. points: Vector3[];
  51185. dashSize?: number;
  51186. gapSize?: number;
  51187. dashNb?: number;
  51188. updatable?: boolean;
  51189. instance?: LinesMesh;
  51190. useVertexAlpha?: boolean;
  51191. }, scene?: Nullable<Scene>): LinesMesh;
  51192. }
  51193. }
  51194. declare module "babylonjs/Misc/timer" {
  51195. import { Observable, Observer } from "babylonjs/Misc/observable";
  51196. import { Nullable } from "babylonjs/types";
  51197. import { IDisposable } from "babylonjs/scene";
  51198. /**
  51199. * Construction options for a timer
  51200. */
  51201. export interface ITimerOptions<T> {
  51202. /**
  51203. * Time-to-end
  51204. */
  51205. timeout: number;
  51206. /**
  51207. * The context observable is used to calculate time deltas and provides the context of the timer's callbacks. Will usually be OnBeforeRenderObservable.
  51208. * Countdown calculation is done ONLY when the observable is notifying its observers, meaning that if
  51209. * you choose an observable that doesn't trigger too often, the wait time might extend further than the requested max time
  51210. */
  51211. contextObservable: Observable<T>;
  51212. /**
  51213. * Optional parameters when adding an observer to the observable
  51214. */
  51215. observableParameters?: {
  51216. mask?: number;
  51217. insertFirst?: boolean;
  51218. scope?: any;
  51219. };
  51220. /**
  51221. * An optional break condition that will stop the times prematurely. In this case onEnded will not be triggered!
  51222. */
  51223. breakCondition?: (data?: ITimerData<T>) => boolean;
  51224. /**
  51225. * Will be triggered when the time condition has met
  51226. */
  51227. onEnded?: (data: ITimerData<any>) => void;
  51228. /**
  51229. * Will be triggered when the break condition has met (prematurely ended)
  51230. */
  51231. onAborted?: (data: ITimerData<any>) => void;
  51232. /**
  51233. * Optional function to execute on each tick (or count)
  51234. */
  51235. onTick?: (data: ITimerData<any>) => void;
  51236. }
  51237. /**
  51238. * An interface defining the data sent by the timer
  51239. */
  51240. export interface ITimerData<T> {
  51241. /**
  51242. * When did it start
  51243. */
  51244. startTime: number;
  51245. /**
  51246. * Time now
  51247. */
  51248. currentTime: number;
  51249. /**
  51250. * Time passed since started
  51251. */
  51252. deltaTime: number;
  51253. /**
  51254. * How much is completed, in [0.0...1.0].
  51255. * Note that this CAN be higher than 1 due to the fact that we don't actually measure time but delta between observable calls
  51256. */
  51257. completeRate: number;
  51258. /**
  51259. * What the registered observable sent in the last count
  51260. */
  51261. payload: T;
  51262. }
  51263. /**
  51264. * The current state of the timer
  51265. */
  51266. export enum TimerState {
  51267. /**
  51268. * Timer initialized, not yet started
  51269. */
  51270. INIT = 0,
  51271. /**
  51272. * Timer started and counting
  51273. */
  51274. STARTED = 1,
  51275. /**
  51276. * Timer ended (whether aborted or time reached)
  51277. */
  51278. ENDED = 2
  51279. }
  51280. /**
  51281. * A simple version of the timer. Will take options and start the timer immediately after calling it
  51282. *
  51283. * @param options options with which to initialize this timer
  51284. */
  51285. export function setAndStartTimer(options: ITimerOptions<any>): Nullable<Observer<any>>;
  51286. /**
  51287. * An advanced implementation of a timer class
  51288. */
  51289. export class AdvancedTimer<T = any> implements IDisposable {
  51290. /**
  51291. * Will notify each time the timer calculates the remaining time
  51292. */
  51293. onEachCountObservable: Observable<ITimerData<T>>;
  51294. /**
  51295. * Will trigger when the timer was aborted due to the break condition
  51296. */
  51297. onTimerAbortedObservable: Observable<ITimerData<T>>;
  51298. /**
  51299. * Will trigger when the timer ended successfully
  51300. */
  51301. onTimerEndedObservable: Observable<ITimerData<T>>;
  51302. /**
  51303. * Will trigger when the timer state has changed
  51304. */
  51305. onStateChangedObservable: Observable<TimerState>;
  51306. private _observer;
  51307. private _contextObservable;
  51308. private _observableParameters;
  51309. private _startTime;
  51310. private _timer;
  51311. private _state;
  51312. private _breakCondition;
  51313. private _timeToEnd;
  51314. private _breakOnNextTick;
  51315. /**
  51316. * Will construct a new advanced timer based on the options provided. Timer will not start until start() is called.
  51317. * @param options construction options for this advanced timer
  51318. */
  51319. constructor(options: ITimerOptions<T>);
  51320. /**
  51321. * set a breaking condition for this timer. Default is to never break during count
  51322. * @param predicate the new break condition. Returns true to break, false otherwise
  51323. */
  51324. set breakCondition(predicate: (data: ITimerData<T>) => boolean);
  51325. /**
  51326. * Reset ALL associated observables in this advanced timer
  51327. */
  51328. clearObservables(): void;
  51329. /**
  51330. * Will start a new iteration of this timer. Only one instance of this timer can run at a time.
  51331. *
  51332. * @param timeToEnd how much time to measure until timer ended
  51333. */
  51334. start(timeToEnd?: number): void;
  51335. /**
  51336. * Will force a stop on the next tick.
  51337. */
  51338. stop(): void;
  51339. /**
  51340. * Dispose this timer, clearing all resources
  51341. */
  51342. dispose(): void;
  51343. private _setState;
  51344. private _tick;
  51345. private _stop;
  51346. }
  51347. }
  51348. declare module "babylonjs/XR/features/WebXRControllerTeleportation" {
  51349. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  51350. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  51351. import { Nullable } from "babylonjs/types";
  51352. import { WebXRInput } from "babylonjs/XR/webXRInput";
  51353. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51354. import { Vector3 } from "babylonjs/Maths/math.vector";
  51355. import { Material } from "babylonjs/Materials/material";
  51356. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  51357. import { Scene } from "babylonjs/scene";
  51358. /**
  51359. * The options container for the teleportation module
  51360. */
  51361. export interface IWebXRTeleportationOptions {
  51362. /**
  51363. * if provided, this scene will be used to render meshes.
  51364. */
  51365. customUtilityLayerScene?: Scene;
  51366. /**
  51367. * Values to configure the default target mesh
  51368. */
  51369. defaultTargetMeshOptions?: {
  51370. /**
  51371. * Fill color of the teleportation area
  51372. */
  51373. teleportationFillColor?: string;
  51374. /**
  51375. * Border color for the teleportation area
  51376. */
  51377. teleportationBorderColor?: string;
  51378. /**
  51379. * Disable the mesh's animation sequence
  51380. */
  51381. disableAnimation?: boolean;
  51382. /**
  51383. * Disable lighting on the material or the ring and arrow
  51384. */
  51385. disableLighting?: boolean;
  51386. /**
  51387. * Override the default material of the torus and arrow
  51388. */
  51389. torusArrowMaterial?: Material;
  51390. };
  51391. /**
  51392. * A list of meshes to use as floor meshes.
  51393. * Meshes can be added and removed after initializing the feature using the
  51394. * addFloorMesh and removeFloorMesh functions
  51395. * If empty, rotation will still work
  51396. */
  51397. floorMeshes?: AbstractMesh[];
  51398. /**
  51399. * use this rendering group id for the meshes (optional)
  51400. */
  51401. renderingGroupId?: number;
  51402. /**
  51403. * Should teleportation move only to snap points
  51404. */
  51405. snapPointsOnly?: boolean;
  51406. /**
  51407. * An array of points to which the teleportation will snap to.
  51408. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  51409. */
  51410. snapPositions?: Vector3[];
  51411. /**
  51412. * How close should the teleportation ray be in order to snap to position.
  51413. * Default to 0.8 units (meters)
  51414. */
  51415. snapToPositionRadius?: number;
  51416. /**
  51417. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  51418. * If you want to support rotation, make sure your mesh has a direction indicator.
  51419. *
  51420. * When left untouched, the default mesh will be initialized.
  51421. */
  51422. teleportationTargetMesh?: AbstractMesh;
  51423. /**
  51424. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  51425. */
  51426. timeToTeleport?: number;
  51427. /**
  51428. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  51429. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  51430. */
  51431. useMainComponentOnly?: boolean;
  51432. /**
  51433. * Should meshes created here be added to a utility layer or the main scene
  51434. */
  51435. useUtilityLayer?: boolean;
  51436. /**
  51437. * Babylon XR Input class for controller
  51438. */
  51439. xrInput: WebXRInput;
  51440. /**
  51441. * Meshes that the teleportation ray cannot go through
  51442. */
  51443. pickBlockerMeshes?: AbstractMesh[];
  51444. }
  51445. /**
  51446. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  51447. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  51448. * the input of the attached controllers.
  51449. */
  51450. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  51451. private _options;
  51452. private _controllers;
  51453. private _currentTeleportationControllerId;
  51454. private _floorMeshes;
  51455. private _quadraticBezierCurve;
  51456. private _selectionFeature;
  51457. private _snapToPositions;
  51458. private _snappedToPoint;
  51459. private _teleportationRingMaterial?;
  51460. private _tmpRay;
  51461. private _tmpVector;
  51462. private _tmpQuaternion;
  51463. /**
  51464. * The module's name
  51465. */
  51466. static readonly Name: string;
  51467. /**
  51468. * The (Babylon) version of this module.
  51469. * This is an integer representing the implementation version.
  51470. * This number does not correspond to the webxr specs version
  51471. */
  51472. static readonly Version: number;
  51473. /**
  51474. * Is movement backwards enabled
  51475. */
  51476. backwardsMovementEnabled: boolean;
  51477. /**
  51478. * Distance to travel when moving backwards
  51479. */
  51480. backwardsTeleportationDistance: number;
  51481. /**
  51482. * The distance from the user to the inspection point in the direction of the controller
  51483. * A higher number will allow the user to move further
  51484. * defaults to 5 (meters, in xr units)
  51485. */
  51486. parabolicCheckRadius: number;
  51487. /**
  51488. * Should the module support parabolic ray on top of direct ray
  51489. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  51490. * Very helpful when moving between floors / different heights
  51491. */
  51492. parabolicRayEnabled: boolean;
  51493. /**
  51494. * How much rotation should be applied when rotating right and left
  51495. */
  51496. rotationAngle: number;
  51497. /**
  51498. * Is rotation enabled when moving forward?
  51499. * Disabling this feature will prevent the user from deciding the direction when teleporting
  51500. */
  51501. rotationEnabled: boolean;
  51502. /**
  51503. * constructs a new anchor system
  51504. * @param _xrSessionManager an instance of WebXRSessionManager
  51505. * @param _options configuration object for this feature
  51506. */
  51507. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  51508. /**
  51509. * Get the snapPointsOnly flag
  51510. */
  51511. get snapPointsOnly(): boolean;
  51512. /**
  51513. * Sets the snapPointsOnly flag
  51514. * @param snapToPoints should teleportation be exclusively to snap points
  51515. */
  51516. set snapPointsOnly(snapToPoints: boolean);
  51517. /**
  51518. * Add a new mesh to the floor meshes array
  51519. * @param mesh the mesh to use as floor mesh
  51520. */
  51521. addFloorMesh(mesh: AbstractMesh): void;
  51522. /**
  51523. * Add a new snap-to point to fix teleportation to this position
  51524. * @param newSnapPoint The new Snap-To point
  51525. */
  51526. addSnapPoint(newSnapPoint: Vector3): void;
  51527. attach(): boolean;
  51528. detach(): boolean;
  51529. dispose(): void;
  51530. /**
  51531. * Remove a mesh from the floor meshes array
  51532. * @param mesh the mesh to remove
  51533. */
  51534. removeFloorMesh(mesh: AbstractMesh): void;
  51535. /**
  51536. * Remove a mesh from the floor meshes array using its name
  51537. * @param name the mesh name to remove
  51538. */
  51539. removeFloorMeshByName(name: string): void;
  51540. /**
  51541. * 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
  51542. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  51543. * @returns was the point found and removed or not
  51544. */
  51545. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  51546. /**
  51547. * This function sets a selection feature that will be disabled when
  51548. * the forward ray is shown and will be reattached when hidden.
  51549. * This is used to remove the selection rays when moving.
  51550. * @param selectionFeature the feature to disable when forward movement is enabled
  51551. */
  51552. setSelectionFeature(selectionFeature: Nullable<IWebXRFeature>): void;
  51553. protected _onXRFrame(_xrFrame: XRFrame): void;
  51554. private _attachController;
  51555. private _createDefaultTargetMesh;
  51556. private _detachController;
  51557. private _findClosestSnapPointWithRadius;
  51558. private _setTargetMeshPosition;
  51559. private _setTargetMeshVisibility;
  51560. private _showParabolicPath;
  51561. private _teleportForward;
  51562. }
  51563. }
  51564. declare module "babylonjs/XR/webXRDefaultExperience" {
  51565. import { WebXRExperienceHelper } from "babylonjs/XR/webXRExperienceHelper";
  51566. import { Scene } from "babylonjs/scene";
  51567. import { WebXRInput, IWebXRInputOptions } from "babylonjs/XR/webXRInput";
  51568. import { WebXRControllerPointerSelection } from "babylonjs/XR/features/WebXRControllerPointerSelection";
  51569. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  51570. import { WebXREnterExitUI, WebXREnterExitUIOptions } from "babylonjs/XR/webXREnterExitUI";
  51571. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51572. import { WebXRManagedOutputCanvasOptions } from "babylonjs/XR/webXRManagedOutputCanvas";
  51573. import { WebXRMotionControllerTeleportation } from "babylonjs/XR/features/WebXRControllerTeleportation";
  51574. /**
  51575. * Options for the default xr helper
  51576. */
  51577. export class WebXRDefaultExperienceOptions {
  51578. /**
  51579. * Enable or disable default UI to enter XR
  51580. */
  51581. disableDefaultUI?: boolean;
  51582. /**
  51583. * Should teleportation not initialize. defaults to false.
  51584. */
  51585. disableTeleportation?: boolean;
  51586. /**
  51587. * Floor meshes that will be used for teleport
  51588. */
  51589. floorMeshes?: Array<AbstractMesh>;
  51590. /**
  51591. * If set to true, the first frame will not be used to reset position
  51592. * The first frame is mainly used when copying transformation from the old camera
  51593. * Mainly used in AR
  51594. */
  51595. ignoreNativeCameraTransformation?: boolean;
  51596. /**
  51597. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  51598. */
  51599. inputOptions?: IWebXRInputOptions;
  51600. /**
  51601. * optional configuration for the output canvas
  51602. */
  51603. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  51604. /**
  51605. * optional UI options. This can be used among other to change session mode and reference space type
  51606. */
  51607. uiOptions?: WebXREnterExitUIOptions;
  51608. /**
  51609. * When loading teleportation and pointer select, use stable versions instead of latest.
  51610. */
  51611. useStablePlugins?: boolean;
  51612. /**
  51613. * An optional rendering group id that will be set globally for teleportation, pointer selection and default controller meshes
  51614. */
  51615. renderingGroupId?: number;
  51616. /**
  51617. * A list of optional features to init the session with
  51618. * If set to true, all features we support will be added
  51619. */
  51620. optionalFeatures?: boolean | string[];
  51621. }
  51622. /**
  51623. * Default experience which provides a similar setup to the previous webVRExperience
  51624. */
  51625. export class WebXRDefaultExperience {
  51626. /**
  51627. * Base experience
  51628. */
  51629. baseExperience: WebXRExperienceHelper;
  51630. /**
  51631. * Enables ui for entering/exiting xr
  51632. */
  51633. enterExitUI: WebXREnterExitUI;
  51634. /**
  51635. * Input experience extension
  51636. */
  51637. input: WebXRInput;
  51638. /**
  51639. * Enables laser pointer and selection
  51640. */
  51641. pointerSelection: WebXRControllerPointerSelection;
  51642. /**
  51643. * Default target xr should render to
  51644. */
  51645. renderTarget: WebXRRenderTarget;
  51646. /**
  51647. * Enables teleportation
  51648. */
  51649. teleportation: WebXRMotionControllerTeleportation;
  51650. private constructor();
  51651. /**
  51652. * Creates the default xr experience
  51653. * @param scene scene
  51654. * @param options options for basic configuration
  51655. * @returns resulting WebXRDefaultExperience
  51656. */
  51657. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  51658. /**
  51659. * DIsposes of the experience helper
  51660. */
  51661. dispose(): void;
  51662. }
  51663. }
  51664. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  51665. import { Observable } from "babylonjs/Misc/observable";
  51666. import { Nullable } from "babylonjs/types";
  51667. import { Camera } from "babylonjs/Cameras/camera";
  51668. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  51669. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  51670. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  51671. import { Scene } from "babylonjs/scene";
  51672. import { Vector3 } from "babylonjs/Maths/math.vector";
  51673. import { Color3 } from "babylonjs/Maths/math.color";
  51674. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  51675. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51676. import { Mesh } from "babylonjs/Meshes/mesh";
  51677. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  51678. import { EasingFunction } from "babylonjs/Animations/easing";
  51679. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  51680. import "babylonjs/Meshes/Builders/groundBuilder";
  51681. import "babylonjs/Meshes/Builders/torusBuilder";
  51682. import "babylonjs/Meshes/Builders/cylinderBuilder";
  51683. import "babylonjs/Gamepads/gamepadSceneComponent";
  51684. import "babylonjs/Animations/animatable";
  51685. import { WebXRDefaultExperience } from "babylonjs/XR/webXRDefaultExperience";
  51686. /**
  51687. * Options to modify the vr teleportation behavior.
  51688. */
  51689. export interface VRTeleportationOptions {
  51690. /**
  51691. * The name of the mesh which should be used as the teleportation floor. (default: null)
  51692. */
  51693. floorMeshName?: string;
  51694. /**
  51695. * A list of meshes to be used as the teleportation floor. (default: empty)
  51696. */
  51697. floorMeshes?: Mesh[];
  51698. /**
  51699. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  51700. */
  51701. teleportationMode?: number;
  51702. /**
  51703. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  51704. */
  51705. teleportationTime?: number;
  51706. /**
  51707. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  51708. */
  51709. teleportationSpeed?: number;
  51710. /**
  51711. * The easing function used in the animation or null for Linear. (default CircleEase)
  51712. */
  51713. easingFunction?: EasingFunction;
  51714. }
  51715. /**
  51716. * Options to modify the vr experience helper's behavior.
  51717. */
  51718. export interface VRExperienceHelperOptions extends WebVROptions {
  51719. /**
  51720. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  51721. */
  51722. createDeviceOrientationCamera?: boolean;
  51723. /**
  51724. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  51725. */
  51726. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  51727. /**
  51728. * Uses the main button on the controller to toggle the laser casted. (default: true)
  51729. */
  51730. laserToggle?: boolean;
  51731. /**
  51732. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  51733. */
  51734. floorMeshes?: Mesh[];
  51735. /**
  51736. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  51737. */
  51738. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  51739. /**
  51740. * Defines if WebXR should be used instead of WebVR (if available)
  51741. */
  51742. useXR?: boolean;
  51743. }
  51744. /**
  51745. * Event containing information after VR has been entered
  51746. */
  51747. export class OnAfterEnteringVRObservableEvent {
  51748. /**
  51749. * If entering vr was successful
  51750. */
  51751. success: boolean;
  51752. }
  51753. /**
  51754. * Helps to quickly add VR support to an existing scene.
  51755. * See https://doc.babylonjs.com/how_to/webvr_helper
  51756. */
  51757. export class VRExperienceHelper {
  51758. /** Options to modify the vr experience helper's behavior. */
  51759. webVROptions: VRExperienceHelperOptions;
  51760. private _scene;
  51761. private _position;
  51762. private _btnVR;
  51763. private _btnVRDisplayed;
  51764. private _webVRsupported;
  51765. private _webVRready;
  51766. private _webVRrequesting;
  51767. private _webVRpresenting;
  51768. private _hasEnteredVR;
  51769. private _fullscreenVRpresenting;
  51770. private _inputElement;
  51771. private _webVRCamera;
  51772. private _vrDeviceOrientationCamera;
  51773. private _deviceOrientationCamera;
  51774. private _existingCamera;
  51775. private _onKeyDown;
  51776. private _onVrDisplayPresentChange;
  51777. private _onVRDisplayChanged;
  51778. private _onVRRequestPresentStart;
  51779. private _onVRRequestPresentComplete;
  51780. /**
  51781. * 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)
  51782. */
  51783. enableGazeEvenWhenNoPointerLock: boolean;
  51784. /**
  51785. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  51786. */
  51787. exitVROnDoubleTap: boolean;
  51788. /**
  51789. * Observable raised right before entering VR.
  51790. */
  51791. onEnteringVRObservable: Observable<VRExperienceHelper>;
  51792. /**
  51793. * Observable raised when entering VR has completed.
  51794. */
  51795. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  51796. /**
  51797. * Observable raised when exiting VR.
  51798. */
  51799. onExitingVRObservable: Observable<VRExperienceHelper>;
  51800. /**
  51801. * Observable raised when controller mesh is loaded.
  51802. */
  51803. onControllerMeshLoadedObservable: Observable<WebVRController>;
  51804. /** Return this.onEnteringVRObservable
  51805. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  51806. */
  51807. get onEnteringVR(): Observable<VRExperienceHelper>;
  51808. /** Return this.onExitingVRObservable
  51809. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  51810. */
  51811. get onExitingVR(): Observable<VRExperienceHelper>;
  51812. /** Return this.onControllerMeshLoadedObservable
  51813. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  51814. */
  51815. get onControllerMeshLoaded(): Observable<WebVRController>;
  51816. private _rayLength;
  51817. private _useCustomVRButton;
  51818. private _teleportationRequested;
  51819. private _teleportActive;
  51820. private _floorMeshName;
  51821. private _floorMeshesCollection;
  51822. private _teleportationMode;
  51823. private _teleportationTime;
  51824. private _teleportationSpeed;
  51825. private _teleportationEasing;
  51826. private _rotationAllowed;
  51827. private _teleportBackwardsVector;
  51828. private _teleportationTarget;
  51829. private _isDefaultTeleportationTarget;
  51830. private _postProcessMove;
  51831. private _teleportationFillColor;
  51832. private _teleportationBorderColor;
  51833. private _rotationAngle;
  51834. private _haloCenter;
  51835. private _cameraGazer;
  51836. private _padSensibilityUp;
  51837. private _padSensibilityDown;
  51838. private _leftController;
  51839. private _rightController;
  51840. private _gazeColor;
  51841. private _laserColor;
  51842. private _pickedLaserColor;
  51843. private _pickedGazeColor;
  51844. /**
  51845. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  51846. */
  51847. onNewMeshSelected: Observable<AbstractMesh>;
  51848. /**
  51849. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  51850. * This observable will provide the mesh and the controller used to select the mesh
  51851. */
  51852. onMeshSelectedWithController: Observable<{
  51853. mesh: AbstractMesh;
  51854. controller: WebVRController;
  51855. }>;
  51856. /**
  51857. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  51858. */
  51859. onNewMeshPicked: Observable<PickingInfo>;
  51860. private _circleEase;
  51861. /**
  51862. * Observable raised before camera teleportation
  51863. */
  51864. onBeforeCameraTeleport: Observable<Vector3>;
  51865. /**
  51866. * Observable raised after camera teleportation
  51867. */
  51868. onAfterCameraTeleport: Observable<Vector3>;
  51869. /**
  51870. * Observable raised when current selected mesh gets unselected
  51871. */
  51872. onSelectedMeshUnselected: Observable<AbstractMesh>;
  51873. private _raySelectionPredicate;
  51874. /**
  51875. * To be optionaly changed by user to define custom ray selection
  51876. */
  51877. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  51878. /**
  51879. * To be optionaly changed by user to define custom selection logic (after ray selection)
  51880. */
  51881. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  51882. /**
  51883. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  51884. */
  51885. teleportationEnabled: boolean;
  51886. private _defaultHeight;
  51887. private _teleportationInitialized;
  51888. private _interactionsEnabled;
  51889. private _interactionsRequested;
  51890. private _displayGaze;
  51891. private _displayLaserPointer;
  51892. /**
  51893. * The mesh used to display where the user is going to teleport.
  51894. */
  51895. get teleportationTarget(): Mesh;
  51896. /**
  51897. * Sets the mesh to be used to display where the user is going to teleport.
  51898. */
  51899. set teleportationTarget(value: Mesh);
  51900. /**
  51901. * 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
  51902. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  51903. * See https://doc.babylonjs.com/resources/baking_transformations
  51904. */
  51905. get gazeTrackerMesh(): Mesh;
  51906. set gazeTrackerMesh(value: Mesh);
  51907. /**
  51908. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  51909. */
  51910. updateGazeTrackerScale: boolean;
  51911. /**
  51912. * If the gaze trackers color should be updated when selecting meshes
  51913. */
  51914. updateGazeTrackerColor: boolean;
  51915. /**
  51916. * If the controller laser color should be updated when selecting meshes
  51917. */
  51918. updateControllerLaserColor: boolean;
  51919. /**
  51920. * The gaze tracking mesh corresponding to the left controller
  51921. */
  51922. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  51923. /**
  51924. * The gaze tracking mesh corresponding to the right controller
  51925. */
  51926. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  51927. /**
  51928. * If the ray of the gaze should be displayed.
  51929. */
  51930. get displayGaze(): boolean;
  51931. /**
  51932. * Sets if the ray of the gaze should be displayed.
  51933. */
  51934. set displayGaze(value: boolean);
  51935. /**
  51936. * If the ray of the LaserPointer should be displayed.
  51937. */
  51938. get displayLaserPointer(): boolean;
  51939. /**
  51940. * Sets if the ray of the LaserPointer should be displayed.
  51941. */
  51942. set displayLaserPointer(value: boolean);
  51943. /**
  51944. * The deviceOrientationCamera used as the camera when not in VR.
  51945. */
  51946. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  51947. /**
  51948. * Based on the current WebVR support, returns the current VR camera used.
  51949. */
  51950. get currentVRCamera(): Nullable<Camera>;
  51951. /**
  51952. * The webVRCamera which is used when in VR.
  51953. */
  51954. get webVRCamera(): WebVRFreeCamera;
  51955. /**
  51956. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  51957. */
  51958. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  51959. /**
  51960. * The html button that is used to trigger entering into VR.
  51961. */
  51962. get vrButton(): Nullable<HTMLButtonElement>;
  51963. private get _teleportationRequestInitiated();
  51964. /**
  51965. * Defines whether or not Pointer lock should be requested when switching to
  51966. * full screen.
  51967. */
  51968. requestPointerLockOnFullScreen: boolean;
  51969. /**
  51970. * If asking to force XR, this will be populated with the default xr experience
  51971. */
  51972. xr: WebXRDefaultExperience;
  51973. /**
  51974. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  51975. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  51976. */
  51977. xrTestDone: boolean;
  51978. /**
  51979. * Instantiates a VRExperienceHelper.
  51980. * Helps to quickly add VR support to an existing scene.
  51981. * @param scene The scene the VRExperienceHelper belongs to.
  51982. * @param webVROptions Options to modify the vr experience helper's behavior.
  51983. */
  51984. constructor(scene: Scene,
  51985. /** Options to modify the vr experience helper's behavior. */
  51986. webVROptions?: VRExperienceHelperOptions);
  51987. private completeVRInit;
  51988. private _onDefaultMeshLoaded;
  51989. private _onResize;
  51990. private _onFullscreenChange;
  51991. /**
  51992. * Gets a value indicating if we are currently in VR mode.
  51993. */
  51994. get isInVRMode(): boolean;
  51995. private onVrDisplayPresentChange;
  51996. private onVRDisplayChanged;
  51997. private moveButtonToBottomRight;
  51998. private displayVRButton;
  51999. private updateButtonVisibility;
  52000. private _cachedAngularSensibility;
  52001. /**
  52002. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  52003. * Otherwise, will use the fullscreen API.
  52004. */
  52005. enterVR(): void;
  52006. /**
  52007. * Attempt to exit VR, or fullscreen.
  52008. */
  52009. exitVR(): void;
  52010. /**
  52011. * The position of the vr experience helper.
  52012. */
  52013. get position(): Vector3;
  52014. /**
  52015. * Sets the position of the vr experience helper.
  52016. */
  52017. set position(value: Vector3);
  52018. /**
  52019. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  52020. */
  52021. enableInteractions(): void;
  52022. private get _noControllerIsActive();
  52023. private beforeRender;
  52024. private _isTeleportationFloor;
  52025. /**
  52026. * Adds a floor mesh to be used for teleportation.
  52027. * @param floorMesh the mesh to be used for teleportation.
  52028. */
  52029. addFloorMesh(floorMesh: Mesh): void;
  52030. /**
  52031. * Removes a floor mesh from being used for teleportation.
  52032. * @param floorMesh the mesh to be removed.
  52033. */
  52034. removeFloorMesh(floorMesh: Mesh): void;
  52035. /**
  52036. * Enables interactions and teleportation using the VR controllers and gaze.
  52037. * @param vrTeleportationOptions options to modify teleportation behavior.
  52038. */
  52039. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  52040. private _onNewGamepadConnected;
  52041. private _tryEnableInteractionOnController;
  52042. private _onNewGamepadDisconnected;
  52043. private _enableInteractionOnController;
  52044. private _checkTeleportWithRay;
  52045. private _checkRotate;
  52046. private _checkTeleportBackwards;
  52047. private _enableTeleportationOnController;
  52048. private _createTeleportationCircles;
  52049. private _displayTeleportationTarget;
  52050. private _hideTeleportationTarget;
  52051. private _rotateCamera;
  52052. private _moveTeleportationSelectorTo;
  52053. private _workingVector;
  52054. private _workingQuaternion;
  52055. private _workingMatrix;
  52056. /**
  52057. * Time Constant Teleportation Mode
  52058. */
  52059. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  52060. /**
  52061. * Speed Constant Teleportation Mode
  52062. */
  52063. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  52064. /**
  52065. * Teleports the users feet to the desired location
  52066. * @param location The location where the user's feet should be placed
  52067. */
  52068. teleportCamera(location: Vector3): void;
  52069. private _convertNormalToDirectionOfRay;
  52070. private _castRayAndSelectObject;
  52071. private _notifySelectedMeshUnselected;
  52072. /**
  52073. * Permanently set new colors for the laser pointer
  52074. * @param color the new laser color
  52075. * @param pickedColor the new laser color when picked mesh detected
  52076. */
  52077. setLaserColor(color: Color3, pickedColor?: Color3): void;
  52078. /**
  52079. * Set lighting enabled / disabled on the laser pointer of both controllers
  52080. * @param enabled should the lighting be enabled on the laser pointer
  52081. */
  52082. setLaserLightingState(enabled?: boolean): void;
  52083. /**
  52084. * Permanently set new colors for the gaze pointer
  52085. * @param color the new gaze color
  52086. * @param pickedColor the new gaze color when picked mesh detected
  52087. */
  52088. setGazeColor(color: Color3, pickedColor?: Color3): void;
  52089. /**
  52090. * Sets the color of the laser ray from the vr controllers.
  52091. * @param color new color for the ray.
  52092. */
  52093. changeLaserColor(color: Color3): void;
  52094. /**
  52095. * Sets the color of the ray from the vr headsets gaze.
  52096. * @param color new color for the ray.
  52097. */
  52098. changeGazeColor(color: Color3): void;
  52099. /**
  52100. * Exits VR and disposes of the vr experience helper
  52101. */
  52102. dispose(): void;
  52103. /**
  52104. * Gets the name of the VRExperienceHelper class
  52105. * @returns "VRExperienceHelper"
  52106. */
  52107. getClassName(): string;
  52108. }
  52109. }
  52110. declare module "babylonjs/Cameras/VR/index" {
  52111. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  52112. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  52113. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  52114. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  52115. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  52116. export * from "babylonjs/Cameras/VR/webVRCamera";
  52117. }
  52118. declare module "babylonjs/Cameras/RigModes/index" {
  52119. export * from "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  52120. export * from "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  52121. export * from "babylonjs/Cameras/RigModes/vrRigMode";
  52122. export * from "babylonjs/Cameras/RigModes/webVRRigMode";
  52123. }
  52124. declare module "babylonjs/Cameras/index" {
  52125. export * from "babylonjs/Cameras/Inputs/index";
  52126. export * from "babylonjs/Cameras/cameraInputsManager";
  52127. export * from "babylonjs/Cameras/camera";
  52128. export * from "babylonjs/Cameras/targetCamera";
  52129. export * from "babylonjs/Cameras/freeCamera";
  52130. export * from "babylonjs/Cameras/freeCameraInputsManager";
  52131. export * from "babylonjs/Cameras/touchCamera";
  52132. export * from "babylonjs/Cameras/arcRotateCamera";
  52133. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  52134. export * from "babylonjs/Cameras/deviceOrientationCamera";
  52135. export * from "babylonjs/Cameras/flyCamera";
  52136. export * from "babylonjs/Cameras/flyCameraInputsManager";
  52137. export * from "babylonjs/Cameras/followCamera";
  52138. export * from "babylonjs/Cameras/followCameraInputsManager";
  52139. export * from "babylonjs/Cameras/gamepadCamera";
  52140. export * from "babylonjs/Cameras/Stereoscopic/index";
  52141. export * from "babylonjs/Cameras/universalCamera";
  52142. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  52143. export * from "babylonjs/Cameras/VR/index";
  52144. export * from "babylonjs/Cameras/RigModes/index";
  52145. }
  52146. declare module "babylonjs/Collisions/index" {
  52147. export * from "babylonjs/Collisions/collider";
  52148. export * from "babylonjs/Collisions/collisionCoordinator";
  52149. export * from "babylonjs/Collisions/pickingInfo";
  52150. export * from "babylonjs/Collisions/intersectionInfo";
  52151. export * from "babylonjs/Collisions/meshCollisionData";
  52152. }
  52153. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  52154. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  52155. import { Vector3 } from "babylonjs/Maths/math.vector";
  52156. import { Ray } from "babylonjs/Culling/ray";
  52157. import { Plane } from "babylonjs/Maths/math.plane";
  52158. /**
  52159. * Contains an array of blocks representing the octree
  52160. */
  52161. export interface IOctreeContainer<T> {
  52162. /**
  52163. * Blocks within the octree
  52164. */
  52165. blocks: Array<OctreeBlock<T>>;
  52166. }
  52167. /**
  52168. * Class used to store a cell in an octree
  52169. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  52170. */
  52171. export class OctreeBlock<T> {
  52172. /**
  52173. * Gets the content of the current block
  52174. */
  52175. entries: T[];
  52176. /**
  52177. * Gets the list of block children
  52178. */
  52179. blocks: Array<OctreeBlock<T>>;
  52180. private _depth;
  52181. private _maxDepth;
  52182. private _capacity;
  52183. private _minPoint;
  52184. private _maxPoint;
  52185. private _boundingVectors;
  52186. private _creationFunc;
  52187. /**
  52188. * Creates a new block
  52189. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  52190. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  52191. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  52192. * @param depth defines the current depth of this block in the octree
  52193. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  52194. * @param creationFunc defines a callback to call when an element is added to the block
  52195. */
  52196. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  52197. /**
  52198. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  52199. */
  52200. get capacity(): number;
  52201. /**
  52202. * Gets the minimum vector (in world space) of the block's bounding box
  52203. */
  52204. get minPoint(): Vector3;
  52205. /**
  52206. * Gets the maximum vector (in world space) of the block's bounding box
  52207. */
  52208. get maxPoint(): Vector3;
  52209. /**
  52210. * Add a new element to this block
  52211. * @param entry defines the element to add
  52212. */
  52213. addEntry(entry: T): void;
  52214. /**
  52215. * Remove an element from this block
  52216. * @param entry defines the element to remove
  52217. */
  52218. removeEntry(entry: T): void;
  52219. /**
  52220. * Add an array of elements to this block
  52221. * @param entries defines the array of elements to add
  52222. */
  52223. addEntries(entries: T[]): void;
  52224. /**
  52225. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  52226. * @param frustumPlanes defines the frustum planes to test
  52227. * @param selection defines the array to store current content if selection is positive
  52228. * @param allowDuplicate defines if the selection array can contains duplicated entries
  52229. */
  52230. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  52231. /**
  52232. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  52233. * @param sphereCenter defines the bounding sphere center
  52234. * @param sphereRadius defines the bounding sphere radius
  52235. * @param selection defines the array to store current content if selection is positive
  52236. * @param allowDuplicate defines if the selection array can contains duplicated entries
  52237. */
  52238. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  52239. /**
  52240. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  52241. * @param ray defines the ray to test with
  52242. * @param selection defines the array to store current content if selection is positive
  52243. */
  52244. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  52245. /**
  52246. * Subdivide the content into child blocks (this block will then be empty)
  52247. */
  52248. createInnerBlocks(): void;
  52249. /**
  52250. * @hidden
  52251. */
  52252. 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;
  52253. }
  52254. }
  52255. declare module "babylonjs/Culling/Octrees/octree" {
  52256. import { SmartArray } from "babylonjs/Misc/smartArray";
  52257. import { Vector3 } from "babylonjs/Maths/math.vector";
  52258. import { SubMesh } from "babylonjs/Meshes/subMesh";
  52259. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52260. import { Ray } from "babylonjs/Culling/ray";
  52261. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  52262. import { Plane } from "babylonjs/Maths/math.plane";
  52263. /**
  52264. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  52265. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  52266. */
  52267. export class Octree<T> {
  52268. /** 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.) */
  52269. maxDepth: number;
  52270. /**
  52271. * Blocks within the octree containing objects
  52272. */
  52273. blocks: Array<OctreeBlock<T>>;
  52274. /**
  52275. * Content stored in the octree
  52276. */
  52277. dynamicContent: T[];
  52278. private _maxBlockCapacity;
  52279. private _selectionContent;
  52280. private _creationFunc;
  52281. /**
  52282. * Creates a octree
  52283. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  52284. * @param creationFunc function to be used to instatiate the octree
  52285. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  52286. * @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.)
  52287. */
  52288. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  52289. /** 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.) */
  52290. maxDepth?: number);
  52291. /**
  52292. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  52293. * @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);
  52294. * @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);
  52295. * @param entries meshes to be added to the octree blocks
  52296. */
  52297. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  52298. /**
  52299. * Adds a mesh to the octree
  52300. * @param entry Mesh to add to the octree
  52301. */
  52302. addMesh(entry: T): void;
  52303. /**
  52304. * Remove an element from the octree
  52305. * @param entry defines the element to remove
  52306. */
  52307. removeMesh(entry: T): void;
  52308. /**
  52309. * Selects an array of meshes within the frustum
  52310. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  52311. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  52312. * @returns array of meshes within the frustum
  52313. */
  52314. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  52315. /**
  52316. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  52317. * @param sphereCenter defines the bounding sphere center
  52318. * @param sphereRadius defines the bounding sphere radius
  52319. * @param allowDuplicate defines if the selection array can contains duplicated entries
  52320. * @returns an array of objects that intersect the sphere
  52321. */
  52322. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  52323. /**
  52324. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  52325. * @param ray defines the ray to test with
  52326. * @returns array of intersected objects
  52327. */
  52328. intersectsRay(ray: Ray): SmartArray<T>;
  52329. /**
  52330. * Adds a mesh into the octree block if it intersects the block
  52331. */
  52332. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  52333. /**
  52334. * Adds a submesh into the octree block if it intersects the block
  52335. */
  52336. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  52337. }
  52338. }
  52339. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  52340. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  52341. import { Scene } from "babylonjs/scene";
  52342. import { SubMesh } from "babylonjs/Meshes/subMesh";
  52343. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52344. import { Ray } from "babylonjs/Culling/ray";
  52345. import { Octree } from "babylonjs/Culling/Octrees/octree";
  52346. import { Collider } from "babylonjs/Collisions/collider";
  52347. module "babylonjs/scene" {
  52348. interface Scene {
  52349. /**
  52350. * @hidden
  52351. * Backing Filed
  52352. */
  52353. _selectionOctree: Octree<AbstractMesh>;
  52354. /**
  52355. * Gets the octree used to boost mesh selection (picking)
  52356. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  52357. */
  52358. selectionOctree: Octree<AbstractMesh>;
  52359. /**
  52360. * Creates or updates the octree used to boost selection (picking)
  52361. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  52362. * @param maxCapacity defines the maximum capacity per leaf
  52363. * @param maxDepth defines the maximum depth of the octree
  52364. * @returns an octree of AbstractMesh
  52365. */
  52366. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  52367. }
  52368. }
  52369. module "babylonjs/Meshes/abstractMesh" {
  52370. interface AbstractMesh {
  52371. /**
  52372. * @hidden
  52373. * Backing Field
  52374. */
  52375. _submeshesOctree: Octree<SubMesh>;
  52376. /**
  52377. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  52378. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  52379. * @param maxCapacity defines the maximum size of each block (64 by default)
  52380. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  52381. * @returns the new octree
  52382. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  52383. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  52384. */
  52385. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  52386. }
  52387. }
  52388. /**
  52389. * Defines the octree scene component responsible to manage any octrees
  52390. * in a given scene.
  52391. */
  52392. export class OctreeSceneComponent {
  52393. /**
  52394. * The component name help to identify the component in the list of scene components.
  52395. */
  52396. readonly name: string;
  52397. /**
  52398. * The scene the component belongs to.
  52399. */
  52400. scene: Scene;
  52401. /**
  52402. * Indicates if the meshes have been checked to make sure they are isEnabled()
  52403. */
  52404. readonly checksIsEnabled: boolean;
  52405. /**
  52406. * Creates a new instance of the component for the given scene
  52407. * @param scene Defines the scene to register the component in
  52408. */
  52409. constructor(scene: Scene);
  52410. /**
  52411. * Registers the component in a given scene
  52412. */
  52413. register(): void;
  52414. /**
  52415. * Return the list of active meshes
  52416. * @returns the list of active meshes
  52417. */
  52418. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  52419. /**
  52420. * Return the list of active sub meshes
  52421. * @param mesh The mesh to get the candidates sub meshes from
  52422. * @returns the list of active sub meshes
  52423. */
  52424. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  52425. private _tempRay;
  52426. /**
  52427. * Return the list of sub meshes intersecting with a given local ray
  52428. * @param mesh defines the mesh to find the submesh for
  52429. * @param localRay defines the ray in local space
  52430. * @returns the list of intersecting sub meshes
  52431. */
  52432. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  52433. /**
  52434. * Return the list of sub meshes colliding with a collider
  52435. * @param mesh defines the mesh to find the submesh for
  52436. * @param collider defines the collider to evaluate the collision against
  52437. * @returns the list of colliding sub meshes
  52438. */
  52439. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  52440. /**
  52441. * Rebuilds the elements related to this component in case of
  52442. * context lost for instance.
  52443. */
  52444. rebuild(): void;
  52445. /**
  52446. * Disposes the component and the associated ressources.
  52447. */
  52448. dispose(): void;
  52449. }
  52450. }
  52451. declare module "babylonjs/Culling/Octrees/index" {
  52452. export * from "babylonjs/Culling/Octrees/octree";
  52453. export * from "babylonjs/Culling/Octrees/octreeBlock";
  52454. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  52455. }
  52456. declare module "babylonjs/Culling/index" {
  52457. export * from "babylonjs/Culling/boundingBox";
  52458. export * from "babylonjs/Culling/boundingInfo";
  52459. export * from "babylonjs/Culling/boundingSphere";
  52460. export * from "babylonjs/Culling/Octrees/index";
  52461. export * from "babylonjs/Culling/ray";
  52462. }
  52463. declare module "babylonjs/Gizmos/gizmo" {
  52464. import { Nullable } from "babylonjs/types";
  52465. import { IDisposable } from "babylonjs/scene";
  52466. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52467. import { Mesh } from "babylonjs/Meshes/mesh";
  52468. import { Node } from "babylonjs/node";
  52469. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  52470. /**
  52471. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  52472. */
  52473. export class Gizmo implements IDisposable {
  52474. /** The utility layer the gizmo will be added to */
  52475. gizmoLayer: UtilityLayerRenderer;
  52476. /**
  52477. * The root mesh of the gizmo
  52478. */
  52479. _rootMesh: Mesh;
  52480. private _attachedMesh;
  52481. private _attachedNode;
  52482. /**
  52483. * Ratio for the scale of the gizmo (Default: 1)
  52484. */
  52485. protected _scaleRatio: number;
  52486. /**
  52487. * Ratio for the scale of the gizmo (Default: 1)
  52488. */
  52489. set scaleRatio(value: number);
  52490. get scaleRatio(): number;
  52491. /**
  52492. * If a custom mesh has been set (Default: false)
  52493. */
  52494. protected _customMeshSet: boolean;
  52495. /**
  52496. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  52497. * * When set, interactions will be enabled
  52498. */
  52499. get attachedMesh(): Nullable<AbstractMesh>;
  52500. set attachedMesh(value: Nullable<AbstractMesh>);
  52501. /**
  52502. * Node that the gizmo will be attached to. (eg. on a drag gizmo the mesh, bone or NodeTransform that will be dragged)
  52503. * * When set, interactions will be enabled
  52504. */
  52505. get attachedNode(): Nullable<Node>;
  52506. set attachedNode(value: Nullable<Node>);
  52507. /**
  52508. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  52509. * @param mesh The mesh to replace the default mesh of the gizmo
  52510. */
  52511. setCustomMesh(mesh: Mesh): void;
  52512. protected _updateGizmoRotationToMatchAttachedMesh: boolean;
  52513. /**
  52514. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  52515. */
  52516. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  52517. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  52518. /**
  52519. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  52520. */
  52521. updateGizmoPositionToMatchAttachedMesh: boolean;
  52522. /**
  52523. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  52524. */
  52525. updateScale: boolean;
  52526. protected _interactionsEnabled: boolean;
  52527. protected _attachedNodeChanged(value: Nullable<Node>): void;
  52528. private _beforeRenderObserver;
  52529. private _tempQuaternion;
  52530. private _tempVector;
  52531. private _tempVector2;
  52532. private _tempMatrix1;
  52533. private _tempMatrix2;
  52534. private _rightHandtoLeftHandMatrix;
  52535. /**
  52536. * Creates a gizmo
  52537. * @param gizmoLayer The utility layer the gizmo will be added to
  52538. */
  52539. constructor(
  52540. /** The utility layer the gizmo will be added to */
  52541. gizmoLayer?: UtilityLayerRenderer);
  52542. /**
  52543. * Updates the gizmo to match the attached mesh's position/rotation
  52544. */
  52545. protected _update(): void;
  52546. /**
  52547. * computes the rotation/scaling/position of the transform once the Node world matrix has changed.
  52548. * @param value Node, TransformNode or mesh
  52549. */
  52550. protected _matrixChanged(): void;
  52551. /**
  52552. * Disposes of the gizmo
  52553. */
  52554. dispose(): void;
  52555. }
  52556. }
  52557. declare module "babylonjs/Gizmos/planeDragGizmo" {
  52558. import { Observable } from "babylonjs/Misc/observable";
  52559. import { Nullable } from "babylonjs/types";
  52560. import { Vector3 } from "babylonjs/Maths/math.vector";
  52561. import { Color3 } from "babylonjs/Maths/math.color";
  52562. import { TransformNode } from "babylonjs/Meshes/transformNode";
  52563. import { Node } from "babylonjs/node";
  52564. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  52565. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  52566. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  52567. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  52568. import { Scene } from "babylonjs/scene";
  52569. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  52570. /**
  52571. * Single plane drag gizmo
  52572. */
  52573. export class PlaneDragGizmo extends Gizmo {
  52574. /**
  52575. * Drag behavior responsible for the gizmos dragging interactions
  52576. */
  52577. dragBehavior: PointerDragBehavior;
  52578. private _pointerObserver;
  52579. /**
  52580. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  52581. */
  52582. snapDistance: number;
  52583. /**
  52584. * Event that fires each time the gizmo snaps to a new location.
  52585. * * snapDistance is the the change in distance
  52586. */
  52587. onSnapObservable: Observable<{
  52588. snapDistance: number;
  52589. }>;
  52590. private _plane;
  52591. private _coloredMaterial;
  52592. private _hoverMaterial;
  52593. private _isEnabled;
  52594. private _parent;
  52595. /** @hidden */
  52596. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  52597. /** @hidden */
  52598. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  52599. /**
  52600. * Creates a PlaneDragGizmo
  52601. * @param gizmoLayer The utility layer the gizmo will be added to
  52602. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  52603. * @param color The color of the gizmo
  52604. */
  52605. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  52606. protected _attachedNodeChanged(value: Nullable<Node>): void;
  52607. /**
  52608. * If the gizmo is enabled
  52609. */
  52610. set isEnabled(value: boolean);
  52611. get isEnabled(): boolean;
  52612. /**
  52613. * Disposes of the gizmo
  52614. */
  52615. dispose(): void;
  52616. }
  52617. }
  52618. declare module "babylonjs/Gizmos/positionGizmo" {
  52619. import { Observable } from "babylonjs/Misc/observable";
  52620. import { Nullable } from "babylonjs/types";
  52621. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52622. import { Node } from "babylonjs/node";
  52623. import { Mesh } from "babylonjs/Meshes/mesh";
  52624. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  52625. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  52626. import { PlaneDragGizmo } from "babylonjs/Gizmos/planeDragGizmo";
  52627. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  52628. /**
  52629. * Gizmo that enables dragging a mesh along 3 axis
  52630. */
  52631. export class PositionGizmo extends Gizmo {
  52632. /**
  52633. * Internal gizmo used for interactions on the x axis
  52634. */
  52635. xGizmo: AxisDragGizmo;
  52636. /**
  52637. * Internal gizmo used for interactions on the y axis
  52638. */
  52639. yGizmo: AxisDragGizmo;
  52640. /**
  52641. * Internal gizmo used for interactions on the z axis
  52642. */
  52643. zGizmo: AxisDragGizmo;
  52644. /**
  52645. * Internal gizmo used for interactions on the yz plane
  52646. */
  52647. xPlaneGizmo: PlaneDragGizmo;
  52648. /**
  52649. * Internal gizmo used for interactions on the xz plane
  52650. */
  52651. yPlaneGizmo: PlaneDragGizmo;
  52652. /**
  52653. * Internal gizmo used for interactions on the xy plane
  52654. */
  52655. zPlaneGizmo: PlaneDragGizmo;
  52656. /**
  52657. * private variables
  52658. */
  52659. private _meshAttached;
  52660. private _nodeAttached;
  52661. private _snapDistance;
  52662. /** Fires an event when any of it's sub gizmos are dragged */
  52663. onDragStartObservable: Observable<unknown>;
  52664. /** Fires an event when any of it's sub gizmos are released from dragging */
  52665. onDragEndObservable: Observable<unknown>;
  52666. /**
  52667. * If set to true, planar drag is enabled
  52668. */
  52669. private _planarGizmoEnabled;
  52670. get attachedMesh(): Nullable<AbstractMesh>;
  52671. set attachedMesh(mesh: Nullable<AbstractMesh>);
  52672. get attachedNode(): Nullable<Node>;
  52673. set attachedNode(node: Nullable<Node>);
  52674. /**
  52675. * Creates a PositionGizmo
  52676. * @param gizmoLayer The utility layer the gizmo will be added to
  52677. @param thickness display gizmo axis thickness
  52678. */
  52679. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number);
  52680. /**
  52681. * If the planar drag gizmo is enabled
  52682. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  52683. */
  52684. set planarGizmoEnabled(value: boolean);
  52685. get planarGizmoEnabled(): boolean;
  52686. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  52687. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  52688. /**
  52689. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  52690. */
  52691. set snapDistance(value: number);
  52692. get snapDistance(): number;
  52693. /**
  52694. * Ratio for the scale of the gizmo (Default: 1)
  52695. */
  52696. set scaleRatio(value: number);
  52697. get scaleRatio(): number;
  52698. /**
  52699. * Disposes of the gizmo
  52700. */
  52701. dispose(): void;
  52702. /**
  52703. * CustomMeshes are not supported by this gizmo
  52704. * @param mesh The mesh to replace the default mesh of the gizmo
  52705. */
  52706. setCustomMesh(mesh: Mesh): void;
  52707. }
  52708. }
  52709. declare module "babylonjs/Gizmos/axisDragGizmo" {
  52710. import { Observable } from "babylonjs/Misc/observable";
  52711. import { Nullable } from "babylonjs/types";
  52712. import { Vector3 } from "babylonjs/Maths/math.vector";
  52713. import { TransformNode } from "babylonjs/Meshes/transformNode";
  52714. import { Node } from "babylonjs/node";
  52715. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  52716. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  52717. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  52718. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  52719. import { Scene } from "babylonjs/scene";
  52720. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  52721. import { Color3 } from "babylonjs/Maths/math.color";
  52722. /**
  52723. * Single axis drag gizmo
  52724. */
  52725. export class AxisDragGizmo extends Gizmo {
  52726. /**
  52727. * Drag behavior responsible for the gizmos dragging interactions
  52728. */
  52729. dragBehavior: PointerDragBehavior;
  52730. private _pointerObserver;
  52731. /**
  52732. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  52733. */
  52734. snapDistance: number;
  52735. /**
  52736. * Event that fires each time the gizmo snaps to a new location.
  52737. * * snapDistance is the the change in distance
  52738. */
  52739. onSnapObservable: Observable<{
  52740. snapDistance: number;
  52741. }>;
  52742. private _isEnabled;
  52743. private _parent;
  52744. private _arrow;
  52745. private _coloredMaterial;
  52746. private _hoverMaterial;
  52747. /** @hidden */
  52748. static _CreateArrow(scene: Scene, material: StandardMaterial, thickness?: number): TransformNode;
  52749. /** @hidden */
  52750. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  52751. /**
  52752. * Creates an AxisDragGizmo
  52753. * @param gizmoLayer The utility layer the gizmo will be added to
  52754. * @param dragAxis The axis which the gizmo will be able to drag on
  52755. * @param color The color of the gizmo
  52756. * @param thickness display gizmo axis thickness
  52757. */
  52758. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>, thickness?: number);
  52759. protected _attachedNodeChanged(value: Nullable<Node>): void;
  52760. /**
  52761. * If the gizmo is enabled
  52762. */
  52763. set isEnabled(value: boolean);
  52764. get isEnabled(): boolean;
  52765. /**
  52766. * Disposes of the gizmo
  52767. */
  52768. dispose(): void;
  52769. }
  52770. }
  52771. declare module "babylonjs/Debug/axesViewer" {
  52772. import { Vector3 } from "babylonjs/Maths/math.vector";
  52773. import { Nullable } from "babylonjs/types";
  52774. import { Scene } from "babylonjs/scene";
  52775. import { TransformNode } from "babylonjs/Meshes/transformNode";
  52776. /**
  52777. * The Axes viewer will show 3 axes in a specific point in space
  52778. */
  52779. export class AxesViewer {
  52780. private _xAxis;
  52781. private _yAxis;
  52782. private _zAxis;
  52783. private _scaleLinesFactor;
  52784. private _instanced;
  52785. /**
  52786. * Gets the hosting scene
  52787. */
  52788. scene: Nullable<Scene>;
  52789. /**
  52790. * Gets or sets a number used to scale line length
  52791. */
  52792. scaleLines: number;
  52793. /** Gets the node hierarchy used to render x-axis */
  52794. get xAxis(): TransformNode;
  52795. /** Gets the node hierarchy used to render y-axis */
  52796. get yAxis(): TransformNode;
  52797. /** Gets the node hierarchy used to render z-axis */
  52798. get zAxis(): TransformNode;
  52799. /**
  52800. * Creates a new AxesViewer
  52801. * @param scene defines the hosting scene
  52802. * @param scaleLines defines a number used to scale line length (1 by default)
  52803. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  52804. * @param xAxis defines the node hierarchy used to render the x-axis
  52805. * @param yAxis defines the node hierarchy used to render the y-axis
  52806. * @param zAxis defines the node hierarchy used to render the z-axis
  52807. */
  52808. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  52809. /**
  52810. * Force the viewer to update
  52811. * @param position defines the position of the viewer
  52812. * @param xaxis defines the x axis of the viewer
  52813. * @param yaxis defines the y axis of the viewer
  52814. * @param zaxis defines the z axis of the viewer
  52815. */
  52816. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  52817. /**
  52818. * Creates an instance of this axes viewer.
  52819. * @returns a new axes viewer with instanced meshes
  52820. */
  52821. createInstance(): AxesViewer;
  52822. /** Releases resources */
  52823. dispose(): void;
  52824. private static _SetRenderingGroupId;
  52825. }
  52826. }
  52827. declare module "babylonjs/Debug/boneAxesViewer" {
  52828. import { Nullable } from "babylonjs/types";
  52829. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  52830. import { Vector3 } from "babylonjs/Maths/math.vector";
  52831. import { Mesh } from "babylonjs/Meshes/mesh";
  52832. import { Bone } from "babylonjs/Bones/bone";
  52833. import { Scene } from "babylonjs/scene";
  52834. /**
  52835. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  52836. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  52837. */
  52838. export class BoneAxesViewer extends AxesViewer {
  52839. /**
  52840. * Gets or sets the target mesh where to display the axes viewer
  52841. */
  52842. mesh: Nullable<Mesh>;
  52843. /**
  52844. * Gets or sets the target bone where to display the axes viewer
  52845. */
  52846. bone: Nullable<Bone>;
  52847. /** Gets current position */
  52848. pos: Vector3;
  52849. /** Gets direction of X axis */
  52850. xaxis: Vector3;
  52851. /** Gets direction of Y axis */
  52852. yaxis: Vector3;
  52853. /** Gets direction of Z axis */
  52854. zaxis: Vector3;
  52855. /**
  52856. * Creates a new BoneAxesViewer
  52857. * @param scene defines the hosting scene
  52858. * @param bone defines the target bone
  52859. * @param mesh defines the target mesh
  52860. * @param scaleLines defines a scaling factor for line length (1 by default)
  52861. */
  52862. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  52863. /**
  52864. * Force the viewer to update
  52865. */
  52866. update(): void;
  52867. /** Releases resources */
  52868. dispose(): void;
  52869. }
  52870. }
  52871. declare module "babylonjs/Debug/debugLayer" {
  52872. import { Scene } from "babylonjs/scene";
  52873. /**
  52874. * Interface used to define scene explorer extensibility option
  52875. */
  52876. export interface IExplorerExtensibilityOption {
  52877. /**
  52878. * Define the option label
  52879. */
  52880. label: string;
  52881. /**
  52882. * Defines the action to execute on click
  52883. */
  52884. action: (entity: any) => void;
  52885. }
  52886. /**
  52887. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  52888. */
  52889. export interface IExplorerExtensibilityGroup {
  52890. /**
  52891. * Defines a predicate to test if a given type mut be extended
  52892. */
  52893. predicate: (entity: any) => boolean;
  52894. /**
  52895. * Gets the list of options added to a type
  52896. */
  52897. entries: IExplorerExtensibilityOption[];
  52898. }
  52899. /**
  52900. * Interface used to define the options to use to create the Inspector
  52901. */
  52902. export interface IInspectorOptions {
  52903. /**
  52904. * Display in overlay mode (default: false)
  52905. */
  52906. overlay?: boolean;
  52907. /**
  52908. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  52909. */
  52910. globalRoot?: HTMLElement;
  52911. /**
  52912. * Display the Scene explorer
  52913. */
  52914. showExplorer?: boolean;
  52915. /**
  52916. * Display the property inspector
  52917. */
  52918. showInspector?: boolean;
  52919. /**
  52920. * Display in embed mode (both panes on the right)
  52921. */
  52922. embedMode?: boolean;
  52923. /**
  52924. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  52925. */
  52926. handleResize?: boolean;
  52927. /**
  52928. * Allow the panes to popup (default: true)
  52929. */
  52930. enablePopup?: boolean;
  52931. /**
  52932. * Allow the panes to be closed by users (default: true)
  52933. */
  52934. enableClose?: boolean;
  52935. /**
  52936. * Optional list of extensibility entries
  52937. */
  52938. explorerExtensibility?: IExplorerExtensibilityGroup[];
  52939. /**
  52940. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  52941. */
  52942. inspectorURL?: string;
  52943. /**
  52944. * Optional initial tab (default to DebugLayerTab.Properties)
  52945. */
  52946. initialTab?: DebugLayerTab;
  52947. }
  52948. module "babylonjs/scene" {
  52949. interface Scene {
  52950. /**
  52951. * @hidden
  52952. * Backing field
  52953. */
  52954. _debugLayer: DebugLayer;
  52955. /**
  52956. * Gets the debug layer (aka Inspector) associated with the scene
  52957. * @see https://doc.babylonjs.com/features/playground_debuglayer
  52958. */
  52959. debugLayer: DebugLayer;
  52960. }
  52961. }
  52962. /**
  52963. * Enum of inspector action tab
  52964. */
  52965. export enum DebugLayerTab {
  52966. /**
  52967. * Properties tag (default)
  52968. */
  52969. Properties = 0,
  52970. /**
  52971. * Debug tab
  52972. */
  52973. Debug = 1,
  52974. /**
  52975. * Statistics tab
  52976. */
  52977. Statistics = 2,
  52978. /**
  52979. * Tools tab
  52980. */
  52981. Tools = 3,
  52982. /**
  52983. * Settings tab
  52984. */
  52985. Settings = 4
  52986. }
  52987. /**
  52988. * The debug layer (aka Inspector) is the go to tool in order to better understand
  52989. * what is happening in your scene
  52990. * @see https://doc.babylonjs.com/features/playground_debuglayer
  52991. */
  52992. export class DebugLayer {
  52993. /**
  52994. * Define the url to get the inspector script from.
  52995. * By default it uses the babylonjs CDN.
  52996. * @ignoreNaming
  52997. */
  52998. static InspectorURL: string;
  52999. private _scene;
  53000. private BJSINSPECTOR;
  53001. private _onPropertyChangedObservable?;
  53002. /**
  53003. * Observable triggered when a property is changed through the inspector.
  53004. */
  53005. get onPropertyChangedObservable(): any;
  53006. /**
  53007. * Instantiates a new debug layer.
  53008. * The debug layer (aka Inspector) is the go to tool in order to better understand
  53009. * what is happening in your scene
  53010. * @see https://doc.babylonjs.com/features/playground_debuglayer
  53011. * @param scene Defines the scene to inspect
  53012. */
  53013. constructor(scene: Scene);
  53014. /** Creates the inspector window. */
  53015. private _createInspector;
  53016. /**
  53017. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  53018. * @param entity defines the entity to select
  53019. * @param lineContainerTitles defines the specific blocks to highlight (could be a string or an array of strings)
  53020. */
  53021. select(entity: any, lineContainerTitles?: string | string[]): void;
  53022. /** Get the inspector from bundle or global */
  53023. private _getGlobalInspector;
  53024. /**
  53025. * Get if the inspector is visible or not.
  53026. * @returns true if visible otherwise, false
  53027. */
  53028. isVisible(): boolean;
  53029. /**
  53030. * Hide the inspector and close its window.
  53031. */
  53032. hide(): void;
  53033. /**
  53034. * Update the scene in the inspector
  53035. */
  53036. setAsActiveScene(): void;
  53037. /**
  53038. * Launch the debugLayer.
  53039. * @param config Define the configuration of the inspector
  53040. * @return a promise fulfilled when the debug layer is visible
  53041. */
  53042. show(config?: IInspectorOptions): Promise<DebugLayer>;
  53043. }
  53044. }
  53045. declare module "babylonjs/Meshes/Builders/boxBuilder" {
  53046. import { Nullable } from "babylonjs/types";
  53047. import { Scene } from "babylonjs/scene";
  53048. import { Vector4 } from "babylonjs/Maths/math.vector";
  53049. import { Color4 } from "babylonjs/Maths/math.color";
  53050. import { Mesh } from "babylonjs/Meshes/mesh";
  53051. /**
  53052. * Class containing static functions to help procedurally build meshes
  53053. */
  53054. export class BoxBuilder {
  53055. /**
  53056. * Creates a box mesh
  53057. * * The parameter `size` sets the size (float) of each box side (default 1)
  53058. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  53059. * * 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)
  53060. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  53061. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53062. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  53063. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53064. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  53065. * @param name defines the name of the mesh
  53066. * @param options defines the options used to create the mesh
  53067. * @param scene defines the hosting scene
  53068. * @returns the box mesh
  53069. */
  53070. static CreateBox(name: string, options: {
  53071. size?: number;
  53072. width?: number;
  53073. height?: number;
  53074. depth?: number;
  53075. faceUV?: Vector4[];
  53076. faceColors?: Color4[];
  53077. sideOrientation?: number;
  53078. frontUVs?: Vector4;
  53079. backUVs?: Vector4;
  53080. wrap?: boolean;
  53081. topBaseAt?: number;
  53082. bottomBaseAt?: number;
  53083. updatable?: boolean;
  53084. }, scene?: Nullable<Scene>): Mesh;
  53085. }
  53086. }
  53087. declare module "babylonjs/Debug/physicsViewer" {
  53088. import { Nullable } from "babylonjs/types";
  53089. import { Scene } from "babylonjs/scene";
  53090. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53091. import { Mesh } from "babylonjs/Meshes/mesh";
  53092. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  53093. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  53094. /**
  53095. * Used to show the physics impostor around the specific mesh
  53096. */
  53097. export class PhysicsViewer {
  53098. /** @hidden */
  53099. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  53100. /** @hidden */
  53101. protected _meshes: Array<Nullable<AbstractMesh>>;
  53102. /** @hidden */
  53103. protected _scene: Nullable<Scene>;
  53104. /** @hidden */
  53105. protected _numMeshes: number;
  53106. /** @hidden */
  53107. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  53108. private _renderFunction;
  53109. private _utilityLayer;
  53110. private _debugBoxMesh;
  53111. private _debugSphereMesh;
  53112. private _debugCylinderMesh;
  53113. private _debugMaterial;
  53114. private _debugMeshMeshes;
  53115. /**
  53116. * Creates a new PhysicsViewer
  53117. * @param scene defines the hosting scene
  53118. */
  53119. constructor(scene: Scene);
  53120. /** @hidden */
  53121. protected _updateDebugMeshes(): void;
  53122. /**
  53123. * Renders a specified physic impostor
  53124. * @param impostor defines the impostor to render
  53125. * @param targetMesh defines the mesh represented by the impostor
  53126. * @returns the new debug mesh used to render the impostor
  53127. */
  53128. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  53129. /**
  53130. * Hides a specified physic impostor
  53131. * @param impostor defines the impostor to hide
  53132. */
  53133. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  53134. private _getDebugMaterial;
  53135. private _getDebugBoxMesh;
  53136. private _getDebugSphereMesh;
  53137. private _getDebugCylinderMesh;
  53138. private _getDebugMeshMesh;
  53139. private _getDebugMesh;
  53140. /** Releases all resources */
  53141. dispose(): void;
  53142. }
  53143. }
  53144. declare module "babylonjs/Debug/rayHelper" {
  53145. import { Nullable } from "babylonjs/types";
  53146. import { Ray } from "babylonjs/Culling/ray";
  53147. import { Vector3 } from "babylonjs/Maths/math.vector";
  53148. import { Color3 } from "babylonjs/Maths/math.color";
  53149. import { Scene } from "babylonjs/scene";
  53150. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53151. import "babylonjs/Meshes/Builders/linesBuilder";
  53152. /**
  53153. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  53154. * in order to better appreciate the issue one might have.
  53155. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  53156. */
  53157. export class RayHelper {
  53158. /**
  53159. * Defines the ray we are currently tryin to visualize.
  53160. */
  53161. ray: Nullable<Ray>;
  53162. private _renderPoints;
  53163. private _renderLine;
  53164. private _renderFunction;
  53165. private _scene;
  53166. private _onAfterRenderObserver;
  53167. private _onAfterStepObserver;
  53168. private _attachedToMesh;
  53169. private _meshSpaceDirection;
  53170. private _meshSpaceOrigin;
  53171. /**
  53172. * Helper function to create a colored helper in a scene in one line.
  53173. * @param ray Defines the ray we are currently tryin to visualize
  53174. * @param scene Defines the scene the ray is used in
  53175. * @param color Defines the color we want to see the ray in
  53176. * @returns The newly created ray helper.
  53177. */
  53178. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  53179. /**
  53180. * Instantiate a new ray helper.
  53181. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  53182. * in order to better appreciate the issue one might have.
  53183. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  53184. * @param ray Defines the ray we are currently tryin to visualize
  53185. */
  53186. constructor(ray: Ray);
  53187. /**
  53188. * Shows the ray we are willing to debug.
  53189. * @param scene Defines the scene the ray needs to be rendered in
  53190. * @param color Defines the color the ray needs to be rendered in
  53191. */
  53192. show(scene: Scene, color?: Color3): void;
  53193. /**
  53194. * Hides the ray we are debugging.
  53195. */
  53196. hide(): void;
  53197. private _render;
  53198. /**
  53199. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  53200. * @param mesh Defines the mesh we want the helper attached to
  53201. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  53202. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  53203. * @param length Defines the length of the ray
  53204. */
  53205. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  53206. /**
  53207. * Detach the ray helper from the mesh it has previously been attached to.
  53208. */
  53209. detachFromMesh(): void;
  53210. private _updateToMesh;
  53211. /**
  53212. * Dispose the helper and release its associated resources.
  53213. */
  53214. dispose(): void;
  53215. }
  53216. }
  53217. declare module "babylonjs/Debug/ISkeletonViewer" {
  53218. import { Skeleton } from "babylonjs/Bones/skeleton";
  53219. import { Color3 } from "babylonjs/Maths/math.color";
  53220. /**
  53221. * Defines the options associated with the creation of a SkeletonViewer.
  53222. */
  53223. export interface ISkeletonViewerOptions {
  53224. /** Should the system pause animations before building the Viewer? */
  53225. pauseAnimations: boolean;
  53226. /** Should the system return the skeleton to rest before building? */
  53227. returnToRest: boolean;
  53228. /** public Display Mode of the Viewer */
  53229. displayMode: number;
  53230. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  53231. displayOptions: ISkeletonViewerDisplayOptions;
  53232. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  53233. computeBonesUsingShaders: boolean;
  53234. /** Flag ignore non weighted bones */
  53235. useAllBones: boolean;
  53236. }
  53237. /**
  53238. * Defines how to display the various bone meshes for the viewer.
  53239. */
  53240. export interface ISkeletonViewerDisplayOptions {
  53241. /** How far down to start tapering the bone spurs */
  53242. midStep?: number;
  53243. /** How big is the midStep? */
  53244. midStepFactor?: number;
  53245. /** Base for the Sphere Size */
  53246. sphereBaseSize?: number;
  53247. /** The ratio of the sphere to the longest bone in units */
  53248. sphereScaleUnit?: number;
  53249. /** Ratio for the Sphere Size */
  53250. sphereFactor?: number;
  53251. }
  53252. /**
  53253. * Defines the constructor options for the BoneWeight Shader.
  53254. */
  53255. export interface IBoneWeightShaderOptions {
  53256. /** Skeleton to Map */
  53257. skeleton: Skeleton;
  53258. /** Colors for Uninfluenced bones */
  53259. colorBase?: Color3;
  53260. /** Colors for 0.0-0.25 Weight bones */
  53261. colorZero?: Color3;
  53262. /** Color for 0.25-0.5 Weight Influence */
  53263. colorQuarter?: Color3;
  53264. /** Color for 0.5-0.75 Weight Influence */
  53265. colorHalf?: Color3;
  53266. /** Color for 0.75-1 Weight Influence */
  53267. colorFull?: Color3;
  53268. /** Color for Zero Weight Influence */
  53269. targetBoneIndex?: number;
  53270. }
  53271. /**
  53272. * Simple structure of the gradient steps for the Color Map.
  53273. */
  53274. export interface ISkeletonMapShaderColorMapKnot {
  53275. /** Color of the Knot */
  53276. color: Color3;
  53277. /** Location of the Knot */
  53278. location: number;
  53279. }
  53280. /**
  53281. * Defines the constructor options for the SkeletonMap Shader.
  53282. */
  53283. export interface ISkeletonMapShaderOptions {
  53284. /** Skeleton to Map */
  53285. skeleton: Skeleton;
  53286. /** Array of ColorMapKnots that make the gradient must be ordered with knot[i].location < knot[i+1].location*/
  53287. colorMap?: ISkeletonMapShaderColorMapKnot[];
  53288. }
  53289. }
  53290. declare module "babylonjs/Meshes/Builders/ribbonBuilder" {
  53291. import { Nullable } from "babylonjs/types";
  53292. import { Scene } from "babylonjs/scene";
  53293. import { Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  53294. import { Color4 } from "babylonjs/Maths/math.color";
  53295. import { Mesh } from "babylonjs/Meshes/mesh";
  53296. /**
  53297. * Class containing static functions to help procedurally build meshes
  53298. */
  53299. export class RibbonBuilder {
  53300. /**
  53301. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  53302. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  53303. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  53304. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  53305. * * 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
  53306. * * 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
  53307. * * 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
  53308. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53309. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  53310. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  53311. * * 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
  53312. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  53313. * * 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
  53314. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  53315. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53316. * @param name defines the name of the mesh
  53317. * @param options defines the options used to create the mesh
  53318. * @param scene defines the hosting scene
  53319. * @returns the ribbon mesh
  53320. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  53321. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  53322. */
  53323. static CreateRibbon(name: string, options: {
  53324. pathArray: Vector3[][];
  53325. closeArray?: boolean;
  53326. closePath?: boolean;
  53327. offset?: number;
  53328. updatable?: boolean;
  53329. sideOrientation?: number;
  53330. frontUVs?: Vector4;
  53331. backUVs?: Vector4;
  53332. instance?: Mesh;
  53333. invertUV?: boolean;
  53334. uvs?: Vector2[];
  53335. colors?: Color4[];
  53336. }, scene?: Nullable<Scene>): Mesh;
  53337. }
  53338. }
  53339. declare module "babylonjs/Meshes/Builders/shapeBuilder" {
  53340. import { Nullable } from "babylonjs/types";
  53341. import { Scene } from "babylonjs/scene";
  53342. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  53343. import { Mesh } from "babylonjs/Meshes/mesh";
  53344. /**
  53345. * Class containing static functions to help procedurally build meshes
  53346. */
  53347. export class ShapeBuilder {
  53348. /**
  53349. * 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.
  53350. * * 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.
  53351. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  53352. * * 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.
  53353. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  53354. * * 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
  53355. * * 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
  53356. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  53357. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53358. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  53359. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  53360. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  53361. * @param name defines the name of the mesh
  53362. * @param options defines the options used to create the mesh
  53363. * @param scene defines the hosting scene
  53364. * @returns the extruded shape mesh
  53365. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  53366. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  53367. */
  53368. static ExtrudeShape(name: string, options: {
  53369. shape: Vector3[];
  53370. path: Vector3[];
  53371. scale?: number;
  53372. rotation?: number;
  53373. cap?: number;
  53374. updatable?: boolean;
  53375. sideOrientation?: number;
  53376. frontUVs?: Vector4;
  53377. backUVs?: Vector4;
  53378. instance?: Mesh;
  53379. invertUV?: boolean;
  53380. }, scene?: Nullable<Scene>): Mesh;
  53381. /**
  53382. * Creates an custom extruded shape mesh.
  53383. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  53384. * * 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.
  53385. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  53386. * * 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
  53387. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  53388. * * 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
  53389. * * It must returns a float value that will be the scale value applied to the shape on each path point
  53390. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  53391. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  53392. * * 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
  53393. * * 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
  53394. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  53395. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53396. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  53397. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  53398. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53399. * @param name defines the name of the mesh
  53400. * @param options defines the options used to create the mesh
  53401. * @param scene defines the hosting scene
  53402. * @returns the custom extruded shape mesh
  53403. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  53404. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  53405. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  53406. */
  53407. static ExtrudeShapeCustom(name: string, options: {
  53408. shape: Vector3[];
  53409. path: Vector3[];
  53410. scaleFunction?: any;
  53411. rotationFunction?: any;
  53412. ribbonCloseArray?: boolean;
  53413. ribbonClosePath?: boolean;
  53414. cap?: number;
  53415. updatable?: boolean;
  53416. sideOrientation?: number;
  53417. frontUVs?: Vector4;
  53418. backUVs?: Vector4;
  53419. instance?: Mesh;
  53420. invertUV?: boolean;
  53421. }, scene?: Nullable<Scene>): Mesh;
  53422. private static _ExtrudeShapeGeneric;
  53423. }
  53424. }
  53425. declare module "babylonjs/Debug/skeletonViewer" {
  53426. import { Color3 } from "babylonjs/Maths/math.color";
  53427. import { Scene } from "babylonjs/scene";
  53428. import { Nullable } from "babylonjs/types";
  53429. import { Skeleton } from "babylonjs/Bones/skeleton";
  53430. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53431. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  53432. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  53433. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  53434. import { ISkeletonViewerOptions, IBoneWeightShaderOptions, ISkeletonMapShaderOptions } from "babylonjs/Debug/ISkeletonViewer";
  53435. /**
  53436. * Class used to render a debug view of a given skeleton
  53437. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  53438. */
  53439. export class SkeletonViewer {
  53440. /** defines the skeleton to render */
  53441. skeleton: Skeleton;
  53442. /** defines the mesh attached to the skeleton */
  53443. mesh: AbstractMesh;
  53444. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  53445. autoUpdateBonesMatrices: boolean;
  53446. /** defines the rendering group id to use with the viewer */
  53447. renderingGroupId: number;
  53448. /** is the options for the viewer */
  53449. options: Partial<ISkeletonViewerOptions>;
  53450. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_LINES */
  53451. static readonly DISPLAY_LINES: number;
  53452. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERES */
  53453. static readonly DISPLAY_SPHERES: number;
  53454. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERE_AND_SPURS */
  53455. static readonly DISPLAY_SPHERE_AND_SPURS: number;
  53456. /** public static method to create a BoneWeight Shader
  53457. * @param options The constructor options
  53458. * @param scene The scene that the shader is scoped to
  53459. * @returns The created ShaderMaterial
  53460. * @see http://www.babylonjs-playground.com/#1BZJVJ#395
  53461. */
  53462. static CreateBoneWeightShader(options: IBoneWeightShaderOptions, scene: Scene): ShaderMaterial;
  53463. /** public static method to create a BoneWeight Shader
  53464. * @param options The constructor options
  53465. * @param scene The scene that the shader is scoped to
  53466. * @returns The created ShaderMaterial
  53467. */
  53468. static CreateSkeletonMapShader(options: ISkeletonMapShaderOptions, scene: Scene): ShaderMaterial;
  53469. /** private static method to create a BoneWeight Shader
  53470. * @param size The size of the buffer to create (usually the bone count)
  53471. * @param colorMap The gradient data to generate
  53472. * @param scene The scene that the shader is scoped to
  53473. * @returns an Array of floats from the color gradient values
  53474. */
  53475. private static _CreateBoneMapColorBuffer;
  53476. /** If SkeletonViewer scene scope. */
  53477. private _scene;
  53478. /** Gets or sets the color used to render the skeleton */
  53479. color: Color3;
  53480. /** Array of the points of the skeleton fo the line view. */
  53481. private _debugLines;
  53482. /** The SkeletonViewers Mesh. */
  53483. private _debugMesh;
  53484. /** If SkeletonViewer is enabled. */
  53485. private _isEnabled;
  53486. /** If SkeletonViewer is ready. */
  53487. private _ready;
  53488. /** SkeletonViewer render observable. */
  53489. private _obs;
  53490. /** The Utility Layer to render the gizmos in. */
  53491. private _utilityLayer;
  53492. private _boneIndices;
  53493. /** Gets the Scene. */
  53494. get scene(): Scene;
  53495. /** Gets the utilityLayer. */
  53496. get utilityLayer(): Nullable<UtilityLayerRenderer>;
  53497. /** Checks Ready Status. */
  53498. get isReady(): Boolean;
  53499. /** Sets Ready Status. */
  53500. set ready(value: boolean);
  53501. /** Gets the debugMesh */
  53502. get debugMesh(): Nullable<AbstractMesh> | Nullable<LinesMesh>;
  53503. /** Sets the debugMesh */
  53504. set debugMesh(value: Nullable<AbstractMesh> | Nullable<LinesMesh>);
  53505. /** Gets the displayMode */
  53506. get displayMode(): number;
  53507. /** Sets the displayMode */
  53508. set displayMode(value: number);
  53509. /**
  53510. * Creates a new SkeletonViewer
  53511. * @param skeleton defines the skeleton to render
  53512. * @param mesh defines the mesh attached to the skeleton
  53513. * @param scene defines the hosting scene
  53514. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  53515. * @param renderingGroupId defines the rendering group id to use with the viewer
  53516. * @param options All of the extra constructor options for the SkeletonViewer
  53517. */
  53518. constructor(
  53519. /** defines the skeleton to render */
  53520. skeleton: Skeleton,
  53521. /** defines the mesh attached to the skeleton */
  53522. mesh: AbstractMesh,
  53523. /** The Scene scope*/
  53524. scene: Scene,
  53525. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  53526. autoUpdateBonesMatrices?: boolean,
  53527. /** defines the rendering group id to use with the viewer */
  53528. renderingGroupId?: number,
  53529. /** is the options for the viewer */
  53530. options?: Partial<ISkeletonViewerOptions>);
  53531. /** The Dynamic bindings for the update functions */
  53532. private _bindObs;
  53533. /** Update the viewer to sync with current skeleton state, only used to manually update. */
  53534. update(): void;
  53535. /** Gets or sets a boolean indicating if the viewer is enabled */
  53536. set isEnabled(value: boolean);
  53537. get isEnabled(): boolean;
  53538. private _getBonePosition;
  53539. private _getLinesForBonesWithLength;
  53540. private _getLinesForBonesNoLength;
  53541. /** function to revert the mesh and scene back to the initial state. */
  53542. private _revert;
  53543. /** function to build and bind sphere joint points and spur bone representations. */
  53544. private _buildSpheresAndSpurs;
  53545. /** Update the viewer to sync with current skeleton state, only used for the line display. */
  53546. private _displayLinesUpdate;
  53547. /** Changes the displayMode of the skeleton viewer
  53548. * @param mode The displayMode numerical value
  53549. */
  53550. changeDisplayMode(mode: number): void;
  53551. /** Changes the displayMode of the skeleton viewer
  53552. * @param option String of the option name
  53553. * @param value The numerical option value
  53554. */
  53555. changeDisplayOptions(option: string, value: number): void;
  53556. /** Release associated resources */
  53557. dispose(): void;
  53558. }
  53559. }
  53560. declare module "babylonjs/Debug/index" {
  53561. export * from "babylonjs/Debug/axesViewer";
  53562. export * from "babylonjs/Debug/boneAxesViewer";
  53563. export * from "babylonjs/Debug/debugLayer";
  53564. export * from "babylonjs/Debug/physicsViewer";
  53565. export * from "babylonjs/Debug/rayHelper";
  53566. export * from "babylonjs/Debug/skeletonViewer";
  53567. export * from "babylonjs/Debug/ISkeletonViewer";
  53568. }
  53569. declare module "babylonjs/DeviceInput/InputDevices/deviceEnums" {
  53570. /**
  53571. * Enum for Device Types
  53572. */
  53573. export enum DeviceType {
  53574. /** Generic */
  53575. Generic = 0,
  53576. /** Keyboard */
  53577. Keyboard = 1,
  53578. /** Mouse */
  53579. Mouse = 2,
  53580. /** Touch Pointers */
  53581. Touch = 3,
  53582. /** PS4 Dual Shock */
  53583. DualShock = 4,
  53584. /** Xbox */
  53585. Xbox = 5,
  53586. /** Switch Controller */
  53587. Switch = 6
  53588. }
  53589. /**
  53590. * Enum for All Pointers (Touch/Mouse)
  53591. */
  53592. export enum PointerInput {
  53593. /** Horizontal Axis */
  53594. Horizontal = 0,
  53595. /** Vertical Axis */
  53596. Vertical = 1,
  53597. /** Left Click or Touch */
  53598. LeftClick = 2,
  53599. /** Middle Click */
  53600. MiddleClick = 3,
  53601. /** Right Click */
  53602. RightClick = 4,
  53603. /** Browser Back */
  53604. BrowserBack = 5,
  53605. /** Browser Forward */
  53606. BrowserForward = 6
  53607. }
  53608. /**
  53609. * Enum for Dual Shock Gamepad
  53610. */
  53611. export enum DualShockInput {
  53612. /** Cross */
  53613. Cross = 0,
  53614. /** Circle */
  53615. Circle = 1,
  53616. /** Square */
  53617. Square = 2,
  53618. /** Triangle */
  53619. Triangle = 3,
  53620. /** L1 */
  53621. L1 = 4,
  53622. /** R1 */
  53623. R1 = 5,
  53624. /** L2 */
  53625. L2 = 6,
  53626. /** R2 */
  53627. R2 = 7,
  53628. /** Share */
  53629. Share = 8,
  53630. /** Options */
  53631. Options = 9,
  53632. /** L3 */
  53633. L3 = 10,
  53634. /** R3 */
  53635. R3 = 11,
  53636. /** DPadUp */
  53637. DPadUp = 12,
  53638. /** DPadDown */
  53639. DPadDown = 13,
  53640. /** DPadLeft */
  53641. DPadLeft = 14,
  53642. /** DRight */
  53643. DPadRight = 15,
  53644. /** Home */
  53645. Home = 16,
  53646. /** TouchPad */
  53647. TouchPad = 17,
  53648. /** LStickXAxis */
  53649. LStickXAxis = 18,
  53650. /** LStickYAxis */
  53651. LStickYAxis = 19,
  53652. /** RStickXAxis */
  53653. RStickXAxis = 20,
  53654. /** RStickYAxis */
  53655. RStickYAxis = 21
  53656. }
  53657. /**
  53658. * Enum for Xbox Gamepad
  53659. */
  53660. export enum XboxInput {
  53661. /** A */
  53662. A = 0,
  53663. /** B */
  53664. B = 1,
  53665. /** X */
  53666. X = 2,
  53667. /** Y */
  53668. Y = 3,
  53669. /** LB */
  53670. LB = 4,
  53671. /** RB */
  53672. RB = 5,
  53673. /** LT */
  53674. LT = 6,
  53675. /** RT */
  53676. RT = 7,
  53677. /** Back */
  53678. Back = 8,
  53679. /** Start */
  53680. Start = 9,
  53681. /** LS */
  53682. LS = 10,
  53683. /** RS */
  53684. RS = 11,
  53685. /** DPadUp */
  53686. DPadUp = 12,
  53687. /** DPadDown */
  53688. DPadDown = 13,
  53689. /** DPadLeft */
  53690. DPadLeft = 14,
  53691. /** DRight */
  53692. DPadRight = 15,
  53693. /** Home */
  53694. Home = 16,
  53695. /** LStickXAxis */
  53696. LStickXAxis = 17,
  53697. /** LStickYAxis */
  53698. LStickYAxis = 18,
  53699. /** RStickXAxis */
  53700. RStickXAxis = 19,
  53701. /** RStickYAxis */
  53702. RStickYAxis = 20
  53703. }
  53704. /**
  53705. * Enum for Switch (Pro/JoyCon L+R) Gamepad
  53706. */
  53707. export enum SwitchInput {
  53708. /** B */
  53709. B = 0,
  53710. /** A */
  53711. A = 1,
  53712. /** Y */
  53713. Y = 2,
  53714. /** X */
  53715. X = 3,
  53716. /** L */
  53717. L = 4,
  53718. /** R */
  53719. R = 5,
  53720. /** ZL */
  53721. ZL = 6,
  53722. /** ZR */
  53723. ZR = 7,
  53724. /** Minus */
  53725. Minus = 8,
  53726. /** Plus */
  53727. Plus = 9,
  53728. /** LS */
  53729. LS = 10,
  53730. /** RS */
  53731. RS = 11,
  53732. /** DPadUp */
  53733. DPadUp = 12,
  53734. /** DPadDown */
  53735. DPadDown = 13,
  53736. /** DPadLeft */
  53737. DPadLeft = 14,
  53738. /** DRight */
  53739. DPadRight = 15,
  53740. /** Home */
  53741. Home = 16,
  53742. /** Capture */
  53743. Capture = 17,
  53744. /** LStickXAxis */
  53745. LStickXAxis = 18,
  53746. /** LStickYAxis */
  53747. LStickYAxis = 19,
  53748. /** RStickXAxis */
  53749. RStickXAxis = 20,
  53750. /** RStickYAxis */
  53751. RStickYAxis = 21
  53752. }
  53753. }
  53754. declare module "babylonjs/DeviceInput/deviceInputSystem" {
  53755. import { Engine } from "babylonjs/Engines/engine";
  53756. import { IDisposable } from "babylonjs/scene";
  53757. import { Nullable } from "babylonjs/types";
  53758. import { DeviceType } from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  53759. /**
  53760. * This class will take all inputs from Keyboard, Pointer, and
  53761. * any Gamepads and provide a polling system that all devices
  53762. * will use. This class assumes that there will only be one
  53763. * pointer device and one keyboard.
  53764. */
  53765. export class DeviceInputSystem implements IDisposable {
  53766. /**
  53767. * Callback to be triggered when a device is connected
  53768. */
  53769. onDeviceConnected: (deviceType: DeviceType, deviceSlot: number) => void;
  53770. /**
  53771. * Callback to be triggered when a device is disconnected
  53772. */
  53773. onDeviceDisconnected: (deviceType: DeviceType, deviceSlot: number) => void;
  53774. /**
  53775. * Callback to be triggered when event driven input is updated
  53776. */
  53777. onInputChanged: (deviceType: DeviceType, deviceSlot: number, inputIndex: number, previousState: Nullable<number>, currentState: Nullable<number>) => void;
  53778. private _inputs;
  53779. private _gamepads;
  53780. private _keyboardActive;
  53781. private _pointerActive;
  53782. private _elementToAttachTo;
  53783. private _keyboardDownEvent;
  53784. private _keyboardUpEvent;
  53785. private _pointerMoveEvent;
  53786. private _pointerDownEvent;
  53787. private _pointerUpEvent;
  53788. private _gamepadConnectedEvent;
  53789. private _gamepadDisconnectedEvent;
  53790. private static _MAX_KEYCODES;
  53791. private static _MAX_POINTER_INPUTS;
  53792. private constructor();
  53793. /**
  53794. * Creates a new DeviceInputSystem instance
  53795. * @param engine Engine to pull input element from
  53796. * @returns The new instance
  53797. */
  53798. static Create(engine: Engine): DeviceInputSystem;
  53799. /**
  53800. * Checks for current device input value, given an id and input index
  53801. * @param deviceName Id of connected device
  53802. * @param inputIndex Index of device input
  53803. * @returns Current value of input
  53804. */
  53805. /**
  53806. * Checks for current device input value, given an id and input index. Throws exception if requested device not initialized.
  53807. * @param deviceType Enum specifiying device type
  53808. * @param deviceSlot "Slot" or index that device is referenced in
  53809. * @param inputIndex Id of input to be checked
  53810. * @returns Current value of input
  53811. */
  53812. pollInput(deviceType: DeviceType, deviceSlot: number, inputIndex: number): number;
  53813. /**
  53814. * Dispose of all the eventlisteners
  53815. */
  53816. dispose(): void;
  53817. /**
  53818. * Add device and inputs to device array
  53819. * @param deviceType Enum specifiying device type
  53820. * @param deviceSlot "Slot" or index that device is referenced in
  53821. * @param numberOfInputs Number of input entries to create for given device
  53822. */
  53823. private _registerDevice;
  53824. /**
  53825. * Given a specific device name, remove that device from the device map
  53826. * @param deviceType Enum specifiying device type
  53827. * @param deviceSlot "Slot" or index that device is referenced in
  53828. */
  53829. private _unregisterDevice;
  53830. /**
  53831. * Handle all actions that come from keyboard interaction
  53832. */
  53833. private _handleKeyActions;
  53834. /**
  53835. * Handle all actions that come from pointer interaction
  53836. */
  53837. private _handlePointerActions;
  53838. /**
  53839. * Handle all actions that come from gamepad interaction
  53840. */
  53841. private _handleGamepadActions;
  53842. /**
  53843. * Update all non-event based devices with each frame
  53844. * @param deviceType Enum specifiying device type
  53845. * @param deviceSlot "Slot" or index that device is referenced in
  53846. * @param inputIndex Id of input to be checked
  53847. */
  53848. private _updateDevice;
  53849. /**
  53850. * Gets DeviceType from the device name
  53851. * @param deviceName Name of Device from DeviceInputSystem
  53852. * @returns DeviceType enum value
  53853. */
  53854. private _getGamepadDeviceType;
  53855. }
  53856. }
  53857. declare module "babylonjs/DeviceInput/InputDevices/deviceTypes" {
  53858. import { DeviceType, PointerInput, DualShockInput, XboxInput, SwitchInput } from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  53859. /**
  53860. * Type to handle enforcement of inputs
  53861. */
  53862. 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;
  53863. }
  53864. declare module "babylonjs/DeviceInput/InputDevices/deviceSourceManager" {
  53865. import { DeviceInputSystem } from "babylonjs/DeviceInput/deviceInputSystem";
  53866. import { Engine } from "babylonjs/Engines/engine";
  53867. import { IDisposable } from "babylonjs/scene";
  53868. import { DeviceType } from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  53869. import { Nullable } from "babylonjs/types";
  53870. import { Observable } from "babylonjs/Misc/observable";
  53871. import { DeviceInput } from "babylonjs/DeviceInput/InputDevices/deviceTypes";
  53872. /**
  53873. * Class that handles all input for a specific device
  53874. */
  53875. export class DeviceSource<T extends DeviceType> {
  53876. /** Type of device */
  53877. readonly deviceType: DeviceType;
  53878. /** "Slot" or index that device is referenced in */
  53879. readonly deviceSlot: number;
  53880. /**
  53881. * Observable to handle device input changes per device
  53882. */
  53883. readonly onInputChangedObservable: Observable<{
  53884. inputIndex: DeviceInput<T>;
  53885. previousState: Nullable<number>;
  53886. currentState: Nullable<number>;
  53887. }>;
  53888. private readonly _deviceInputSystem;
  53889. /**
  53890. * Default Constructor
  53891. * @param deviceInputSystem Reference to DeviceInputSystem
  53892. * @param deviceType Type of device
  53893. * @param deviceSlot "Slot" or index that device is referenced in
  53894. */
  53895. constructor(deviceInputSystem: DeviceInputSystem,
  53896. /** Type of device */
  53897. deviceType: DeviceType,
  53898. /** "Slot" or index that device is referenced in */
  53899. deviceSlot?: number);
  53900. /**
  53901. * Get input for specific input
  53902. * @param inputIndex index of specific input on device
  53903. * @returns Input value from DeviceInputSystem
  53904. */
  53905. getInput(inputIndex: DeviceInput<T>): number;
  53906. }
  53907. /**
  53908. * Class to keep track of devices
  53909. */
  53910. export class DeviceSourceManager implements IDisposable {
  53911. /**
  53912. * Observable to be triggered when before a device is connected
  53913. */
  53914. readonly onBeforeDeviceConnectedObservable: Observable<{
  53915. deviceType: DeviceType;
  53916. deviceSlot: number;
  53917. }>;
  53918. /**
  53919. * Observable to be triggered when before a device is disconnected
  53920. */
  53921. readonly onBeforeDeviceDisconnectedObservable: Observable<{
  53922. deviceType: DeviceType;
  53923. deviceSlot: number;
  53924. }>;
  53925. /**
  53926. * Observable to be triggered when after a device is connected
  53927. */
  53928. readonly onAfterDeviceConnectedObservable: Observable<{
  53929. deviceType: DeviceType;
  53930. deviceSlot: number;
  53931. }>;
  53932. /**
  53933. * Observable to be triggered when after a device is disconnected
  53934. */
  53935. readonly onAfterDeviceDisconnectedObservable: Observable<{
  53936. deviceType: DeviceType;
  53937. deviceSlot: number;
  53938. }>;
  53939. private readonly _devices;
  53940. private readonly _firstDevice;
  53941. private readonly _deviceInputSystem;
  53942. /**
  53943. * Default Constructor
  53944. * @param engine engine to pull input element from
  53945. */
  53946. constructor(engine: Engine);
  53947. /**
  53948. * Gets a DeviceSource, given a type and slot
  53949. * @param deviceType Enum specifying device type
  53950. * @param deviceSlot "Slot" or index that device is referenced in
  53951. * @returns DeviceSource object
  53952. */
  53953. getDeviceSource<T extends DeviceType>(deviceType: T, deviceSlot?: number): Nullable<DeviceSource<T>>;
  53954. /**
  53955. * Gets an array of DeviceSource objects for a given device type
  53956. * @param deviceType Enum specifying device type
  53957. * @returns Array of DeviceSource objects
  53958. */
  53959. getDeviceSources<T extends DeviceType>(deviceType: T): ReadonlyArray<DeviceSource<T>>;
  53960. /**
  53961. * Dispose of DeviceInputSystem and other parts
  53962. */
  53963. dispose(): void;
  53964. /**
  53965. * Function to add device name to device list
  53966. * @param deviceType Enum specifying device type
  53967. * @param deviceSlot "Slot" or index that device is referenced in
  53968. */
  53969. private _addDevice;
  53970. /**
  53971. * Function to remove device name to device list
  53972. * @param deviceType Enum specifying device type
  53973. * @param deviceSlot "Slot" or index that device is referenced in
  53974. */
  53975. private _removeDevice;
  53976. /**
  53977. * Updates array storing first connected device of each type
  53978. * @param type Type of Device
  53979. */
  53980. private _updateFirstDevices;
  53981. }
  53982. }
  53983. declare module "babylonjs/DeviceInput/index" {
  53984. export * from "babylonjs/DeviceInput/deviceInputSystem";
  53985. export * from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  53986. export * from "babylonjs/DeviceInput/InputDevices/deviceTypes";
  53987. import "babylonjs/DeviceInput/InputDevices/deviceSourceManager";
  53988. export * from "babylonjs/DeviceInput/InputDevices/deviceSourceManager";
  53989. }
  53990. declare module "babylonjs/Engines/nullEngine" {
  53991. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  53992. import { Engine } from "babylonjs/Engines/engine";
  53993. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  53994. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  53995. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  53996. import { Effect } from "babylonjs/Materials/effect";
  53997. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  53998. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  53999. import { IColor4Like, IViewportLike } from "babylonjs/Maths/math.like";
  54000. import { ISceneLike } from "babylonjs/Engines/thinEngine";
  54001. /**
  54002. * Options to create the null engine
  54003. */
  54004. export class NullEngineOptions {
  54005. /**
  54006. * Render width (Default: 512)
  54007. */
  54008. renderWidth: number;
  54009. /**
  54010. * Render height (Default: 256)
  54011. */
  54012. renderHeight: number;
  54013. /**
  54014. * Texture size (Default: 512)
  54015. */
  54016. textureSize: number;
  54017. /**
  54018. * If delta time between frames should be constant
  54019. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  54020. */
  54021. deterministicLockstep: boolean;
  54022. /**
  54023. * Maximum about of steps between frames (Default: 4)
  54024. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  54025. */
  54026. lockstepMaxSteps: number;
  54027. /**
  54028. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  54029. */
  54030. useHighPrecisionMatrix?: boolean;
  54031. }
  54032. /**
  54033. * The null engine class provides support for headless version of babylon.js.
  54034. * This can be used in server side scenario or for testing purposes
  54035. */
  54036. export class NullEngine extends Engine {
  54037. private _options;
  54038. /**
  54039. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  54040. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  54041. * @returns true if engine is in deterministic lock step mode
  54042. */
  54043. isDeterministicLockStep(): boolean;
  54044. /**
  54045. * Gets the max steps when engine is running in deterministic lock step
  54046. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  54047. * @returns the max steps
  54048. */
  54049. getLockstepMaxSteps(): number;
  54050. /**
  54051. * Gets the current hardware scaling level.
  54052. * By default the hardware scaling level is computed from the window device ratio.
  54053. * 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.
  54054. * @returns a number indicating the current hardware scaling level
  54055. */
  54056. getHardwareScalingLevel(): number;
  54057. constructor(options?: NullEngineOptions);
  54058. /**
  54059. * Creates a vertex buffer
  54060. * @param vertices the data for the vertex buffer
  54061. * @returns the new WebGL static buffer
  54062. */
  54063. createVertexBuffer(vertices: FloatArray): DataBuffer;
  54064. /**
  54065. * Creates a new index buffer
  54066. * @param indices defines the content of the index buffer
  54067. * @param updatable defines if the index buffer must be updatable
  54068. * @returns a new webGL buffer
  54069. */
  54070. createIndexBuffer(indices: IndicesArray): DataBuffer;
  54071. /**
  54072. * Clear the current render buffer or the current render target (if any is set up)
  54073. * @param color defines the color to use
  54074. * @param backBuffer defines if the back buffer must be cleared
  54075. * @param depth defines if the depth buffer must be cleared
  54076. * @param stencil defines if the stencil buffer must be cleared
  54077. */
  54078. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  54079. /**
  54080. * Gets the current render width
  54081. * @param useScreen defines if screen size must be used (or the current render target if any)
  54082. * @returns a number defining the current render width
  54083. */
  54084. getRenderWidth(useScreen?: boolean): number;
  54085. /**
  54086. * Gets the current render height
  54087. * @param useScreen defines if screen size must be used (or the current render target if any)
  54088. * @returns a number defining the current render height
  54089. */
  54090. getRenderHeight(useScreen?: boolean): number;
  54091. /**
  54092. * Set the WebGL's viewport
  54093. * @param viewport defines the viewport element to be used
  54094. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  54095. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  54096. */
  54097. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  54098. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  54099. /**
  54100. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  54101. * @param pipelineContext defines the pipeline context to use
  54102. * @param uniformsNames defines the list of uniform names
  54103. * @returns an array of webGL uniform locations
  54104. */
  54105. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  54106. /**
  54107. * Gets the lsit of active attributes for a given webGL program
  54108. * @param pipelineContext defines the pipeline context to use
  54109. * @param attributesNames defines the list of attribute names to get
  54110. * @returns an array of indices indicating the offset of each attribute
  54111. */
  54112. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  54113. /**
  54114. * Binds an effect to the webGL context
  54115. * @param effect defines the effect to bind
  54116. */
  54117. bindSamplers(effect: Effect): void;
  54118. /**
  54119. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  54120. * @param effect defines the effect to activate
  54121. */
  54122. enableEffect(effect: Effect): void;
  54123. /**
  54124. * Set various states to the webGL context
  54125. * @param culling defines backface culling state
  54126. * @param zOffset defines the value to apply to zOffset (0 by default)
  54127. * @param force defines if states must be applied even if cache is up to date
  54128. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  54129. */
  54130. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  54131. /**
  54132. * Set the value of an uniform to an array of int32
  54133. * @param uniform defines the webGL uniform location where to store the value
  54134. * @param array defines the array of int32 to store
  54135. */
  54136. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  54137. /**
  54138. * Set the value of an uniform to an array of int32 (stored as vec2)
  54139. * @param uniform defines the webGL uniform location where to store the value
  54140. * @param array defines the array of int32 to store
  54141. */
  54142. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  54143. /**
  54144. * Set the value of an uniform to an array of int32 (stored as vec3)
  54145. * @param uniform defines the webGL uniform location where to store the value
  54146. * @param array defines the array of int32 to store
  54147. */
  54148. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  54149. /**
  54150. * Set the value of an uniform to an array of int32 (stored as vec4)
  54151. * @param uniform defines the webGL uniform location where to store the value
  54152. * @param array defines the array of int32 to store
  54153. */
  54154. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  54155. /**
  54156. * Set the value of an uniform to an array of float32
  54157. * @param uniform defines the webGL uniform location where to store the value
  54158. * @param array defines the array of float32 to store
  54159. */
  54160. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  54161. /**
  54162. * Set the value of an uniform to an array of float32 (stored as vec2)
  54163. * @param uniform defines the webGL uniform location where to store the value
  54164. * @param array defines the array of float32 to store
  54165. */
  54166. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  54167. /**
  54168. * Set the value of an uniform to an array of float32 (stored as vec3)
  54169. * @param uniform defines the webGL uniform location where to store the value
  54170. * @param array defines the array of float32 to store
  54171. */
  54172. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  54173. /**
  54174. * Set the value of an uniform to an array of float32 (stored as vec4)
  54175. * @param uniform defines the webGL uniform location where to store the value
  54176. * @param array defines the array of float32 to store
  54177. */
  54178. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  54179. /**
  54180. * Set the value of an uniform to an array of number
  54181. * @param uniform defines the webGL uniform location where to store the value
  54182. * @param array defines the array of number to store
  54183. */
  54184. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  54185. /**
  54186. * Set the value of an uniform to an array of number (stored as vec2)
  54187. * @param uniform defines the webGL uniform location where to store the value
  54188. * @param array defines the array of number to store
  54189. */
  54190. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  54191. /**
  54192. * Set the value of an uniform to an array of number (stored as vec3)
  54193. * @param uniform defines the webGL uniform location where to store the value
  54194. * @param array defines the array of number to store
  54195. */
  54196. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  54197. /**
  54198. * Set the value of an uniform to an array of number (stored as vec4)
  54199. * @param uniform defines the webGL uniform location where to store the value
  54200. * @param array defines the array of number to store
  54201. */
  54202. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  54203. /**
  54204. * Set the value of an uniform to an array of float32 (stored as matrices)
  54205. * @param uniform defines the webGL uniform location where to store the value
  54206. * @param matrices defines the array of float32 to store
  54207. */
  54208. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  54209. /**
  54210. * Set the value of an uniform to a matrix (3x3)
  54211. * @param uniform defines the webGL uniform location where to store the value
  54212. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  54213. */
  54214. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  54215. /**
  54216. * Set the value of an uniform to a matrix (2x2)
  54217. * @param uniform defines the webGL uniform location where to store the value
  54218. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  54219. */
  54220. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  54221. /**
  54222. * Set the value of an uniform to a number (float)
  54223. * @param uniform defines the webGL uniform location where to store the value
  54224. * @param value defines the float number to store
  54225. */
  54226. setFloat(uniform: WebGLUniformLocation, value: number): void;
  54227. /**
  54228. * Set the value of an uniform to a vec2
  54229. * @param uniform defines the webGL uniform location where to store the value
  54230. * @param x defines the 1st component of the value
  54231. * @param y defines the 2nd component of the value
  54232. */
  54233. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  54234. /**
  54235. * Set the value of an uniform to a vec3
  54236. * @param uniform defines the webGL uniform location where to store the value
  54237. * @param x defines the 1st component of the value
  54238. * @param y defines the 2nd component of the value
  54239. * @param z defines the 3rd component of the value
  54240. */
  54241. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  54242. /**
  54243. * Set the value of an uniform to a boolean
  54244. * @param uniform defines the webGL uniform location where to store the value
  54245. * @param bool defines the boolean to store
  54246. */
  54247. setBool(uniform: WebGLUniformLocation, bool: number): void;
  54248. /**
  54249. * Set the value of an uniform to a vec4
  54250. * @param uniform defines the webGL uniform location where to store the value
  54251. * @param x defines the 1st component of the value
  54252. * @param y defines the 2nd component of the value
  54253. * @param z defines the 3rd component of the value
  54254. * @param w defines the 4th component of the value
  54255. */
  54256. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  54257. /**
  54258. * Sets the current alpha mode
  54259. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  54260. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  54261. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  54262. */
  54263. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  54264. /**
  54265. * Bind webGl buffers directly to the webGL context
  54266. * @param vertexBuffers defines the vertex buffer to bind
  54267. * @param indexBuffer defines the index buffer to bind
  54268. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  54269. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  54270. * @param effect defines the effect associated with the vertex buffer
  54271. */
  54272. bindBuffers(vertexBuffers: {
  54273. [key: string]: VertexBuffer;
  54274. }, indexBuffer: DataBuffer, effect: Effect): void;
  54275. /**
  54276. * Force the entire cache to be cleared
  54277. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  54278. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  54279. */
  54280. wipeCaches(bruteForce?: boolean): void;
  54281. /**
  54282. * Send a draw order
  54283. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  54284. * @param indexStart defines the starting index
  54285. * @param indexCount defines the number of index to draw
  54286. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  54287. */
  54288. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  54289. /**
  54290. * Draw a list of indexed primitives
  54291. * @param fillMode defines the primitive to use
  54292. * @param indexStart defines the starting index
  54293. * @param indexCount defines the number of index to draw
  54294. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  54295. */
  54296. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  54297. /**
  54298. * Draw a list of unindexed primitives
  54299. * @param fillMode defines the primitive to use
  54300. * @param verticesStart defines the index of first vertex to draw
  54301. * @param verticesCount defines the count of vertices to draw
  54302. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  54303. */
  54304. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  54305. /** @hidden */
  54306. _createTexture(): WebGLTexture;
  54307. /** @hidden */
  54308. _releaseTexture(texture: InternalTexture): void;
  54309. /**
  54310. * Usually called from Texture.ts.
  54311. * Passed information to create a WebGLTexture
  54312. * @param urlArg defines a value which contains one of the following:
  54313. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  54314. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  54315. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  54316. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  54317. * @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)
  54318. * @param scene needed for loading to the correct scene
  54319. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  54320. * @param onLoad optional callback to be called upon successful completion
  54321. * @param onError optional callback to be called upon failure
  54322. * @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
  54323. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  54324. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  54325. * @param forcedExtension defines the extension to use to pick the right loader
  54326. * @param mimeType defines an optional mime type
  54327. * @returns a InternalTexture for assignment back into BABYLON.Texture
  54328. */
  54329. 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;
  54330. /**
  54331. * Creates a new render target texture
  54332. * @param size defines the size of the texture
  54333. * @param options defines the options used to create the texture
  54334. * @returns a new render target texture stored in an InternalTexture
  54335. */
  54336. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  54337. /**
  54338. * Update the sampling mode of a given texture
  54339. * @param samplingMode defines the required sampling mode
  54340. * @param texture defines the texture to update
  54341. */
  54342. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  54343. /**
  54344. * Binds the frame buffer to the specified texture.
  54345. * @param texture The texture to render to or null for the default canvas
  54346. * @param faceIndex The face of the texture to render to in case of cube texture
  54347. * @param requiredWidth The width of the target to render to
  54348. * @param requiredHeight The height of the target to render to
  54349. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  54350. * @param lodLevel defines le lod level to bind to the frame buffer
  54351. */
  54352. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  54353. /**
  54354. * Unbind the current render target texture from the webGL context
  54355. * @param texture defines the render target texture to unbind
  54356. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  54357. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  54358. */
  54359. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  54360. /**
  54361. * Creates a dynamic vertex buffer
  54362. * @param vertices the data for the dynamic vertex buffer
  54363. * @returns the new WebGL dynamic buffer
  54364. */
  54365. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  54366. /**
  54367. * Update the content of a dynamic texture
  54368. * @param texture defines the texture to update
  54369. * @param canvas defines the canvas containing the source
  54370. * @param invertY defines if data must be stored with Y axis inverted
  54371. * @param premulAlpha defines if alpha is stored as premultiplied
  54372. * @param format defines the format of the data
  54373. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  54374. */
  54375. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  54376. /**
  54377. * Gets a boolean indicating if all created effects are ready
  54378. * @returns true if all effects are ready
  54379. */
  54380. areAllEffectsReady(): boolean;
  54381. /**
  54382. * @hidden
  54383. * Get the current error code of the webGL context
  54384. * @returns the error code
  54385. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  54386. */
  54387. getError(): number;
  54388. /** @hidden */
  54389. _getUnpackAlignement(): number;
  54390. /** @hidden */
  54391. _unpackFlipY(value: boolean): void;
  54392. /**
  54393. * Update a dynamic index buffer
  54394. * @param indexBuffer defines the target index buffer
  54395. * @param indices defines the data to update
  54396. * @param offset defines the offset in the target index buffer where update should start
  54397. */
  54398. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  54399. /**
  54400. * Updates a dynamic vertex buffer.
  54401. * @param vertexBuffer the vertex buffer to update
  54402. * @param vertices the data used to update the vertex buffer
  54403. * @param byteOffset the byte offset of the data (optional)
  54404. * @param byteLength the byte length of the data (optional)
  54405. */
  54406. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  54407. /** @hidden */
  54408. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  54409. /** @hidden */
  54410. _bindTexture(channel: number, texture: InternalTexture): void;
  54411. protected _deleteBuffer(buffer: WebGLBuffer): void;
  54412. /**
  54413. * 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
  54414. */
  54415. releaseEffects(): void;
  54416. displayLoadingUI(): void;
  54417. hideLoadingUI(): void;
  54418. /** @hidden */
  54419. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  54420. /** @hidden */
  54421. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  54422. /** @hidden */
  54423. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  54424. /** @hidden */
  54425. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  54426. }
  54427. }
  54428. declare module "babylonjs/Instrumentation/timeToken" {
  54429. import { Nullable } from "babylonjs/types";
  54430. /**
  54431. * @hidden
  54432. **/
  54433. export class _TimeToken {
  54434. _startTimeQuery: Nullable<WebGLQuery>;
  54435. _endTimeQuery: Nullable<WebGLQuery>;
  54436. _timeElapsedQuery: Nullable<WebGLQuery>;
  54437. _timeElapsedQueryEnded: boolean;
  54438. }
  54439. }
  54440. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  54441. import { Nullable, int } from "babylonjs/types";
  54442. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  54443. /** @hidden */
  54444. export class _OcclusionDataStorage {
  54445. /** @hidden */
  54446. occlusionInternalRetryCounter: number;
  54447. /** @hidden */
  54448. isOcclusionQueryInProgress: boolean;
  54449. /** @hidden */
  54450. isOccluded: boolean;
  54451. /** @hidden */
  54452. occlusionRetryCount: number;
  54453. /** @hidden */
  54454. occlusionType: number;
  54455. /** @hidden */
  54456. occlusionQueryAlgorithmType: number;
  54457. }
  54458. module "babylonjs/Engines/engine" {
  54459. interface Engine {
  54460. /**
  54461. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  54462. * @return the new query
  54463. */
  54464. createQuery(): WebGLQuery;
  54465. /**
  54466. * Delete and release a webGL query
  54467. * @param query defines the query to delete
  54468. * @return the current engine
  54469. */
  54470. deleteQuery(query: WebGLQuery): Engine;
  54471. /**
  54472. * Check if a given query has resolved and got its value
  54473. * @param query defines the query to check
  54474. * @returns true if the query got its value
  54475. */
  54476. isQueryResultAvailable(query: WebGLQuery): boolean;
  54477. /**
  54478. * Gets the value of a given query
  54479. * @param query defines the query to check
  54480. * @returns the value of the query
  54481. */
  54482. getQueryResult(query: WebGLQuery): number;
  54483. /**
  54484. * Initiates an occlusion query
  54485. * @param algorithmType defines the algorithm to use
  54486. * @param query defines the query to use
  54487. * @returns the current engine
  54488. * @see https://doc.babylonjs.com/features/occlusionquery
  54489. */
  54490. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  54491. /**
  54492. * Ends an occlusion query
  54493. * @see https://doc.babylonjs.com/features/occlusionquery
  54494. * @param algorithmType defines the algorithm to use
  54495. * @returns the current engine
  54496. */
  54497. endOcclusionQuery(algorithmType: number): Engine;
  54498. /**
  54499. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  54500. * Please note that only one query can be issued at a time
  54501. * @returns a time token used to track the time span
  54502. */
  54503. startTimeQuery(): Nullable<_TimeToken>;
  54504. /**
  54505. * Ends a time query
  54506. * @param token defines the token used to measure the time span
  54507. * @returns the time spent (in ns)
  54508. */
  54509. endTimeQuery(token: _TimeToken): int;
  54510. /** @hidden */
  54511. _currentNonTimestampToken: Nullable<_TimeToken>;
  54512. /** @hidden */
  54513. _createTimeQuery(): WebGLQuery;
  54514. /** @hidden */
  54515. _deleteTimeQuery(query: WebGLQuery): void;
  54516. /** @hidden */
  54517. _getGlAlgorithmType(algorithmType: number): number;
  54518. /** @hidden */
  54519. _getTimeQueryResult(query: WebGLQuery): any;
  54520. /** @hidden */
  54521. _getTimeQueryAvailability(query: WebGLQuery): any;
  54522. }
  54523. }
  54524. module "babylonjs/Meshes/abstractMesh" {
  54525. interface AbstractMesh {
  54526. /**
  54527. * Backing filed
  54528. * @hidden
  54529. */
  54530. __occlusionDataStorage: _OcclusionDataStorage;
  54531. /**
  54532. * Access property
  54533. * @hidden
  54534. */
  54535. _occlusionDataStorage: _OcclusionDataStorage;
  54536. /**
  54537. * 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.
  54538. * The default value is -1 which means don't break the query and wait till the result
  54539. * @see https://doc.babylonjs.com/features/occlusionquery
  54540. */
  54541. occlusionRetryCount: number;
  54542. /**
  54543. * 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:
  54544. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  54545. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  54546. * * 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.
  54547. * @see https://doc.babylonjs.com/features/occlusionquery
  54548. */
  54549. occlusionType: number;
  54550. /**
  54551. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  54552. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  54553. * * 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.
  54554. * @see https://doc.babylonjs.com/features/occlusionquery
  54555. */
  54556. occlusionQueryAlgorithmType: number;
  54557. /**
  54558. * 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
  54559. * @see https://doc.babylonjs.com/features/occlusionquery
  54560. */
  54561. isOccluded: boolean;
  54562. /**
  54563. * Flag to check the progress status of the query
  54564. * @see https://doc.babylonjs.com/features/occlusionquery
  54565. */
  54566. isOcclusionQueryInProgress: boolean;
  54567. }
  54568. }
  54569. }
  54570. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  54571. import { Nullable } from "babylonjs/types";
  54572. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  54573. /** @hidden */
  54574. export var _forceTransformFeedbackToBundle: boolean;
  54575. module "babylonjs/Engines/engine" {
  54576. interface Engine {
  54577. /**
  54578. * Creates a webGL transform feedback object
  54579. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  54580. * @returns the webGL transform feedback object
  54581. */
  54582. createTransformFeedback(): WebGLTransformFeedback;
  54583. /**
  54584. * Delete a webGL transform feedback object
  54585. * @param value defines the webGL transform feedback object to delete
  54586. */
  54587. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  54588. /**
  54589. * Bind a webGL transform feedback object to the webgl context
  54590. * @param value defines the webGL transform feedback object to bind
  54591. */
  54592. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  54593. /**
  54594. * Begins a transform feedback operation
  54595. * @param usePoints defines if points or triangles must be used
  54596. */
  54597. beginTransformFeedback(usePoints: boolean): void;
  54598. /**
  54599. * Ends a transform feedback operation
  54600. */
  54601. endTransformFeedback(): void;
  54602. /**
  54603. * Specify the varyings to use with transform feedback
  54604. * @param program defines the associated webGL program
  54605. * @param value defines the list of strings representing the varying names
  54606. */
  54607. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  54608. /**
  54609. * Bind a webGL buffer for a transform feedback operation
  54610. * @param value defines the webGL buffer to bind
  54611. */
  54612. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  54613. }
  54614. }
  54615. }
  54616. declare module "babylonjs/Engines/Extensions/engine.views" {
  54617. import { Camera } from "babylonjs/Cameras/camera";
  54618. import { Nullable } from "babylonjs/types";
  54619. /**
  54620. * Class used to define an additional view for the engine
  54621. * @see https://doc.babylonjs.com/how_to/multi_canvases
  54622. */
  54623. export class EngineView {
  54624. /** Defines the canvas where to render the view */
  54625. target: HTMLCanvasElement;
  54626. /** Defines an optional camera used to render the view (will use active camera else) */
  54627. camera?: Camera;
  54628. }
  54629. module "babylonjs/Engines/engine" {
  54630. interface Engine {
  54631. /**
  54632. * Gets or sets the HTML element to use for attaching events
  54633. */
  54634. inputElement: Nullable<HTMLElement>;
  54635. /**
  54636. * Gets the current engine view
  54637. * @see https://doc.babylonjs.com/how_to/multi_canvases
  54638. */
  54639. activeView: Nullable<EngineView>;
  54640. /** Gets or sets the list of views */
  54641. views: EngineView[];
  54642. /**
  54643. * Register a new child canvas
  54644. * @param canvas defines the canvas to register
  54645. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  54646. * @returns the associated view
  54647. */
  54648. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  54649. /**
  54650. * Remove a registered child canvas
  54651. * @param canvas defines the canvas to remove
  54652. * @returns the current engine
  54653. */
  54654. unRegisterView(canvas: HTMLCanvasElement): Engine;
  54655. }
  54656. }
  54657. }
  54658. declare module "babylonjs/Engines/Extensions/engine.textureSelector" {
  54659. import { Nullable } from "babylonjs/types";
  54660. module "babylonjs/Engines/engine" {
  54661. interface Engine {
  54662. /** @hidden */
  54663. _excludedCompressedTextures: string[];
  54664. /** @hidden */
  54665. _textureFormatInUse: string;
  54666. /**
  54667. * Gets the list of texture formats supported
  54668. */
  54669. readonly texturesSupported: Array<string>;
  54670. /**
  54671. * Gets the texture format in use
  54672. */
  54673. readonly textureFormatInUse: Nullable<string>;
  54674. /**
  54675. * Set the compressed texture extensions or file names to skip.
  54676. *
  54677. * @param skippedFiles defines the list of those texture files you want to skip
  54678. * Example: [".dds", ".env", "myfile.png"]
  54679. */
  54680. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  54681. /**
  54682. * Set the compressed texture format to use, based on the formats you have, and the formats
  54683. * supported by the hardware / browser.
  54684. *
  54685. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  54686. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  54687. * to API arguments needed to compressed textures. This puts the burden on the container
  54688. * generator to house the arcane code for determining these for current & future formats.
  54689. *
  54690. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  54691. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  54692. *
  54693. * Note: The result of this call is not taken into account when a texture is base64.
  54694. *
  54695. * @param formatsAvailable defines the list of those format families you have created
  54696. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  54697. *
  54698. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  54699. * @returns The extension selected.
  54700. */
  54701. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  54702. }
  54703. }
  54704. }
  54705. declare module "babylonjs/Engines/Extensions/index" {
  54706. export * from "babylonjs/Engines/Extensions/engine.alpha";
  54707. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  54708. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  54709. export * from "babylonjs/Engines/Extensions/engine.multiview";
  54710. export * from "babylonjs/Engines/Extensions/engine.rawTexture";
  54711. export * from "babylonjs/Engines/Extensions/engine.dynamicTexture";
  54712. export * from "babylonjs/Engines/Extensions/engine.videoTexture";
  54713. export * from "babylonjs/Engines/Extensions/engine.multiRender";
  54714. export * from "babylonjs/Engines/Extensions/engine.cubeTexture";
  54715. export * from "babylonjs/Engines/Extensions/engine.renderTarget";
  54716. export * from "babylonjs/Engines/Extensions/engine.renderTargetCube";
  54717. export * from "babylonjs/Engines/Extensions/engine.webVR";
  54718. export * from "babylonjs/Engines/Extensions/engine.uniformBuffer";
  54719. export * from "babylonjs/Engines/Extensions/engine.dynamicBuffer";
  54720. export * from "babylonjs/Engines/Extensions/engine.views";
  54721. export * from "babylonjs/Engines/Extensions/engine.readTexture";
  54722. import "babylonjs/Engines/Extensions/engine.textureSelector";
  54723. export * from "babylonjs/Engines/Extensions/engine.textureSelector";
  54724. }
  54725. declare module "babylonjs/Misc/HighDynamicRange/panoramaToCubemap" {
  54726. import { Nullable } from "babylonjs/types";
  54727. /**
  54728. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  54729. */
  54730. export interface CubeMapInfo {
  54731. /**
  54732. * The pixel array for the front face.
  54733. * This is stored in format, left to right, up to down format.
  54734. */
  54735. front: Nullable<ArrayBufferView>;
  54736. /**
  54737. * The pixel array for the back face.
  54738. * This is stored in format, left to right, up to down format.
  54739. */
  54740. back: Nullable<ArrayBufferView>;
  54741. /**
  54742. * The pixel array for the left face.
  54743. * This is stored in format, left to right, up to down format.
  54744. */
  54745. left: Nullable<ArrayBufferView>;
  54746. /**
  54747. * The pixel array for the right face.
  54748. * This is stored in format, left to right, up to down format.
  54749. */
  54750. right: Nullable<ArrayBufferView>;
  54751. /**
  54752. * The pixel array for the up face.
  54753. * This is stored in format, left to right, up to down format.
  54754. */
  54755. up: Nullable<ArrayBufferView>;
  54756. /**
  54757. * The pixel array for the down face.
  54758. * This is stored in format, left to right, up to down format.
  54759. */
  54760. down: Nullable<ArrayBufferView>;
  54761. /**
  54762. * The size of the cubemap stored.
  54763. *
  54764. * Each faces will be size * size pixels.
  54765. */
  54766. size: number;
  54767. /**
  54768. * The format of the texture.
  54769. *
  54770. * RGBA, RGB.
  54771. */
  54772. format: number;
  54773. /**
  54774. * The type of the texture data.
  54775. *
  54776. * UNSIGNED_INT, FLOAT.
  54777. */
  54778. type: number;
  54779. /**
  54780. * Specifies whether the texture is in gamma space.
  54781. */
  54782. gammaSpace: boolean;
  54783. }
  54784. /**
  54785. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  54786. */
  54787. export class PanoramaToCubeMapTools {
  54788. private static FACE_LEFT;
  54789. private static FACE_RIGHT;
  54790. private static FACE_FRONT;
  54791. private static FACE_BACK;
  54792. private static FACE_DOWN;
  54793. private static FACE_UP;
  54794. /**
  54795. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  54796. *
  54797. * @param float32Array The source data.
  54798. * @param inputWidth The width of the input panorama.
  54799. * @param inputHeight The height of the input panorama.
  54800. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  54801. * @return The cubemap data
  54802. */
  54803. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  54804. private static CreateCubemapTexture;
  54805. private static CalcProjectionSpherical;
  54806. }
  54807. }
  54808. declare module "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial" {
  54809. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  54810. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54811. import { Nullable } from "babylonjs/types";
  54812. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  54813. /**
  54814. * Helper class dealing with the extraction of spherical polynomial dataArray
  54815. * from a cube map.
  54816. */
  54817. export class CubeMapToSphericalPolynomialTools {
  54818. private static FileFaces;
  54819. /**
  54820. * Converts a texture to the according Spherical Polynomial data.
  54821. * This extracts the first 3 orders only as they are the only one used in the lighting.
  54822. *
  54823. * @param texture The texture to extract the information from.
  54824. * @return The Spherical Polynomial data.
  54825. */
  54826. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  54827. /**
  54828. * Converts a cubemap to the according Spherical Polynomial data.
  54829. * This extracts the first 3 orders only as they are the only one used in the lighting.
  54830. *
  54831. * @param cubeInfo The Cube map to extract the information from.
  54832. * @return The Spherical Polynomial data.
  54833. */
  54834. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  54835. }
  54836. }
  54837. declare module "babylonjs/Materials/Textures/baseTexture.polynomial" {
  54838. import { Nullable } from "babylonjs/types";
  54839. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  54840. module "babylonjs/Materials/Textures/baseTexture" {
  54841. interface BaseTexture {
  54842. /**
  54843. * Get the polynomial representation of the texture data.
  54844. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  54845. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  54846. */
  54847. sphericalPolynomial: Nullable<SphericalPolynomial>;
  54848. }
  54849. }
  54850. }
  54851. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  54852. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  54853. /** @hidden */
  54854. export var rgbdEncodePixelShader: {
  54855. name: string;
  54856. shader: string;
  54857. };
  54858. }
  54859. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  54860. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  54861. /** @hidden */
  54862. export var rgbdDecodePixelShader: {
  54863. name: string;
  54864. shader: string;
  54865. };
  54866. }
  54867. declare module "babylonjs/Misc/environmentTextureTools" {
  54868. import { Nullable } from "babylonjs/types";
  54869. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  54870. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54871. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54872. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  54873. import "babylonjs/Engines/Extensions/engine.readTexture";
  54874. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  54875. import "babylonjs/Shaders/rgbdEncode.fragment";
  54876. import "babylonjs/Shaders/rgbdDecode.fragment";
  54877. /**
  54878. * Raw texture data and descriptor sufficient for WebGL texture upload
  54879. */
  54880. export interface EnvironmentTextureInfo {
  54881. /**
  54882. * Version of the environment map
  54883. */
  54884. version: number;
  54885. /**
  54886. * Width of image
  54887. */
  54888. width: number;
  54889. /**
  54890. * Irradiance information stored in the file.
  54891. */
  54892. irradiance: any;
  54893. /**
  54894. * Specular information stored in the file.
  54895. */
  54896. specular: any;
  54897. }
  54898. /**
  54899. * Defines One Image in the file. It requires only the position in the file
  54900. * as well as the length.
  54901. */
  54902. interface BufferImageData {
  54903. /**
  54904. * Length of the image data.
  54905. */
  54906. length: number;
  54907. /**
  54908. * Position of the data from the null terminator delimiting the end of the JSON.
  54909. */
  54910. position: number;
  54911. }
  54912. /**
  54913. * Defines the specular data enclosed in the file.
  54914. * This corresponds to the version 1 of the data.
  54915. */
  54916. export interface EnvironmentTextureSpecularInfoV1 {
  54917. /**
  54918. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  54919. */
  54920. specularDataPosition?: number;
  54921. /**
  54922. * This contains all the images data needed to reconstruct the cubemap.
  54923. */
  54924. mipmaps: Array<BufferImageData>;
  54925. /**
  54926. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  54927. */
  54928. lodGenerationScale: number;
  54929. }
  54930. /**
  54931. * Sets of helpers addressing the serialization and deserialization of environment texture
  54932. * stored in a BabylonJS env file.
  54933. * Those files are usually stored as .env files.
  54934. */
  54935. export class EnvironmentTextureTools {
  54936. /**
  54937. * Magic number identifying the env file.
  54938. */
  54939. private static _MagicBytes;
  54940. /**
  54941. * Gets the environment info from an env file.
  54942. * @param data The array buffer containing the .env bytes.
  54943. * @returns the environment file info (the json header) if successfully parsed.
  54944. */
  54945. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  54946. /**
  54947. * Creates an environment texture from a loaded cube texture.
  54948. * @param texture defines the cube texture to convert in env file
  54949. * @return a promise containing the environment data if succesfull.
  54950. */
  54951. static CreateEnvTextureAsync(texture: BaseTexture): Promise<ArrayBuffer>;
  54952. /**
  54953. * Creates a JSON representation of the spherical data.
  54954. * @param texture defines the texture containing the polynomials
  54955. * @return the JSON representation of the spherical info
  54956. */
  54957. private static _CreateEnvTextureIrradiance;
  54958. /**
  54959. * Creates the ArrayBufferViews used for initializing environment texture image data.
  54960. * @param data the image data
  54961. * @param info parameters that determine what views will be created for accessing the underlying buffer
  54962. * @return the views described by info providing access to the underlying buffer
  54963. */
  54964. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  54965. /**
  54966. * Uploads the texture info contained in the env file to the GPU.
  54967. * @param texture defines the internal texture to upload to
  54968. * @param data defines the data to load
  54969. * @param info defines the texture info retrieved through the GetEnvInfo method
  54970. * @returns a promise
  54971. */
  54972. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  54973. private static _OnImageReadyAsync;
  54974. /**
  54975. * Uploads the levels of image data to the GPU.
  54976. * @param texture defines the internal texture to upload to
  54977. * @param imageData defines the array buffer views of image data [mipmap][face]
  54978. * @returns a promise
  54979. */
  54980. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  54981. /**
  54982. * Uploads spherical polynomials information to the texture.
  54983. * @param texture defines the texture we are trying to upload the information to
  54984. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  54985. */
  54986. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  54987. /** @hidden */
  54988. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  54989. }
  54990. }
  54991. declare module "babylonjs/Engines/Processors/shaderCodeInliner" {
  54992. /**
  54993. * Class used to inline functions in shader code
  54994. */
  54995. export class ShaderCodeInliner {
  54996. private static readonly _RegexpFindFunctionNameAndType;
  54997. private _sourceCode;
  54998. private _functionDescr;
  54999. private _numMaxIterations;
  55000. /** Gets or sets the token used to mark the functions to inline */
  55001. inlineToken: string;
  55002. /** Gets or sets the debug mode */
  55003. debug: boolean;
  55004. /** Gets the code after the inlining process */
  55005. get code(): string;
  55006. /**
  55007. * Initializes the inliner
  55008. * @param sourceCode shader code source to inline
  55009. * @param numMaxIterations maximum number of iterations (used to detect recursive calls)
  55010. */
  55011. constructor(sourceCode: string, numMaxIterations?: number);
  55012. /**
  55013. * Start the processing of the shader code
  55014. */
  55015. processCode(): void;
  55016. private _collectFunctions;
  55017. private _processInlining;
  55018. private _extractBetweenMarkers;
  55019. private _skipWhitespaces;
  55020. private _removeComments;
  55021. private _replaceFunctionCallsByCode;
  55022. private _findBackward;
  55023. private _escapeRegExp;
  55024. private _replaceNames;
  55025. }
  55026. }
  55027. declare module "babylonjs/Engines/nativeEngine" {
  55028. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  55029. import { Engine } from "babylonjs/Engines/engine";
  55030. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  55031. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  55032. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  55033. import { Effect } from "babylonjs/Materials/effect";
  55034. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  55035. import { Matrix, Viewport, Color3 } from "babylonjs/Maths/math";
  55036. import { IColor4Like } from "babylonjs/Maths/math.like";
  55037. import { Scene } from "babylonjs/scene";
  55038. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  55039. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  55040. import { ISceneLike } from "babylonjs/Engines/thinEngine";
  55041. /**
  55042. * Container for accessors for natively-stored mesh data buffers.
  55043. */
  55044. class NativeDataBuffer extends DataBuffer {
  55045. /**
  55046. * Accessor value used to identify/retrieve a natively-stored index buffer.
  55047. */
  55048. nativeIndexBuffer?: any;
  55049. /**
  55050. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  55051. */
  55052. nativeVertexBuffer?: any;
  55053. }
  55054. /** @hidden */
  55055. class NativeTexture extends InternalTexture {
  55056. getInternalTexture(): InternalTexture;
  55057. getViewCount(): number;
  55058. }
  55059. /** @hidden */
  55060. export class NativeEngine extends Engine {
  55061. private readonly _native;
  55062. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  55063. private readonly INVALID_HANDLE;
  55064. private _boundBuffersVertexArray;
  55065. getHardwareScalingLevel(): number;
  55066. constructor();
  55067. dispose(): void;
  55068. /**
  55069. * Can be used to override the current requestAnimationFrame requester.
  55070. * @hidden
  55071. */
  55072. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  55073. /**
  55074. * Override default engine behavior.
  55075. * @param color
  55076. * @param backBuffer
  55077. * @param depth
  55078. * @param stencil
  55079. */
  55080. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  55081. /**
  55082. * Gets host document
  55083. * @returns the host document object
  55084. */
  55085. getHostDocument(): Nullable<Document>;
  55086. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  55087. createIndexBuffer(indices: IndicesArray, updateable?: boolean): NativeDataBuffer;
  55088. createVertexBuffer(data: DataArray, updateable?: boolean): NativeDataBuffer;
  55089. protected _recordVertexArrayObject(vertexArray: any, vertexBuffers: {
  55090. [key: string]: VertexBuffer;
  55091. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  55092. bindBuffers(vertexBuffers: {
  55093. [key: string]: VertexBuffer;
  55094. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  55095. recordVertexArrayObject(vertexBuffers: {
  55096. [key: string]: VertexBuffer;
  55097. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  55098. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  55099. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  55100. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  55101. /**
  55102. * Draw a list of indexed primitives
  55103. * @param fillMode defines the primitive to use
  55104. * @param indexStart defines the starting index
  55105. * @param indexCount defines the number of index to draw
  55106. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  55107. */
  55108. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  55109. /**
  55110. * Draw a list of unindexed primitives
  55111. * @param fillMode defines the primitive to use
  55112. * @param verticesStart defines the index of first vertex to draw
  55113. * @param verticesCount defines the count of vertices to draw
  55114. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  55115. */
  55116. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  55117. createPipelineContext(): IPipelineContext;
  55118. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  55119. /** @hidden */
  55120. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  55121. /** @hidden */
  55122. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  55123. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  55124. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  55125. protected _setProgram(program: WebGLProgram): void;
  55126. _releaseEffect(effect: Effect): void;
  55127. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  55128. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  55129. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  55130. bindSamplers(effect: Effect): void;
  55131. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  55132. getRenderWidth(useScreen?: boolean): number;
  55133. getRenderHeight(useScreen?: boolean): number;
  55134. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  55135. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  55136. /**
  55137. * Set the z offset to apply to current rendering
  55138. * @param value defines the offset to apply
  55139. */
  55140. setZOffset(value: number): void;
  55141. /**
  55142. * Gets the current value of the zOffset
  55143. * @returns the current zOffset state
  55144. */
  55145. getZOffset(): number;
  55146. /**
  55147. * Enable or disable depth buffering
  55148. * @param enable defines the state to set
  55149. */
  55150. setDepthBuffer(enable: boolean): void;
  55151. /**
  55152. * Gets a boolean indicating if depth writing is enabled
  55153. * @returns the current depth writing state
  55154. */
  55155. getDepthWrite(): boolean;
  55156. /**
  55157. * Enable or disable depth writing
  55158. * @param enable defines the state to set
  55159. */
  55160. setDepthWrite(enable: boolean): void;
  55161. /**
  55162. * Enable or disable color writing
  55163. * @param enable defines the state to set
  55164. */
  55165. setColorWrite(enable: boolean): void;
  55166. /**
  55167. * Gets a boolean indicating if color writing is enabled
  55168. * @returns the current color writing state
  55169. */
  55170. getColorWrite(): boolean;
  55171. /**
  55172. * Sets alpha constants used by some alpha blending modes
  55173. * @param r defines the red component
  55174. * @param g defines the green component
  55175. * @param b defines the blue component
  55176. * @param a defines the alpha component
  55177. */
  55178. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  55179. /**
  55180. * Sets the current alpha mode
  55181. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  55182. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  55183. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  55184. */
  55185. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  55186. /**
  55187. * Gets the current alpha mode
  55188. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  55189. * @returns the current alpha mode
  55190. */
  55191. getAlphaMode(): number;
  55192. setInt(uniform: WebGLUniformLocation, int: number): void;
  55193. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  55194. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  55195. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  55196. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  55197. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  55198. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  55199. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  55200. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  55201. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  55202. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  55203. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  55204. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  55205. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  55206. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  55207. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  55208. setFloat(uniform: WebGLUniformLocation, value: number): void;
  55209. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  55210. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  55211. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  55212. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  55213. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  55214. wipeCaches(bruteForce?: boolean): void;
  55215. _createTexture(): WebGLTexture;
  55216. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  55217. /**
  55218. * Usually called from Texture.ts.
  55219. * Passed information to create a WebGLTexture
  55220. * @param url defines a value which contains one of the following:
  55221. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  55222. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  55223. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  55224. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  55225. * @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)
  55226. * @param scene needed for loading to the correct scene
  55227. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  55228. * @param onLoad optional callback to be called upon successful completion
  55229. * @param onError optional callback to be called upon failure
  55230. * @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
  55231. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  55232. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  55233. * @param forcedExtension defines the extension to use to pick the right loader
  55234. * @param mimeType defines an optional mime type
  55235. * @returns a InternalTexture for assignment back into BABYLON.Texture
  55236. */
  55237. 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;
  55238. /**
  55239. * Creates a cube texture
  55240. * @param rootUrl defines the url where the files to load is located
  55241. * @param scene defines the current scene
  55242. * @param files defines the list of files to load (1 per face)
  55243. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  55244. * @param onLoad defines an optional callback raised when the texture is loaded
  55245. * @param onError defines an optional callback raised if there is an issue to load the texture
  55246. * @param format defines the format of the data
  55247. * @param forcedExtension defines the extension to use to pick the right loader
  55248. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  55249. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  55250. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  55251. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  55252. * @returns the cube texture as an InternalTexture
  55253. */
  55254. 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;
  55255. private _getSamplingFilter;
  55256. private static _GetNativeTextureFormat;
  55257. createRenderTargetTexture(size: number | {
  55258. width: number;
  55259. height: number;
  55260. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  55261. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  55262. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  55263. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  55264. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  55265. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  55266. /**
  55267. * Updates a dynamic vertex buffer.
  55268. * @param vertexBuffer the vertex buffer to update
  55269. * @param data the data used to update the vertex buffer
  55270. * @param byteOffset the byte offset of the data (optional)
  55271. * @param byteLength the byte length of the data (optional)
  55272. */
  55273. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  55274. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  55275. private _updateAnisotropicLevel;
  55276. private _getAddressMode;
  55277. /** @hidden */
  55278. _bindTexture(channel: number, texture: InternalTexture): void;
  55279. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  55280. releaseEffects(): void;
  55281. /** @hidden */
  55282. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  55283. /** @hidden */
  55284. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  55285. /** @hidden */
  55286. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  55287. /** @hidden */
  55288. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  55289. }
  55290. }
  55291. declare module "babylonjs/Engines/index" {
  55292. export * from "babylonjs/Engines/constants";
  55293. export * from "babylonjs/Engines/engineCapabilities";
  55294. export * from "babylonjs/Engines/instancingAttributeInfo";
  55295. export * from "babylonjs/Engines/thinEngine";
  55296. export * from "babylonjs/Engines/engine";
  55297. export * from "babylonjs/Engines/engineStore";
  55298. export * from "babylonjs/Engines/nullEngine";
  55299. export * from "babylonjs/Engines/Extensions/index";
  55300. export * from "babylonjs/Engines/IPipelineContext";
  55301. export * from "babylonjs/Engines/WebGL/webGLPipelineContext";
  55302. export * from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  55303. export * from "babylonjs/Engines/nativeEngine";
  55304. export * from "babylonjs/Engines/Processors/shaderCodeInliner";
  55305. export * from "babylonjs/Engines/performanceConfigurator";
  55306. }
  55307. declare module "babylonjs/Events/clipboardEvents" {
  55308. /**
  55309. * Gather the list of clipboard event types as constants.
  55310. */
  55311. export class ClipboardEventTypes {
  55312. /**
  55313. * The clipboard event is fired when a copy command is active (pressed).
  55314. */
  55315. static readonly COPY: number;
  55316. /**
  55317. * The clipboard event is fired when a cut command is active (pressed).
  55318. */
  55319. static readonly CUT: number;
  55320. /**
  55321. * The clipboard event is fired when a paste command is active (pressed).
  55322. */
  55323. static readonly PASTE: number;
  55324. }
  55325. /**
  55326. * This class is used to store clipboard related info for the onClipboardObservable event.
  55327. */
  55328. export class ClipboardInfo {
  55329. /**
  55330. * Defines the type of event (BABYLON.ClipboardEventTypes)
  55331. */
  55332. type: number;
  55333. /**
  55334. * Defines the related dom event
  55335. */
  55336. event: ClipboardEvent;
  55337. /**
  55338. *Creates an instance of ClipboardInfo.
  55339. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  55340. * @param event Defines the related dom event
  55341. */
  55342. constructor(
  55343. /**
  55344. * Defines the type of event (BABYLON.ClipboardEventTypes)
  55345. */
  55346. type: number,
  55347. /**
  55348. * Defines the related dom event
  55349. */
  55350. event: ClipboardEvent);
  55351. /**
  55352. * Get the clipboard event's type from the keycode.
  55353. * @param keyCode Defines the keyCode for the current keyboard event.
  55354. * @return {number}
  55355. */
  55356. static GetTypeFromCharacter(keyCode: number): number;
  55357. }
  55358. }
  55359. declare module "babylonjs/Events/index" {
  55360. export * from "babylonjs/Events/keyboardEvents";
  55361. export * from "babylonjs/Events/pointerEvents";
  55362. export * from "babylonjs/Events/clipboardEvents";
  55363. }
  55364. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  55365. import { Scene } from "babylonjs/scene";
  55366. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55367. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  55368. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  55369. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  55370. /**
  55371. * Google Daydream controller
  55372. */
  55373. export class DaydreamController extends WebVRController {
  55374. /**
  55375. * Base Url for the controller model.
  55376. */
  55377. static MODEL_BASE_URL: string;
  55378. /**
  55379. * File name for the controller model.
  55380. */
  55381. static MODEL_FILENAME: string;
  55382. /**
  55383. * Gamepad Id prefix used to identify Daydream Controller.
  55384. */
  55385. static readonly GAMEPAD_ID_PREFIX: string;
  55386. /**
  55387. * Creates a new DaydreamController from a gamepad
  55388. * @param vrGamepad the gamepad that the controller should be created from
  55389. */
  55390. constructor(vrGamepad: any);
  55391. /**
  55392. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  55393. * @param scene scene in which to add meshes
  55394. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  55395. */
  55396. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  55397. /**
  55398. * Called once for each button that changed state since the last frame
  55399. * @param buttonIdx Which button index changed
  55400. * @param state New state of the button
  55401. * @param changes Which properties on the state changed since last frame
  55402. */
  55403. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  55404. }
  55405. }
  55406. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  55407. import { Scene } from "babylonjs/scene";
  55408. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55409. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  55410. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  55411. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  55412. /**
  55413. * Gear VR Controller
  55414. */
  55415. export class GearVRController extends WebVRController {
  55416. /**
  55417. * Base Url for the controller model.
  55418. */
  55419. static MODEL_BASE_URL: string;
  55420. /**
  55421. * File name for the controller model.
  55422. */
  55423. static MODEL_FILENAME: string;
  55424. /**
  55425. * Gamepad Id prefix used to identify this controller.
  55426. */
  55427. static readonly GAMEPAD_ID_PREFIX: string;
  55428. private readonly _buttonIndexToObservableNameMap;
  55429. /**
  55430. * Creates a new GearVRController from a gamepad
  55431. * @param vrGamepad the gamepad that the controller should be created from
  55432. */
  55433. constructor(vrGamepad: any);
  55434. /**
  55435. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  55436. * @param scene scene in which to add meshes
  55437. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  55438. */
  55439. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  55440. /**
  55441. * Called once for each button that changed state since the last frame
  55442. * @param buttonIdx Which button index changed
  55443. * @param state New state of the button
  55444. * @param changes Which properties on the state changed since last frame
  55445. */
  55446. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  55447. }
  55448. }
  55449. declare module "babylonjs/Gamepads/Controllers/genericController" {
  55450. import { Scene } from "babylonjs/scene";
  55451. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55452. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  55453. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  55454. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  55455. /**
  55456. * Generic Controller
  55457. */
  55458. export class GenericController extends WebVRController {
  55459. /**
  55460. * Base Url for the controller model.
  55461. */
  55462. static readonly MODEL_BASE_URL: string;
  55463. /**
  55464. * File name for the controller model.
  55465. */
  55466. static readonly MODEL_FILENAME: string;
  55467. /**
  55468. * Creates a new GenericController from a gamepad
  55469. * @param vrGamepad the gamepad that the controller should be created from
  55470. */
  55471. constructor(vrGamepad: any);
  55472. /**
  55473. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  55474. * @param scene scene in which to add meshes
  55475. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  55476. */
  55477. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  55478. /**
  55479. * Called once for each button that changed state since the last frame
  55480. * @param buttonIdx Which button index changed
  55481. * @param state New state of the button
  55482. * @param changes Which properties on the state changed since last frame
  55483. */
  55484. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  55485. }
  55486. }
  55487. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  55488. import { Observable } from "babylonjs/Misc/observable";
  55489. import { Scene } from "babylonjs/scene";
  55490. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55491. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  55492. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  55493. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  55494. /**
  55495. * Oculus Touch Controller
  55496. */
  55497. export class OculusTouchController extends WebVRController {
  55498. /**
  55499. * Base Url for the controller model.
  55500. */
  55501. static MODEL_BASE_URL: string;
  55502. /**
  55503. * File name for the left controller model.
  55504. */
  55505. static MODEL_LEFT_FILENAME: string;
  55506. /**
  55507. * File name for the right controller model.
  55508. */
  55509. static MODEL_RIGHT_FILENAME: string;
  55510. /**
  55511. * Base Url for the Quest controller model.
  55512. */
  55513. static QUEST_MODEL_BASE_URL: string;
  55514. /**
  55515. * @hidden
  55516. * If the controllers are running on a device that needs the updated Quest controller models
  55517. */
  55518. static _IsQuest: boolean;
  55519. /**
  55520. * Fired when the secondary trigger on this controller is modified
  55521. */
  55522. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  55523. /**
  55524. * Fired when the thumb rest on this controller is modified
  55525. */
  55526. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  55527. /**
  55528. * Creates a new OculusTouchController from a gamepad
  55529. * @param vrGamepad the gamepad that the controller should be created from
  55530. */
  55531. constructor(vrGamepad: any);
  55532. /**
  55533. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  55534. * @param scene scene in which to add meshes
  55535. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  55536. */
  55537. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  55538. /**
  55539. * Fired when the A button on this controller is modified
  55540. */
  55541. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55542. /**
  55543. * Fired when the B button on this controller is modified
  55544. */
  55545. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55546. /**
  55547. * Fired when the X button on this controller is modified
  55548. */
  55549. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55550. /**
  55551. * Fired when the Y button on this controller is modified
  55552. */
  55553. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55554. /**
  55555. * Called once for each button that changed state since the last frame
  55556. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  55557. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  55558. * 2) secondary trigger (same)
  55559. * 3) A (right) X (left), touch, pressed = value
  55560. * 4) B / Y
  55561. * 5) thumb rest
  55562. * @param buttonIdx Which button index changed
  55563. * @param state New state of the button
  55564. * @param changes Which properties on the state changed since last frame
  55565. */
  55566. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  55567. }
  55568. }
  55569. declare module "babylonjs/Gamepads/Controllers/viveController" {
  55570. import { Scene } from "babylonjs/scene";
  55571. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55572. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  55573. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  55574. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  55575. import { Observable } from "babylonjs/Misc/observable";
  55576. /**
  55577. * Vive Controller
  55578. */
  55579. export class ViveController extends WebVRController {
  55580. /**
  55581. * Base Url for the controller model.
  55582. */
  55583. static MODEL_BASE_URL: string;
  55584. /**
  55585. * File name for the controller model.
  55586. */
  55587. static MODEL_FILENAME: string;
  55588. /**
  55589. * Creates a new ViveController from a gamepad
  55590. * @param vrGamepad the gamepad that the controller should be created from
  55591. */
  55592. constructor(vrGamepad: any);
  55593. /**
  55594. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  55595. * @param scene scene in which to add meshes
  55596. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  55597. */
  55598. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  55599. /**
  55600. * Fired when the left button on this controller is modified
  55601. */
  55602. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55603. /**
  55604. * Fired when the right button on this controller is modified
  55605. */
  55606. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55607. /**
  55608. * Fired when the menu button on this controller is modified
  55609. */
  55610. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55611. /**
  55612. * Called once for each button that changed state since the last frame
  55613. * Vive mapping:
  55614. * 0: touchpad
  55615. * 1: trigger
  55616. * 2: left AND right buttons
  55617. * 3: menu button
  55618. * @param buttonIdx Which button index changed
  55619. * @param state New state of the button
  55620. * @param changes Which properties on the state changed since last frame
  55621. */
  55622. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  55623. }
  55624. }
  55625. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  55626. import { Observable } from "babylonjs/Misc/observable";
  55627. import { Scene } from "babylonjs/scene";
  55628. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55629. import { Ray } from "babylonjs/Culling/ray";
  55630. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  55631. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  55632. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  55633. /**
  55634. * Defines the WindowsMotionController object that the state of the windows motion controller
  55635. */
  55636. export class WindowsMotionController extends WebVRController {
  55637. /**
  55638. * The base url used to load the left and right controller models
  55639. */
  55640. static MODEL_BASE_URL: string;
  55641. /**
  55642. * The name of the left controller model file
  55643. */
  55644. static MODEL_LEFT_FILENAME: string;
  55645. /**
  55646. * The name of the right controller model file
  55647. */
  55648. static MODEL_RIGHT_FILENAME: string;
  55649. /**
  55650. * The controller name prefix for this controller type
  55651. */
  55652. static readonly GAMEPAD_ID_PREFIX: string;
  55653. /**
  55654. * The controller id pattern for this controller type
  55655. */
  55656. private static readonly GAMEPAD_ID_PATTERN;
  55657. private _loadedMeshInfo;
  55658. protected readonly _mapping: {
  55659. buttons: string[];
  55660. buttonMeshNames: {
  55661. trigger: string;
  55662. menu: string;
  55663. grip: string;
  55664. thumbstick: string;
  55665. trackpad: string;
  55666. };
  55667. buttonObservableNames: {
  55668. trigger: string;
  55669. menu: string;
  55670. grip: string;
  55671. thumbstick: string;
  55672. trackpad: string;
  55673. };
  55674. axisMeshNames: string[];
  55675. pointingPoseMeshName: string;
  55676. };
  55677. /**
  55678. * Fired when the trackpad on this controller is clicked
  55679. */
  55680. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  55681. /**
  55682. * Fired when the trackpad on this controller is modified
  55683. */
  55684. onTrackpadValuesChangedObservable: Observable<StickValues>;
  55685. /**
  55686. * The current x and y values of this controller's trackpad
  55687. */
  55688. trackpad: StickValues;
  55689. /**
  55690. * Creates a new WindowsMotionController from a gamepad
  55691. * @param vrGamepad the gamepad that the controller should be created from
  55692. */
  55693. constructor(vrGamepad: any);
  55694. /**
  55695. * Fired when the trigger on this controller is modified
  55696. */
  55697. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55698. /**
  55699. * Fired when the menu button on this controller is modified
  55700. */
  55701. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55702. /**
  55703. * Fired when the grip button on this controller is modified
  55704. */
  55705. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55706. /**
  55707. * Fired when the thumbstick button on this controller is modified
  55708. */
  55709. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55710. /**
  55711. * Fired when the touchpad button on this controller is modified
  55712. */
  55713. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55714. /**
  55715. * Fired when the touchpad values on this controller are modified
  55716. */
  55717. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  55718. protected _updateTrackpad(): void;
  55719. /**
  55720. * Called once per frame by the engine.
  55721. */
  55722. update(): void;
  55723. /**
  55724. * Called once for each button that changed state since the last frame
  55725. * @param buttonIdx Which button index changed
  55726. * @param state New state of the button
  55727. * @param changes Which properties on the state changed since last frame
  55728. */
  55729. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  55730. /**
  55731. * Moves the buttons on the controller mesh based on their current state
  55732. * @param buttonName the name of the button to move
  55733. * @param buttonValue the value of the button which determines the buttons new position
  55734. */
  55735. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  55736. /**
  55737. * Moves the axis on the controller mesh based on its current state
  55738. * @param axis the index of the axis
  55739. * @param axisValue the value of the axis which determines the meshes new position
  55740. * @hidden
  55741. */
  55742. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  55743. /**
  55744. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  55745. * @param scene scene in which to add meshes
  55746. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  55747. */
  55748. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  55749. /**
  55750. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  55751. * can be transformed by button presses and axes values, based on this._mapping.
  55752. *
  55753. * @param scene scene in which the meshes exist
  55754. * @param meshes list of meshes that make up the controller model to process
  55755. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  55756. */
  55757. private processModel;
  55758. private createMeshInfo;
  55759. /**
  55760. * Gets the ray of the controller in the direction the controller is pointing
  55761. * @param length the length the resulting ray should be
  55762. * @returns a ray in the direction the controller is pointing
  55763. */
  55764. getForwardRay(length?: number): Ray;
  55765. /**
  55766. * Disposes of the controller
  55767. */
  55768. dispose(): void;
  55769. }
  55770. /**
  55771. * This class represents a new windows motion controller in XR.
  55772. */
  55773. export class XRWindowsMotionController extends WindowsMotionController {
  55774. /**
  55775. * Changing the original WIndowsMotionController mapping to fir the new mapping
  55776. */
  55777. protected readonly _mapping: {
  55778. buttons: string[];
  55779. buttonMeshNames: {
  55780. trigger: string;
  55781. menu: string;
  55782. grip: string;
  55783. thumbstick: string;
  55784. trackpad: string;
  55785. };
  55786. buttonObservableNames: {
  55787. trigger: string;
  55788. menu: string;
  55789. grip: string;
  55790. thumbstick: string;
  55791. trackpad: string;
  55792. };
  55793. axisMeshNames: string[];
  55794. pointingPoseMeshName: string;
  55795. };
  55796. /**
  55797. * Construct a new XR-Based windows motion controller
  55798. *
  55799. * @param gamepadInfo the gamepad object from the browser
  55800. */
  55801. constructor(gamepadInfo: any);
  55802. /**
  55803. * holds the thumbstick values (X,Y)
  55804. */
  55805. thumbstickValues: StickValues;
  55806. /**
  55807. * Fired when the thumbstick on this controller is clicked
  55808. */
  55809. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  55810. /**
  55811. * Fired when the thumbstick on this controller is modified
  55812. */
  55813. onThumbstickValuesChangedObservable: Observable<StickValues>;
  55814. /**
  55815. * Fired when the touchpad button on this controller is modified
  55816. */
  55817. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  55818. /**
  55819. * Fired when the touchpad values on this controller are modified
  55820. */
  55821. onTrackpadValuesChangedObservable: Observable<StickValues>;
  55822. /**
  55823. * Fired when the thumbstick button on this controller is modified
  55824. * here to prevent breaking changes
  55825. */
  55826. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55827. /**
  55828. * updating the thumbstick(!) and not the trackpad.
  55829. * This is named this way due to the difference between WebVR and XR and to avoid
  55830. * changing the parent class.
  55831. */
  55832. protected _updateTrackpad(): void;
  55833. /**
  55834. * Disposes the class with joy
  55835. */
  55836. dispose(): void;
  55837. }
  55838. }
  55839. declare module "babylonjs/Gamepads/Controllers/index" {
  55840. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  55841. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  55842. export * from "babylonjs/Gamepads/Controllers/genericController";
  55843. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  55844. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  55845. export * from "babylonjs/Gamepads/Controllers/viveController";
  55846. export * from "babylonjs/Gamepads/Controllers/webVRController";
  55847. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  55848. }
  55849. declare module "babylonjs/Gamepads/index" {
  55850. export * from "babylonjs/Gamepads/Controllers/index";
  55851. export * from "babylonjs/Gamepads/gamepad";
  55852. export * from "babylonjs/Gamepads/gamepadManager";
  55853. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  55854. export * from "babylonjs/Gamepads/xboxGamepad";
  55855. export * from "babylonjs/Gamepads/dualShockGamepad";
  55856. }
  55857. declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
  55858. import { Scene } from "babylonjs/scene";
  55859. import { Vector4 } from "babylonjs/Maths/math.vector";
  55860. import { Color4 } from "babylonjs/Maths/math.color";
  55861. import { Mesh } from "babylonjs/Meshes/mesh";
  55862. import { Nullable } from "babylonjs/types";
  55863. /**
  55864. * Class containing static functions to help procedurally build meshes
  55865. */
  55866. export class PolyhedronBuilder {
  55867. /**
  55868. * Creates a polyhedron mesh
  55869. * * 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
  55870. * * The parameter `size` (positive float, default 1) sets the polygon size
  55871. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  55872. * * 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`
  55873. * * 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
  55874. * * 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)`)
  55875. * * 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
  55876. * * 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
  55877. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55878. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55879. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55880. * @param name defines the name of the mesh
  55881. * @param options defines the options used to create the mesh
  55882. * @param scene defines the hosting scene
  55883. * @returns the polyhedron mesh
  55884. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  55885. */
  55886. static CreatePolyhedron(name: string, options: {
  55887. type?: number;
  55888. size?: number;
  55889. sizeX?: number;
  55890. sizeY?: number;
  55891. sizeZ?: number;
  55892. custom?: any;
  55893. faceUV?: Vector4[];
  55894. faceColors?: Color4[];
  55895. flat?: boolean;
  55896. updatable?: boolean;
  55897. sideOrientation?: number;
  55898. frontUVs?: Vector4;
  55899. backUVs?: Vector4;
  55900. }, scene?: Nullable<Scene>): Mesh;
  55901. }
  55902. }
  55903. declare module "babylonjs/Gizmos/scaleGizmo" {
  55904. import { Observable } from "babylonjs/Misc/observable";
  55905. import { Nullable } from "babylonjs/types";
  55906. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55907. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  55908. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  55909. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  55910. import { Node } from "babylonjs/node";
  55911. /**
  55912. * Gizmo that enables scaling a mesh along 3 axis
  55913. */
  55914. export class ScaleGizmo extends Gizmo {
  55915. /**
  55916. * Internal gizmo used for interactions on the x axis
  55917. */
  55918. xGizmo: AxisScaleGizmo;
  55919. /**
  55920. * Internal gizmo used for interactions on the y axis
  55921. */
  55922. yGizmo: AxisScaleGizmo;
  55923. /**
  55924. * Internal gizmo used for interactions on the z axis
  55925. */
  55926. zGizmo: AxisScaleGizmo;
  55927. /**
  55928. * Internal gizmo used to scale all axis equally
  55929. */
  55930. uniformScaleGizmo: AxisScaleGizmo;
  55931. private _meshAttached;
  55932. private _nodeAttached;
  55933. private _snapDistance;
  55934. private _uniformScalingMesh;
  55935. private _octahedron;
  55936. private _sensitivity;
  55937. /** Fires an event when any of it's sub gizmos are dragged */
  55938. onDragStartObservable: Observable<unknown>;
  55939. /** Fires an event when any of it's sub gizmos are released from dragging */
  55940. onDragEndObservable: Observable<unknown>;
  55941. get attachedMesh(): Nullable<AbstractMesh>;
  55942. set attachedMesh(mesh: Nullable<AbstractMesh>);
  55943. get attachedNode(): Nullable<Node>;
  55944. set attachedNode(node: Nullable<Node>);
  55945. /**
  55946. * Creates a ScaleGizmo
  55947. * @param gizmoLayer The utility layer the gizmo will be added to
  55948. * @param thickness display gizmo axis thickness
  55949. */
  55950. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number);
  55951. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  55952. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  55953. /**
  55954. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  55955. */
  55956. set snapDistance(value: number);
  55957. get snapDistance(): number;
  55958. /**
  55959. * Ratio for the scale of the gizmo (Default: 1)
  55960. */
  55961. set scaleRatio(value: number);
  55962. get scaleRatio(): number;
  55963. /**
  55964. * Sensitivity factor for dragging (Default: 1)
  55965. */
  55966. set sensitivity(value: number);
  55967. get sensitivity(): number;
  55968. /**
  55969. * Disposes of the gizmo
  55970. */
  55971. dispose(): void;
  55972. }
  55973. }
  55974. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  55975. import { Observable } from "babylonjs/Misc/observable";
  55976. import { Nullable } from "babylonjs/types";
  55977. import { Vector3 } from "babylonjs/Maths/math.vector";
  55978. import { Node } from "babylonjs/node";
  55979. import { Mesh } from "babylonjs/Meshes/mesh";
  55980. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  55981. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  55982. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  55983. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  55984. import { Color3 } from "babylonjs/Maths/math.color";
  55985. /**
  55986. * Single axis scale gizmo
  55987. */
  55988. export class AxisScaleGizmo extends Gizmo {
  55989. /**
  55990. * Drag behavior responsible for the gizmos dragging interactions
  55991. */
  55992. dragBehavior: PointerDragBehavior;
  55993. private _pointerObserver;
  55994. /**
  55995. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  55996. */
  55997. snapDistance: number;
  55998. /**
  55999. * Event that fires each time the gizmo snaps to a new location.
  56000. * * snapDistance is the the change in distance
  56001. */
  56002. onSnapObservable: Observable<{
  56003. snapDistance: number;
  56004. }>;
  56005. /**
  56006. * If the scaling operation should be done on all axis (default: false)
  56007. */
  56008. uniformScaling: boolean;
  56009. /**
  56010. * Custom sensitivity value for the drag strength
  56011. */
  56012. sensitivity: number;
  56013. private _isEnabled;
  56014. private _parent;
  56015. private _arrow;
  56016. private _coloredMaterial;
  56017. private _hoverMaterial;
  56018. /**
  56019. * Creates an AxisScaleGizmo
  56020. * @param gizmoLayer The utility layer the gizmo will be added to
  56021. * @param dragAxis The axis which the gizmo will be able to scale on
  56022. * @param color The color of the gizmo
  56023. * @param thickness display gizmo axis thickness
  56024. */
  56025. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>, thickness?: number);
  56026. protected _attachedNodeChanged(value: Nullable<Node>): void;
  56027. /**
  56028. * If the gizmo is enabled
  56029. */
  56030. set isEnabled(value: boolean);
  56031. get isEnabled(): boolean;
  56032. /**
  56033. * Disposes of the gizmo
  56034. */
  56035. dispose(): void;
  56036. /**
  56037. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  56038. * @param mesh The mesh to replace the default mesh of the gizmo
  56039. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  56040. */
  56041. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  56042. }
  56043. }
  56044. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  56045. import { Observable } from "babylonjs/Misc/observable";
  56046. import { Nullable } from "babylonjs/types";
  56047. import { Vector3 } from "babylonjs/Maths/math.vector";
  56048. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56049. import { Mesh } from "babylonjs/Meshes/mesh";
  56050. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  56051. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  56052. import { Color3 } from "babylonjs/Maths/math.color";
  56053. import "babylonjs/Meshes/Builders/boxBuilder";
  56054. /**
  56055. * Bounding box gizmo
  56056. */
  56057. export class BoundingBoxGizmo extends Gizmo {
  56058. private _lineBoundingBox;
  56059. private _rotateSpheresParent;
  56060. private _scaleBoxesParent;
  56061. private _boundingDimensions;
  56062. private _renderObserver;
  56063. private _pointerObserver;
  56064. private _scaleDragSpeed;
  56065. private _tmpQuaternion;
  56066. private _tmpVector;
  56067. private _tmpRotationMatrix;
  56068. /**
  56069. * 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)
  56070. */
  56071. ignoreChildren: boolean;
  56072. /**
  56073. * 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)
  56074. */
  56075. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  56076. /**
  56077. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  56078. */
  56079. rotationSphereSize: number;
  56080. /**
  56081. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  56082. */
  56083. scaleBoxSize: number;
  56084. /**
  56085. * 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)
  56086. */
  56087. fixedDragMeshScreenSize: boolean;
  56088. /**
  56089. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  56090. */
  56091. fixedDragMeshScreenSizeDistanceFactor: number;
  56092. /**
  56093. * Fired when a rotation sphere or scale box is dragged
  56094. */
  56095. onDragStartObservable: Observable<{}>;
  56096. /**
  56097. * Fired when a scale box is dragged
  56098. */
  56099. onScaleBoxDragObservable: Observable<{}>;
  56100. /**
  56101. * Fired when a scale box drag is ended
  56102. */
  56103. onScaleBoxDragEndObservable: Observable<{}>;
  56104. /**
  56105. * Fired when a rotation sphere is dragged
  56106. */
  56107. onRotationSphereDragObservable: Observable<{}>;
  56108. /**
  56109. * Fired when a rotation sphere drag is ended
  56110. */
  56111. onRotationSphereDragEndObservable: Observable<{}>;
  56112. /**
  56113. * 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)
  56114. */
  56115. scalePivot: Nullable<Vector3>;
  56116. /**
  56117. * Mesh used as a pivot to rotate the attached node
  56118. */
  56119. private _anchorMesh;
  56120. private _existingMeshScale;
  56121. private _dragMesh;
  56122. private pointerDragBehavior;
  56123. private coloredMaterial;
  56124. private hoverColoredMaterial;
  56125. /**
  56126. * Sets the color of the bounding box gizmo
  56127. * @param color the color to set
  56128. */
  56129. setColor(color: Color3): void;
  56130. /**
  56131. * Creates an BoundingBoxGizmo
  56132. * @param gizmoLayer The utility layer the gizmo will be added to
  56133. * @param color The color of the gizmo
  56134. */
  56135. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  56136. protected _attachedNodeChanged(value: Nullable<AbstractMesh>): void;
  56137. private _selectNode;
  56138. /**
  56139. * Updates the bounding box information for the Gizmo
  56140. */
  56141. updateBoundingBox(): void;
  56142. private _updateRotationSpheres;
  56143. private _updateScaleBoxes;
  56144. /**
  56145. * Enables rotation on the specified axis and disables rotation on the others
  56146. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  56147. */
  56148. setEnabledRotationAxis(axis: string): void;
  56149. /**
  56150. * Enables/disables scaling
  56151. * @param enable if scaling should be enabled
  56152. * @param homogeneousScaling defines if scaling should only be homogeneous
  56153. */
  56154. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  56155. private _updateDummy;
  56156. /**
  56157. * Enables a pointer drag behavior on the bounding box of the gizmo
  56158. */
  56159. enableDragBehavior(): void;
  56160. /**
  56161. * Disposes of the gizmo
  56162. */
  56163. dispose(): void;
  56164. /**
  56165. * 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)
  56166. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  56167. * @returns the bounding box mesh with the passed in mesh as a child
  56168. */
  56169. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  56170. /**
  56171. * CustomMeshes are not supported by this gizmo
  56172. * @param mesh The mesh to replace the default mesh of the gizmo
  56173. */
  56174. setCustomMesh(mesh: Mesh): void;
  56175. }
  56176. }
  56177. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  56178. import { Observable } from "babylonjs/Misc/observable";
  56179. import { Nullable } from "babylonjs/types";
  56180. import { Vector3 } from "babylonjs/Maths/math.vector";
  56181. import { Color3 } from "babylonjs/Maths/math.color";
  56182. import { Node } from "babylonjs/node";
  56183. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  56184. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  56185. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  56186. import "babylonjs/Meshes/Builders/linesBuilder";
  56187. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  56188. /**
  56189. * Single plane rotation gizmo
  56190. */
  56191. export class PlaneRotationGizmo extends Gizmo {
  56192. /**
  56193. * Drag behavior responsible for the gizmos dragging interactions
  56194. */
  56195. dragBehavior: PointerDragBehavior;
  56196. private _pointerObserver;
  56197. /**
  56198. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  56199. */
  56200. snapDistance: number;
  56201. /**
  56202. * Event that fires each time the gizmo snaps to a new location.
  56203. * * snapDistance is the the change in distance
  56204. */
  56205. onSnapObservable: Observable<{
  56206. snapDistance: number;
  56207. }>;
  56208. private _isEnabled;
  56209. private _parent;
  56210. /**
  56211. * Creates a PlaneRotationGizmo
  56212. * @param gizmoLayer The utility layer the gizmo will be added to
  56213. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  56214. * @param color The color of the gizmo
  56215. * @param tessellation Amount of tessellation to be used when creating rotation circles
  56216. * @param useEulerRotation Use and update Euler angle instead of quaternion
  56217. * @param thickness display gizmo axis thickness
  56218. */
  56219. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean, thickness?: number);
  56220. protected _attachedNodeChanged(value: Nullable<Node>): void;
  56221. /**
  56222. * If the gizmo is enabled
  56223. */
  56224. set isEnabled(value: boolean);
  56225. get isEnabled(): boolean;
  56226. /**
  56227. * Disposes of the gizmo
  56228. */
  56229. dispose(): void;
  56230. }
  56231. }
  56232. declare module "babylonjs/Gizmos/rotationGizmo" {
  56233. import { Observable } from "babylonjs/Misc/observable";
  56234. import { Nullable } from "babylonjs/types";
  56235. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56236. import { Mesh } from "babylonjs/Meshes/mesh";
  56237. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  56238. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  56239. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  56240. import { Node } from "babylonjs/node";
  56241. /**
  56242. * Gizmo that enables rotating a mesh along 3 axis
  56243. */
  56244. export class RotationGizmo extends Gizmo {
  56245. /**
  56246. * Internal gizmo used for interactions on the x axis
  56247. */
  56248. xGizmo: PlaneRotationGizmo;
  56249. /**
  56250. * Internal gizmo used for interactions on the y axis
  56251. */
  56252. yGizmo: PlaneRotationGizmo;
  56253. /**
  56254. * Internal gizmo used for interactions on the z axis
  56255. */
  56256. zGizmo: PlaneRotationGizmo;
  56257. /** Fires an event when any of it's sub gizmos are dragged */
  56258. onDragStartObservable: Observable<unknown>;
  56259. /** Fires an event when any of it's sub gizmos are released from dragging */
  56260. onDragEndObservable: Observable<unknown>;
  56261. private _meshAttached;
  56262. private _nodeAttached;
  56263. get attachedMesh(): Nullable<AbstractMesh>;
  56264. set attachedMesh(mesh: Nullable<AbstractMesh>);
  56265. get attachedNode(): Nullable<Node>;
  56266. set attachedNode(node: Nullable<Node>);
  56267. /**
  56268. * Creates a RotationGizmo
  56269. * @param gizmoLayer The utility layer the gizmo will be added to
  56270. * @param tessellation Amount of tessellation to be used when creating rotation circles
  56271. * @param useEulerRotation Use and update Euler angle instead of quaternion
  56272. * @param thickness display gizmo axis thickness
  56273. */
  56274. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean, thickness?: number);
  56275. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  56276. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  56277. /**
  56278. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  56279. */
  56280. set snapDistance(value: number);
  56281. get snapDistance(): number;
  56282. /**
  56283. * Ratio for the scale of the gizmo (Default: 1)
  56284. */
  56285. set scaleRatio(value: number);
  56286. get scaleRatio(): number;
  56287. /**
  56288. * Disposes of the gizmo
  56289. */
  56290. dispose(): void;
  56291. /**
  56292. * CustomMeshes are not supported by this gizmo
  56293. * @param mesh The mesh to replace the default mesh of the gizmo
  56294. */
  56295. setCustomMesh(mesh: Mesh): void;
  56296. }
  56297. }
  56298. declare module "babylonjs/Gizmos/gizmoManager" {
  56299. import { Observable } from "babylonjs/Misc/observable";
  56300. import { Nullable } from "babylonjs/types";
  56301. import { Scene, IDisposable } from "babylonjs/scene";
  56302. import { Node } from "babylonjs/node";
  56303. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56304. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  56305. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  56306. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  56307. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  56308. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  56309. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  56310. /**
  56311. * Helps setup gizmo's in the scene to rotate/scale/position nodes
  56312. */
  56313. export class GizmoManager implements IDisposable {
  56314. private scene;
  56315. /**
  56316. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  56317. */
  56318. gizmos: {
  56319. positionGizmo: Nullable<PositionGizmo>;
  56320. rotationGizmo: Nullable<RotationGizmo>;
  56321. scaleGizmo: Nullable<ScaleGizmo>;
  56322. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  56323. };
  56324. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  56325. clearGizmoOnEmptyPointerEvent: boolean;
  56326. /** Fires an event when the manager is attached to a mesh */
  56327. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  56328. /** Fires an event when the manager is attached to a node */
  56329. onAttachedToNodeObservable: Observable<Nullable<Node>>;
  56330. private _gizmosEnabled;
  56331. private _pointerObserver;
  56332. private _attachedMesh;
  56333. private _attachedNode;
  56334. private _boundingBoxColor;
  56335. private _defaultUtilityLayer;
  56336. private _defaultKeepDepthUtilityLayer;
  56337. private _thickness;
  56338. /**
  56339. * When bounding box gizmo is enabled, this can be used to track drag/end events
  56340. */
  56341. boundingBoxDragBehavior: SixDofDragBehavior;
  56342. /**
  56343. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  56344. */
  56345. attachableMeshes: Nullable<Array<AbstractMesh>>;
  56346. /**
  56347. * Array of nodes which will have the gizmo attached when a pointer selected them. If null, all nodes are attachable. (Default: null)
  56348. */
  56349. attachableNodes: Nullable<Array<Node>>;
  56350. /**
  56351. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh/attachToNode. (Default: true)
  56352. */
  56353. usePointerToAttachGizmos: boolean;
  56354. /**
  56355. * Utility layer that the bounding box gizmo belongs to
  56356. */
  56357. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  56358. /**
  56359. * Utility layer that all gizmos besides bounding box belong to
  56360. */
  56361. get utilityLayer(): UtilityLayerRenderer;
  56362. /**
  56363. * Instatiates a gizmo manager
  56364. * @param scene the scene to overlay the gizmos on top of
  56365. * @param thickness display gizmo axis thickness
  56366. */
  56367. constructor(scene: Scene, thickness?: number);
  56368. /**
  56369. * Attaches a set of gizmos to the specified mesh
  56370. * @param mesh The mesh the gizmo's should be attached to
  56371. */
  56372. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  56373. /**
  56374. * Attaches a set of gizmos to the specified node
  56375. * @param node The node the gizmo's should be attached to
  56376. */
  56377. attachToNode(node: Nullable<Node>): void;
  56378. /**
  56379. * If the position gizmo is enabled
  56380. */
  56381. set positionGizmoEnabled(value: boolean);
  56382. get positionGizmoEnabled(): boolean;
  56383. /**
  56384. * If the rotation gizmo is enabled
  56385. */
  56386. set rotationGizmoEnabled(value: boolean);
  56387. get rotationGizmoEnabled(): boolean;
  56388. /**
  56389. * If the scale gizmo is enabled
  56390. */
  56391. set scaleGizmoEnabled(value: boolean);
  56392. get scaleGizmoEnabled(): boolean;
  56393. /**
  56394. * If the boundingBox gizmo is enabled
  56395. */
  56396. set boundingBoxGizmoEnabled(value: boolean);
  56397. get boundingBoxGizmoEnabled(): boolean;
  56398. /**
  56399. * Disposes of the gizmo manager
  56400. */
  56401. dispose(): void;
  56402. }
  56403. }
  56404. declare module "babylonjs/Lights/directionalLight" {
  56405. import { Camera } from "babylonjs/Cameras/camera";
  56406. import { Scene } from "babylonjs/scene";
  56407. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  56408. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56409. import { Light } from "babylonjs/Lights/light";
  56410. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  56411. import { Effect } from "babylonjs/Materials/effect";
  56412. /**
  56413. * A directional light is defined by a direction (what a surprise!).
  56414. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  56415. * 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.
  56416. * Documentation: https://doc.babylonjs.com/babylon101/lights
  56417. */
  56418. export class DirectionalLight extends ShadowLight {
  56419. private _shadowFrustumSize;
  56420. /**
  56421. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  56422. */
  56423. get shadowFrustumSize(): number;
  56424. /**
  56425. * Specifies a fix frustum size for the shadow generation.
  56426. */
  56427. set shadowFrustumSize(value: number);
  56428. private _shadowOrthoScale;
  56429. /**
  56430. * Gets the shadow projection scale against the optimal computed one.
  56431. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  56432. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  56433. */
  56434. get shadowOrthoScale(): number;
  56435. /**
  56436. * Sets the shadow projection scale against the optimal computed one.
  56437. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  56438. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  56439. */
  56440. set shadowOrthoScale(value: number);
  56441. /**
  56442. * Automatically compute the projection matrix to best fit (including all the casters)
  56443. * on each frame.
  56444. */
  56445. autoUpdateExtends: boolean;
  56446. /**
  56447. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  56448. * on each frame. autoUpdateExtends must be set to true for this to work
  56449. */
  56450. autoCalcShadowZBounds: boolean;
  56451. private _orthoLeft;
  56452. private _orthoRight;
  56453. private _orthoTop;
  56454. private _orthoBottom;
  56455. /**
  56456. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  56457. * The directional light is emitted from everywhere in the given direction.
  56458. * It can cast shadows.
  56459. * Documentation : https://doc.babylonjs.com/babylon101/lights
  56460. * @param name The friendly name of the light
  56461. * @param direction The direction of the light
  56462. * @param scene The scene the light belongs to
  56463. */
  56464. constructor(name: string, direction: Vector3, scene: Scene);
  56465. /**
  56466. * Returns the string "DirectionalLight".
  56467. * @return The class name
  56468. */
  56469. getClassName(): string;
  56470. /**
  56471. * Returns the integer 1.
  56472. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  56473. */
  56474. getTypeID(): number;
  56475. /**
  56476. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  56477. * Returns the DirectionalLight Shadow projection matrix.
  56478. */
  56479. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  56480. /**
  56481. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  56482. * Returns the DirectionalLight Shadow projection matrix.
  56483. */
  56484. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  56485. /**
  56486. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  56487. * Returns the DirectionalLight Shadow projection matrix.
  56488. */
  56489. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  56490. protected _buildUniformLayout(): void;
  56491. /**
  56492. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  56493. * @param effect The effect to update
  56494. * @param lightIndex The index of the light in the effect to update
  56495. * @returns The directional light
  56496. */
  56497. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  56498. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  56499. /**
  56500. * Gets the minZ used for shadow according to both the scene and the light.
  56501. *
  56502. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  56503. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  56504. * @param activeCamera The camera we are returning the min for
  56505. * @returns the depth min z
  56506. */
  56507. getDepthMinZ(activeCamera: Camera): number;
  56508. /**
  56509. * Gets the maxZ used for shadow according to both the scene and the light.
  56510. *
  56511. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  56512. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  56513. * @param activeCamera The camera we are returning the max for
  56514. * @returns the depth max z
  56515. */
  56516. getDepthMaxZ(activeCamera: Camera): number;
  56517. /**
  56518. * Prepares the list of defines specific to the light type.
  56519. * @param defines the list of defines
  56520. * @param lightIndex defines the index of the light for the effect
  56521. */
  56522. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  56523. }
  56524. }
  56525. declare module "babylonjs/Meshes/Builders/hemisphereBuilder" {
  56526. import { Mesh } from "babylonjs/Meshes/mesh";
  56527. /**
  56528. * Class containing static functions to help procedurally build meshes
  56529. */
  56530. export class HemisphereBuilder {
  56531. /**
  56532. * Creates a hemisphere mesh
  56533. * @param name defines the name of the mesh
  56534. * @param options defines the options used to create the mesh
  56535. * @param scene defines the hosting scene
  56536. * @returns the hemisphere mesh
  56537. */
  56538. static CreateHemisphere(name: string, options: {
  56539. segments?: number;
  56540. diameter?: number;
  56541. sideOrientation?: number;
  56542. }, scene: any): Mesh;
  56543. }
  56544. }
  56545. declare module "babylonjs/Lights/spotLight" {
  56546. import { Nullable } from "babylonjs/types";
  56547. import { Scene } from "babylonjs/scene";
  56548. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  56549. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56550. import { Effect } from "babylonjs/Materials/effect";
  56551. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  56552. import { Light } from "babylonjs/Lights/light";
  56553. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  56554. /**
  56555. * A spot light is defined by a position, a direction, an angle, and an exponent.
  56556. * These values define a cone of light starting from the position, emitting toward the direction.
  56557. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  56558. * and the exponent defines the speed of the decay of the light with distance (reach).
  56559. * Documentation: https://doc.babylonjs.com/babylon101/lights
  56560. */
  56561. export class SpotLight extends ShadowLight {
  56562. private _angle;
  56563. private _innerAngle;
  56564. private _cosHalfAngle;
  56565. private _lightAngleScale;
  56566. private _lightAngleOffset;
  56567. /**
  56568. * Gets the cone angle of the spot light in Radians.
  56569. */
  56570. get angle(): number;
  56571. /**
  56572. * Sets the cone angle of the spot light in Radians.
  56573. */
  56574. set angle(value: number);
  56575. /**
  56576. * Only used in gltf falloff mode, this defines the angle where
  56577. * the directional falloff will start before cutting at angle which could be seen
  56578. * as outer angle.
  56579. */
  56580. get innerAngle(): number;
  56581. /**
  56582. * Only used in gltf falloff mode, this defines the angle where
  56583. * the directional falloff will start before cutting at angle which could be seen
  56584. * as outer angle.
  56585. */
  56586. set innerAngle(value: number);
  56587. private _shadowAngleScale;
  56588. /**
  56589. * Allows scaling the angle of the light for shadow generation only.
  56590. */
  56591. get shadowAngleScale(): number;
  56592. /**
  56593. * Allows scaling the angle of the light for shadow generation only.
  56594. */
  56595. set shadowAngleScale(value: number);
  56596. /**
  56597. * The light decay speed with the distance from the emission spot.
  56598. */
  56599. exponent: number;
  56600. private _projectionTextureMatrix;
  56601. /**
  56602. * Allows reading the projecton texture
  56603. */
  56604. get projectionTextureMatrix(): Matrix;
  56605. protected _projectionTextureLightNear: number;
  56606. /**
  56607. * Gets the near clip of the Spotlight for texture projection.
  56608. */
  56609. get projectionTextureLightNear(): number;
  56610. /**
  56611. * Sets the near clip of the Spotlight for texture projection.
  56612. */
  56613. set projectionTextureLightNear(value: number);
  56614. protected _projectionTextureLightFar: number;
  56615. /**
  56616. * Gets the far clip of the Spotlight for texture projection.
  56617. */
  56618. get projectionTextureLightFar(): number;
  56619. /**
  56620. * Sets the far clip of the Spotlight for texture projection.
  56621. */
  56622. set projectionTextureLightFar(value: number);
  56623. protected _projectionTextureUpDirection: Vector3;
  56624. /**
  56625. * Gets the Up vector of the Spotlight for texture projection.
  56626. */
  56627. get projectionTextureUpDirection(): Vector3;
  56628. /**
  56629. * Sets the Up vector of the Spotlight for texture projection.
  56630. */
  56631. set projectionTextureUpDirection(value: Vector3);
  56632. private _projectionTexture;
  56633. /**
  56634. * Gets the projection texture of the light.
  56635. */
  56636. get projectionTexture(): Nullable<BaseTexture>;
  56637. /**
  56638. * Sets the projection texture of the light.
  56639. */
  56640. set projectionTexture(value: Nullable<BaseTexture>);
  56641. private _projectionTextureViewLightDirty;
  56642. private _projectionTextureProjectionLightDirty;
  56643. private _projectionTextureDirty;
  56644. private _projectionTextureViewTargetVector;
  56645. private _projectionTextureViewLightMatrix;
  56646. private _projectionTextureProjectionLightMatrix;
  56647. private _projectionTextureScalingMatrix;
  56648. /**
  56649. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  56650. * It can cast shadows.
  56651. * Documentation : https://doc.babylonjs.com/babylon101/lights
  56652. * @param name The light friendly name
  56653. * @param position The position of the spot light in the scene
  56654. * @param direction The direction of the light in the scene
  56655. * @param angle The cone angle of the light in Radians
  56656. * @param exponent The light decay speed with the distance from the emission spot
  56657. * @param scene The scene the lights belongs to
  56658. */
  56659. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  56660. /**
  56661. * Returns the string "SpotLight".
  56662. * @returns the class name
  56663. */
  56664. getClassName(): string;
  56665. /**
  56666. * Returns the integer 2.
  56667. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  56668. */
  56669. getTypeID(): number;
  56670. /**
  56671. * Overrides the direction setter to recompute the projection texture view light Matrix.
  56672. */
  56673. protected _setDirection(value: Vector3): void;
  56674. /**
  56675. * Overrides the position setter to recompute the projection texture view light Matrix.
  56676. */
  56677. protected _setPosition(value: Vector3): void;
  56678. /**
  56679. * 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.
  56680. * Returns the SpotLight.
  56681. */
  56682. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  56683. protected _computeProjectionTextureViewLightMatrix(): void;
  56684. protected _computeProjectionTextureProjectionLightMatrix(): void;
  56685. /**
  56686. * Main function for light texture projection matrix computing.
  56687. */
  56688. protected _computeProjectionTextureMatrix(): void;
  56689. protected _buildUniformLayout(): void;
  56690. private _computeAngleValues;
  56691. /**
  56692. * Sets the passed Effect "effect" with the Light textures.
  56693. * @param effect The effect to update
  56694. * @param lightIndex The index of the light in the effect to update
  56695. * @returns The light
  56696. */
  56697. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  56698. /**
  56699. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  56700. * @param effect The effect to update
  56701. * @param lightIndex The index of the light in the effect to update
  56702. * @returns The spot light
  56703. */
  56704. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  56705. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  56706. /**
  56707. * Disposes the light and the associated resources.
  56708. */
  56709. dispose(): void;
  56710. /**
  56711. * Prepares the list of defines specific to the light type.
  56712. * @param defines the list of defines
  56713. * @param lightIndex defines the index of the light for the effect
  56714. */
  56715. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  56716. }
  56717. }
  56718. declare module "babylonjs/Gizmos/lightGizmo" {
  56719. import { Nullable } from "babylonjs/types";
  56720. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  56721. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  56722. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  56723. import { Light } from "babylonjs/Lights/light";
  56724. import { Observable } from "babylonjs/Misc/observable";
  56725. /**
  56726. * Gizmo that enables viewing a light
  56727. */
  56728. export class LightGizmo extends Gizmo {
  56729. private _lightMesh;
  56730. private _material;
  56731. private _cachedPosition;
  56732. private _cachedForward;
  56733. private _attachedMeshParent;
  56734. private _pointerObserver;
  56735. /**
  56736. * Event that fires each time the gizmo is clicked
  56737. */
  56738. onClickedObservable: Observable<Light>;
  56739. /**
  56740. * Creates a LightGizmo
  56741. * @param gizmoLayer The utility layer the gizmo will be added to
  56742. */
  56743. constructor(gizmoLayer?: UtilityLayerRenderer);
  56744. private _light;
  56745. /**
  56746. * The light that the gizmo is attached to
  56747. */
  56748. set light(light: Nullable<Light>);
  56749. get light(): Nullable<Light>;
  56750. /**
  56751. * Gets the material used to render the light gizmo
  56752. */
  56753. get material(): StandardMaterial;
  56754. /**
  56755. * @hidden
  56756. * Updates the gizmo to match the attached mesh's position/rotation
  56757. */
  56758. protected _update(): void;
  56759. private static _Scale;
  56760. /**
  56761. * Creates the lines for a light mesh
  56762. */
  56763. private static _CreateLightLines;
  56764. /**
  56765. * Disposes of the light gizmo
  56766. */
  56767. dispose(): void;
  56768. private static _CreateHemisphericLightMesh;
  56769. private static _CreatePointLightMesh;
  56770. private static _CreateSpotLightMesh;
  56771. private static _CreateDirectionalLightMesh;
  56772. }
  56773. }
  56774. declare module "babylonjs/Gizmos/cameraGizmo" {
  56775. import { Nullable } from "babylonjs/types";
  56776. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  56777. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  56778. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  56779. import { Camera } from "babylonjs/Cameras/camera";
  56780. import { Observable } from "babylonjs/Misc/observable";
  56781. /**
  56782. * Gizmo that enables viewing a camera
  56783. */
  56784. export class CameraGizmo extends Gizmo {
  56785. private _cameraMesh;
  56786. private _cameraLinesMesh;
  56787. private _material;
  56788. private _pointerObserver;
  56789. /**
  56790. * Event that fires each time the gizmo is clicked
  56791. */
  56792. onClickedObservable: Observable<Camera>;
  56793. /**
  56794. * Creates a CameraGizmo
  56795. * @param gizmoLayer The utility layer the gizmo will be added to
  56796. */
  56797. constructor(gizmoLayer?: UtilityLayerRenderer);
  56798. private _camera;
  56799. /** Gets or sets a boolean indicating if frustum lines must be rendered (true by default)) */
  56800. get displayFrustum(): boolean;
  56801. set displayFrustum(value: boolean);
  56802. /**
  56803. * The camera that the gizmo is attached to
  56804. */
  56805. set camera(camera: Nullable<Camera>);
  56806. get camera(): Nullable<Camera>;
  56807. /**
  56808. * Gets the material used to render the camera gizmo
  56809. */
  56810. get material(): StandardMaterial;
  56811. /**
  56812. * @hidden
  56813. * Updates the gizmo to match the attached mesh's position/rotation
  56814. */
  56815. protected _update(): void;
  56816. private static _Scale;
  56817. private _invProjection;
  56818. /**
  56819. * Disposes of the camera gizmo
  56820. */
  56821. dispose(): void;
  56822. private static _CreateCameraMesh;
  56823. private static _CreateCameraFrustum;
  56824. }
  56825. }
  56826. declare module "babylonjs/Gizmos/index" {
  56827. export * from "babylonjs/Gizmos/axisDragGizmo";
  56828. export * from "babylonjs/Gizmos/axisScaleGizmo";
  56829. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  56830. export * from "babylonjs/Gizmos/gizmo";
  56831. export * from "babylonjs/Gizmos/gizmoManager";
  56832. export * from "babylonjs/Gizmos/planeRotationGizmo";
  56833. export * from "babylonjs/Gizmos/positionGizmo";
  56834. export * from "babylonjs/Gizmos/rotationGizmo";
  56835. export * from "babylonjs/Gizmos/scaleGizmo";
  56836. export * from "babylonjs/Gizmos/lightGizmo";
  56837. export * from "babylonjs/Gizmos/cameraGizmo";
  56838. export * from "babylonjs/Gizmos/planeDragGizmo";
  56839. }
  56840. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  56841. /** @hidden */
  56842. export var backgroundFragmentDeclaration: {
  56843. name: string;
  56844. shader: string;
  56845. };
  56846. }
  56847. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  56848. /** @hidden */
  56849. export var backgroundUboDeclaration: {
  56850. name: string;
  56851. shader: string;
  56852. };
  56853. }
  56854. declare module "babylonjs/Shaders/background.fragment" {
  56855. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  56856. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  56857. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  56858. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  56859. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  56860. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  56861. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  56862. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  56863. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  56864. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  56865. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  56866. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  56867. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  56868. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  56869. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  56870. /** @hidden */
  56871. export var backgroundPixelShader: {
  56872. name: string;
  56873. shader: string;
  56874. };
  56875. }
  56876. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  56877. /** @hidden */
  56878. export var backgroundVertexDeclaration: {
  56879. name: string;
  56880. shader: string;
  56881. };
  56882. }
  56883. declare module "babylonjs/Shaders/background.vertex" {
  56884. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  56885. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  56886. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  56887. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  56888. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  56889. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  56890. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  56891. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  56892. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  56893. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  56894. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  56895. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  56896. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  56897. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  56898. /** @hidden */
  56899. export var backgroundVertexShader: {
  56900. name: string;
  56901. shader: string;
  56902. };
  56903. }
  56904. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  56905. import { Nullable, int, float } from "babylonjs/types";
  56906. import { Scene } from "babylonjs/scene";
  56907. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  56908. import { SubMesh } from "babylonjs/Meshes/subMesh";
  56909. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56910. import { Mesh } from "babylonjs/Meshes/mesh";
  56911. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  56912. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  56913. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  56914. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  56915. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  56916. import { Color3 } from "babylonjs/Maths/math.color";
  56917. import "babylonjs/Shaders/background.fragment";
  56918. import "babylonjs/Shaders/background.vertex";
  56919. /**
  56920. * Background material used to create an efficient environement around your scene.
  56921. */
  56922. export class BackgroundMaterial extends PushMaterial {
  56923. /**
  56924. * Standard reflectance value at parallel view angle.
  56925. */
  56926. static StandardReflectance0: number;
  56927. /**
  56928. * Standard reflectance value at grazing angle.
  56929. */
  56930. static StandardReflectance90: number;
  56931. protected _primaryColor: Color3;
  56932. /**
  56933. * Key light Color (multiply against the environement texture)
  56934. */
  56935. primaryColor: Color3;
  56936. protected __perceptualColor: Nullable<Color3>;
  56937. /**
  56938. * Experimental Internal Use Only.
  56939. *
  56940. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  56941. * This acts as a helper to set the primary color to a more "human friendly" value.
  56942. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  56943. * output color as close as possible from the chosen value.
  56944. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  56945. * part of lighting setup.)
  56946. */
  56947. get _perceptualColor(): Nullable<Color3>;
  56948. set _perceptualColor(value: Nullable<Color3>);
  56949. protected _primaryColorShadowLevel: float;
  56950. /**
  56951. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  56952. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  56953. */
  56954. get primaryColorShadowLevel(): float;
  56955. set primaryColorShadowLevel(value: float);
  56956. protected _primaryColorHighlightLevel: float;
  56957. /**
  56958. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  56959. * The primary color is used at the level chosen to define what the white area would look.
  56960. */
  56961. get primaryColorHighlightLevel(): float;
  56962. set primaryColorHighlightLevel(value: float);
  56963. protected _reflectionTexture: Nullable<BaseTexture>;
  56964. /**
  56965. * Reflection Texture used in the material.
  56966. * Should be author in a specific way for the best result (refer to the documentation).
  56967. */
  56968. reflectionTexture: Nullable<BaseTexture>;
  56969. protected _reflectionBlur: float;
  56970. /**
  56971. * Reflection Texture level of blur.
  56972. *
  56973. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  56974. * texture twice.
  56975. */
  56976. reflectionBlur: float;
  56977. protected _diffuseTexture: Nullable<BaseTexture>;
  56978. /**
  56979. * Diffuse Texture used in the material.
  56980. * Should be author in a specific way for the best result (refer to the documentation).
  56981. */
  56982. diffuseTexture: Nullable<BaseTexture>;
  56983. protected _shadowLights: Nullable<IShadowLight[]>;
  56984. /**
  56985. * Specify the list of lights casting shadow on the material.
  56986. * All scene shadow lights will be included if null.
  56987. */
  56988. shadowLights: Nullable<IShadowLight[]>;
  56989. protected _shadowLevel: float;
  56990. /**
  56991. * Helps adjusting the shadow to a softer level if required.
  56992. * 0 means black shadows and 1 means no shadows.
  56993. */
  56994. shadowLevel: float;
  56995. protected _sceneCenter: Vector3;
  56996. /**
  56997. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  56998. * It is usually zero but might be interesting to modify according to your setup.
  56999. */
  57000. sceneCenter: Vector3;
  57001. protected _opacityFresnel: boolean;
  57002. /**
  57003. * This helps specifying that the material is falling off to the sky box at grazing angle.
  57004. * This helps ensuring a nice transition when the camera goes under the ground.
  57005. */
  57006. opacityFresnel: boolean;
  57007. protected _reflectionFresnel: boolean;
  57008. /**
  57009. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  57010. * This helps adding a mirror texture on the ground.
  57011. */
  57012. reflectionFresnel: boolean;
  57013. protected _reflectionFalloffDistance: number;
  57014. /**
  57015. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  57016. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  57017. */
  57018. reflectionFalloffDistance: number;
  57019. protected _reflectionAmount: number;
  57020. /**
  57021. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  57022. */
  57023. reflectionAmount: number;
  57024. protected _reflectionReflectance0: number;
  57025. /**
  57026. * This specifies the weight of the reflection at grazing angle.
  57027. */
  57028. reflectionReflectance0: number;
  57029. protected _reflectionReflectance90: number;
  57030. /**
  57031. * This specifies the weight of the reflection at a perpendicular point of view.
  57032. */
  57033. reflectionReflectance90: number;
  57034. /**
  57035. * Sets the reflection reflectance fresnel values according to the default standard
  57036. * empirically know to work well :-)
  57037. */
  57038. set reflectionStandardFresnelWeight(value: number);
  57039. protected _useRGBColor: boolean;
  57040. /**
  57041. * Helps to directly use the maps channels instead of their level.
  57042. */
  57043. useRGBColor: boolean;
  57044. protected _enableNoise: boolean;
  57045. /**
  57046. * This helps reducing the banding effect that could occur on the background.
  57047. */
  57048. enableNoise: boolean;
  57049. /**
  57050. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  57051. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  57052. * Recommended to be keep at 1.0 except for special cases.
  57053. */
  57054. get fovMultiplier(): number;
  57055. set fovMultiplier(value: number);
  57056. private _fovMultiplier;
  57057. /**
  57058. * Enable the FOV adjustment feature controlled by fovMultiplier.
  57059. */
  57060. useEquirectangularFOV: boolean;
  57061. private _maxSimultaneousLights;
  57062. /**
  57063. * Number of Simultaneous lights allowed on the material.
  57064. */
  57065. maxSimultaneousLights: int;
  57066. private _shadowOnly;
  57067. /**
  57068. * Make the material only render shadows
  57069. */
  57070. shadowOnly: boolean;
  57071. /**
  57072. * Default configuration related to image processing available in the Background Material.
  57073. */
  57074. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  57075. /**
  57076. * Keep track of the image processing observer to allow dispose and replace.
  57077. */
  57078. private _imageProcessingObserver;
  57079. /**
  57080. * Attaches a new image processing configuration to the PBR Material.
  57081. * @param configuration (if null the scene configuration will be use)
  57082. */
  57083. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  57084. /**
  57085. * Gets the image processing configuration used either in this material.
  57086. */
  57087. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  57088. /**
  57089. * Sets the Default image processing configuration used either in the this material.
  57090. *
  57091. * If sets to null, the scene one is in use.
  57092. */
  57093. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  57094. /**
  57095. * Gets wether the color curves effect is enabled.
  57096. */
  57097. get cameraColorCurvesEnabled(): boolean;
  57098. /**
  57099. * Sets wether the color curves effect is enabled.
  57100. */
  57101. set cameraColorCurvesEnabled(value: boolean);
  57102. /**
  57103. * Gets wether the color grading effect is enabled.
  57104. */
  57105. get cameraColorGradingEnabled(): boolean;
  57106. /**
  57107. * Gets wether the color grading effect is enabled.
  57108. */
  57109. set cameraColorGradingEnabled(value: boolean);
  57110. /**
  57111. * Gets wether tonemapping is enabled or not.
  57112. */
  57113. get cameraToneMappingEnabled(): boolean;
  57114. /**
  57115. * Sets wether tonemapping is enabled or not
  57116. */
  57117. set cameraToneMappingEnabled(value: boolean);
  57118. /**
  57119. * The camera exposure used on this material.
  57120. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  57121. * This corresponds to a photographic exposure.
  57122. */
  57123. get cameraExposure(): float;
  57124. /**
  57125. * The camera exposure used on this material.
  57126. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  57127. * This corresponds to a photographic exposure.
  57128. */
  57129. set cameraExposure(value: float);
  57130. /**
  57131. * Gets The camera contrast used on this material.
  57132. */
  57133. get cameraContrast(): float;
  57134. /**
  57135. * Sets The camera contrast used on this material.
  57136. */
  57137. set cameraContrast(value: float);
  57138. /**
  57139. * Gets the Color Grading 2D Lookup Texture.
  57140. */
  57141. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  57142. /**
  57143. * Sets the Color Grading 2D Lookup Texture.
  57144. */
  57145. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  57146. /**
  57147. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  57148. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  57149. * 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;
  57150. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  57151. */
  57152. get cameraColorCurves(): Nullable<ColorCurves>;
  57153. /**
  57154. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  57155. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  57156. * 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;
  57157. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  57158. */
  57159. set cameraColorCurves(value: Nullable<ColorCurves>);
  57160. /**
  57161. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  57162. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  57163. */
  57164. switchToBGR: boolean;
  57165. private _renderTargets;
  57166. private _reflectionControls;
  57167. private _white;
  57168. private _primaryShadowColor;
  57169. private _primaryHighlightColor;
  57170. /**
  57171. * Instantiates a Background Material in the given scene
  57172. * @param name The friendly name of the material
  57173. * @param scene The scene to add the material to
  57174. */
  57175. constructor(name: string, scene: Scene);
  57176. /**
  57177. * Gets a boolean indicating that current material needs to register RTT
  57178. */
  57179. get hasRenderTargetTextures(): boolean;
  57180. /**
  57181. * The entire material has been created in order to prevent overdraw.
  57182. * @returns false
  57183. */
  57184. needAlphaTesting(): boolean;
  57185. /**
  57186. * The entire material has been created in order to prevent overdraw.
  57187. * @returns true if blending is enable
  57188. */
  57189. needAlphaBlending(): boolean;
  57190. /**
  57191. * Checks wether the material is ready to be rendered for a given mesh.
  57192. * @param mesh The mesh to render
  57193. * @param subMesh The submesh to check against
  57194. * @param useInstances Specify wether or not the material is used with instances
  57195. * @returns true if all the dependencies are ready (Textures, Effects...)
  57196. */
  57197. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  57198. /**
  57199. * Compute the primary color according to the chosen perceptual color.
  57200. */
  57201. private _computePrimaryColorFromPerceptualColor;
  57202. /**
  57203. * Compute the highlights and shadow colors according to their chosen levels.
  57204. */
  57205. private _computePrimaryColors;
  57206. /**
  57207. * Build the uniform buffer used in the material.
  57208. */
  57209. buildUniformLayout(): void;
  57210. /**
  57211. * Unbind the material.
  57212. */
  57213. unbind(): void;
  57214. /**
  57215. * Bind only the world matrix to the material.
  57216. * @param world The world matrix to bind.
  57217. */
  57218. bindOnlyWorldMatrix(world: Matrix): void;
  57219. /**
  57220. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  57221. * @param world The world matrix to bind.
  57222. * @param subMesh The submesh to bind for.
  57223. */
  57224. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  57225. /**
  57226. * Checks to see if a texture is used in the material.
  57227. * @param texture - Base texture to use.
  57228. * @returns - Boolean specifying if a texture is used in the material.
  57229. */
  57230. hasTexture(texture: BaseTexture): boolean;
  57231. /**
  57232. * Dispose the material.
  57233. * @param forceDisposeEffect Force disposal of the associated effect.
  57234. * @param forceDisposeTextures Force disposal of the associated textures.
  57235. */
  57236. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  57237. /**
  57238. * Clones the material.
  57239. * @param name The cloned name.
  57240. * @returns The cloned material.
  57241. */
  57242. clone(name: string): BackgroundMaterial;
  57243. /**
  57244. * Serializes the current material to its JSON representation.
  57245. * @returns The JSON representation.
  57246. */
  57247. serialize(): any;
  57248. /**
  57249. * Gets the class name of the material
  57250. * @returns "BackgroundMaterial"
  57251. */
  57252. getClassName(): string;
  57253. /**
  57254. * Parse a JSON input to create back a background material.
  57255. * @param source The JSON data to parse
  57256. * @param scene The scene to create the parsed material in
  57257. * @param rootUrl The root url of the assets the material depends upon
  57258. * @returns the instantiated BackgroundMaterial.
  57259. */
  57260. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  57261. }
  57262. }
  57263. declare module "babylonjs/Helpers/environmentHelper" {
  57264. import { Observable } from "babylonjs/Misc/observable";
  57265. import { Nullable } from "babylonjs/types";
  57266. import { Scene } from "babylonjs/scene";
  57267. import { Vector3 } from "babylonjs/Maths/math.vector";
  57268. import { Color3 } from "babylonjs/Maths/math.color";
  57269. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57270. import { Mesh } from "babylonjs/Meshes/mesh";
  57271. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  57272. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  57273. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  57274. import "babylonjs/Meshes/Builders/planeBuilder";
  57275. import "babylonjs/Meshes/Builders/boxBuilder";
  57276. /**
  57277. * Represents the different options available during the creation of
  57278. * a Environment helper.
  57279. *
  57280. * This can control the default ground, skybox and image processing setup of your scene.
  57281. */
  57282. export interface IEnvironmentHelperOptions {
  57283. /**
  57284. * Specifies whether or not to create a ground.
  57285. * True by default.
  57286. */
  57287. createGround: boolean;
  57288. /**
  57289. * Specifies the ground size.
  57290. * 15 by default.
  57291. */
  57292. groundSize: number;
  57293. /**
  57294. * The texture used on the ground for the main color.
  57295. * Comes from the BabylonJS CDN by default.
  57296. *
  57297. * Remarks: Can be either a texture or a url.
  57298. */
  57299. groundTexture: string | BaseTexture;
  57300. /**
  57301. * The color mixed in the ground texture by default.
  57302. * BabylonJS clearColor by default.
  57303. */
  57304. groundColor: Color3;
  57305. /**
  57306. * Specifies the ground opacity.
  57307. * 1 by default.
  57308. */
  57309. groundOpacity: number;
  57310. /**
  57311. * Enables the ground to receive shadows.
  57312. * True by default.
  57313. */
  57314. enableGroundShadow: boolean;
  57315. /**
  57316. * Helps preventing the shadow to be fully black on the ground.
  57317. * 0.5 by default.
  57318. */
  57319. groundShadowLevel: number;
  57320. /**
  57321. * Creates a mirror texture attach to the ground.
  57322. * false by default.
  57323. */
  57324. enableGroundMirror: boolean;
  57325. /**
  57326. * Specifies the ground mirror size ratio.
  57327. * 0.3 by default as the default kernel is 64.
  57328. */
  57329. groundMirrorSizeRatio: number;
  57330. /**
  57331. * Specifies the ground mirror blur kernel size.
  57332. * 64 by default.
  57333. */
  57334. groundMirrorBlurKernel: number;
  57335. /**
  57336. * Specifies the ground mirror visibility amount.
  57337. * 1 by default
  57338. */
  57339. groundMirrorAmount: number;
  57340. /**
  57341. * Specifies the ground mirror reflectance weight.
  57342. * This uses the standard weight of the background material to setup the fresnel effect
  57343. * of the mirror.
  57344. * 1 by default.
  57345. */
  57346. groundMirrorFresnelWeight: number;
  57347. /**
  57348. * Specifies the ground mirror Falloff distance.
  57349. * This can helps reducing the size of the reflection.
  57350. * 0 by Default.
  57351. */
  57352. groundMirrorFallOffDistance: number;
  57353. /**
  57354. * Specifies the ground mirror texture type.
  57355. * Unsigned Int by Default.
  57356. */
  57357. groundMirrorTextureType: number;
  57358. /**
  57359. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  57360. * the shown objects.
  57361. */
  57362. groundYBias: number;
  57363. /**
  57364. * Specifies whether or not to create a skybox.
  57365. * True by default.
  57366. */
  57367. createSkybox: boolean;
  57368. /**
  57369. * Specifies the skybox size.
  57370. * 20 by default.
  57371. */
  57372. skyboxSize: number;
  57373. /**
  57374. * The texture used on the skybox for the main color.
  57375. * Comes from the BabylonJS CDN by default.
  57376. *
  57377. * Remarks: Can be either a texture or a url.
  57378. */
  57379. skyboxTexture: string | BaseTexture;
  57380. /**
  57381. * The color mixed in the skybox texture by default.
  57382. * BabylonJS clearColor by default.
  57383. */
  57384. skyboxColor: Color3;
  57385. /**
  57386. * The background rotation around the Y axis of the scene.
  57387. * This helps aligning the key lights of your scene with the background.
  57388. * 0 by default.
  57389. */
  57390. backgroundYRotation: number;
  57391. /**
  57392. * Compute automatically the size of the elements to best fit with the scene.
  57393. */
  57394. sizeAuto: boolean;
  57395. /**
  57396. * Default position of the rootMesh if autoSize is not true.
  57397. */
  57398. rootPosition: Vector3;
  57399. /**
  57400. * Sets up the image processing in the scene.
  57401. * true by default.
  57402. */
  57403. setupImageProcessing: boolean;
  57404. /**
  57405. * The texture used as your environment texture in the scene.
  57406. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  57407. *
  57408. * Remarks: Can be either a texture or a url.
  57409. */
  57410. environmentTexture: string | BaseTexture;
  57411. /**
  57412. * The value of the exposure to apply to the scene.
  57413. * 0.6 by default if setupImageProcessing is true.
  57414. */
  57415. cameraExposure: number;
  57416. /**
  57417. * The value of the contrast to apply to the scene.
  57418. * 1.6 by default if setupImageProcessing is true.
  57419. */
  57420. cameraContrast: number;
  57421. /**
  57422. * Specifies whether or not tonemapping should be enabled in the scene.
  57423. * true by default if setupImageProcessing is true.
  57424. */
  57425. toneMappingEnabled: boolean;
  57426. }
  57427. /**
  57428. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  57429. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  57430. * It also helps with the default setup of your imageProcessing configuration.
  57431. */
  57432. export class EnvironmentHelper {
  57433. /**
  57434. * Default ground texture URL.
  57435. */
  57436. private static _groundTextureCDNUrl;
  57437. /**
  57438. * Default skybox texture URL.
  57439. */
  57440. private static _skyboxTextureCDNUrl;
  57441. /**
  57442. * Default environment texture URL.
  57443. */
  57444. private static _environmentTextureCDNUrl;
  57445. /**
  57446. * Creates the default options for the helper.
  57447. */
  57448. private static _getDefaultOptions;
  57449. private _rootMesh;
  57450. /**
  57451. * Gets the root mesh created by the helper.
  57452. */
  57453. get rootMesh(): Mesh;
  57454. private _skybox;
  57455. /**
  57456. * Gets the skybox created by the helper.
  57457. */
  57458. get skybox(): Nullable<Mesh>;
  57459. private _skyboxTexture;
  57460. /**
  57461. * Gets the skybox texture created by the helper.
  57462. */
  57463. get skyboxTexture(): Nullable<BaseTexture>;
  57464. private _skyboxMaterial;
  57465. /**
  57466. * Gets the skybox material created by the helper.
  57467. */
  57468. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  57469. private _ground;
  57470. /**
  57471. * Gets the ground mesh created by the helper.
  57472. */
  57473. get ground(): Nullable<Mesh>;
  57474. private _groundTexture;
  57475. /**
  57476. * Gets the ground texture created by the helper.
  57477. */
  57478. get groundTexture(): Nullable<BaseTexture>;
  57479. private _groundMirror;
  57480. /**
  57481. * Gets the ground mirror created by the helper.
  57482. */
  57483. get groundMirror(): Nullable<MirrorTexture>;
  57484. /**
  57485. * Gets the ground mirror render list to helps pushing the meshes
  57486. * you wish in the ground reflection.
  57487. */
  57488. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  57489. private _groundMaterial;
  57490. /**
  57491. * Gets the ground material created by the helper.
  57492. */
  57493. get groundMaterial(): Nullable<BackgroundMaterial>;
  57494. /**
  57495. * Stores the creation options.
  57496. */
  57497. private readonly _scene;
  57498. private _options;
  57499. /**
  57500. * This observable will be notified with any error during the creation of the environment,
  57501. * mainly texture creation errors.
  57502. */
  57503. onErrorObservable: Observable<{
  57504. message?: string;
  57505. exception?: any;
  57506. }>;
  57507. /**
  57508. * constructor
  57509. * @param options Defines the options we want to customize the helper
  57510. * @param scene The scene to add the material to
  57511. */
  57512. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  57513. /**
  57514. * Updates the background according to the new options
  57515. * @param options
  57516. */
  57517. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  57518. /**
  57519. * Sets the primary color of all the available elements.
  57520. * @param color the main color to affect to the ground and the background
  57521. */
  57522. setMainColor(color: Color3): void;
  57523. /**
  57524. * Setup the image processing according to the specified options.
  57525. */
  57526. private _setupImageProcessing;
  57527. /**
  57528. * Setup the environment texture according to the specified options.
  57529. */
  57530. private _setupEnvironmentTexture;
  57531. /**
  57532. * Setup the background according to the specified options.
  57533. */
  57534. private _setupBackground;
  57535. /**
  57536. * Get the scene sizes according to the setup.
  57537. */
  57538. private _getSceneSize;
  57539. /**
  57540. * Setup the ground according to the specified options.
  57541. */
  57542. private _setupGround;
  57543. /**
  57544. * Setup the ground material according to the specified options.
  57545. */
  57546. private _setupGroundMaterial;
  57547. /**
  57548. * Setup the ground diffuse texture according to the specified options.
  57549. */
  57550. private _setupGroundDiffuseTexture;
  57551. /**
  57552. * Setup the ground mirror texture according to the specified options.
  57553. */
  57554. private _setupGroundMirrorTexture;
  57555. /**
  57556. * Setup the ground to receive the mirror texture.
  57557. */
  57558. private _setupMirrorInGroundMaterial;
  57559. /**
  57560. * Setup the skybox according to the specified options.
  57561. */
  57562. private _setupSkybox;
  57563. /**
  57564. * Setup the skybox material according to the specified options.
  57565. */
  57566. private _setupSkyboxMaterial;
  57567. /**
  57568. * Setup the skybox reflection texture according to the specified options.
  57569. */
  57570. private _setupSkyboxReflectionTexture;
  57571. private _errorHandler;
  57572. /**
  57573. * Dispose all the elements created by the Helper.
  57574. */
  57575. dispose(): void;
  57576. }
  57577. }
  57578. declare module "babylonjs/Helpers/textureDome" {
  57579. import { Scene } from "babylonjs/scene";
  57580. import { TransformNode } from "babylonjs/Meshes/transformNode";
  57581. import { Mesh } from "babylonjs/Meshes/mesh";
  57582. import { Texture } from "babylonjs/Materials/Textures/texture";
  57583. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  57584. import "babylonjs/Meshes/Builders/sphereBuilder";
  57585. import { Nullable } from "babylonjs/types";
  57586. import { Observable } from "babylonjs/Misc/observable";
  57587. /**
  57588. * Display a 360/180 degree texture on an approximately spherical surface, useful for VR applications or skyboxes.
  57589. * As a subclass of TransformNode, this allow parenting to the camera or multiple textures with different locations in the scene.
  57590. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  57591. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  57592. */
  57593. export abstract class TextureDome<T extends Texture> extends TransformNode {
  57594. protected onError: Nullable<(message?: string, exception?: any) => void>;
  57595. /**
  57596. * Define the source as a Monoscopic panoramic 360/180.
  57597. */
  57598. static readonly MODE_MONOSCOPIC: number;
  57599. /**
  57600. * Define the source as a Stereoscopic TopBottom/OverUnder panoramic 360/180.
  57601. */
  57602. static readonly MODE_TOPBOTTOM: number;
  57603. /**
  57604. * Define the source as a Stereoscopic Side by Side panoramic 360/180.
  57605. */
  57606. static readonly MODE_SIDEBYSIDE: number;
  57607. private _halfDome;
  57608. protected _useDirectMapping: boolean;
  57609. /**
  57610. * The texture being displayed on the sphere
  57611. */
  57612. protected _texture: T;
  57613. /**
  57614. * Gets the texture being displayed on the sphere
  57615. */
  57616. get texture(): T;
  57617. /**
  57618. * Sets the texture being displayed on the sphere
  57619. */
  57620. set texture(newTexture: T);
  57621. /**
  57622. * The skybox material
  57623. */
  57624. protected _material: BackgroundMaterial;
  57625. /**
  57626. * The surface used for the dome
  57627. */
  57628. protected _mesh: Mesh;
  57629. /**
  57630. * Gets the mesh used for the dome.
  57631. */
  57632. get mesh(): Mesh;
  57633. /**
  57634. * A mesh that will be used to mask the back of the dome in case it is a 180 degree movie.
  57635. */
  57636. private _halfDomeMask;
  57637. /**
  57638. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  57639. * Also see the options.resolution property.
  57640. */
  57641. get fovMultiplier(): number;
  57642. set fovMultiplier(value: number);
  57643. protected _textureMode: number;
  57644. /**
  57645. * Gets or set the current texture mode for the texture. It can be:
  57646. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  57647. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  57648. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  57649. */
  57650. get textureMode(): number;
  57651. /**
  57652. * Sets the current texture mode for the texture. It can be:
  57653. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  57654. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  57655. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  57656. */
  57657. set textureMode(value: number);
  57658. /**
  57659. * Is it a 180 degrees dome (half dome) or 360 texture (full dome)
  57660. */
  57661. get halfDome(): boolean;
  57662. /**
  57663. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  57664. */
  57665. set halfDome(enabled: boolean);
  57666. /**
  57667. * Oberserver used in Stereoscopic VR Mode.
  57668. */
  57669. private _onBeforeCameraRenderObserver;
  57670. /**
  57671. * Observable raised when an error occured while loading the 360 image
  57672. */
  57673. onLoadErrorObservable: Observable<string>;
  57674. /**
  57675. * Create an instance of this class and pass through the parameters to the relevant classes- Texture, StandardMaterial, and Mesh.
  57676. * @param name Element's name, child elements will append suffixes for their own names.
  57677. * @param textureUrlOrElement defines the url(s) or the (video) HTML element to use
  57678. * @param options An object containing optional or exposed sub element properties
  57679. */
  57680. constructor(name: string, textureUrlOrElement: string | string[] | HTMLVideoElement, options: {
  57681. resolution?: number;
  57682. clickToPlay?: boolean;
  57683. autoPlay?: boolean;
  57684. loop?: boolean;
  57685. size?: number;
  57686. poster?: string;
  57687. faceForward?: boolean;
  57688. useDirectMapping?: boolean;
  57689. halfDomeMode?: boolean;
  57690. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  57691. protected abstract _initTexture(urlsOrElement: string | string[] | HTMLElement, scene: Scene, options: any): T;
  57692. protected _changeTextureMode(value: number): void;
  57693. /**
  57694. * Releases resources associated with this node.
  57695. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  57696. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  57697. */
  57698. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  57699. }
  57700. }
  57701. declare module "babylonjs/Helpers/photoDome" {
  57702. import { Scene } from "babylonjs/scene";
  57703. import { Texture } from "babylonjs/Materials/Textures/texture";
  57704. import { TextureDome } from "babylonjs/Helpers/textureDome";
  57705. /**
  57706. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  57707. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  57708. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  57709. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  57710. */
  57711. export class PhotoDome extends TextureDome<Texture> {
  57712. /**
  57713. * Define the image as a Monoscopic panoramic 360 image.
  57714. */
  57715. static readonly MODE_MONOSCOPIC: number;
  57716. /**
  57717. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  57718. */
  57719. static readonly MODE_TOPBOTTOM: number;
  57720. /**
  57721. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  57722. */
  57723. static readonly MODE_SIDEBYSIDE: number;
  57724. /**
  57725. * Gets or sets the texture being displayed on the sphere
  57726. */
  57727. get photoTexture(): Texture;
  57728. /**
  57729. * sets the texture being displayed on the sphere
  57730. */
  57731. set photoTexture(value: Texture);
  57732. /**
  57733. * Gets the current video mode for the video. It can be:
  57734. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  57735. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  57736. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  57737. */
  57738. get imageMode(): number;
  57739. /**
  57740. * Sets the current video mode for the video. It can be:
  57741. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  57742. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  57743. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  57744. */
  57745. set imageMode(value: number);
  57746. protected _initTexture(urlsOrElement: string, scene: Scene, options: any): Texture;
  57747. }
  57748. }
  57749. declare module "babylonjs/Misc/rgbdTextureTools" {
  57750. import "babylonjs/Shaders/rgbdDecode.fragment";
  57751. import "babylonjs/Engines/Extensions/engine.renderTarget";
  57752. import { Texture } from "babylonjs/Materials/Textures/texture";
  57753. /**
  57754. * Class used to host RGBD texture specific utilities
  57755. */
  57756. export class RGBDTextureTools {
  57757. /**
  57758. * Expand the RGBD Texture from RGBD to Half Float if possible.
  57759. * @param texture the texture to expand.
  57760. */
  57761. static ExpandRGBDTexture(texture: Texture): void;
  57762. }
  57763. }
  57764. declare module "babylonjs/Misc/brdfTextureTools" {
  57765. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  57766. import { Scene } from "babylonjs/scene";
  57767. /**
  57768. * Class used to host texture specific utilities
  57769. */
  57770. export class BRDFTextureTools {
  57771. /**
  57772. * Prevents texture cache collision
  57773. */
  57774. private static _instanceNumber;
  57775. /**
  57776. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  57777. * @param scene defines the hosting scene
  57778. * @returns the environment BRDF texture
  57779. */
  57780. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  57781. private static _environmentBRDFBase64Texture;
  57782. }
  57783. }
  57784. declare module "babylonjs/Materials/PBR/pbrClearCoatConfiguration" {
  57785. import { Nullable } from "babylonjs/types";
  57786. import { Color3 } from "babylonjs/Maths/math.color";
  57787. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  57788. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  57789. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  57790. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  57791. import { Engine } from "babylonjs/Engines/engine";
  57792. import { Scene } from "babylonjs/scene";
  57793. /**
  57794. * @hidden
  57795. */
  57796. export interface IMaterialClearCoatDefines {
  57797. CLEARCOAT: boolean;
  57798. CLEARCOAT_DEFAULTIOR: boolean;
  57799. CLEARCOAT_TEXTURE: boolean;
  57800. CLEARCOAT_TEXTUREDIRECTUV: number;
  57801. CLEARCOAT_BUMP: boolean;
  57802. CLEARCOAT_BUMPDIRECTUV: number;
  57803. CLEARCOAT_TINT: boolean;
  57804. CLEARCOAT_TINT_TEXTURE: boolean;
  57805. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  57806. /** @hidden */
  57807. _areTexturesDirty: boolean;
  57808. }
  57809. /**
  57810. * Define the code related to the clear coat parameters of the pbr material.
  57811. */
  57812. export class PBRClearCoatConfiguration {
  57813. /**
  57814. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  57815. * The default fits with a polyurethane material.
  57816. */
  57817. private static readonly _DefaultIndexOfRefraction;
  57818. private _isEnabled;
  57819. /**
  57820. * Defines if the clear coat is enabled in the material.
  57821. */
  57822. isEnabled: boolean;
  57823. /**
  57824. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  57825. */
  57826. intensity: number;
  57827. /**
  57828. * Defines the clear coat layer roughness.
  57829. */
  57830. roughness: number;
  57831. private _indexOfRefraction;
  57832. /**
  57833. * Defines the index of refraction of the clear coat.
  57834. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  57835. * The default fits with a polyurethane material.
  57836. * Changing the default value is more performance intensive.
  57837. */
  57838. indexOfRefraction: number;
  57839. private _texture;
  57840. /**
  57841. * Stores the clear coat values in a texture.
  57842. */
  57843. texture: Nullable<BaseTexture>;
  57844. private _bumpTexture;
  57845. /**
  57846. * Define the clear coat specific bump texture.
  57847. */
  57848. bumpTexture: Nullable<BaseTexture>;
  57849. private _isTintEnabled;
  57850. /**
  57851. * Defines if the clear coat tint is enabled in the material.
  57852. */
  57853. isTintEnabled: boolean;
  57854. /**
  57855. * Defines the clear coat tint of the material.
  57856. * This is only use if tint is enabled
  57857. */
  57858. tintColor: Color3;
  57859. /**
  57860. * Defines the distance at which the tint color should be found in the
  57861. * clear coat media.
  57862. * This is only use if tint is enabled
  57863. */
  57864. tintColorAtDistance: number;
  57865. /**
  57866. * Defines the clear coat layer thickness.
  57867. * This is only use if tint is enabled
  57868. */
  57869. tintThickness: number;
  57870. private _tintTexture;
  57871. /**
  57872. * Stores the clear tint values in a texture.
  57873. * rgb is tint
  57874. * a is a thickness factor
  57875. */
  57876. tintTexture: Nullable<BaseTexture>;
  57877. /** @hidden */
  57878. private _internalMarkAllSubMeshesAsTexturesDirty;
  57879. /** @hidden */
  57880. _markAllSubMeshesAsTexturesDirty(): void;
  57881. /**
  57882. * Instantiate a new istance of clear coat configuration.
  57883. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  57884. */
  57885. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  57886. /**
  57887. * Gets wehter the submesh is ready to be used or not.
  57888. * @param defines the list of "defines" to update.
  57889. * @param scene defines the scene the material belongs to.
  57890. * @param engine defines the engine the material belongs to.
  57891. * @param disableBumpMap defines wether the material disables bump or not.
  57892. * @returns - boolean indicating that the submesh is ready or not.
  57893. */
  57894. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  57895. /**
  57896. * Checks to see if a texture is used in the material.
  57897. * @param defines the list of "defines" to update.
  57898. * @param scene defines the scene to the material belongs to.
  57899. */
  57900. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  57901. /**
  57902. * Binds the material data.
  57903. * @param uniformBuffer defines the Uniform buffer to fill in.
  57904. * @param scene defines the scene the material belongs to.
  57905. * @param engine defines the engine the material belongs to.
  57906. * @param disableBumpMap defines wether the material disables bump or not.
  57907. * @param isFrozen defines wether the material is frozen or not.
  57908. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  57909. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  57910. */
  57911. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  57912. /**
  57913. * Checks to see if a texture is used in the material.
  57914. * @param texture - Base texture to use.
  57915. * @returns - Boolean specifying if a texture is used in the material.
  57916. */
  57917. hasTexture(texture: BaseTexture): boolean;
  57918. /**
  57919. * Returns an array of the actively used textures.
  57920. * @param activeTextures Array of BaseTextures
  57921. */
  57922. getActiveTextures(activeTextures: BaseTexture[]): void;
  57923. /**
  57924. * Returns the animatable textures.
  57925. * @param animatables Array of animatable textures.
  57926. */
  57927. getAnimatables(animatables: IAnimatable[]): void;
  57928. /**
  57929. * Disposes the resources of the material.
  57930. * @param forceDisposeTextures - Forces the disposal of all textures.
  57931. */
  57932. dispose(forceDisposeTextures?: boolean): void;
  57933. /**
  57934. * Get the current class name of the texture useful for serialization or dynamic coding.
  57935. * @returns "PBRClearCoatConfiguration"
  57936. */
  57937. getClassName(): string;
  57938. /**
  57939. * Add fallbacks to the effect fallbacks list.
  57940. * @param defines defines the Base texture to use.
  57941. * @param fallbacks defines the current fallback list.
  57942. * @param currentRank defines the current fallback rank.
  57943. * @returns the new fallback rank.
  57944. */
  57945. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  57946. /**
  57947. * Add the required uniforms to the current list.
  57948. * @param uniforms defines the current uniform list.
  57949. */
  57950. static AddUniforms(uniforms: string[]): void;
  57951. /**
  57952. * Add the required samplers to the current list.
  57953. * @param samplers defines the current sampler list.
  57954. */
  57955. static AddSamplers(samplers: string[]): void;
  57956. /**
  57957. * Add the required uniforms to the current buffer.
  57958. * @param uniformBuffer defines the current uniform buffer.
  57959. */
  57960. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  57961. /**
  57962. * Makes a duplicate of the current configuration into another one.
  57963. * @param clearCoatConfiguration define the config where to copy the info
  57964. */
  57965. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  57966. /**
  57967. * Serializes this clear coat configuration.
  57968. * @returns - An object with the serialized config.
  57969. */
  57970. serialize(): any;
  57971. /**
  57972. * Parses a anisotropy Configuration from a serialized object.
  57973. * @param source - Serialized object.
  57974. * @param scene Defines the scene we are parsing for
  57975. * @param rootUrl Defines the rootUrl to load from
  57976. */
  57977. parse(source: any, scene: Scene, rootUrl: string): void;
  57978. }
  57979. }
  57980. declare module "babylonjs/Materials/PBR/pbrAnisotropicConfiguration" {
  57981. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  57982. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57983. import { Vector2 } from "babylonjs/Maths/math.vector";
  57984. import { Scene } from "babylonjs/scene";
  57985. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  57986. import { Nullable } from "babylonjs/types";
  57987. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  57988. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  57989. /**
  57990. * @hidden
  57991. */
  57992. export interface IMaterialAnisotropicDefines {
  57993. ANISOTROPIC: boolean;
  57994. ANISOTROPIC_TEXTURE: boolean;
  57995. ANISOTROPIC_TEXTUREDIRECTUV: number;
  57996. MAINUV1: boolean;
  57997. _areTexturesDirty: boolean;
  57998. _needUVs: boolean;
  57999. }
  58000. /**
  58001. * Define the code related to the anisotropic parameters of the pbr material.
  58002. */
  58003. export class PBRAnisotropicConfiguration {
  58004. private _isEnabled;
  58005. /**
  58006. * Defines if the anisotropy is enabled in the material.
  58007. */
  58008. isEnabled: boolean;
  58009. /**
  58010. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  58011. */
  58012. intensity: number;
  58013. /**
  58014. * Defines if the effect is along the tangents, bitangents or in between.
  58015. * By default, the effect is "strectching" the highlights along the tangents.
  58016. */
  58017. direction: Vector2;
  58018. private _texture;
  58019. /**
  58020. * Stores the anisotropy values in a texture.
  58021. * rg is direction (like normal from -1 to 1)
  58022. * b is a intensity
  58023. */
  58024. texture: Nullable<BaseTexture>;
  58025. /** @hidden */
  58026. private _internalMarkAllSubMeshesAsTexturesDirty;
  58027. /** @hidden */
  58028. _markAllSubMeshesAsTexturesDirty(): void;
  58029. /**
  58030. * Instantiate a new istance of anisotropy configuration.
  58031. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  58032. */
  58033. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  58034. /**
  58035. * Specifies that the submesh is ready to be used.
  58036. * @param defines the list of "defines" to update.
  58037. * @param scene defines the scene the material belongs to.
  58038. * @returns - boolean indicating that the submesh is ready or not.
  58039. */
  58040. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  58041. /**
  58042. * Checks to see if a texture is used in the material.
  58043. * @param defines the list of "defines" to update.
  58044. * @param mesh the mesh we are preparing the defines for.
  58045. * @param scene defines the scene the material belongs to.
  58046. */
  58047. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  58048. /**
  58049. * Binds the material data.
  58050. * @param uniformBuffer defines the Uniform buffer to fill in.
  58051. * @param scene defines the scene the material belongs to.
  58052. * @param isFrozen defines wether the material is frozen or not.
  58053. */
  58054. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  58055. /**
  58056. * Checks to see if a texture is used in the material.
  58057. * @param texture - Base texture to use.
  58058. * @returns - Boolean specifying if a texture is used in the material.
  58059. */
  58060. hasTexture(texture: BaseTexture): boolean;
  58061. /**
  58062. * Returns an array of the actively used textures.
  58063. * @param activeTextures Array of BaseTextures
  58064. */
  58065. getActiveTextures(activeTextures: BaseTexture[]): void;
  58066. /**
  58067. * Returns the animatable textures.
  58068. * @param animatables Array of animatable textures.
  58069. */
  58070. getAnimatables(animatables: IAnimatable[]): void;
  58071. /**
  58072. * Disposes the resources of the material.
  58073. * @param forceDisposeTextures - Forces the disposal of all textures.
  58074. */
  58075. dispose(forceDisposeTextures?: boolean): void;
  58076. /**
  58077. * Get the current class name of the texture useful for serialization or dynamic coding.
  58078. * @returns "PBRAnisotropicConfiguration"
  58079. */
  58080. getClassName(): string;
  58081. /**
  58082. * Add fallbacks to the effect fallbacks list.
  58083. * @param defines defines the Base texture to use.
  58084. * @param fallbacks defines the current fallback list.
  58085. * @param currentRank defines the current fallback rank.
  58086. * @returns the new fallback rank.
  58087. */
  58088. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  58089. /**
  58090. * Add the required uniforms to the current list.
  58091. * @param uniforms defines the current uniform list.
  58092. */
  58093. static AddUniforms(uniforms: string[]): void;
  58094. /**
  58095. * Add the required uniforms to the current buffer.
  58096. * @param uniformBuffer defines the current uniform buffer.
  58097. */
  58098. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  58099. /**
  58100. * Add the required samplers to the current list.
  58101. * @param samplers defines the current sampler list.
  58102. */
  58103. static AddSamplers(samplers: string[]): void;
  58104. /**
  58105. * Makes a duplicate of the current configuration into another one.
  58106. * @param anisotropicConfiguration define the config where to copy the info
  58107. */
  58108. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  58109. /**
  58110. * Serializes this anisotropy configuration.
  58111. * @returns - An object with the serialized config.
  58112. */
  58113. serialize(): any;
  58114. /**
  58115. * Parses a anisotropy Configuration from a serialized object.
  58116. * @param source - Serialized object.
  58117. * @param scene Defines the scene we are parsing for
  58118. * @param rootUrl Defines the rootUrl to load from
  58119. */
  58120. parse(source: any, scene: Scene, rootUrl: string): void;
  58121. }
  58122. }
  58123. declare module "babylonjs/Materials/PBR/pbrBRDFConfiguration" {
  58124. import { Scene } from "babylonjs/scene";
  58125. /**
  58126. * @hidden
  58127. */
  58128. export interface IMaterialBRDFDefines {
  58129. BRDF_V_HEIGHT_CORRELATED: boolean;
  58130. MS_BRDF_ENERGY_CONSERVATION: boolean;
  58131. SPHERICAL_HARMONICS: boolean;
  58132. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  58133. /** @hidden */
  58134. _areMiscDirty: boolean;
  58135. }
  58136. /**
  58137. * Define the code related to the BRDF parameters of the pbr material.
  58138. */
  58139. export class PBRBRDFConfiguration {
  58140. /**
  58141. * Default value used for the energy conservation.
  58142. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  58143. */
  58144. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  58145. /**
  58146. * Default value used for the Smith Visibility Height Correlated mode.
  58147. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  58148. */
  58149. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  58150. /**
  58151. * Default value used for the IBL diffuse part.
  58152. * This can help switching back to the polynomials mode globally which is a tiny bit
  58153. * less GPU intensive at the drawback of a lower quality.
  58154. */
  58155. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  58156. /**
  58157. * Default value used for activating energy conservation for the specular workflow.
  58158. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  58159. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  58160. */
  58161. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  58162. private _useEnergyConservation;
  58163. /**
  58164. * Defines if the material uses energy conservation.
  58165. */
  58166. useEnergyConservation: boolean;
  58167. private _useSmithVisibilityHeightCorrelated;
  58168. /**
  58169. * LEGACY Mode set to false
  58170. * Defines if the material uses height smith correlated visibility term.
  58171. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  58172. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  58173. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  58174. * Not relying on height correlated will also disable energy conservation.
  58175. */
  58176. useSmithVisibilityHeightCorrelated: boolean;
  58177. private _useSphericalHarmonics;
  58178. /**
  58179. * LEGACY Mode set to false
  58180. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  58181. * diffuse part of the IBL.
  58182. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  58183. * to the ground truth.
  58184. */
  58185. useSphericalHarmonics: boolean;
  58186. private _useSpecularGlossinessInputEnergyConservation;
  58187. /**
  58188. * Defines if the material uses energy conservation, when the specular workflow is active.
  58189. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  58190. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  58191. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  58192. */
  58193. useSpecularGlossinessInputEnergyConservation: boolean;
  58194. /** @hidden */
  58195. private _internalMarkAllSubMeshesAsMiscDirty;
  58196. /** @hidden */
  58197. _markAllSubMeshesAsMiscDirty(): void;
  58198. /**
  58199. * Instantiate a new istance of clear coat configuration.
  58200. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  58201. */
  58202. constructor(markAllSubMeshesAsMiscDirty: () => void);
  58203. /**
  58204. * Checks to see if a texture is used in the material.
  58205. * @param defines the list of "defines" to update.
  58206. */
  58207. prepareDefines(defines: IMaterialBRDFDefines): void;
  58208. /**
  58209. * Get the current class name of the texture useful for serialization or dynamic coding.
  58210. * @returns "PBRClearCoatConfiguration"
  58211. */
  58212. getClassName(): string;
  58213. /**
  58214. * Makes a duplicate of the current configuration into another one.
  58215. * @param brdfConfiguration define the config where to copy the info
  58216. */
  58217. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  58218. /**
  58219. * Serializes this BRDF configuration.
  58220. * @returns - An object with the serialized config.
  58221. */
  58222. serialize(): any;
  58223. /**
  58224. * Parses a anisotropy Configuration from a serialized object.
  58225. * @param source - Serialized object.
  58226. * @param scene Defines the scene we are parsing for
  58227. * @param rootUrl Defines the rootUrl to load from
  58228. */
  58229. parse(source: any, scene: Scene, rootUrl: string): void;
  58230. }
  58231. }
  58232. declare module "babylonjs/Materials/PBR/pbrSheenConfiguration" {
  58233. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  58234. import { Color3 } from "babylonjs/Maths/math.color";
  58235. import { Scene } from "babylonjs/scene";
  58236. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58237. import { Nullable } from "babylonjs/types";
  58238. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  58239. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  58240. /**
  58241. * @hidden
  58242. */
  58243. export interface IMaterialSheenDefines {
  58244. SHEEN: boolean;
  58245. SHEEN_TEXTURE: boolean;
  58246. SHEEN_TEXTUREDIRECTUV: number;
  58247. SHEEN_LINKWITHALBEDO: boolean;
  58248. SHEEN_ROUGHNESS: boolean;
  58249. SHEEN_ALBEDOSCALING: boolean;
  58250. /** @hidden */
  58251. _areTexturesDirty: boolean;
  58252. }
  58253. /**
  58254. * Define the code related to the Sheen parameters of the pbr material.
  58255. */
  58256. export class PBRSheenConfiguration {
  58257. private _isEnabled;
  58258. /**
  58259. * Defines if the material uses sheen.
  58260. */
  58261. isEnabled: boolean;
  58262. private _linkSheenWithAlbedo;
  58263. /**
  58264. * Defines if the sheen is linked to the sheen color.
  58265. */
  58266. linkSheenWithAlbedo: boolean;
  58267. /**
  58268. * Defines the sheen intensity.
  58269. */
  58270. intensity: number;
  58271. /**
  58272. * Defines the sheen color.
  58273. */
  58274. color: Color3;
  58275. private _texture;
  58276. /**
  58277. * Stores the sheen tint values in a texture.
  58278. * rgb is tint
  58279. * a is a intensity or roughness if roughness has been defined
  58280. */
  58281. texture: Nullable<BaseTexture>;
  58282. private _roughness;
  58283. /**
  58284. * Defines the sheen roughness.
  58285. * It is not taken into account if linkSheenWithAlbedo is true.
  58286. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  58287. */
  58288. roughness: Nullable<number>;
  58289. private _albedoScaling;
  58290. /**
  58291. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  58292. * It allows the strength of the sheen effect to not depend on the base color of the material,
  58293. * making it easier to setup and tweak the effect
  58294. */
  58295. albedoScaling: boolean;
  58296. /** @hidden */
  58297. private _internalMarkAllSubMeshesAsTexturesDirty;
  58298. /** @hidden */
  58299. _markAllSubMeshesAsTexturesDirty(): void;
  58300. /**
  58301. * Instantiate a new istance of clear coat configuration.
  58302. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  58303. */
  58304. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  58305. /**
  58306. * Specifies that the submesh is ready to be used.
  58307. * @param defines the list of "defines" to update.
  58308. * @param scene defines the scene the material belongs to.
  58309. * @returns - boolean indicating that the submesh is ready or not.
  58310. */
  58311. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  58312. /**
  58313. * Checks to see if a texture is used in the material.
  58314. * @param defines the list of "defines" to update.
  58315. * @param scene defines the scene the material belongs to.
  58316. */
  58317. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  58318. /**
  58319. * Binds the material data.
  58320. * @param uniformBuffer defines the Uniform buffer to fill in.
  58321. * @param scene defines the scene the material belongs to.
  58322. * @param isFrozen defines wether the material is frozen or not.
  58323. */
  58324. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  58325. /**
  58326. * Checks to see if a texture is used in the material.
  58327. * @param texture - Base texture to use.
  58328. * @returns - Boolean specifying if a texture is used in the material.
  58329. */
  58330. hasTexture(texture: BaseTexture): boolean;
  58331. /**
  58332. * Returns an array of the actively used textures.
  58333. * @param activeTextures Array of BaseTextures
  58334. */
  58335. getActiveTextures(activeTextures: BaseTexture[]): void;
  58336. /**
  58337. * Returns the animatable textures.
  58338. * @param animatables Array of animatable textures.
  58339. */
  58340. getAnimatables(animatables: IAnimatable[]): void;
  58341. /**
  58342. * Disposes the resources of the material.
  58343. * @param forceDisposeTextures - Forces the disposal of all textures.
  58344. */
  58345. dispose(forceDisposeTextures?: boolean): void;
  58346. /**
  58347. * Get the current class name of the texture useful for serialization or dynamic coding.
  58348. * @returns "PBRSheenConfiguration"
  58349. */
  58350. getClassName(): string;
  58351. /**
  58352. * Add fallbacks to the effect fallbacks list.
  58353. * @param defines defines the Base texture to use.
  58354. * @param fallbacks defines the current fallback list.
  58355. * @param currentRank defines the current fallback rank.
  58356. * @returns the new fallback rank.
  58357. */
  58358. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  58359. /**
  58360. * Add the required uniforms to the current list.
  58361. * @param uniforms defines the current uniform list.
  58362. */
  58363. static AddUniforms(uniforms: string[]): void;
  58364. /**
  58365. * Add the required uniforms to the current buffer.
  58366. * @param uniformBuffer defines the current uniform buffer.
  58367. */
  58368. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  58369. /**
  58370. * Add the required samplers to the current list.
  58371. * @param samplers defines the current sampler list.
  58372. */
  58373. static AddSamplers(samplers: string[]): void;
  58374. /**
  58375. * Makes a duplicate of the current configuration into another one.
  58376. * @param sheenConfiguration define the config where to copy the info
  58377. */
  58378. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  58379. /**
  58380. * Serializes this BRDF configuration.
  58381. * @returns - An object with the serialized config.
  58382. */
  58383. serialize(): any;
  58384. /**
  58385. * Parses a anisotropy Configuration from a serialized object.
  58386. * @param source - Serialized object.
  58387. * @param scene Defines the scene we are parsing for
  58388. * @param rootUrl Defines the rootUrl to load from
  58389. */
  58390. parse(source: any, scene: Scene, rootUrl: string): void;
  58391. }
  58392. }
  58393. declare module "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration" {
  58394. import { Nullable } from "babylonjs/types";
  58395. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  58396. import { Color3 } from "babylonjs/Maths/math.color";
  58397. import { SmartArray } from "babylonjs/Misc/smartArray";
  58398. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58399. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  58400. import { Effect } from "babylonjs/Materials/effect";
  58401. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  58402. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  58403. import { Engine } from "babylonjs/Engines/engine";
  58404. import { Scene } from "babylonjs/scene";
  58405. /**
  58406. * @hidden
  58407. */
  58408. export interface IMaterialSubSurfaceDefines {
  58409. SUBSURFACE: boolean;
  58410. SS_REFRACTION: boolean;
  58411. SS_TRANSLUCENCY: boolean;
  58412. SS_SCATTERING: boolean;
  58413. SS_THICKNESSANDMASK_TEXTURE: boolean;
  58414. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  58415. SS_REFRACTIONMAP_3D: boolean;
  58416. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  58417. SS_LODINREFRACTIONALPHA: boolean;
  58418. SS_GAMMAREFRACTION: boolean;
  58419. SS_RGBDREFRACTION: boolean;
  58420. SS_LINEARSPECULARREFRACTION: boolean;
  58421. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  58422. SS_ALBEDOFORREFRACTIONTINT: boolean;
  58423. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  58424. /** @hidden */
  58425. _areTexturesDirty: boolean;
  58426. }
  58427. /**
  58428. * Define the code related to the sub surface parameters of the pbr material.
  58429. */
  58430. export class PBRSubSurfaceConfiguration {
  58431. private _isRefractionEnabled;
  58432. /**
  58433. * Defines if the refraction is enabled in the material.
  58434. */
  58435. isRefractionEnabled: boolean;
  58436. private _isTranslucencyEnabled;
  58437. /**
  58438. * Defines if the translucency is enabled in the material.
  58439. */
  58440. isTranslucencyEnabled: boolean;
  58441. private _isScatteringEnabled;
  58442. /**
  58443. * Defines if the sub surface scattering is enabled in the material.
  58444. */
  58445. isScatteringEnabled: boolean;
  58446. private _scatteringDiffusionProfileIndex;
  58447. /**
  58448. * Diffusion profile for subsurface scattering.
  58449. * Useful for better scattering in the skins or foliages.
  58450. */
  58451. get scatteringDiffusionProfile(): Nullable<Color3>;
  58452. set scatteringDiffusionProfile(c: Nullable<Color3>);
  58453. /**
  58454. * Defines the refraction intensity of the material.
  58455. * The refraction when enabled replaces the Diffuse part of the material.
  58456. * The intensity helps transitionning between diffuse and refraction.
  58457. */
  58458. refractionIntensity: number;
  58459. /**
  58460. * Defines the translucency intensity of the material.
  58461. * When translucency has been enabled, this defines how much of the "translucency"
  58462. * is addded to the diffuse part of the material.
  58463. */
  58464. translucencyIntensity: number;
  58465. /**
  58466. * When enabled, transparent surfaces will be tinted with the albedo colour (independent of thickness)
  58467. */
  58468. useAlbedoToTintRefraction: boolean;
  58469. private _thicknessTexture;
  58470. /**
  58471. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  58472. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  58473. * 0 would mean minimumThickness
  58474. * 1 would mean maximumThickness
  58475. * The other channels might be use as a mask to vary the different effects intensity.
  58476. */
  58477. thicknessTexture: Nullable<BaseTexture>;
  58478. private _refractionTexture;
  58479. /**
  58480. * Defines the texture to use for refraction.
  58481. */
  58482. refractionTexture: Nullable<BaseTexture>;
  58483. private _indexOfRefraction;
  58484. /**
  58485. * Index of refraction of the material base layer.
  58486. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  58487. *
  58488. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  58489. *
  58490. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  58491. */
  58492. indexOfRefraction: number;
  58493. private _volumeIndexOfRefraction;
  58494. /**
  58495. * Index of refraction of the material's volume.
  58496. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  58497. *
  58498. * This ONLY impacts refraction. If not provided or given a non-valid value,
  58499. * the volume will use the same IOR as the surface.
  58500. */
  58501. get volumeIndexOfRefraction(): number;
  58502. set volumeIndexOfRefraction(value: number);
  58503. private _invertRefractionY;
  58504. /**
  58505. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  58506. */
  58507. invertRefractionY: boolean;
  58508. private _linkRefractionWithTransparency;
  58509. /**
  58510. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  58511. * Materials half opaque for instance using refraction could benefit from this control.
  58512. */
  58513. linkRefractionWithTransparency: boolean;
  58514. /**
  58515. * Defines the minimum thickness stored in the thickness map.
  58516. * If no thickness map is defined, this value will be used to simulate thickness.
  58517. */
  58518. minimumThickness: number;
  58519. /**
  58520. * Defines the maximum thickness stored in the thickness map.
  58521. */
  58522. maximumThickness: number;
  58523. /**
  58524. * Defines the volume tint of the material.
  58525. * This is used for both translucency and scattering.
  58526. */
  58527. tintColor: Color3;
  58528. /**
  58529. * Defines the distance at which the tint color should be found in the media.
  58530. * This is used for refraction only.
  58531. */
  58532. tintColorAtDistance: number;
  58533. /**
  58534. * Defines how far each channel transmit through the media.
  58535. * It is defined as a color to simplify it selection.
  58536. */
  58537. diffusionDistance: Color3;
  58538. private _useMaskFromThicknessTexture;
  58539. /**
  58540. * Stores the intensity of the different subsurface effects in the thickness texture.
  58541. * * the green channel is the translucency intensity.
  58542. * * the blue channel is the scattering intensity.
  58543. * * the alpha channel is the refraction intensity.
  58544. */
  58545. useMaskFromThicknessTexture: boolean;
  58546. private _scene;
  58547. /** @hidden */
  58548. private _internalMarkAllSubMeshesAsTexturesDirty;
  58549. private _internalMarkScenePrePassDirty;
  58550. /** @hidden */
  58551. _markAllSubMeshesAsTexturesDirty(): void;
  58552. /** @hidden */
  58553. _markScenePrePassDirty(): void;
  58554. /**
  58555. * Instantiate a new istance of sub surface configuration.
  58556. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  58557. * @param markScenePrePassDirty Callback to flag the scene as prepass dirty
  58558. * @param scene The scene
  58559. */
  58560. constructor(markAllSubMeshesAsTexturesDirty: () => void, markScenePrePassDirty: () => void, scene: Scene);
  58561. /**
  58562. * Gets wehter the submesh is ready to be used or not.
  58563. * @param defines the list of "defines" to update.
  58564. * @param scene defines the scene the material belongs to.
  58565. * @returns - boolean indicating that the submesh is ready or not.
  58566. */
  58567. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  58568. /**
  58569. * Checks to see if a texture is used in the material.
  58570. * @param defines the list of "defines" to update.
  58571. * @param scene defines the scene to the material belongs to.
  58572. */
  58573. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  58574. /**
  58575. * Binds the material data.
  58576. * @param uniformBuffer defines the Uniform buffer to fill in.
  58577. * @param scene defines the scene the material belongs to.
  58578. * @param engine defines the engine the material belongs to.
  58579. * @param isFrozen defines whether the material is frozen or not.
  58580. * @param lodBasedMicrosurface defines whether the material relies on lod based microsurface or not.
  58581. * @param realTimeFiltering defines whether the textures should be filtered on the fly.
  58582. */
  58583. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean, realTimeFiltering: boolean): void;
  58584. /**
  58585. * Unbinds the material from the mesh.
  58586. * @param activeEffect defines the effect that should be unbound from.
  58587. * @returns true if unbound, otherwise false
  58588. */
  58589. unbind(activeEffect: Effect): boolean;
  58590. /**
  58591. * Returns the texture used for refraction or null if none is used.
  58592. * @param scene defines the scene the material belongs to.
  58593. * @returns - Refraction texture if present. If no refraction texture and refraction
  58594. * is linked with transparency, returns environment texture. Otherwise, returns null.
  58595. */
  58596. private _getRefractionTexture;
  58597. /**
  58598. * Returns true if alpha blending should be disabled.
  58599. */
  58600. get disableAlphaBlending(): boolean;
  58601. /**
  58602. * Fills the list of render target textures.
  58603. * @param renderTargets the list of render targets to update
  58604. */
  58605. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  58606. /**
  58607. * Checks to see if a texture is used in the material.
  58608. * @param texture - Base texture to use.
  58609. * @returns - Boolean specifying if a texture is used in the material.
  58610. */
  58611. hasTexture(texture: BaseTexture): boolean;
  58612. /**
  58613. * Gets a boolean indicating that current material needs to register RTT
  58614. * @returns true if this uses a render target otherwise false.
  58615. */
  58616. hasRenderTargetTextures(): boolean;
  58617. /**
  58618. * Returns an array of the actively used textures.
  58619. * @param activeTextures Array of BaseTextures
  58620. */
  58621. getActiveTextures(activeTextures: BaseTexture[]): void;
  58622. /**
  58623. * Returns the animatable textures.
  58624. * @param animatables Array of animatable textures.
  58625. */
  58626. getAnimatables(animatables: IAnimatable[]): void;
  58627. /**
  58628. * Disposes the resources of the material.
  58629. * @param forceDisposeTextures - Forces the disposal of all textures.
  58630. */
  58631. dispose(forceDisposeTextures?: boolean): void;
  58632. /**
  58633. * Get the current class name of the texture useful for serialization or dynamic coding.
  58634. * @returns "PBRSubSurfaceConfiguration"
  58635. */
  58636. getClassName(): string;
  58637. /**
  58638. * Add fallbacks to the effect fallbacks list.
  58639. * @param defines defines the Base texture to use.
  58640. * @param fallbacks defines the current fallback list.
  58641. * @param currentRank defines the current fallback rank.
  58642. * @returns the new fallback rank.
  58643. */
  58644. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  58645. /**
  58646. * Add the required uniforms to the current list.
  58647. * @param uniforms defines the current uniform list.
  58648. */
  58649. static AddUniforms(uniforms: string[]): void;
  58650. /**
  58651. * Add the required samplers to the current list.
  58652. * @param samplers defines the current sampler list.
  58653. */
  58654. static AddSamplers(samplers: string[]): void;
  58655. /**
  58656. * Add the required uniforms to the current buffer.
  58657. * @param uniformBuffer defines the current uniform buffer.
  58658. */
  58659. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  58660. /**
  58661. * Makes a duplicate of the current configuration into another one.
  58662. * @param configuration define the config where to copy the info
  58663. */
  58664. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  58665. /**
  58666. * Serializes this Sub Surface configuration.
  58667. * @returns - An object with the serialized config.
  58668. */
  58669. serialize(): any;
  58670. /**
  58671. * Parses a anisotropy Configuration from a serialized object.
  58672. * @param source - Serialized object.
  58673. * @param scene Defines the scene we are parsing for
  58674. * @param rootUrl Defines the rootUrl to load from
  58675. */
  58676. parse(source: any, scene: Scene, rootUrl: string): void;
  58677. }
  58678. }
  58679. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  58680. /** @hidden */
  58681. export var pbrFragmentDeclaration: {
  58682. name: string;
  58683. shader: string;
  58684. };
  58685. }
  58686. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  58687. /** @hidden */
  58688. export var pbrUboDeclaration: {
  58689. name: string;
  58690. shader: string;
  58691. };
  58692. }
  58693. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration" {
  58694. /** @hidden */
  58695. export var pbrFragmentExtraDeclaration: {
  58696. name: string;
  58697. shader: string;
  58698. };
  58699. }
  58700. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration" {
  58701. /** @hidden */
  58702. export var pbrFragmentSamplersDeclaration: {
  58703. name: string;
  58704. shader: string;
  58705. };
  58706. }
  58707. declare module "babylonjs/Shaders/ShadersInclude/importanceSampling" {
  58708. /** @hidden */
  58709. export var importanceSampling: {
  58710. name: string;
  58711. shader: string;
  58712. };
  58713. }
  58714. declare module "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions" {
  58715. /** @hidden */
  58716. export var pbrHelperFunctions: {
  58717. name: string;
  58718. shader: string;
  58719. };
  58720. }
  58721. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  58722. /** @hidden */
  58723. export var harmonicsFunctions: {
  58724. name: string;
  58725. shader: string;
  58726. };
  58727. }
  58728. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions" {
  58729. /** @hidden */
  58730. export var pbrDirectLightingSetupFunctions: {
  58731. name: string;
  58732. shader: string;
  58733. };
  58734. }
  58735. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions" {
  58736. /** @hidden */
  58737. export var pbrDirectLightingFalloffFunctions: {
  58738. name: string;
  58739. shader: string;
  58740. };
  58741. }
  58742. declare module "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions" {
  58743. /** @hidden */
  58744. export var pbrBRDFFunctions: {
  58745. name: string;
  58746. shader: string;
  58747. };
  58748. }
  58749. declare module "babylonjs/Shaders/ShadersInclude/hdrFilteringFunctions" {
  58750. /** @hidden */
  58751. export var hdrFilteringFunctions: {
  58752. name: string;
  58753. shader: string;
  58754. };
  58755. }
  58756. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions" {
  58757. /** @hidden */
  58758. export var pbrDirectLightingFunctions: {
  58759. name: string;
  58760. shader: string;
  58761. };
  58762. }
  58763. declare module "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions" {
  58764. /** @hidden */
  58765. export var pbrIBLFunctions: {
  58766. name: string;
  58767. shader: string;
  58768. };
  58769. }
  58770. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAlbedoOpacity" {
  58771. /** @hidden */
  58772. export var pbrBlockAlbedoOpacity: {
  58773. name: string;
  58774. shader: string;
  58775. };
  58776. }
  58777. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflectivity" {
  58778. /** @hidden */
  58779. export var pbrBlockReflectivity: {
  58780. name: string;
  58781. shader: string;
  58782. };
  58783. }
  58784. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAmbientOcclusion" {
  58785. /** @hidden */
  58786. export var pbrBlockAmbientOcclusion: {
  58787. name: string;
  58788. shader: string;
  58789. };
  58790. }
  58791. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAlphaFresnel" {
  58792. /** @hidden */
  58793. export var pbrBlockAlphaFresnel: {
  58794. name: string;
  58795. shader: string;
  58796. };
  58797. }
  58798. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAnisotropic" {
  58799. /** @hidden */
  58800. export var pbrBlockAnisotropic: {
  58801. name: string;
  58802. shader: string;
  58803. };
  58804. }
  58805. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflection" {
  58806. /** @hidden */
  58807. export var pbrBlockReflection: {
  58808. name: string;
  58809. shader: string;
  58810. };
  58811. }
  58812. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockSheen" {
  58813. /** @hidden */
  58814. export var pbrBlockSheen: {
  58815. name: string;
  58816. shader: string;
  58817. };
  58818. }
  58819. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockClearcoat" {
  58820. /** @hidden */
  58821. export var pbrBlockClearcoat: {
  58822. name: string;
  58823. shader: string;
  58824. };
  58825. }
  58826. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockSubSurface" {
  58827. /** @hidden */
  58828. export var pbrBlockSubSurface: {
  58829. name: string;
  58830. shader: string;
  58831. };
  58832. }
  58833. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockNormalGeometric" {
  58834. /** @hidden */
  58835. export var pbrBlockNormalGeometric: {
  58836. name: string;
  58837. shader: string;
  58838. };
  58839. }
  58840. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockNormalFinal" {
  58841. /** @hidden */
  58842. export var pbrBlockNormalFinal: {
  58843. name: string;
  58844. shader: string;
  58845. };
  58846. }
  58847. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockLightmapInit" {
  58848. /** @hidden */
  58849. export var pbrBlockLightmapInit: {
  58850. name: string;
  58851. shader: string;
  58852. };
  58853. }
  58854. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockGeometryInfo" {
  58855. /** @hidden */
  58856. export var pbrBlockGeometryInfo: {
  58857. name: string;
  58858. shader: string;
  58859. };
  58860. }
  58861. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance0" {
  58862. /** @hidden */
  58863. export var pbrBlockReflectance0: {
  58864. name: string;
  58865. shader: string;
  58866. };
  58867. }
  58868. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance" {
  58869. /** @hidden */
  58870. export var pbrBlockReflectance: {
  58871. name: string;
  58872. shader: string;
  58873. };
  58874. }
  58875. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockDirectLighting" {
  58876. /** @hidden */
  58877. export var pbrBlockDirectLighting: {
  58878. name: string;
  58879. shader: string;
  58880. };
  58881. }
  58882. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockFinalLitComponents" {
  58883. /** @hidden */
  58884. export var pbrBlockFinalLitComponents: {
  58885. name: string;
  58886. shader: string;
  58887. };
  58888. }
  58889. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockFinalUnlitComponents" {
  58890. /** @hidden */
  58891. export var pbrBlockFinalUnlitComponents: {
  58892. name: string;
  58893. shader: string;
  58894. };
  58895. }
  58896. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockFinalColorComposition" {
  58897. /** @hidden */
  58898. export var pbrBlockFinalColorComposition: {
  58899. name: string;
  58900. shader: string;
  58901. };
  58902. }
  58903. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockImageProcessing" {
  58904. /** @hidden */
  58905. export var pbrBlockImageProcessing: {
  58906. name: string;
  58907. shader: string;
  58908. };
  58909. }
  58910. declare module "babylonjs/Shaders/ShadersInclude/pbrDebug" {
  58911. /** @hidden */
  58912. export var pbrDebug: {
  58913. name: string;
  58914. shader: string;
  58915. };
  58916. }
  58917. declare module "babylonjs/Shaders/pbr.fragment" {
  58918. import "babylonjs/Shaders/ShadersInclude/prePassDeclaration";
  58919. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  58920. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  58921. import "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration";
  58922. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  58923. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  58924. import "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration";
  58925. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  58926. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  58927. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  58928. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  58929. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  58930. import "babylonjs/Shaders/ShadersInclude/subSurfaceScatteringFunctions";
  58931. import "babylonjs/Shaders/ShadersInclude/importanceSampling";
  58932. import "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions";
  58933. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  58934. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  58935. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  58936. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions";
  58937. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions";
  58938. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  58939. import "babylonjs/Shaders/ShadersInclude/hdrFilteringFunctions";
  58940. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions";
  58941. import "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions";
  58942. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  58943. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  58944. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  58945. import "babylonjs/Shaders/ShadersInclude/pbrBlockAlbedoOpacity";
  58946. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflectivity";
  58947. import "babylonjs/Shaders/ShadersInclude/pbrBlockAmbientOcclusion";
  58948. import "babylonjs/Shaders/ShadersInclude/pbrBlockAlphaFresnel";
  58949. import "babylonjs/Shaders/ShadersInclude/pbrBlockAnisotropic";
  58950. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflection";
  58951. import "babylonjs/Shaders/ShadersInclude/pbrBlockSheen";
  58952. import "babylonjs/Shaders/ShadersInclude/pbrBlockClearcoat";
  58953. import "babylonjs/Shaders/ShadersInclude/pbrBlockSubSurface";
  58954. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  58955. import "babylonjs/Shaders/ShadersInclude/pbrBlockNormalGeometric";
  58956. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  58957. import "babylonjs/Shaders/ShadersInclude/pbrBlockNormalFinal";
  58958. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  58959. import "babylonjs/Shaders/ShadersInclude/pbrBlockLightmapInit";
  58960. import "babylonjs/Shaders/ShadersInclude/pbrBlockGeometryInfo";
  58961. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance0";
  58962. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance";
  58963. import "babylonjs/Shaders/ShadersInclude/pbrBlockDirectLighting";
  58964. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  58965. import "babylonjs/Shaders/ShadersInclude/pbrBlockFinalLitComponents";
  58966. import "babylonjs/Shaders/ShadersInclude/pbrBlockFinalUnlitComponents";
  58967. import "babylonjs/Shaders/ShadersInclude/pbrBlockFinalColorComposition";
  58968. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  58969. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  58970. import "babylonjs/Shaders/ShadersInclude/pbrBlockImageProcessing";
  58971. import "babylonjs/Shaders/ShadersInclude/pbrDebug";
  58972. /** @hidden */
  58973. export var pbrPixelShader: {
  58974. name: string;
  58975. shader: string;
  58976. };
  58977. }
  58978. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  58979. /** @hidden */
  58980. export var pbrVertexDeclaration: {
  58981. name: string;
  58982. shader: string;
  58983. };
  58984. }
  58985. declare module "babylonjs/Shaders/pbr.vertex" {
  58986. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  58987. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  58988. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  58989. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  58990. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  58991. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  58992. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  58993. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  58994. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  58995. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  58996. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  58997. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  58998. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  58999. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  59000. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  59001. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  59002. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  59003. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  59004. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  59005. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  59006. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  59007. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  59008. /** @hidden */
  59009. export var pbrVertexShader: {
  59010. name: string;
  59011. shader: string;
  59012. };
  59013. }
  59014. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  59015. import { Nullable } from "babylonjs/types";
  59016. import { Scene } from "babylonjs/scene";
  59017. import { Matrix } from "babylonjs/Maths/math.vector";
  59018. import { SubMesh } from "babylonjs/Meshes/subMesh";
  59019. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59020. import { Mesh } from "babylonjs/Meshes/mesh";
  59021. import { IMaterialClearCoatDefines, PBRClearCoatConfiguration } from "babylonjs/Materials/PBR/pbrClearCoatConfiguration";
  59022. import { IMaterialAnisotropicDefines, PBRAnisotropicConfiguration } from "babylonjs/Materials/PBR/pbrAnisotropicConfiguration";
  59023. import { IMaterialBRDFDefines, PBRBRDFConfiguration } from "babylonjs/Materials/PBR/pbrBRDFConfiguration";
  59024. import { IMaterialSheenDefines, PBRSheenConfiguration } from "babylonjs/Materials/PBR/pbrSheenConfiguration";
  59025. import { IMaterialSubSurfaceDefines, PBRSubSurfaceConfiguration } from "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration";
  59026. import { Color3 } from "babylonjs/Maths/math.color";
  59027. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  59028. import { Material, IMaterialCompilationOptions } from "babylonjs/Materials/material";
  59029. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  59030. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  59031. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  59032. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  59033. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  59034. import "babylonjs/Shaders/pbr.fragment";
  59035. import "babylonjs/Shaders/pbr.vertex";
  59036. import { IMaterialDetailMapDefines, DetailMapConfiguration } from "babylonjs/Materials/material.detailMapConfiguration";
  59037. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  59038. /**
  59039. * Manages the defines for the PBR Material.
  59040. * @hidden
  59041. */
  59042. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines, IMaterialDetailMapDefines {
  59043. PBR: boolean;
  59044. NUM_SAMPLES: string;
  59045. REALTIME_FILTERING: boolean;
  59046. MAINUV1: boolean;
  59047. MAINUV2: boolean;
  59048. UV1: boolean;
  59049. UV2: boolean;
  59050. ALBEDO: boolean;
  59051. GAMMAALBEDO: boolean;
  59052. ALBEDODIRECTUV: number;
  59053. VERTEXCOLOR: boolean;
  59054. DETAIL: boolean;
  59055. DETAILDIRECTUV: number;
  59056. DETAIL_NORMALBLENDMETHOD: number;
  59057. AMBIENT: boolean;
  59058. AMBIENTDIRECTUV: number;
  59059. AMBIENTINGRAYSCALE: boolean;
  59060. OPACITY: boolean;
  59061. VERTEXALPHA: boolean;
  59062. OPACITYDIRECTUV: number;
  59063. OPACITYRGB: boolean;
  59064. ALPHATEST: boolean;
  59065. DEPTHPREPASS: boolean;
  59066. ALPHABLEND: boolean;
  59067. ALPHAFROMALBEDO: boolean;
  59068. ALPHATESTVALUE: string;
  59069. SPECULAROVERALPHA: boolean;
  59070. RADIANCEOVERALPHA: boolean;
  59071. ALPHAFRESNEL: boolean;
  59072. LINEARALPHAFRESNEL: boolean;
  59073. PREMULTIPLYALPHA: boolean;
  59074. EMISSIVE: boolean;
  59075. EMISSIVEDIRECTUV: number;
  59076. REFLECTIVITY: boolean;
  59077. REFLECTIVITYDIRECTUV: number;
  59078. SPECULARTERM: boolean;
  59079. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  59080. MICROSURFACEAUTOMATIC: boolean;
  59081. LODBASEDMICROSFURACE: boolean;
  59082. MICROSURFACEMAP: boolean;
  59083. MICROSURFACEMAPDIRECTUV: number;
  59084. METALLICWORKFLOW: boolean;
  59085. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  59086. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  59087. METALLNESSSTOREINMETALMAPBLUE: boolean;
  59088. AOSTOREINMETALMAPRED: boolean;
  59089. METALLIC_REFLECTANCE: boolean;
  59090. METALLIC_REFLECTANCEDIRECTUV: number;
  59091. ENVIRONMENTBRDF: boolean;
  59092. ENVIRONMENTBRDF_RGBD: boolean;
  59093. NORMAL: boolean;
  59094. TANGENT: boolean;
  59095. BUMP: boolean;
  59096. BUMPDIRECTUV: number;
  59097. OBJECTSPACE_NORMALMAP: boolean;
  59098. PARALLAX: boolean;
  59099. PARALLAXOCCLUSION: boolean;
  59100. NORMALXYSCALE: boolean;
  59101. LIGHTMAP: boolean;
  59102. LIGHTMAPDIRECTUV: number;
  59103. USELIGHTMAPASSHADOWMAP: boolean;
  59104. GAMMALIGHTMAP: boolean;
  59105. RGBDLIGHTMAP: boolean;
  59106. REFLECTION: boolean;
  59107. REFLECTIONMAP_3D: boolean;
  59108. REFLECTIONMAP_SPHERICAL: boolean;
  59109. REFLECTIONMAP_PLANAR: boolean;
  59110. REFLECTIONMAP_CUBIC: boolean;
  59111. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  59112. REFLECTIONMAP_PROJECTION: boolean;
  59113. REFLECTIONMAP_SKYBOX: boolean;
  59114. REFLECTIONMAP_EXPLICIT: boolean;
  59115. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  59116. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  59117. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  59118. INVERTCUBICMAP: boolean;
  59119. USESPHERICALFROMREFLECTIONMAP: boolean;
  59120. USEIRRADIANCEMAP: boolean;
  59121. SPHERICAL_HARMONICS: boolean;
  59122. USESPHERICALINVERTEX: boolean;
  59123. REFLECTIONMAP_OPPOSITEZ: boolean;
  59124. LODINREFLECTIONALPHA: boolean;
  59125. GAMMAREFLECTION: boolean;
  59126. RGBDREFLECTION: boolean;
  59127. LINEARSPECULARREFLECTION: boolean;
  59128. RADIANCEOCCLUSION: boolean;
  59129. HORIZONOCCLUSION: boolean;
  59130. INSTANCES: boolean;
  59131. THIN_INSTANCES: boolean;
  59132. PREPASS: boolean;
  59133. SCENE_MRT_COUNT: number;
  59134. NUM_BONE_INFLUENCERS: number;
  59135. BonesPerMesh: number;
  59136. BONETEXTURE: boolean;
  59137. NONUNIFORMSCALING: boolean;
  59138. MORPHTARGETS: boolean;
  59139. MORPHTARGETS_NORMAL: boolean;
  59140. MORPHTARGETS_TANGENT: boolean;
  59141. MORPHTARGETS_UV: boolean;
  59142. NUM_MORPH_INFLUENCERS: number;
  59143. IMAGEPROCESSING: boolean;
  59144. VIGNETTE: boolean;
  59145. VIGNETTEBLENDMODEMULTIPLY: boolean;
  59146. VIGNETTEBLENDMODEOPAQUE: boolean;
  59147. TONEMAPPING: boolean;
  59148. TONEMAPPING_ACES: boolean;
  59149. CONTRAST: boolean;
  59150. COLORCURVES: boolean;
  59151. COLORGRADING: boolean;
  59152. COLORGRADING3D: boolean;
  59153. SAMPLER3DGREENDEPTH: boolean;
  59154. SAMPLER3DBGRMAP: boolean;
  59155. IMAGEPROCESSINGPOSTPROCESS: boolean;
  59156. EXPOSURE: boolean;
  59157. MULTIVIEW: boolean;
  59158. USEPHYSICALLIGHTFALLOFF: boolean;
  59159. USEGLTFLIGHTFALLOFF: boolean;
  59160. TWOSIDEDLIGHTING: boolean;
  59161. SHADOWFLOAT: boolean;
  59162. CLIPPLANE: boolean;
  59163. CLIPPLANE2: boolean;
  59164. CLIPPLANE3: boolean;
  59165. CLIPPLANE4: boolean;
  59166. CLIPPLANE5: boolean;
  59167. CLIPPLANE6: boolean;
  59168. POINTSIZE: boolean;
  59169. FOG: boolean;
  59170. LOGARITHMICDEPTH: boolean;
  59171. FORCENORMALFORWARD: boolean;
  59172. SPECULARAA: boolean;
  59173. CLEARCOAT: boolean;
  59174. CLEARCOAT_DEFAULTIOR: boolean;
  59175. CLEARCOAT_TEXTURE: boolean;
  59176. CLEARCOAT_TEXTUREDIRECTUV: number;
  59177. CLEARCOAT_BUMP: boolean;
  59178. CLEARCOAT_BUMPDIRECTUV: number;
  59179. CLEARCOAT_TINT: boolean;
  59180. CLEARCOAT_TINT_TEXTURE: boolean;
  59181. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  59182. ANISOTROPIC: boolean;
  59183. ANISOTROPIC_TEXTURE: boolean;
  59184. ANISOTROPIC_TEXTUREDIRECTUV: number;
  59185. BRDF_V_HEIGHT_CORRELATED: boolean;
  59186. MS_BRDF_ENERGY_CONSERVATION: boolean;
  59187. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  59188. SHEEN: boolean;
  59189. SHEEN_TEXTURE: boolean;
  59190. SHEEN_TEXTUREDIRECTUV: number;
  59191. SHEEN_LINKWITHALBEDO: boolean;
  59192. SHEEN_ROUGHNESS: boolean;
  59193. SHEEN_ALBEDOSCALING: boolean;
  59194. SUBSURFACE: boolean;
  59195. SS_REFRACTION: boolean;
  59196. SS_TRANSLUCENCY: boolean;
  59197. SS_SCATTERING: boolean;
  59198. SS_THICKNESSANDMASK_TEXTURE: boolean;
  59199. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  59200. SS_REFRACTIONMAP_3D: boolean;
  59201. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  59202. SS_LODINREFRACTIONALPHA: boolean;
  59203. SS_GAMMAREFRACTION: boolean;
  59204. SS_RGBDREFRACTION: boolean;
  59205. SS_LINEARSPECULARREFRACTION: boolean;
  59206. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  59207. SS_ALBEDOFORREFRACTIONTINT: boolean;
  59208. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  59209. UNLIT: boolean;
  59210. DEBUGMODE: number;
  59211. /**
  59212. * Initializes the PBR Material defines.
  59213. */
  59214. constructor();
  59215. /**
  59216. * Resets the PBR Material defines.
  59217. */
  59218. reset(): void;
  59219. }
  59220. /**
  59221. * The Physically based material base class of BJS.
  59222. *
  59223. * This offers the main features of a standard PBR material.
  59224. * For more information, please refer to the documentation :
  59225. * https://doc.babylonjs.com/how_to/physically_based_rendering
  59226. */
  59227. export abstract class PBRBaseMaterial extends PushMaterial {
  59228. /**
  59229. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  59230. */
  59231. static readonly PBRMATERIAL_OPAQUE: number;
  59232. /**
  59233. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  59234. */
  59235. static readonly PBRMATERIAL_ALPHATEST: number;
  59236. /**
  59237. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  59238. */
  59239. static readonly PBRMATERIAL_ALPHABLEND: number;
  59240. /**
  59241. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  59242. * They are also discarded below the alpha cutoff threshold to improve performances.
  59243. */
  59244. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  59245. /**
  59246. * Defines the default value of how much AO map is occluding the analytical lights
  59247. * (point spot...).
  59248. */
  59249. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  59250. /**
  59251. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  59252. */
  59253. static readonly LIGHTFALLOFF_PHYSICAL: number;
  59254. /**
  59255. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  59256. * to enhance interoperability with other engines.
  59257. */
  59258. static readonly LIGHTFALLOFF_GLTF: number;
  59259. /**
  59260. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  59261. * to enhance interoperability with other materials.
  59262. */
  59263. static readonly LIGHTFALLOFF_STANDARD: number;
  59264. /**
  59265. * Intensity of the direct lights e.g. the four lights available in your scene.
  59266. * This impacts both the direct diffuse and specular highlights.
  59267. */
  59268. protected _directIntensity: number;
  59269. /**
  59270. * Intensity of the emissive part of the material.
  59271. * This helps controlling the emissive effect without modifying the emissive color.
  59272. */
  59273. protected _emissiveIntensity: number;
  59274. /**
  59275. * Intensity of the environment e.g. how much the environment will light the object
  59276. * either through harmonics for rough material or through the refelction for shiny ones.
  59277. */
  59278. protected _environmentIntensity: number;
  59279. /**
  59280. * This is a special control allowing the reduction of the specular highlights coming from the
  59281. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  59282. */
  59283. protected _specularIntensity: number;
  59284. /**
  59285. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  59286. */
  59287. private _lightingInfos;
  59288. /**
  59289. * Debug Control allowing disabling the bump map on this material.
  59290. */
  59291. protected _disableBumpMap: boolean;
  59292. /**
  59293. * AKA Diffuse Texture in standard nomenclature.
  59294. */
  59295. protected _albedoTexture: Nullable<BaseTexture>;
  59296. /**
  59297. * AKA Occlusion Texture in other nomenclature.
  59298. */
  59299. protected _ambientTexture: Nullable<BaseTexture>;
  59300. /**
  59301. * AKA Occlusion Texture Intensity in other nomenclature.
  59302. */
  59303. protected _ambientTextureStrength: number;
  59304. /**
  59305. * Defines how much the AO map is occluding the analytical lights (point spot...).
  59306. * 1 means it completely occludes it
  59307. * 0 mean it has no impact
  59308. */
  59309. protected _ambientTextureImpactOnAnalyticalLights: number;
  59310. /**
  59311. * Stores the alpha values in a texture.
  59312. */
  59313. protected _opacityTexture: Nullable<BaseTexture>;
  59314. /**
  59315. * Stores the reflection values in a texture.
  59316. */
  59317. protected _reflectionTexture: Nullable<BaseTexture>;
  59318. /**
  59319. * Stores the emissive values in a texture.
  59320. */
  59321. protected _emissiveTexture: Nullable<BaseTexture>;
  59322. /**
  59323. * AKA Specular texture in other nomenclature.
  59324. */
  59325. protected _reflectivityTexture: Nullable<BaseTexture>;
  59326. /**
  59327. * Used to switch from specular/glossiness to metallic/roughness workflow.
  59328. */
  59329. protected _metallicTexture: Nullable<BaseTexture>;
  59330. /**
  59331. * Specifies the metallic scalar of the metallic/roughness workflow.
  59332. * Can also be used to scale the metalness values of the metallic texture.
  59333. */
  59334. protected _metallic: Nullable<number>;
  59335. /**
  59336. * Specifies the roughness scalar of the metallic/roughness workflow.
  59337. * Can also be used to scale the roughness values of the metallic texture.
  59338. */
  59339. protected _roughness: Nullable<number>;
  59340. /**
  59341. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  59342. * By default the indexOfrefraction is used to compute F0;
  59343. *
  59344. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  59345. *
  59346. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  59347. * F90 = metallicReflectanceColor;
  59348. */
  59349. protected _metallicF0Factor: number;
  59350. /**
  59351. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  59352. * By default the F90 is always 1;
  59353. *
  59354. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  59355. *
  59356. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  59357. * F90 = metallicReflectanceColor;
  59358. */
  59359. protected _metallicReflectanceColor: Color3;
  59360. /**
  59361. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  59362. * This is multiply against the scalar values defined in the material.
  59363. */
  59364. protected _metallicReflectanceTexture: Nullable<BaseTexture>;
  59365. /**
  59366. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  59367. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  59368. */
  59369. protected _microSurfaceTexture: Nullable<BaseTexture>;
  59370. /**
  59371. * Stores surface normal data used to displace a mesh in a texture.
  59372. */
  59373. protected _bumpTexture: Nullable<BaseTexture>;
  59374. /**
  59375. * Stores the pre-calculated light information of a mesh in a texture.
  59376. */
  59377. protected _lightmapTexture: Nullable<BaseTexture>;
  59378. /**
  59379. * The color of a material in ambient lighting.
  59380. */
  59381. protected _ambientColor: Color3;
  59382. /**
  59383. * AKA Diffuse Color in other nomenclature.
  59384. */
  59385. protected _albedoColor: Color3;
  59386. /**
  59387. * AKA Specular Color in other nomenclature.
  59388. */
  59389. protected _reflectivityColor: Color3;
  59390. /**
  59391. * The color applied when light is reflected from a material.
  59392. */
  59393. protected _reflectionColor: Color3;
  59394. /**
  59395. * The color applied when light is emitted from a material.
  59396. */
  59397. protected _emissiveColor: Color3;
  59398. /**
  59399. * AKA Glossiness in other nomenclature.
  59400. */
  59401. protected _microSurface: number;
  59402. /**
  59403. * Specifies that the material will use the light map as a show map.
  59404. */
  59405. protected _useLightmapAsShadowmap: boolean;
  59406. /**
  59407. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  59408. * makes the reflect vector face the model (under horizon).
  59409. */
  59410. protected _useHorizonOcclusion: boolean;
  59411. /**
  59412. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  59413. * too much the area relying on ambient texture to define their ambient occlusion.
  59414. */
  59415. protected _useRadianceOcclusion: boolean;
  59416. /**
  59417. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  59418. */
  59419. protected _useAlphaFromAlbedoTexture: boolean;
  59420. /**
  59421. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  59422. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  59423. */
  59424. protected _useSpecularOverAlpha: boolean;
  59425. /**
  59426. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  59427. */
  59428. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  59429. /**
  59430. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  59431. */
  59432. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  59433. /**
  59434. * Specifies if the metallic texture contains the roughness information in its green channel.
  59435. */
  59436. protected _useRoughnessFromMetallicTextureGreen: boolean;
  59437. /**
  59438. * Specifies if the metallic texture contains the metallness information in its blue channel.
  59439. */
  59440. protected _useMetallnessFromMetallicTextureBlue: boolean;
  59441. /**
  59442. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  59443. */
  59444. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  59445. /**
  59446. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  59447. */
  59448. protected _useAmbientInGrayScale: boolean;
  59449. /**
  59450. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  59451. * The material will try to infer what glossiness each pixel should be.
  59452. */
  59453. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  59454. /**
  59455. * Defines the falloff type used in this material.
  59456. * It by default is Physical.
  59457. */
  59458. protected _lightFalloff: number;
  59459. /**
  59460. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  59461. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  59462. */
  59463. protected _useRadianceOverAlpha: boolean;
  59464. /**
  59465. * Allows using an object space normal map (instead of tangent space).
  59466. */
  59467. protected _useObjectSpaceNormalMap: boolean;
  59468. /**
  59469. * Allows using the bump map in parallax mode.
  59470. */
  59471. protected _useParallax: boolean;
  59472. /**
  59473. * Allows using the bump map in parallax occlusion mode.
  59474. */
  59475. protected _useParallaxOcclusion: boolean;
  59476. /**
  59477. * Controls the scale bias of the parallax mode.
  59478. */
  59479. protected _parallaxScaleBias: number;
  59480. /**
  59481. * If sets to true, disables all the lights affecting the material.
  59482. */
  59483. protected _disableLighting: boolean;
  59484. /**
  59485. * Number of Simultaneous lights allowed on the material.
  59486. */
  59487. protected _maxSimultaneousLights: number;
  59488. /**
  59489. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  59490. */
  59491. protected _invertNormalMapX: boolean;
  59492. /**
  59493. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  59494. */
  59495. protected _invertNormalMapY: boolean;
  59496. /**
  59497. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  59498. */
  59499. protected _twoSidedLighting: boolean;
  59500. /**
  59501. * Defines the alpha limits in alpha test mode.
  59502. */
  59503. protected _alphaCutOff: number;
  59504. /**
  59505. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  59506. */
  59507. protected _forceAlphaTest: boolean;
  59508. /**
  59509. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  59510. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  59511. */
  59512. protected _useAlphaFresnel: boolean;
  59513. /**
  59514. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  59515. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  59516. */
  59517. protected _useLinearAlphaFresnel: boolean;
  59518. /**
  59519. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  59520. * from cos thetav and roughness:
  59521. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  59522. */
  59523. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  59524. /**
  59525. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  59526. */
  59527. protected _forceIrradianceInFragment: boolean;
  59528. private _realTimeFiltering;
  59529. /**
  59530. * Enables realtime filtering on the texture.
  59531. */
  59532. get realTimeFiltering(): boolean;
  59533. set realTimeFiltering(b: boolean);
  59534. private _realTimeFilteringQuality;
  59535. /**
  59536. * Quality switch for realtime filtering
  59537. */
  59538. get realTimeFilteringQuality(): number;
  59539. set realTimeFilteringQuality(n: number);
  59540. /**
  59541. * Can this material render to several textures at once
  59542. */
  59543. get canRenderToMRT(): boolean;
  59544. /**
  59545. * Force normal to face away from face.
  59546. */
  59547. protected _forceNormalForward: boolean;
  59548. /**
  59549. * Enables specular anti aliasing in the PBR shader.
  59550. * It will both interacts on the Geometry for analytical and IBL lighting.
  59551. * It also prefilter the roughness map based on the bump values.
  59552. */
  59553. protected _enableSpecularAntiAliasing: boolean;
  59554. /**
  59555. * Default configuration related to image processing available in the PBR Material.
  59556. */
  59557. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  59558. /**
  59559. * Keep track of the image processing observer to allow dispose and replace.
  59560. */
  59561. private _imageProcessingObserver;
  59562. /**
  59563. * Attaches a new image processing configuration to the PBR Material.
  59564. * @param configuration
  59565. */
  59566. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  59567. /**
  59568. * Stores the available render targets.
  59569. */
  59570. private _renderTargets;
  59571. /**
  59572. * Sets the global ambient color for the material used in lighting calculations.
  59573. */
  59574. private _globalAmbientColor;
  59575. /**
  59576. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  59577. */
  59578. private _useLogarithmicDepth;
  59579. /**
  59580. * If set to true, no lighting calculations will be applied.
  59581. */
  59582. private _unlit;
  59583. private _debugMode;
  59584. /**
  59585. * @hidden
  59586. * This is reserved for the inspector.
  59587. * Defines the material debug mode.
  59588. * It helps seeing only some components of the material while troubleshooting.
  59589. */
  59590. debugMode: number;
  59591. /**
  59592. * @hidden
  59593. * This is reserved for the inspector.
  59594. * Specify from where on screen the debug mode should start.
  59595. * The value goes from -1 (full screen) to 1 (not visible)
  59596. * It helps with side by side comparison against the final render
  59597. * This defaults to -1
  59598. */
  59599. private debugLimit;
  59600. /**
  59601. * @hidden
  59602. * This is reserved for the inspector.
  59603. * As the default viewing range might not be enough (if the ambient is really small for instance)
  59604. * You can use the factor to better multiply the final value.
  59605. */
  59606. private debugFactor;
  59607. /**
  59608. * Defines the clear coat layer parameters for the material.
  59609. */
  59610. readonly clearCoat: PBRClearCoatConfiguration;
  59611. /**
  59612. * Defines the anisotropic parameters for the material.
  59613. */
  59614. readonly anisotropy: PBRAnisotropicConfiguration;
  59615. /**
  59616. * Defines the BRDF parameters for the material.
  59617. */
  59618. readonly brdf: PBRBRDFConfiguration;
  59619. /**
  59620. * Defines the Sheen parameters for the material.
  59621. */
  59622. readonly sheen: PBRSheenConfiguration;
  59623. /**
  59624. * Defines the SubSurface parameters for the material.
  59625. */
  59626. readonly subSurface: PBRSubSurfaceConfiguration;
  59627. /**
  59628. * Defines the detail map parameters for the material.
  59629. */
  59630. readonly detailMap: DetailMapConfiguration;
  59631. protected _rebuildInParallel: boolean;
  59632. /**
  59633. * Instantiates a new PBRMaterial instance.
  59634. *
  59635. * @param name The material name
  59636. * @param scene The scene the material will be use in.
  59637. */
  59638. constructor(name: string, scene: Scene);
  59639. /**
  59640. * Gets a boolean indicating that current material needs to register RTT
  59641. */
  59642. get hasRenderTargetTextures(): boolean;
  59643. /**
  59644. * Gets the name of the material class.
  59645. */
  59646. getClassName(): string;
  59647. /**
  59648. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  59649. */
  59650. get useLogarithmicDepth(): boolean;
  59651. /**
  59652. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  59653. */
  59654. set useLogarithmicDepth(value: boolean);
  59655. /**
  59656. * Returns true if alpha blending should be disabled.
  59657. */
  59658. protected get _disableAlphaBlending(): boolean;
  59659. /**
  59660. * Specifies whether or not this material should be rendered in alpha blend mode.
  59661. */
  59662. needAlphaBlending(): boolean;
  59663. /**
  59664. * Specifies whether or not this material should be rendered in alpha test mode.
  59665. */
  59666. needAlphaTesting(): boolean;
  59667. /**
  59668. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  59669. */
  59670. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  59671. /**
  59672. * Gets the texture used for the alpha test.
  59673. */
  59674. getAlphaTestTexture(): Nullable<BaseTexture>;
  59675. /**
  59676. * Specifies that the submesh is ready to be used.
  59677. * @param mesh - BJS mesh.
  59678. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  59679. * @param useInstances - Specifies that instances should be used.
  59680. * @returns - boolean indicating that the submesh is ready or not.
  59681. */
  59682. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  59683. /**
  59684. * Specifies if the material uses metallic roughness workflow.
  59685. * @returns boolean specifiying if the material uses metallic roughness workflow.
  59686. */
  59687. isMetallicWorkflow(): boolean;
  59688. private _prepareEffect;
  59689. private _prepareDefines;
  59690. /**
  59691. * Force shader compilation
  59692. */
  59693. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  59694. /**
  59695. * Initializes the uniform buffer layout for the shader.
  59696. */
  59697. buildUniformLayout(): void;
  59698. /**
  59699. * Unbinds the material from the mesh
  59700. */
  59701. unbind(): void;
  59702. /**
  59703. * Binds the submesh data.
  59704. * @param world - The world matrix.
  59705. * @param mesh - The BJS mesh.
  59706. * @param subMesh - A submesh of the BJS mesh.
  59707. */
  59708. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  59709. /**
  59710. * Returns the animatable textures.
  59711. * @returns - Array of animatable textures.
  59712. */
  59713. getAnimatables(): IAnimatable[];
  59714. /**
  59715. * Returns the texture used for reflections.
  59716. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  59717. */
  59718. private _getReflectionTexture;
  59719. /**
  59720. * Returns an array of the actively used textures.
  59721. * @returns - Array of BaseTextures
  59722. */
  59723. getActiveTextures(): BaseTexture[];
  59724. /**
  59725. * Checks to see if a texture is used in the material.
  59726. * @param texture - Base texture to use.
  59727. * @returns - Boolean specifying if a texture is used in the material.
  59728. */
  59729. hasTexture(texture: BaseTexture): boolean;
  59730. /**
  59731. * Sets the required values to the prepass renderer.
  59732. * @param prePassRenderer defines the prepass renderer to setup
  59733. */
  59734. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  59735. /**
  59736. * Disposes the resources of the material.
  59737. * @param forceDisposeEffect - Forces the disposal of effects.
  59738. * @param forceDisposeTextures - Forces the disposal of all textures.
  59739. */
  59740. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  59741. }
  59742. }
  59743. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  59744. import { Nullable } from "babylonjs/types";
  59745. import { Scene } from "babylonjs/scene";
  59746. import { Color3 } from "babylonjs/Maths/math.color";
  59747. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  59748. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  59749. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  59750. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  59751. /**
  59752. * The Physically based material of BJS.
  59753. *
  59754. * This offers the main features of a standard PBR material.
  59755. * For more information, please refer to the documentation :
  59756. * https://doc.babylonjs.com/how_to/physically_based_rendering
  59757. */
  59758. export class PBRMaterial extends PBRBaseMaterial {
  59759. /**
  59760. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  59761. */
  59762. static readonly PBRMATERIAL_OPAQUE: number;
  59763. /**
  59764. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  59765. */
  59766. static readonly PBRMATERIAL_ALPHATEST: number;
  59767. /**
  59768. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  59769. */
  59770. static readonly PBRMATERIAL_ALPHABLEND: number;
  59771. /**
  59772. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  59773. * They are also discarded below the alpha cutoff threshold to improve performances.
  59774. */
  59775. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  59776. /**
  59777. * Defines the default value of how much AO map is occluding the analytical lights
  59778. * (point spot...).
  59779. */
  59780. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  59781. /**
  59782. * Intensity of the direct lights e.g. the four lights available in your scene.
  59783. * This impacts both the direct diffuse and specular highlights.
  59784. */
  59785. directIntensity: number;
  59786. /**
  59787. * Intensity of the emissive part of the material.
  59788. * This helps controlling the emissive effect without modifying the emissive color.
  59789. */
  59790. emissiveIntensity: number;
  59791. /**
  59792. * Intensity of the environment e.g. how much the environment will light the object
  59793. * either through harmonics for rough material or through the refelction for shiny ones.
  59794. */
  59795. environmentIntensity: number;
  59796. /**
  59797. * This is a special control allowing the reduction of the specular highlights coming from the
  59798. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  59799. */
  59800. specularIntensity: number;
  59801. /**
  59802. * Debug Control allowing disabling the bump map on this material.
  59803. */
  59804. disableBumpMap: boolean;
  59805. /**
  59806. * AKA Diffuse Texture in standard nomenclature.
  59807. */
  59808. albedoTexture: BaseTexture;
  59809. /**
  59810. * AKA Occlusion Texture in other nomenclature.
  59811. */
  59812. ambientTexture: BaseTexture;
  59813. /**
  59814. * AKA Occlusion Texture Intensity in other nomenclature.
  59815. */
  59816. ambientTextureStrength: number;
  59817. /**
  59818. * Defines how much the AO map is occluding the analytical lights (point spot...).
  59819. * 1 means it completely occludes it
  59820. * 0 mean it has no impact
  59821. */
  59822. ambientTextureImpactOnAnalyticalLights: number;
  59823. /**
  59824. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  59825. */
  59826. opacityTexture: BaseTexture;
  59827. /**
  59828. * Stores the reflection values in a texture.
  59829. */
  59830. reflectionTexture: Nullable<BaseTexture>;
  59831. /**
  59832. * Stores the emissive values in a texture.
  59833. */
  59834. emissiveTexture: BaseTexture;
  59835. /**
  59836. * AKA Specular texture in other nomenclature.
  59837. */
  59838. reflectivityTexture: BaseTexture;
  59839. /**
  59840. * Used to switch from specular/glossiness to metallic/roughness workflow.
  59841. */
  59842. metallicTexture: BaseTexture;
  59843. /**
  59844. * Specifies the metallic scalar of the metallic/roughness workflow.
  59845. * Can also be used to scale the metalness values of the metallic texture.
  59846. */
  59847. metallic: Nullable<number>;
  59848. /**
  59849. * Specifies the roughness scalar of the metallic/roughness workflow.
  59850. * Can also be used to scale the roughness values of the metallic texture.
  59851. */
  59852. roughness: Nullable<number>;
  59853. /**
  59854. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  59855. * By default the indexOfrefraction is used to compute F0;
  59856. *
  59857. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  59858. *
  59859. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  59860. * F90 = metallicReflectanceColor;
  59861. */
  59862. metallicF0Factor: number;
  59863. /**
  59864. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  59865. * By default the F90 is always 1;
  59866. *
  59867. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  59868. *
  59869. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  59870. * F90 = metallicReflectanceColor;
  59871. */
  59872. metallicReflectanceColor: Color3;
  59873. /**
  59874. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  59875. * This is multiply against the scalar values defined in the material.
  59876. */
  59877. metallicReflectanceTexture: Nullable<BaseTexture>;
  59878. /**
  59879. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  59880. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  59881. */
  59882. microSurfaceTexture: BaseTexture;
  59883. /**
  59884. * Stores surface normal data used to displace a mesh in a texture.
  59885. */
  59886. bumpTexture: BaseTexture;
  59887. /**
  59888. * Stores the pre-calculated light information of a mesh in a texture.
  59889. */
  59890. lightmapTexture: BaseTexture;
  59891. /**
  59892. * Stores the refracted light information in a texture.
  59893. */
  59894. get refractionTexture(): Nullable<BaseTexture>;
  59895. set refractionTexture(value: Nullable<BaseTexture>);
  59896. /**
  59897. * The color of a material in ambient lighting.
  59898. */
  59899. ambientColor: Color3;
  59900. /**
  59901. * AKA Diffuse Color in other nomenclature.
  59902. */
  59903. albedoColor: Color3;
  59904. /**
  59905. * AKA Specular Color in other nomenclature.
  59906. */
  59907. reflectivityColor: Color3;
  59908. /**
  59909. * The color reflected from the material.
  59910. */
  59911. reflectionColor: Color3;
  59912. /**
  59913. * The color emitted from the material.
  59914. */
  59915. emissiveColor: Color3;
  59916. /**
  59917. * AKA Glossiness in other nomenclature.
  59918. */
  59919. microSurface: number;
  59920. /**
  59921. * Index of refraction of the material base layer.
  59922. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  59923. *
  59924. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  59925. *
  59926. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  59927. */
  59928. get indexOfRefraction(): number;
  59929. set indexOfRefraction(value: number);
  59930. /**
  59931. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  59932. */
  59933. get invertRefractionY(): boolean;
  59934. set invertRefractionY(value: boolean);
  59935. /**
  59936. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  59937. * Materials half opaque for instance using refraction could benefit from this control.
  59938. */
  59939. get linkRefractionWithTransparency(): boolean;
  59940. set linkRefractionWithTransparency(value: boolean);
  59941. /**
  59942. * If true, the light map contains occlusion information instead of lighting info.
  59943. */
  59944. useLightmapAsShadowmap: boolean;
  59945. /**
  59946. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  59947. */
  59948. useAlphaFromAlbedoTexture: boolean;
  59949. /**
  59950. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  59951. */
  59952. forceAlphaTest: boolean;
  59953. /**
  59954. * Defines the alpha limits in alpha test mode.
  59955. */
  59956. alphaCutOff: number;
  59957. /**
  59958. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  59959. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  59960. */
  59961. useSpecularOverAlpha: boolean;
  59962. /**
  59963. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  59964. */
  59965. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  59966. /**
  59967. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  59968. */
  59969. useRoughnessFromMetallicTextureAlpha: boolean;
  59970. /**
  59971. * Specifies if the metallic texture contains the roughness information in its green channel.
  59972. */
  59973. useRoughnessFromMetallicTextureGreen: boolean;
  59974. /**
  59975. * Specifies if the metallic texture contains the metallness information in its blue channel.
  59976. */
  59977. useMetallnessFromMetallicTextureBlue: boolean;
  59978. /**
  59979. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  59980. */
  59981. useAmbientOcclusionFromMetallicTextureRed: boolean;
  59982. /**
  59983. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  59984. */
  59985. useAmbientInGrayScale: boolean;
  59986. /**
  59987. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  59988. * The material will try to infer what glossiness each pixel should be.
  59989. */
  59990. useAutoMicroSurfaceFromReflectivityMap: boolean;
  59991. /**
  59992. * BJS is using an harcoded light falloff based on a manually sets up range.
  59993. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  59994. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  59995. */
  59996. get usePhysicalLightFalloff(): boolean;
  59997. /**
  59998. * BJS is using an harcoded light falloff based on a manually sets up range.
  59999. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  60000. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  60001. */
  60002. set usePhysicalLightFalloff(value: boolean);
  60003. /**
  60004. * In order to support the falloff compatibility with gltf, a special mode has been added
  60005. * to reproduce the gltf light falloff.
  60006. */
  60007. get useGLTFLightFalloff(): boolean;
  60008. /**
  60009. * In order to support the falloff compatibility with gltf, a special mode has been added
  60010. * to reproduce the gltf light falloff.
  60011. */
  60012. set useGLTFLightFalloff(value: boolean);
  60013. /**
  60014. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  60015. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  60016. */
  60017. useRadianceOverAlpha: boolean;
  60018. /**
  60019. * Allows using an object space normal map (instead of tangent space).
  60020. */
  60021. useObjectSpaceNormalMap: boolean;
  60022. /**
  60023. * Allows using the bump map in parallax mode.
  60024. */
  60025. useParallax: boolean;
  60026. /**
  60027. * Allows using the bump map in parallax occlusion mode.
  60028. */
  60029. useParallaxOcclusion: boolean;
  60030. /**
  60031. * Controls the scale bias of the parallax mode.
  60032. */
  60033. parallaxScaleBias: number;
  60034. /**
  60035. * If sets to true, disables all the lights affecting the material.
  60036. */
  60037. disableLighting: boolean;
  60038. /**
  60039. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  60040. */
  60041. forceIrradianceInFragment: boolean;
  60042. /**
  60043. * Number of Simultaneous lights allowed on the material.
  60044. */
  60045. maxSimultaneousLights: number;
  60046. /**
  60047. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  60048. */
  60049. invertNormalMapX: boolean;
  60050. /**
  60051. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  60052. */
  60053. invertNormalMapY: boolean;
  60054. /**
  60055. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  60056. */
  60057. twoSidedLighting: boolean;
  60058. /**
  60059. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  60060. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  60061. */
  60062. useAlphaFresnel: boolean;
  60063. /**
  60064. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  60065. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  60066. */
  60067. useLinearAlphaFresnel: boolean;
  60068. /**
  60069. * Let user defines the brdf lookup texture used for IBL.
  60070. * A default 8bit version is embedded but you could point at :
  60071. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  60072. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  60073. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  60074. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  60075. */
  60076. environmentBRDFTexture: Nullable<BaseTexture>;
  60077. /**
  60078. * Force normal to face away from face.
  60079. */
  60080. forceNormalForward: boolean;
  60081. /**
  60082. * Enables specular anti aliasing in the PBR shader.
  60083. * It will both interacts on the Geometry for analytical and IBL lighting.
  60084. * It also prefilter the roughness map based on the bump values.
  60085. */
  60086. enableSpecularAntiAliasing: boolean;
  60087. /**
  60088. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  60089. * makes the reflect vector face the model (under horizon).
  60090. */
  60091. useHorizonOcclusion: boolean;
  60092. /**
  60093. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  60094. * too much the area relying on ambient texture to define their ambient occlusion.
  60095. */
  60096. useRadianceOcclusion: boolean;
  60097. /**
  60098. * If set to true, no lighting calculations will be applied.
  60099. */
  60100. unlit: boolean;
  60101. /**
  60102. * Gets the image processing configuration used either in this material.
  60103. */
  60104. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  60105. /**
  60106. * Sets the Default image processing configuration used either in the this material.
  60107. *
  60108. * If sets to null, the scene one is in use.
  60109. */
  60110. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  60111. /**
  60112. * Gets wether the color curves effect is enabled.
  60113. */
  60114. get cameraColorCurvesEnabled(): boolean;
  60115. /**
  60116. * Sets wether the color curves effect is enabled.
  60117. */
  60118. set cameraColorCurvesEnabled(value: boolean);
  60119. /**
  60120. * Gets wether the color grading effect is enabled.
  60121. */
  60122. get cameraColorGradingEnabled(): boolean;
  60123. /**
  60124. * Gets wether the color grading effect is enabled.
  60125. */
  60126. set cameraColorGradingEnabled(value: boolean);
  60127. /**
  60128. * Gets wether tonemapping is enabled or not.
  60129. */
  60130. get cameraToneMappingEnabled(): boolean;
  60131. /**
  60132. * Sets wether tonemapping is enabled or not
  60133. */
  60134. set cameraToneMappingEnabled(value: boolean);
  60135. /**
  60136. * The camera exposure used on this material.
  60137. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  60138. * This corresponds to a photographic exposure.
  60139. */
  60140. get cameraExposure(): number;
  60141. /**
  60142. * The camera exposure used on this material.
  60143. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  60144. * This corresponds to a photographic exposure.
  60145. */
  60146. set cameraExposure(value: number);
  60147. /**
  60148. * Gets The camera contrast used on this material.
  60149. */
  60150. get cameraContrast(): number;
  60151. /**
  60152. * Sets The camera contrast used on this material.
  60153. */
  60154. set cameraContrast(value: number);
  60155. /**
  60156. * Gets the Color Grading 2D Lookup Texture.
  60157. */
  60158. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  60159. /**
  60160. * Sets the Color Grading 2D Lookup Texture.
  60161. */
  60162. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  60163. /**
  60164. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  60165. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  60166. * 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;
  60167. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  60168. */
  60169. get cameraColorCurves(): Nullable<ColorCurves>;
  60170. /**
  60171. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  60172. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  60173. * 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;
  60174. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  60175. */
  60176. set cameraColorCurves(value: Nullable<ColorCurves>);
  60177. /**
  60178. * Instantiates a new PBRMaterial instance.
  60179. *
  60180. * @param name The material name
  60181. * @param scene The scene the material will be use in.
  60182. */
  60183. constructor(name: string, scene: Scene);
  60184. /**
  60185. * Returns the name of this material class.
  60186. */
  60187. getClassName(): string;
  60188. /**
  60189. * Makes a duplicate of the current material.
  60190. * @param name - name to use for the new material.
  60191. */
  60192. clone(name: string): PBRMaterial;
  60193. /**
  60194. * Serializes this PBR Material.
  60195. * @returns - An object with the serialized material.
  60196. */
  60197. serialize(): any;
  60198. /**
  60199. * Parses a PBR Material from a serialized object.
  60200. * @param source - Serialized object.
  60201. * @param scene - BJS scene instance.
  60202. * @param rootUrl - url for the scene object
  60203. * @returns - PBRMaterial
  60204. */
  60205. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  60206. }
  60207. }
  60208. declare module "babylonjs/Misc/dds" {
  60209. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  60210. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  60211. import { Nullable } from "babylonjs/types";
  60212. import { Scene } from "babylonjs/scene";
  60213. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  60214. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  60215. /**
  60216. * Direct draw surface info
  60217. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  60218. */
  60219. export interface DDSInfo {
  60220. /**
  60221. * Width of the texture
  60222. */
  60223. width: number;
  60224. /**
  60225. * Width of the texture
  60226. */
  60227. height: number;
  60228. /**
  60229. * Number of Mipmaps for the texture
  60230. * @see https://en.wikipedia.org/wiki/Mipmap
  60231. */
  60232. mipmapCount: number;
  60233. /**
  60234. * If the textures format is a known fourCC format
  60235. * @see https://www.fourcc.org/
  60236. */
  60237. isFourCC: boolean;
  60238. /**
  60239. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  60240. */
  60241. isRGB: boolean;
  60242. /**
  60243. * If the texture is a lumincance format
  60244. */
  60245. isLuminance: boolean;
  60246. /**
  60247. * If this is a cube texture
  60248. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  60249. */
  60250. isCube: boolean;
  60251. /**
  60252. * If the texture is a compressed format eg. FOURCC_DXT1
  60253. */
  60254. isCompressed: boolean;
  60255. /**
  60256. * The dxgiFormat of the texture
  60257. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  60258. */
  60259. dxgiFormat: number;
  60260. /**
  60261. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  60262. */
  60263. textureType: number;
  60264. /**
  60265. * Sphericle polynomial created for the dds texture
  60266. */
  60267. sphericalPolynomial?: SphericalPolynomial;
  60268. }
  60269. /**
  60270. * Class used to provide DDS decompression tools
  60271. */
  60272. export class DDSTools {
  60273. /**
  60274. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  60275. */
  60276. static StoreLODInAlphaChannel: boolean;
  60277. /**
  60278. * Gets DDS information from an array buffer
  60279. * @param data defines the array buffer view to read data from
  60280. * @returns the DDS information
  60281. */
  60282. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  60283. private static _FloatView;
  60284. private static _Int32View;
  60285. private static _ToHalfFloat;
  60286. private static _FromHalfFloat;
  60287. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  60288. private static _GetHalfFloatRGBAArrayBuffer;
  60289. private static _GetFloatRGBAArrayBuffer;
  60290. private static _GetFloatAsUIntRGBAArrayBuffer;
  60291. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  60292. private static _GetRGBAArrayBuffer;
  60293. private static _ExtractLongWordOrder;
  60294. private static _GetRGBArrayBuffer;
  60295. private static _GetLuminanceArrayBuffer;
  60296. /**
  60297. * Uploads DDS Levels to a Babylon Texture
  60298. * @hidden
  60299. */
  60300. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  60301. }
  60302. module "babylonjs/Engines/thinEngine" {
  60303. interface ThinEngine {
  60304. /**
  60305. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  60306. * @param rootUrl defines the url where the file to load is located
  60307. * @param scene defines the current scene
  60308. * @param lodScale defines scale to apply to the mip map selection
  60309. * @param lodOffset defines offset to apply to the mip map selection
  60310. * @param onLoad defines an optional callback raised when the texture is loaded
  60311. * @param onError defines an optional callback raised if there is an issue to load the texture
  60312. * @param format defines the format of the data
  60313. * @param forcedExtension defines the extension to use to pick the right loader
  60314. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  60315. * @returns the cube texture as an InternalTexture
  60316. */
  60317. 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;
  60318. }
  60319. }
  60320. }
  60321. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  60322. import { Nullable } from "babylonjs/types";
  60323. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  60324. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  60325. /**
  60326. * Implementation of the DDS Texture Loader.
  60327. * @hidden
  60328. */
  60329. export class _DDSTextureLoader implements IInternalTextureLoader {
  60330. /**
  60331. * Defines wether the loader supports cascade loading the different faces.
  60332. */
  60333. readonly supportCascades: boolean;
  60334. /**
  60335. * This returns if the loader support the current file information.
  60336. * @param extension defines the file extension of the file being loaded
  60337. * @returns true if the loader can load the specified file
  60338. */
  60339. canLoad(extension: string): boolean;
  60340. /**
  60341. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  60342. * @param data contains the texture data
  60343. * @param texture defines the BabylonJS internal texture
  60344. * @param createPolynomials will be true if polynomials have been requested
  60345. * @param onLoad defines the callback to trigger once the texture is ready
  60346. * @param onError defines the callback to trigger in case of error
  60347. */
  60348. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  60349. /**
  60350. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  60351. * @param data contains the texture data
  60352. * @param texture defines the BabylonJS internal texture
  60353. * @param callback defines the method to call once ready to upload
  60354. */
  60355. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  60356. }
  60357. }
  60358. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  60359. import { Nullable } from "babylonjs/types";
  60360. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  60361. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  60362. /**
  60363. * Implementation of the ENV Texture Loader.
  60364. * @hidden
  60365. */
  60366. export class _ENVTextureLoader implements IInternalTextureLoader {
  60367. /**
  60368. * Defines wether the loader supports cascade loading the different faces.
  60369. */
  60370. readonly supportCascades: boolean;
  60371. /**
  60372. * This returns if the loader support the current file information.
  60373. * @param extension defines the file extension of the file being loaded
  60374. * @returns true if the loader can load the specified file
  60375. */
  60376. canLoad(extension: string): boolean;
  60377. /**
  60378. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  60379. * @param data contains the texture data
  60380. * @param texture defines the BabylonJS internal texture
  60381. * @param createPolynomials will be true if polynomials have been requested
  60382. * @param onLoad defines the callback to trigger once the texture is ready
  60383. * @param onError defines the callback to trigger in case of error
  60384. */
  60385. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  60386. /**
  60387. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  60388. * @param data contains the texture data
  60389. * @param texture defines the BabylonJS internal texture
  60390. * @param callback defines the method to call once ready to upload
  60391. */
  60392. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  60393. }
  60394. }
  60395. declare module "babylonjs/Misc/khronosTextureContainer" {
  60396. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  60397. /**
  60398. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  60399. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  60400. */
  60401. export class KhronosTextureContainer {
  60402. /** contents of the KTX container file */
  60403. data: ArrayBufferView;
  60404. private static HEADER_LEN;
  60405. private static COMPRESSED_2D;
  60406. private static COMPRESSED_3D;
  60407. private static TEX_2D;
  60408. private static TEX_3D;
  60409. /**
  60410. * Gets the openGL type
  60411. */
  60412. glType: number;
  60413. /**
  60414. * Gets the openGL type size
  60415. */
  60416. glTypeSize: number;
  60417. /**
  60418. * Gets the openGL format
  60419. */
  60420. glFormat: number;
  60421. /**
  60422. * Gets the openGL internal format
  60423. */
  60424. glInternalFormat: number;
  60425. /**
  60426. * Gets the base internal format
  60427. */
  60428. glBaseInternalFormat: number;
  60429. /**
  60430. * Gets image width in pixel
  60431. */
  60432. pixelWidth: number;
  60433. /**
  60434. * Gets image height in pixel
  60435. */
  60436. pixelHeight: number;
  60437. /**
  60438. * Gets image depth in pixels
  60439. */
  60440. pixelDepth: number;
  60441. /**
  60442. * Gets the number of array elements
  60443. */
  60444. numberOfArrayElements: number;
  60445. /**
  60446. * Gets the number of faces
  60447. */
  60448. numberOfFaces: number;
  60449. /**
  60450. * Gets the number of mipmap levels
  60451. */
  60452. numberOfMipmapLevels: number;
  60453. /**
  60454. * Gets the bytes of key value data
  60455. */
  60456. bytesOfKeyValueData: number;
  60457. /**
  60458. * Gets the load type
  60459. */
  60460. loadType: number;
  60461. /**
  60462. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  60463. */
  60464. isInvalid: boolean;
  60465. /**
  60466. * Creates a new KhronosTextureContainer
  60467. * @param data contents of the KTX container file
  60468. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  60469. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  60470. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  60471. */
  60472. constructor(
  60473. /** contents of the KTX container file */
  60474. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  60475. /**
  60476. * Uploads KTX content to a Babylon Texture.
  60477. * It is assumed that the texture has already been created & is currently bound
  60478. * @hidden
  60479. */
  60480. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  60481. private _upload2DCompressedLevels;
  60482. /**
  60483. * Checks if the given data starts with a KTX file identifier.
  60484. * @param data the data to check
  60485. * @returns true if the data is a KTX file or false otherwise
  60486. */
  60487. static IsValid(data: ArrayBufferView): boolean;
  60488. }
  60489. }
  60490. declare module "babylonjs/Misc/workerPool" {
  60491. import { IDisposable } from "babylonjs/scene";
  60492. /**
  60493. * Helper class to push actions to a pool of workers.
  60494. */
  60495. export class WorkerPool implements IDisposable {
  60496. private _workerInfos;
  60497. private _pendingActions;
  60498. /**
  60499. * Constructor
  60500. * @param workers Array of workers to use for actions
  60501. */
  60502. constructor(workers: Array<Worker>);
  60503. /**
  60504. * Terminates all workers and clears any pending actions.
  60505. */
  60506. dispose(): void;
  60507. /**
  60508. * Pushes an action to the worker pool. If all the workers are active, the action will be
  60509. * pended until a worker has completed its action.
  60510. * @param action The action to perform. Call onComplete when the action is complete.
  60511. */
  60512. push(action: (worker: Worker, onComplete: () => void) => void): void;
  60513. private _execute;
  60514. }
  60515. }
  60516. declare module "babylonjs/Misc/khronosTextureContainer2" {
  60517. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  60518. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  60519. /**
  60520. * Class for loading KTX2 files
  60521. * @hidden
  60522. */
  60523. export class KhronosTextureContainer2 {
  60524. private static _WorkerPoolPromise?;
  60525. private static _Initialized;
  60526. private static _Ktx2Decoder;
  60527. /**
  60528. * URL to use when loading the KTX2 decoder module
  60529. */
  60530. static JSModuleURL: string;
  60531. /**
  60532. * Default number of workers used to handle data decoding
  60533. */
  60534. static DefaultNumWorkers: number;
  60535. private static GetDefaultNumWorkers;
  60536. private _engine;
  60537. private static _CreateWorkerPool;
  60538. /**
  60539. * Constructor
  60540. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  60541. */
  60542. constructor(engine: ThinEngine, numWorkers?: number);
  60543. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture): Promise<void>;
  60544. /**
  60545. * Stop all async operations and release resources.
  60546. */
  60547. dispose(): void;
  60548. protected _createTexture(data: any, internalTexture: InternalTexture): void;
  60549. /**
  60550. * Checks if the given data starts with a KTX2 file identifier.
  60551. * @param data the data to check
  60552. * @returns true if the data is a KTX2 file or false otherwise
  60553. */
  60554. static IsValid(data: ArrayBufferView): boolean;
  60555. }
  60556. export function workerFunc(): void;
  60557. }
  60558. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  60559. import { Nullable } from "babylonjs/types";
  60560. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  60561. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  60562. /**
  60563. * Implementation of the KTX Texture Loader.
  60564. * @hidden
  60565. */
  60566. export class _KTXTextureLoader implements IInternalTextureLoader {
  60567. /**
  60568. * Defines wether the loader supports cascade loading the different faces.
  60569. */
  60570. readonly supportCascades: boolean;
  60571. /**
  60572. * This returns if the loader support the current file information.
  60573. * @param extension defines the file extension of the file being loaded
  60574. * @param mimeType defines the optional mime type of the file being loaded
  60575. * @returns true if the loader can load the specified file
  60576. */
  60577. canLoad(extension: string, mimeType?: string): boolean;
  60578. /**
  60579. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  60580. * @param data contains the texture data
  60581. * @param texture defines the BabylonJS internal texture
  60582. * @param createPolynomials will be true if polynomials have been requested
  60583. * @param onLoad defines the callback to trigger once the texture is ready
  60584. * @param onError defines the callback to trigger in case of error
  60585. */
  60586. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  60587. /**
  60588. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  60589. * @param data contains the texture data
  60590. * @param texture defines the BabylonJS internal texture
  60591. * @param callback defines the method to call once ready to upload
  60592. */
  60593. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  60594. }
  60595. }
  60596. declare module "babylonjs/Helpers/sceneHelpers" {
  60597. import { Nullable } from "babylonjs/types";
  60598. import { Mesh } from "babylonjs/Meshes/mesh";
  60599. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  60600. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  60601. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  60602. import "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  60603. import "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  60604. import "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  60605. import "babylonjs/Meshes/Builders/boxBuilder";
  60606. import { WebXRDefaultExperience, WebXRDefaultExperienceOptions } from "babylonjs/XR/webXRDefaultExperience";
  60607. /** @hidden */
  60608. export var _forceSceneHelpersToBundle: boolean;
  60609. module "babylonjs/scene" {
  60610. interface Scene {
  60611. /**
  60612. * Creates a default light for the scene.
  60613. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  60614. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  60615. */
  60616. createDefaultLight(replace?: boolean): void;
  60617. /**
  60618. * Creates a default camera for the scene.
  60619. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  60620. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  60621. * @param replace has default false, when true replaces the active camera in the scene
  60622. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  60623. */
  60624. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  60625. /**
  60626. * Creates a default camera and a default light.
  60627. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  60628. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  60629. * @param replace has the default false, when true replaces the active camera/light in the scene
  60630. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  60631. */
  60632. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  60633. /**
  60634. * Creates a new sky box
  60635. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  60636. * @param environmentTexture defines the texture to use as environment texture
  60637. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  60638. * @param scale defines the overall scale of the skybox
  60639. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  60640. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  60641. * @returns a new mesh holding the sky box
  60642. */
  60643. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  60644. /**
  60645. * Creates a new environment
  60646. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  60647. * @param options defines the options you can use to configure the environment
  60648. * @returns the new EnvironmentHelper
  60649. */
  60650. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  60651. /**
  60652. * Creates a new VREXperienceHelper
  60653. * @see https://doc.babylonjs.com/how_to/webvr_helper
  60654. * @param webVROptions defines the options used to create the new VREXperienceHelper
  60655. * @returns a new VREXperienceHelper
  60656. */
  60657. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  60658. /**
  60659. * Creates a new WebXRDefaultExperience
  60660. * @see https://doc.babylonjs.com/how_to/introduction_to_webxr
  60661. * @param options experience options
  60662. * @returns a promise for a new WebXRDefaultExperience
  60663. */
  60664. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  60665. }
  60666. }
  60667. }
  60668. declare module "babylonjs/Helpers/videoDome" {
  60669. import { Scene } from "babylonjs/scene";
  60670. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  60671. import { TextureDome } from "babylonjs/Helpers/textureDome";
  60672. /**
  60673. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  60674. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  60675. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  60676. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  60677. */
  60678. export class VideoDome extends TextureDome<VideoTexture> {
  60679. /**
  60680. * Define the video source as a Monoscopic panoramic 360 video.
  60681. */
  60682. static readonly MODE_MONOSCOPIC: number;
  60683. /**
  60684. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  60685. */
  60686. static readonly MODE_TOPBOTTOM: number;
  60687. /**
  60688. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  60689. */
  60690. static readonly MODE_SIDEBYSIDE: number;
  60691. /**
  60692. * Get the video texture associated with this video dome
  60693. */
  60694. get videoTexture(): VideoTexture;
  60695. /**
  60696. * Get the video mode of this dome
  60697. */
  60698. get videoMode(): number;
  60699. /**
  60700. * Set the video mode of this dome.
  60701. * @see textureMode
  60702. */
  60703. set videoMode(value: number);
  60704. protected _initTexture(urlsOrElement: string | string[] | HTMLVideoElement, scene: Scene, options: any): VideoTexture;
  60705. }
  60706. }
  60707. declare module "babylonjs/Helpers/index" {
  60708. export * from "babylonjs/Helpers/environmentHelper";
  60709. export * from "babylonjs/Helpers/photoDome";
  60710. export * from "babylonjs/Helpers/sceneHelpers";
  60711. export * from "babylonjs/Helpers/videoDome";
  60712. }
  60713. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  60714. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  60715. import { IDisposable } from "babylonjs/scene";
  60716. import { Engine } from "babylonjs/Engines/engine";
  60717. /**
  60718. * This class can be used to get instrumentation data from a Babylon engine
  60719. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  60720. */
  60721. export class EngineInstrumentation implements IDisposable {
  60722. /**
  60723. * Define the instrumented engine.
  60724. */
  60725. engine: Engine;
  60726. private _captureGPUFrameTime;
  60727. private _gpuFrameTimeToken;
  60728. private _gpuFrameTime;
  60729. private _captureShaderCompilationTime;
  60730. private _shaderCompilationTime;
  60731. private _onBeginFrameObserver;
  60732. private _onEndFrameObserver;
  60733. private _onBeforeShaderCompilationObserver;
  60734. private _onAfterShaderCompilationObserver;
  60735. /**
  60736. * Gets the perf counter used for GPU frame time
  60737. */
  60738. get gpuFrameTimeCounter(): PerfCounter;
  60739. /**
  60740. * Gets the GPU frame time capture status
  60741. */
  60742. get captureGPUFrameTime(): boolean;
  60743. /**
  60744. * Enable or disable the GPU frame time capture
  60745. */
  60746. set captureGPUFrameTime(value: boolean);
  60747. /**
  60748. * Gets the perf counter used for shader compilation time
  60749. */
  60750. get shaderCompilationTimeCounter(): PerfCounter;
  60751. /**
  60752. * Gets the shader compilation time capture status
  60753. */
  60754. get captureShaderCompilationTime(): boolean;
  60755. /**
  60756. * Enable or disable the shader compilation time capture
  60757. */
  60758. set captureShaderCompilationTime(value: boolean);
  60759. /**
  60760. * Instantiates a new engine instrumentation.
  60761. * This class can be used to get instrumentation data from a Babylon engine
  60762. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  60763. * @param engine Defines the engine to instrument
  60764. */
  60765. constructor(
  60766. /**
  60767. * Define the instrumented engine.
  60768. */
  60769. engine: Engine);
  60770. /**
  60771. * Dispose and release associated resources.
  60772. */
  60773. dispose(): void;
  60774. }
  60775. }
  60776. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  60777. import { Scene, IDisposable } from "babylonjs/scene";
  60778. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  60779. /**
  60780. * This class can be used to get instrumentation data from a Babylon engine
  60781. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  60782. */
  60783. export class SceneInstrumentation implements IDisposable {
  60784. /**
  60785. * Defines the scene to instrument
  60786. */
  60787. scene: Scene;
  60788. private _captureActiveMeshesEvaluationTime;
  60789. private _activeMeshesEvaluationTime;
  60790. private _captureRenderTargetsRenderTime;
  60791. private _renderTargetsRenderTime;
  60792. private _captureFrameTime;
  60793. private _frameTime;
  60794. private _captureRenderTime;
  60795. private _renderTime;
  60796. private _captureInterFrameTime;
  60797. private _interFrameTime;
  60798. private _captureParticlesRenderTime;
  60799. private _particlesRenderTime;
  60800. private _captureSpritesRenderTime;
  60801. private _spritesRenderTime;
  60802. private _capturePhysicsTime;
  60803. private _physicsTime;
  60804. private _captureAnimationsTime;
  60805. private _animationsTime;
  60806. private _captureCameraRenderTime;
  60807. private _cameraRenderTime;
  60808. private _onBeforeActiveMeshesEvaluationObserver;
  60809. private _onAfterActiveMeshesEvaluationObserver;
  60810. private _onBeforeRenderTargetsRenderObserver;
  60811. private _onAfterRenderTargetsRenderObserver;
  60812. private _onAfterRenderObserver;
  60813. private _onBeforeDrawPhaseObserver;
  60814. private _onAfterDrawPhaseObserver;
  60815. private _onBeforeAnimationsObserver;
  60816. private _onBeforeParticlesRenderingObserver;
  60817. private _onAfterParticlesRenderingObserver;
  60818. private _onBeforeSpritesRenderingObserver;
  60819. private _onAfterSpritesRenderingObserver;
  60820. private _onBeforePhysicsObserver;
  60821. private _onAfterPhysicsObserver;
  60822. private _onAfterAnimationsObserver;
  60823. private _onBeforeCameraRenderObserver;
  60824. private _onAfterCameraRenderObserver;
  60825. /**
  60826. * Gets the perf counter used for active meshes evaluation time
  60827. */
  60828. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  60829. /**
  60830. * Gets the active meshes evaluation time capture status
  60831. */
  60832. get captureActiveMeshesEvaluationTime(): boolean;
  60833. /**
  60834. * Enable or disable the active meshes evaluation time capture
  60835. */
  60836. set captureActiveMeshesEvaluationTime(value: boolean);
  60837. /**
  60838. * Gets the perf counter used for render targets render time
  60839. */
  60840. get renderTargetsRenderTimeCounter(): PerfCounter;
  60841. /**
  60842. * Gets the render targets render time capture status
  60843. */
  60844. get captureRenderTargetsRenderTime(): boolean;
  60845. /**
  60846. * Enable or disable the render targets render time capture
  60847. */
  60848. set captureRenderTargetsRenderTime(value: boolean);
  60849. /**
  60850. * Gets the perf counter used for particles render time
  60851. */
  60852. get particlesRenderTimeCounter(): PerfCounter;
  60853. /**
  60854. * Gets the particles render time capture status
  60855. */
  60856. get captureParticlesRenderTime(): boolean;
  60857. /**
  60858. * Enable or disable the particles render time capture
  60859. */
  60860. set captureParticlesRenderTime(value: boolean);
  60861. /**
  60862. * Gets the perf counter used for sprites render time
  60863. */
  60864. get spritesRenderTimeCounter(): PerfCounter;
  60865. /**
  60866. * Gets the sprites render time capture status
  60867. */
  60868. get captureSpritesRenderTime(): boolean;
  60869. /**
  60870. * Enable or disable the sprites render time capture
  60871. */
  60872. set captureSpritesRenderTime(value: boolean);
  60873. /**
  60874. * Gets the perf counter used for physics time
  60875. */
  60876. get physicsTimeCounter(): PerfCounter;
  60877. /**
  60878. * Gets the physics time capture status
  60879. */
  60880. get capturePhysicsTime(): boolean;
  60881. /**
  60882. * Enable or disable the physics time capture
  60883. */
  60884. set capturePhysicsTime(value: boolean);
  60885. /**
  60886. * Gets the perf counter used for animations time
  60887. */
  60888. get animationsTimeCounter(): PerfCounter;
  60889. /**
  60890. * Gets the animations time capture status
  60891. */
  60892. get captureAnimationsTime(): boolean;
  60893. /**
  60894. * Enable or disable the animations time capture
  60895. */
  60896. set captureAnimationsTime(value: boolean);
  60897. /**
  60898. * Gets the perf counter used for frame time capture
  60899. */
  60900. get frameTimeCounter(): PerfCounter;
  60901. /**
  60902. * Gets the frame time capture status
  60903. */
  60904. get captureFrameTime(): boolean;
  60905. /**
  60906. * Enable or disable the frame time capture
  60907. */
  60908. set captureFrameTime(value: boolean);
  60909. /**
  60910. * Gets the perf counter used for inter-frames time capture
  60911. */
  60912. get interFrameTimeCounter(): PerfCounter;
  60913. /**
  60914. * Gets the inter-frames time capture status
  60915. */
  60916. get captureInterFrameTime(): boolean;
  60917. /**
  60918. * Enable or disable the inter-frames time capture
  60919. */
  60920. set captureInterFrameTime(value: boolean);
  60921. /**
  60922. * Gets the perf counter used for render time capture
  60923. */
  60924. get renderTimeCounter(): PerfCounter;
  60925. /**
  60926. * Gets the render time capture status
  60927. */
  60928. get captureRenderTime(): boolean;
  60929. /**
  60930. * Enable or disable the render time capture
  60931. */
  60932. set captureRenderTime(value: boolean);
  60933. /**
  60934. * Gets the perf counter used for camera render time capture
  60935. */
  60936. get cameraRenderTimeCounter(): PerfCounter;
  60937. /**
  60938. * Gets the camera render time capture status
  60939. */
  60940. get captureCameraRenderTime(): boolean;
  60941. /**
  60942. * Enable or disable the camera render time capture
  60943. */
  60944. set captureCameraRenderTime(value: boolean);
  60945. /**
  60946. * Gets the perf counter used for draw calls
  60947. */
  60948. get drawCallsCounter(): PerfCounter;
  60949. /**
  60950. * Instantiates a new scene instrumentation.
  60951. * This class can be used to get instrumentation data from a Babylon engine
  60952. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  60953. * @param scene Defines the scene to instrument
  60954. */
  60955. constructor(
  60956. /**
  60957. * Defines the scene to instrument
  60958. */
  60959. scene: Scene);
  60960. /**
  60961. * Dispose and release associated resources.
  60962. */
  60963. dispose(): void;
  60964. }
  60965. }
  60966. declare module "babylonjs/Instrumentation/index" {
  60967. export * from "babylonjs/Instrumentation/engineInstrumentation";
  60968. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  60969. export * from "babylonjs/Instrumentation/timeToken";
  60970. }
  60971. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  60972. /** @hidden */
  60973. export var glowMapGenerationPixelShader: {
  60974. name: string;
  60975. shader: string;
  60976. };
  60977. }
  60978. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  60979. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  60980. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  60981. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  60982. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  60983. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  60984. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  60985. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  60986. /** @hidden */
  60987. export var glowMapGenerationVertexShader: {
  60988. name: string;
  60989. shader: string;
  60990. };
  60991. }
  60992. declare module "babylonjs/Layers/effectLayer" {
  60993. import { Observable } from "babylonjs/Misc/observable";
  60994. import { Nullable } from "babylonjs/types";
  60995. import { Camera } from "babylonjs/Cameras/camera";
  60996. import { Scene } from "babylonjs/scene";
  60997. import { ISize } from "babylonjs/Maths/math.size";
  60998. import { Color4 } from "babylonjs/Maths/math.color";
  60999. import { Engine } from "babylonjs/Engines/engine";
  61000. import { SubMesh } from "babylonjs/Meshes/subMesh";
  61001. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61002. import { Mesh } from "babylonjs/Meshes/mesh";
  61003. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  61004. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  61005. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  61006. import { Effect } from "babylonjs/Materials/effect";
  61007. import { Material } from "babylonjs/Materials/material";
  61008. import "babylonjs/Shaders/glowMapGeneration.fragment";
  61009. import "babylonjs/Shaders/glowMapGeneration.vertex";
  61010. /**
  61011. * Effect layer options. This helps customizing the behaviour
  61012. * of the effect layer.
  61013. */
  61014. export interface IEffectLayerOptions {
  61015. /**
  61016. * Multiplication factor apply to the canvas size to compute the render target size
  61017. * used to generated the objects (the smaller the faster).
  61018. */
  61019. mainTextureRatio: number;
  61020. /**
  61021. * Enforces a fixed size texture to ensure effect stability across devices.
  61022. */
  61023. mainTextureFixedSize?: number;
  61024. /**
  61025. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  61026. */
  61027. alphaBlendingMode: number;
  61028. /**
  61029. * The camera attached to the layer.
  61030. */
  61031. camera: Nullable<Camera>;
  61032. /**
  61033. * The rendering group to draw the layer in.
  61034. */
  61035. renderingGroupId: number;
  61036. }
  61037. /**
  61038. * The effect layer Helps adding post process effect blended with the main pass.
  61039. *
  61040. * This can be for instance use to generate glow or higlight effects on the scene.
  61041. *
  61042. * The effect layer class can not be used directly and is intented to inherited from to be
  61043. * customized per effects.
  61044. */
  61045. export abstract class EffectLayer {
  61046. private _vertexBuffers;
  61047. private _indexBuffer;
  61048. private _cachedDefines;
  61049. private _effectLayerMapGenerationEffect;
  61050. private _effectLayerOptions;
  61051. private _mergeEffect;
  61052. protected _scene: Scene;
  61053. protected _engine: Engine;
  61054. protected _maxSize: number;
  61055. protected _mainTextureDesiredSize: ISize;
  61056. protected _mainTexture: RenderTargetTexture;
  61057. protected _shouldRender: boolean;
  61058. protected _postProcesses: PostProcess[];
  61059. protected _textures: BaseTexture[];
  61060. protected _emissiveTextureAndColor: {
  61061. texture: Nullable<BaseTexture>;
  61062. color: Color4;
  61063. };
  61064. /**
  61065. * The name of the layer
  61066. */
  61067. name: string;
  61068. /**
  61069. * The clear color of the texture used to generate the glow map.
  61070. */
  61071. neutralColor: Color4;
  61072. /**
  61073. * Specifies whether the highlight layer is enabled or not.
  61074. */
  61075. isEnabled: boolean;
  61076. /**
  61077. * Gets the camera attached to the layer.
  61078. */
  61079. get camera(): Nullable<Camera>;
  61080. /**
  61081. * Gets the rendering group id the layer should render in.
  61082. */
  61083. get renderingGroupId(): number;
  61084. set renderingGroupId(renderingGroupId: number);
  61085. /**
  61086. * An event triggered when the effect layer has been disposed.
  61087. */
  61088. onDisposeObservable: Observable<EffectLayer>;
  61089. /**
  61090. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  61091. */
  61092. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  61093. /**
  61094. * An event triggered when the generated texture is being merged in the scene.
  61095. */
  61096. onBeforeComposeObservable: Observable<EffectLayer>;
  61097. /**
  61098. * An event triggered when the mesh is rendered into the effect render target.
  61099. */
  61100. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  61101. /**
  61102. * An event triggered after the mesh has been rendered into the effect render target.
  61103. */
  61104. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  61105. /**
  61106. * An event triggered when the generated texture has been merged in the scene.
  61107. */
  61108. onAfterComposeObservable: Observable<EffectLayer>;
  61109. /**
  61110. * An event triggered when the efffect layer changes its size.
  61111. */
  61112. onSizeChangedObservable: Observable<EffectLayer>;
  61113. /** @hidden */
  61114. static _SceneComponentInitialization: (scene: Scene) => void;
  61115. /**
  61116. * Instantiates a new effect Layer and references it in the scene.
  61117. * @param name The name of the layer
  61118. * @param scene The scene to use the layer in
  61119. */
  61120. constructor(
  61121. /** The Friendly of the effect in the scene */
  61122. name: string, scene: Scene);
  61123. /**
  61124. * Get the effect name of the layer.
  61125. * @return The effect name
  61126. */
  61127. abstract getEffectName(): string;
  61128. /**
  61129. * Checks for the readiness of the element composing the layer.
  61130. * @param subMesh the mesh to check for
  61131. * @param useInstances specify whether or not to use instances to render the mesh
  61132. * @return true if ready otherwise, false
  61133. */
  61134. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  61135. /**
  61136. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  61137. * @returns true if the effect requires stencil during the main canvas render pass.
  61138. */
  61139. abstract needStencil(): boolean;
  61140. /**
  61141. * Create the merge effect. This is the shader use to blit the information back
  61142. * to the main canvas at the end of the scene rendering.
  61143. * @returns The effect containing the shader used to merge the effect on the main canvas
  61144. */
  61145. protected abstract _createMergeEffect(): Effect;
  61146. /**
  61147. * Creates the render target textures and post processes used in the effect layer.
  61148. */
  61149. protected abstract _createTextureAndPostProcesses(): void;
  61150. /**
  61151. * Implementation specific of rendering the generating effect on the main canvas.
  61152. * @param effect The effect used to render through
  61153. */
  61154. protected abstract _internalRender(effect: Effect): void;
  61155. /**
  61156. * Sets the required values for both the emissive texture and and the main color.
  61157. */
  61158. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  61159. /**
  61160. * Free any resources and references associated to a mesh.
  61161. * Internal use
  61162. * @param mesh The mesh to free.
  61163. */
  61164. abstract _disposeMesh(mesh: Mesh): void;
  61165. /**
  61166. * Serializes this layer (Glow or Highlight for example)
  61167. * @returns a serialized layer object
  61168. */
  61169. abstract serialize?(): any;
  61170. /**
  61171. * Initializes the effect layer with the required options.
  61172. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  61173. */
  61174. protected _init(options: Partial<IEffectLayerOptions>): void;
  61175. /**
  61176. * Generates the index buffer of the full screen quad blending to the main canvas.
  61177. */
  61178. private _generateIndexBuffer;
  61179. /**
  61180. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  61181. */
  61182. private _generateVertexBuffer;
  61183. /**
  61184. * Sets the main texture desired size which is the closest power of two
  61185. * of the engine canvas size.
  61186. */
  61187. private _setMainTextureSize;
  61188. /**
  61189. * Creates the main texture for the effect layer.
  61190. */
  61191. protected _createMainTexture(): void;
  61192. /**
  61193. * Adds specific effects defines.
  61194. * @param defines The defines to add specifics to.
  61195. */
  61196. protected _addCustomEffectDefines(defines: string[]): void;
  61197. /**
  61198. * Checks for the readiness of the element composing the layer.
  61199. * @param subMesh the mesh to check for
  61200. * @param useInstances specify whether or not to use instances to render the mesh
  61201. * @param emissiveTexture the associated emissive texture used to generate the glow
  61202. * @return true if ready otherwise, false
  61203. */
  61204. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  61205. /**
  61206. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  61207. */
  61208. render(): void;
  61209. /**
  61210. * Determine if a given mesh will be used in the current effect.
  61211. * @param mesh mesh to test
  61212. * @returns true if the mesh will be used
  61213. */
  61214. hasMesh(mesh: AbstractMesh): boolean;
  61215. /**
  61216. * Returns true if the layer contains information to display, otherwise false.
  61217. * @returns true if the glow layer should be rendered
  61218. */
  61219. shouldRender(): boolean;
  61220. /**
  61221. * Returns true if the mesh should render, otherwise false.
  61222. * @param mesh The mesh to render
  61223. * @returns true if it should render otherwise false
  61224. */
  61225. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  61226. /**
  61227. * Returns true if the mesh can be rendered, otherwise false.
  61228. * @param mesh The mesh to render
  61229. * @param material The material used on the mesh
  61230. * @returns true if it can be rendered otherwise false
  61231. */
  61232. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  61233. /**
  61234. * Returns true if the mesh should render, otherwise false.
  61235. * @param mesh The mesh to render
  61236. * @returns true if it should render otherwise false
  61237. */
  61238. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  61239. /**
  61240. * Renders the submesh passed in parameter to the generation map.
  61241. */
  61242. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  61243. /**
  61244. * Defines whether the current material of the mesh should be use to render the effect.
  61245. * @param mesh defines the current mesh to render
  61246. */
  61247. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  61248. /**
  61249. * Rebuild the required buffers.
  61250. * @hidden Internal use only.
  61251. */
  61252. _rebuild(): void;
  61253. /**
  61254. * Dispose only the render target textures and post process.
  61255. */
  61256. private _disposeTextureAndPostProcesses;
  61257. /**
  61258. * Dispose the highlight layer and free resources.
  61259. */
  61260. dispose(): void;
  61261. /**
  61262. * Gets the class name of the effect layer
  61263. * @returns the string with the class name of the effect layer
  61264. */
  61265. getClassName(): string;
  61266. /**
  61267. * Creates an effect layer from parsed effect layer data
  61268. * @param parsedEffectLayer defines effect layer data
  61269. * @param scene defines the current scene
  61270. * @param rootUrl defines the root URL containing the effect layer information
  61271. * @returns a parsed effect Layer
  61272. */
  61273. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  61274. }
  61275. }
  61276. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  61277. import { Scene } from "babylonjs/scene";
  61278. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  61279. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  61280. import { AbstractScene } from "babylonjs/abstractScene";
  61281. module "babylonjs/abstractScene" {
  61282. interface AbstractScene {
  61283. /**
  61284. * The list of effect layers (highlights/glow) added to the scene
  61285. * @see https://doc.babylonjs.com/how_to/highlight_layer
  61286. * @see https://doc.babylonjs.com/how_to/glow_layer
  61287. */
  61288. effectLayers: Array<EffectLayer>;
  61289. /**
  61290. * Removes the given effect layer from this scene.
  61291. * @param toRemove defines the effect layer to remove
  61292. * @returns the index of the removed effect layer
  61293. */
  61294. removeEffectLayer(toRemove: EffectLayer): number;
  61295. /**
  61296. * Adds the given effect layer to this scene
  61297. * @param newEffectLayer defines the effect layer to add
  61298. */
  61299. addEffectLayer(newEffectLayer: EffectLayer): void;
  61300. }
  61301. }
  61302. /**
  61303. * Defines the layer scene component responsible to manage any effect layers
  61304. * in a given scene.
  61305. */
  61306. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  61307. /**
  61308. * The component name helpfull to identify the component in the list of scene components.
  61309. */
  61310. readonly name: string;
  61311. /**
  61312. * The scene the component belongs to.
  61313. */
  61314. scene: Scene;
  61315. private _engine;
  61316. private _renderEffects;
  61317. private _needStencil;
  61318. private _previousStencilState;
  61319. /**
  61320. * Creates a new instance of the component for the given scene
  61321. * @param scene Defines the scene to register the component in
  61322. */
  61323. constructor(scene: Scene);
  61324. /**
  61325. * Registers the component in a given scene
  61326. */
  61327. register(): void;
  61328. /**
  61329. * Rebuilds the elements related to this component in case of
  61330. * context lost for instance.
  61331. */
  61332. rebuild(): void;
  61333. /**
  61334. * Serializes the component data to the specified json object
  61335. * @param serializationObject The object to serialize to
  61336. */
  61337. serialize(serializationObject: any): void;
  61338. /**
  61339. * Adds all the elements from the container to the scene
  61340. * @param container the container holding the elements
  61341. */
  61342. addFromContainer(container: AbstractScene): void;
  61343. /**
  61344. * Removes all the elements in the container from the scene
  61345. * @param container contains the elements to remove
  61346. * @param dispose if the removed element should be disposed (default: false)
  61347. */
  61348. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  61349. /**
  61350. * Disposes the component and the associated ressources.
  61351. */
  61352. dispose(): void;
  61353. private _isReadyForMesh;
  61354. private _renderMainTexture;
  61355. private _setStencil;
  61356. private _setStencilBack;
  61357. private _draw;
  61358. private _drawCamera;
  61359. private _drawRenderingGroup;
  61360. }
  61361. }
  61362. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  61363. /** @hidden */
  61364. export var glowMapMergePixelShader: {
  61365. name: string;
  61366. shader: string;
  61367. };
  61368. }
  61369. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  61370. /** @hidden */
  61371. export var glowMapMergeVertexShader: {
  61372. name: string;
  61373. shader: string;
  61374. };
  61375. }
  61376. declare module "babylonjs/Layers/glowLayer" {
  61377. import { Nullable } from "babylonjs/types";
  61378. import { Camera } from "babylonjs/Cameras/camera";
  61379. import { Scene } from "babylonjs/scene";
  61380. import { SubMesh } from "babylonjs/Meshes/subMesh";
  61381. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61382. import { Mesh } from "babylonjs/Meshes/mesh";
  61383. import { Texture } from "babylonjs/Materials/Textures/texture";
  61384. import { Effect } from "babylonjs/Materials/effect";
  61385. import { Material } from "babylonjs/Materials/material";
  61386. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  61387. import { Color4 } from "babylonjs/Maths/math.color";
  61388. import "babylonjs/Shaders/glowMapMerge.fragment";
  61389. import "babylonjs/Shaders/glowMapMerge.vertex";
  61390. import "babylonjs/Layers/effectLayerSceneComponent";
  61391. module "babylonjs/abstractScene" {
  61392. interface AbstractScene {
  61393. /**
  61394. * Return a the first highlight layer of the scene with a given name.
  61395. * @param name The name of the highlight layer to look for.
  61396. * @return The highlight layer if found otherwise null.
  61397. */
  61398. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  61399. }
  61400. }
  61401. /**
  61402. * Glow layer options. This helps customizing the behaviour
  61403. * of the glow layer.
  61404. */
  61405. export interface IGlowLayerOptions {
  61406. /**
  61407. * Multiplication factor apply to the canvas size to compute the render target size
  61408. * used to generated the glowing objects (the smaller the faster).
  61409. */
  61410. mainTextureRatio: number;
  61411. /**
  61412. * Enforces a fixed size texture to ensure resize independant blur.
  61413. */
  61414. mainTextureFixedSize?: number;
  61415. /**
  61416. * How big is the kernel of the blur texture.
  61417. */
  61418. blurKernelSize: number;
  61419. /**
  61420. * The camera attached to the layer.
  61421. */
  61422. camera: Nullable<Camera>;
  61423. /**
  61424. * Enable MSAA by chosing the number of samples.
  61425. */
  61426. mainTextureSamples?: number;
  61427. /**
  61428. * The rendering group to draw the layer in.
  61429. */
  61430. renderingGroupId: number;
  61431. }
  61432. /**
  61433. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  61434. *
  61435. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  61436. *
  61437. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  61438. */
  61439. export class GlowLayer extends EffectLayer {
  61440. /**
  61441. * Effect Name of the layer.
  61442. */
  61443. static readonly EffectName: string;
  61444. /**
  61445. * The default blur kernel size used for the glow.
  61446. */
  61447. static DefaultBlurKernelSize: number;
  61448. /**
  61449. * The default texture size ratio used for the glow.
  61450. */
  61451. static DefaultTextureRatio: number;
  61452. /**
  61453. * Sets the kernel size of the blur.
  61454. */
  61455. set blurKernelSize(value: number);
  61456. /**
  61457. * Gets the kernel size of the blur.
  61458. */
  61459. get blurKernelSize(): number;
  61460. /**
  61461. * Sets the glow intensity.
  61462. */
  61463. set intensity(value: number);
  61464. /**
  61465. * Gets the glow intensity.
  61466. */
  61467. get intensity(): number;
  61468. private _options;
  61469. private _intensity;
  61470. private _horizontalBlurPostprocess1;
  61471. private _verticalBlurPostprocess1;
  61472. private _horizontalBlurPostprocess2;
  61473. private _verticalBlurPostprocess2;
  61474. private _blurTexture1;
  61475. private _blurTexture2;
  61476. private _postProcesses1;
  61477. private _postProcesses2;
  61478. private _includedOnlyMeshes;
  61479. private _excludedMeshes;
  61480. private _meshesUsingTheirOwnMaterials;
  61481. /**
  61482. * Callback used to let the user override the color selection on a per mesh basis
  61483. */
  61484. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  61485. /**
  61486. * Callback used to let the user override the texture selection on a per mesh basis
  61487. */
  61488. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  61489. /**
  61490. * Instantiates a new glow Layer and references it to the scene.
  61491. * @param name The name of the layer
  61492. * @param scene The scene to use the layer in
  61493. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  61494. */
  61495. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  61496. /**
  61497. * Get the effect name of the layer.
  61498. * @return The effect name
  61499. */
  61500. getEffectName(): string;
  61501. /**
  61502. * Create the merge effect. This is the shader use to blit the information back
  61503. * to the main canvas at the end of the scene rendering.
  61504. */
  61505. protected _createMergeEffect(): Effect;
  61506. /**
  61507. * Creates the render target textures and post processes used in the glow layer.
  61508. */
  61509. protected _createTextureAndPostProcesses(): void;
  61510. /**
  61511. * Checks for the readiness of the element composing the layer.
  61512. * @param subMesh the mesh to check for
  61513. * @param useInstances specify wether or not to use instances to render the mesh
  61514. * @param emissiveTexture the associated emissive texture used to generate the glow
  61515. * @return true if ready otherwise, false
  61516. */
  61517. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  61518. /**
  61519. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  61520. */
  61521. needStencil(): boolean;
  61522. /**
  61523. * Returns true if the mesh can be rendered, otherwise false.
  61524. * @param mesh The mesh to render
  61525. * @param material The material used on the mesh
  61526. * @returns true if it can be rendered otherwise false
  61527. */
  61528. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  61529. /**
  61530. * Implementation specific of rendering the generating effect on the main canvas.
  61531. * @param effect The effect used to render through
  61532. */
  61533. protected _internalRender(effect: Effect): void;
  61534. /**
  61535. * Sets the required values for both the emissive texture and and the main color.
  61536. */
  61537. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  61538. /**
  61539. * Returns true if the mesh should render, otherwise false.
  61540. * @param mesh The mesh to render
  61541. * @returns true if it should render otherwise false
  61542. */
  61543. protected _shouldRenderMesh(mesh: Mesh): boolean;
  61544. /**
  61545. * Adds specific effects defines.
  61546. * @param defines The defines to add specifics to.
  61547. */
  61548. protected _addCustomEffectDefines(defines: string[]): void;
  61549. /**
  61550. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  61551. * @param mesh The mesh to exclude from the glow layer
  61552. */
  61553. addExcludedMesh(mesh: Mesh): void;
  61554. /**
  61555. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  61556. * @param mesh The mesh to remove
  61557. */
  61558. removeExcludedMesh(mesh: Mesh): void;
  61559. /**
  61560. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  61561. * @param mesh The mesh to include in the glow layer
  61562. */
  61563. addIncludedOnlyMesh(mesh: Mesh): void;
  61564. /**
  61565. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  61566. * @param mesh The mesh to remove
  61567. */
  61568. removeIncludedOnlyMesh(mesh: Mesh): void;
  61569. /**
  61570. * Determine if a given mesh will be used in the glow layer
  61571. * @param mesh The mesh to test
  61572. * @returns true if the mesh will be highlighted by the current glow layer
  61573. */
  61574. hasMesh(mesh: AbstractMesh): boolean;
  61575. /**
  61576. * Defines whether the current material of the mesh should be use to render the effect.
  61577. * @param mesh defines the current mesh to render
  61578. */
  61579. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  61580. /**
  61581. * Add a mesh to be rendered through its own material and not with emissive only.
  61582. * @param mesh The mesh for which we need to use its material
  61583. */
  61584. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  61585. /**
  61586. * Remove a mesh from being rendered through its own material and not with emissive only.
  61587. * @param mesh The mesh for which we need to not use its material
  61588. */
  61589. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  61590. /**
  61591. * Free any resources and references associated to a mesh.
  61592. * Internal use
  61593. * @param mesh The mesh to free.
  61594. * @hidden
  61595. */
  61596. _disposeMesh(mesh: Mesh): void;
  61597. /**
  61598. * Gets the class name of the effect layer
  61599. * @returns the string with the class name of the effect layer
  61600. */
  61601. getClassName(): string;
  61602. /**
  61603. * Serializes this glow layer
  61604. * @returns a serialized glow layer object
  61605. */
  61606. serialize(): any;
  61607. /**
  61608. * Creates a Glow Layer from parsed glow layer data
  61609. * @param parsedGlowLayer defines glow layer data
  61610. * @param scene defines the current scene
  61611. * @param rootUrl defines the root URL containing the glow layer information
  61612. * @returns a parsed Glow Layer
  61613. */
  61614. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  61615. }
  61616. }
  61617. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  61618. /** @hidden */
  61619. export var glowBlurPostProcessPixelShader: {
  61620. name: string;
  61621. shader: string;
  61622. };
  61623. }
  61624. declare module "babylonjs/Layers/highlightLayer" {
  61625. import { Observable } from "babylonjs/Misc/observable";
  61626. import { Nullable } from "babylonjs/types";
  61627. import { Camera } from "babylonjs/Cameras/camera";
  61628. import { Scene } from "babylonjs/scene";
  61629. import { SubMesh } from "babylonjs/Meshes/subMesh";
  61630. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61631. import { Mesh } from "babylonjs/Meshes/mesh";
  61632. import { Effect } from "babylonjs/Materials/effect";
  61633. import { Material } from "babylonjs/Materials/material";
  61634. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  61635. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  61636. import "babylonjs/Shaders/glowMapMerge.fragment";
  61637. import "babylonjs/Shaders/glowMapMerge.vertex";
  61638. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  61639. module "babylonjs/abstractScene" {
  61640. interface AbstractScene {
  61641. /**
  61642. * Return a the first highlight layer of the scene with a given name.
  61643. * @param name The name of the highlight layer to look for.
  61644. * @return The highlight layer if found otherwise null.
  61645. */
  61646. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  61647. }
  61648. }
  61649. /**
  61650. * Highlight layer options. This helps customizing the behaviour
  61651. * of the highlight layer.
  61652. */
  61653. export interface IHighlightLayerOptions {
  61654. /**
  61655. * Multiplication factor apply to the canvas size to compute the render target size
  61656. * used to generated the glowing objects (the smaller the faster).
  61657. */
  61658. mainTextureRatio: number;
  61659. /**
  61660. * Enforces a fixed size texture to ensure resize independant blur.
  61661. */
  61662. mainTextureFixedSize?: number;
  61663. /**
  61664. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  61665. * of the picture to blur (the smaller the faster).
  61666. */
  61667. blurTextureSizeRatio: number;
  61668. /**
  61669. * How big in texel of the blur texture is the vertical blur.
  61670. */
  61671. blurVerticalSize: number;
  61672. /**
  61673. * How big in texel of the blur texture is the horizontal blur.
  61674. */
  61675. blurHorizontalSize: number;
  61676. /**
  61677. * Alpha blending mode used to apply the blur. Default is combine.
  61678. */
  61679. alphaBlendingMode: number;
  61680. /**
  61681. * The camera attached to the layer.
  61682. */
  61683. camera: Nullable<Camera>;
  61684. /**
  61685. * Should we display highlight as a solid stroke?
  61686. */
  61687. isStroke?: boolean;
  61688. /**
  61689. * The rendering group to draw the layer in.
  61690. */
  61691. renderingGroupId: number;
  61692. }
  61693. /**
  61694. * The highlight layer Helps adding a glow effect around a mesh.
  61695. *
  61696. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  61697. * glowy meshes to your scene.
  61698. *
  61699. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  61700. */
  61701. export class HighlightLayer extends EffectLayer {
  61702. name: string;
  61703. /**
  61704. * Effect Name of the highlight layer.
  61705. */
  61706. static readonly EffectName: string;
  61707. /**
  61708. * The neutral color used during the preparation of the glow effect.
  61709. * This is black by default as the blend operation is a blend operation.
  61710. */
  61711. static NeutralColor: Color4;
  61712. /**
  61713. * Stencil value used for glowing meshes.
  61714. */
  61715. static GlowingMeshStencilReference: number;
  61716. /**
  61717. * Stencil value used for the other meshes in the scene.
  61718. */
  61719. static NormalMeshStencilReference: number;
  61720. /**
  61721. * Specifies whether or not the inner glow is ACTIVE in the layer.
  61722. */
  61723. innerGlow: boolean;
  61724. /**
  61725. * Specifies whether or not the outer glow is ACTIVE in the layer.
  61726. */
  61727. outerGlow: boolean;
  61728. /**
  61729. * Specifies the horizontal size of the blur.
  61730. */
  61731. set blurHorizontalSize(value: number);
  61732. /**
  61733. * Specifies the vertical size of the blur.
  61734. */
  61735. set blurVerticalSize(value: number);
  61736. /**
  61737. * Gets the horizontal size of the blur.
  61738. */
  61739. get blurHorizontalSize(): number;
  61740. /**
  61741. * Gets the vertical size of the blur.
  61742. */
  61743. get blurVerticalSize(): number;
  61744. /**
  61745. * An event triggered when the highlight layer is being blurred.
  61746. */
  61747. onBeforeBlurObservable: Observable<HighlightLayer>;
  61748. /**
  61749. * An event triggered when the highlight layer has been blurred.
  61750. */
  61751. onAfterBlurObservable: Observable<HighlightLayer>;
  61752. private _instanceGlowingMeshStencilReference;
  61753. private _options;
  61754. private _downSamplePostprocess;
  61755. private _horizontalBlurPostprocess;
  61756. private _verticalBlurPostprocess;
  61757. private _blurTexture;
  61758. private _meshes;
  61759. private _excludedMeshes;
  61760. /**
  61761. * Instantiates a new highlight Layer and references it to the scene..
  61762. * @param name The name of the layer
  61763. * @param scene The scene to use the layer in
  61764. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  61765. */
  61766. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  61767. /**
  61768. * Get the effect name of the layer.
  61769. * @return The effect name
  61770. */
  61771. getEffectName(): string;
  61772. /**
  61773. * Create the merge effect. This is the shader use to blit the information back
  61774. * to the main canvas at the end of the scene rendering.
  61775. */
  61776. protected _createMergeEffect(): Effect;
  61777. /**
  61778. * Creates the render target textures and post processes used in the highlight layer.
  61779. */
  61780. protected _createTextureAndPostProcesses(): void;
  61781. /**
  61782. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  61783. */
  61784. needStencil(): boolean;
  61785. /**
  61786. * Checks for the readiness of the element composing the layer.
  61787. * @param subMesh the mesh to check for
  61788. * @param useInstances specify wether or not to use instances to render the mesh
  61789. * @param emissiveTexture the associated emissive texture used to generate the glow
  61790. * @return true if ready otherwise, false
  61791. */
  61792. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  61793. /**
  61794. * Implementation specific of rendering the generating effect on the main canvas.
  61795. * @param effect The effect used to render through
  61796. */
  61797. protected _internalRender(effect: Effect): void;
  61798. /**
  61799. * Returns true if the layer contains information to display, otherwise false.
  61800. */
  61801. shouldRender(): boolean;
  61802. /**
  61803. * Returns true if the mesh should render, otherwise false.
  61804. * @param mesh The mesh to render
  61805. * @returns true if it should render otherwise false
  61806. */
  61807. protected _shouldRenderMesh(mesh: Mesh): boolean;
  61808. /**
  61809. * Returns true if the mesh can be rendered, otherwise false.
  61810. * @param mesh The mesh to render
  61811. * @param material The material used on the mesh
  61812. * @returns true if it can be rendered otherwise false
  61813. */
  61814. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  61815. /**
  61816. * Adds specific effects defines.
  61817. * @param defines The defines to add specifics to.
  61818. */
  61819. protected _addCustomEffectDefines(defines: string[]): void;
  61820. /**
  61821. * Sets the required values for both the emissive texture and and the main color.
  61822. */
  61823. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  61824. /**
  61825. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  61826. * @param mesh The mesh to exclude from the highlight layer
  61827. */
  61828. addExcludedMesh(mesh: Mesh): void;
  61829. /**
  61830. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  61831. * @param mesh The mesh to highlight
  61832. */
  61833. removeExcludedMesh(mesh: Mesh): void;
  61834. /**
  61835. * Determine if a given mesh will be highlighted by the current HighlightLayer
  61836. * @param mesh mesh to test
  61837. * @returns true if the mesh will be highlighted by the current HighlightLayer
  61838. */
  61839. hasMesh(mesh: AbstractMesh): boolean;
  61840. /**
  61841. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  61842. * @param mesh The mesh to highlight
  61843. * @param color The color of the highlight
  61844. * @param glowEmissiveOnly Extract the glow from the emissive texture
  61845. */
  61846. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  61847. /**
  61848. * Remove a mesh from the highlight layer in order to make it stop glowing.
  61849. * @param mesh The mesh to highlight
  61850. */
  61851. removeMesh(mesh: Mesh): void;
  61852. /**
  61853. * Remove all the meshes currently referenced in the highlight layer
  61854. */
  61855. removeAllMeshes(): void;
  61856. /**
  61857. * Force the stencil to the normal expected value for none glowing parts
  61858. */
  61859. private _defaultStencilReference;
  61860. /**
  61861. * Free any resources and references associated to a mesh.
  61862. * Internal use
  61863. * @param mesh The mesh to free.
  61864. * @hidden
  61865. */
  61866. _disposeMesh(mesh: Mesh): void;
  61867. /**
  61868. * Dispose the highlight layer and free resources.
  61869. */
  61870. dispose(): void;
  61871. /**
  61872. * Gets the class name of the effect layer
  61873. * @returns the string with the class name of the effect layer
  61874. */
  61875. getClassName(): string;
  61876. /**
  61877. * Serializes this Highlight layer
  61878. * @returns a serialized Highlight layer object
  61879. */
  61880. serialize(): any;
  61881. /**
  61882. * Creates a Highlight layer from parsed Highlight layer data
  61883. * @param parsedHightlightLayer defines the Highlight layer data
  61884. * @param scene defines the current scene
  61885. * @param rootUrl defines the root URL containing the Highlight layer information
  61886. * @returns a parsed Highlight layer
  61887. */
  61888. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  61889. }
  61890. }
  61891. declare module "babylonjs/Layers/layerSceneComponent" {
  61892. import { Scene } from "babylonjs/scene";
  61893. import { ISceneComponent } from "babylonjs/sceneComponent";
  61894. import { Layer } from "babylonjs/Layers/layer";
  61895. import { AbstractScene } from "babylonjs/abstractScene";
  61896. module "babylonjs/abstractScene" {
  61897. interface AbstractScene {
  61898. /**
  61899. * The list of layers (background and foreground) of the scene
  61900. */
  61901. layers: Array<Layer>;
  61902. }
  61903. }
  61904. /**
  61905. * Defines the layer scene component responsible to manage any layers
  61906. * in a given scene.
  61907. */
  61908. export class LayerSceneComponent implements ISceneComponent {
  61909. /**
  61910. * The component name helpfull to identify the component in the list of scene components.
  61911. */
  61912. readonly name: string;
  61913. /**
  61914. * The scene the component belongs to.
  61915. */
  61916. scene: Scene;
  61917. private _engine;
  61918. /**
  61919. * Creates a new instance of the component for the given scene
  61920. * @param scene Defines the scene to register the component in
  61921. */
  61922. constructor(scene: Scene);
  61923. /**
  61924. * Registers the component in a given scene
  61925. */
  61926. register(): void;
  61927. /**
  61928. * Rebuilds the elements related to this component in case of
  61929. * context lost for instance.
  61930. */
  61931. rebuild(): void;
  61932. /**
  61933. * Disposes the component and the associated ressources.
  61934. */
  61935. dispose(): void;
  61936. private _draw;
  61937. private _drawCameraPredicate;
  61938. private _drawCameraBackground;
  61939. private _drawCameraForeground;
  61940. private _drawRenderTargetPredicate;
  61941. private _drawRenderTargetBackground;
  61942. private _drawRenderTargetForeground;
  61943. /**
  61944. * Adds all the elements from the container to the scene
  61945. * @param container the container holding the elements
  61946. */
  61947. addFromContainer(container: AbstractScene): void;
  61948. /**
  61949. * Removes all the elements in the container from the scene
  61950. * @param container contains the elements to remove
  61951. * @param dispose if the removed element should be disposed (default: false)
  61952. */
  61953. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  61954. }
  61955. }
  61956. declare module "babylonjs/Shaders/layer.fragment" {
  61957. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  61958. /** @hidden */
  61959. export var layerPixelShader: {
  61960. name: string;
  61961. shader: string;
  61962. };
  61963. }
  61964. declare module "babylonjs/Shaders/layer.vertex" {
  61965. /** @hidden */
  61966. export var layerVertexShader: {
  61967. name: string;
  61968. shader: string;
  61969. };
  61970. }
  61971. declare module "babylonjs/Layers/layer" {
  61972. import { Observable } from "babylonjs/Misc/observable";
  61973. import { Nullable } from "babylonjs/types";
  61974. import { Scene } from "babylonjs/scene";
  61975. import { Vector2 } from "babylonjs/Maths/math.vector";
  61976. import { Color4 } from "babylonjs/Maths/math.color";
  61977. import { Texture } from "babylonjs/Materials/Textures/texture";
  61978. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  61979. import "babylonjs/Shaders/layer.fragment";
  61980. import "babylonjs/Shaders/layer.vertex";
  61981. /**
  61982. * This represents a full screen 2d layer.
  61983. * This can be useful to display a picture in the background of your scene for instance.
  61984. * @see https://www.babylonjs-playground.com/#08A2BS#1
  61985. */
  61986. export class Layer {
  61987. /**
  61988. * Define the name of the layer.
  61989. */
  61990. name: string;
  61991. /**
  61992. * Define the texture the layer should display.
  61993. */
  61994. texture: Nullable<Texture>;
  61995. /**
  61996. * Is the layer in background or foreground.
  61997. */
  61998. isBackground: boolean;
  61999. /**
  62000. * Define the color of the layer (instead of texture).
  62001. */
  62002. color: Color4;
  62003. /**
  62004. * Define the scale of the layer in order to zoom in out of the texture.
  62005. */
  62006. scale: Vector2;
  62007. /**
  62008. * Define an offset for the layer in order to shift the texture.
  62009. */
  62010. offset: Vector2;
  62011. /**
  62012. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  62013. */
  62014. alphaBlendingMode: number;
  62015. /**
  62016. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  62017. * Alpha test will not mix with the background color in case of transparency.
  62018. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  62019. */
  62020. alphaTest: boolean;
  62021. /**
  62022. * Define a mask to restrict the layer to only some of the scene cameras.
  62023. */
  62024. layerMask: number;
  62025. /**
  62026. * Define the list of render target the layer is visible into.
  62027. */
  62028. renderTargetTextures: RenderTargetTexture[];
  62029. /**
  62030. * Define if the layer is only used in renderTarget or if it also
  62031. * renders in the main frame buffer of the canvas.
  62032. */
  62033. renderOnlyInRenderTargetTextures: boolean;
  62034. private _scene;
  62035. private _vertexBuffers;
  62036. private _indexBuffer;
  62037. private _effect;
  62038. private _previousDefines;
  62039. /**
  62040. * An event triggered when the layer is disposed.
  62041. */
  62042. onDisposeObservable: Observable<Layer>;
  62043. private _onDisposeObserver;
  62044. /**
  62045. * Back compatibility with callback before the onDisposeObservable existed.
  62046. * The set callback will be triggered when the layer has been disposed.
  62047. */
  62048. set onDispose(callback: () => void);
  62049. /**
  62050. * An event triggered before rendering the scene
  62051. */
  62052. onBeforeRenderObservable: Observable<Layer>;
  62053. private _onBeforeRenderObserver;
  62054. /**
  62055. * Back compatibility with callback before the onBeforeRenderObservable existed.
  62056. * The set callback will be triggered just before rendering the layer.
  62057. */
  62058. set onBeforeRender(callback: () => void);
  62059. /**
  62060. * An event triggered after rendering the scene
  62061. */
  62062. onAfterRenderObservable: Observable<Layer>;
  62063. private _onAfterRenderObserver;
  62064. /**
  62065. * Back compatibility with callback before the onAfterRenderObservable existed.
  62066. * The set callback will be triggered just after rendering the layer.
  62067. */
  62068. set onAfterRender(callback: () => void);
  62069. /**
  62070. * Instantiates a new layer.
  62071. * This represents a full screen 2d layer.
  62072. * This can be useful to display a picture in the background of your scene for instance.
  62073. * @see https://www.babylonjs-playground.com/#08A2BS#1
  62074. * @param name Define the name of the layer in the scene
  62075. * @param imgUrl Define the url of the texture to display in the layer
  62076. * @param scene Define the scene the layer belongs to
  62077. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  62078. * @param color Defines a color for the layer
  62079. */
  62080. constructor(
  62081. /**
  62082. * Define the name of the layer.
  62083. */
  62084. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  62085. private _createIndexBuffer;
  62086. /** @hidden */
  62087. _rebuild(): void;
  62088. /**
  62089. * Renders the layer in the scene.
  62090. */
  62091. render(): void;
  62092. /**
  62093. * Disposes and releases the associated ressources.
  62094. */
  62095. dispose(): void;
  62096. }
  62097. }
  62098. declare module "babylonjs/Layers/index" {
  62099. export * from "babylonjs/Layers/effectLayer";
  62100. export * from "babylonjs/Layers/effectLayerSceneComponent";
  62101. export * from "babylonjs/Layers/glowLayer";
  62102. export * from "babylonjs/Layers/highlightLayer";
  62103. export * from "babylonjs/Layers/layer";
  62104. export * from "babylonjs/Layers/layerSceneComponent";
  62105. }
  62106. declare module "babylonjs/Shaders/lensFlare.fragment" {
  62107. /** @hidden */
  62108. export var lensFlarePixelShader: {
  62109. name: string;
  62110. shader: string;
  62111. };
  62112. }
  62113. declare module "babylonjs/Shaders/lensFlare.vertex" {
  62114. /** @hidden */
  62115. export var lensFlareVertexShader: {
  62116. name: string;
  62117. shader: string;
  62118. };
  62119. }
  62120. declare module "babylonjs/LensFlares/lensFlareSystem" {
  62121. import { Scene } from "babylonjs/scene";
  62122. import { Vector3 } from "babylonjs/Maths/math.vector";
  62123. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62124. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  62125. import "babylonjs/Shaders/lensFlare.fragment";
  62126. import "babylonjs/Shaders/lensFlare.vertex";
  62127. import { Viewport } from "babylonjs/Maths/math.viewport";
  62128. /**
  62129. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  62130. * It is usually composed of several `lensFlare`.
  62131. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  62132. */
  62133. export class LensFlareSystem {
  62134. /**
  62135. * Define the name of the lens flare system
  62136. */
  62137. name: string;
  62138. /**
  62139. * List of lens flares used in this system.
  62140. */
  62141. lensFlares: LensFlare[];
  62142. /**
  62143. * Define a limit from the border the lens flare can be visible.
  62144. */
  62145. borderLimit: number;
  62146. /**
  62147. * Define a viewport border we do not want to see the lens flare in.
  62148. */
  62149. viewportBorder: number;
  62150. /**
  62151. * Define a predicate which could limit the list of meshes able to occlude the effect.
  62152. */
  62153. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  62154. /**
  62155. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  62156. */
  62157. layerMask: number;
  62158. /**
  62159. * Define the id of the lens flare system in the scene.
  62160. * (equal to name by default)
  62161. */
  62162. id: string;
  62163. private _scene;
  62164. private _emitter;
  62165. private _vertexBuffers;
  62166. private _indexBuffer;
  62167. private _effect;
  62168. private _positionX;
  62169. private _positionY;
  62170. private _isEnabled;
  62171. /** @hidden */
  62172. static _SceneComponentInitialization: (scene: Scene) => void;
  62173. /**
  62174. * Instantiates a lens flare system.
  62175. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  62176. * It is usually composed of several `lensFlare`.
  62177. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  62178. * @param name Define the name of the lens flare system in the scene
  62179. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  62180. * @param scene Define the scene the lens flare system belongs to
  62181. */
  62182. constructor(
  62183. /**
  62184. * Define the name of the lens flare system
  62185. */
  62186. name: string, emitter: any, scene: Scene);
  62187. /**
  62188. * Define if the lens flare system is enabled.
  62189. */
  62190. get isEnabled(): boolean;
  62191. set isEnabled(value: boolean);
  62192. /**
  62193. * Get the scene the effects belongs to.
  62194. * @returns the scene holding the lens flare system
  62195. */
  62196. getScene(): Scene;
  62197. /**
  62198. * Get the emitter of the lens flare system.
  62199. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  62200. * @returns the emitter of the lens flare system
  62201. */
  62202. getEmitter(): any;
  62203. /**
  62204. * Set the emitter of the lens flare system.
  62205. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  62206. * @param newEmitter Define the new emitter of the system
  62207. */
  62208. setEmitter(newEmitter: any): void;
  62209. /**
  62210. * Get the lens flare system emitter position.
  62211. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  62212. * @returns the position
  62213. */
  62214. getEmitterPosition(): Vector3;
  62215. /**
  62216. * @hidden
  62217. */
  62218. computeEffectivePosition(globalViewport: Viewport): boolean;
  62219. /** @hidden */
  62220. _isVisible(): boolean;
  62221. /**
  62222. * @hidden
  62223. */
  62224. render(): boolean;
  62225. /**
  62226. * Dispose and release the lens flare with its associated resources.
  62227. */
  62228. dispose(): void;
  62229. /**
  62230. * Parse a lens flare system from a JSON repressentation
  62231. * @param parsedLensFlareSystem Define the JSON to parse
  62232. * @param scene Define the scene the parsed system should be instantiated in
  62233. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  62234. * @returns the parsed system
  62235. */
  62236. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  62237. /**
  62238. * Serialize the current Lens Flare System into a JSON representation.
  62239. * @returns the serialized JSON
  62240. */
  62241. serialize(): any;
  62242. }
  62243. }
  62244. declare module "babylonjs/LensFlares/lensFlare" {
  62245. import { Nullable } from "babylonjs/types";
  62246. import { Color3 } from "babylonjs/Maths/math.color";
  62247. import { Texture } from "babylonjs/Materials/Textures/texture";
  62248. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  62249. /**
  62250. * This represents one of the lens effect in a `lensFlareSystem`.
  62251. * It controls one of the indiviual texture used in the effect.
  62252. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  62253. */
  62254. export class LensFlare {
  62255. /**
  62256. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  62257. */
  62258. size: number;
  62259. /**
  62260. * 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.
  62261. */
  62262. position: number;
  62263. /**
  62264. * Define the lens color.
  62265. */
  62266. color: Color3;
  62267. /**
  62268. * Define the lens texture.
  62269. */
  62270. texture: Nullable<Texture>;
  62271. /**
  62272. * Define the alpha mode to render this particular lens.
  62273. */
  62274. alphaMode: number;
  62275. private _system;
  62276. /**
  62277. * Creates a new Lens Flare.
  62278. * This represents one of the lens effect in a `lensFlareSystem`.
  62279. * It controls one of the indiviual texture used in the effect.
  62280. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  62281. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  62282. * @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.
  62283. * @param color Define the lens color
  62284. * @param imgUrl Define the lens texture url
  62285. * @param system Define the `lensFlareSystem` this flare is part of
  62286. * @returns The newly created Lens Flare
  62287. */
  62288. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  62289. /**
  62290. * Instantiates a new Lens Flare.
  62291. * This represents one of the lens effect in a `lensFlareSystem`.
  62292. * It controls one of the indiviual texture used in the effect.
  62293. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  62294. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  62295. * @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.
  62296. * @param color Define the lens color
  62297. * @param imgUrl Define the lens texture url
  62298. * @param system Define the `lensFlareSystem` this flare is part of
  62299. */
  62300. constructor(
  62301. /**
  62302. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  62303. */
  62304. size: number,
  62305. /**
  62306. * 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.
  62307. */
  62308. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  62309. /**
  62310. * Dispose and release the lens flare with its associated resources.
  62311. */
  62312. dispose(): void;
  62313. }
  62314. }
  62315. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  62316. import { Nullable } from "babylonjs/types";
  62317. import { Scene } from "babylonjs/scene";
  62318. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  62319. import { AbstractScene } from "babylonjs/abstractScene";
  62320. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  62321. module "babylonjs/abstractScene" {
  62322. interface AbstractScene {
  62323. /**
  62324. * The list of lens flare system added to the scene
  62325. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  62326. */
  62327. lensFlareSystems: Array<LensFlareSystem>;
  62328. /**
  62329. * Removes the given lens flare system from this scene.
  62330. * @param toRemove The lens flare system to remove
  62331. * @returns The index of the removed lens flare system
  62332. */
  62333. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  62334. /**
  62335. * Adds the given lens flare system to this scene
  62336. * @param newLensFlareSystem The lens flare system to add
  62337. */
  62338. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  62339. /**
  62340. * Gets a lens flare system using its name
  62341. * @param name defines the name to look for
  62342. * @returns the lens flare system or null if not found
  62343. */
  62344. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  62345. /**
  62346. * Gets a lens flare system using its id
  62347. * @param id defines the id to look for
  62348. * @returns the lens flare system or null if not found
  62349. */
  62350. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  62351. }
  62352. }
  62353. /**
  62354. * Defines the lens flare scene component responsible to manage any lens flares
  62355. * in a given scene.
  62356. */
  62357. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  62358. /**
  62359. * The component name helpfull to identify the component in the list of scene components.
  62360. */
  62361. readonly name: string;
  62362. /**
  62363. * The scene the component belongs to.
  62364. */
  62365. scene: Scene;
  62366. /**
  62367. * Creates a new instance of the component for the given scene
  62368. * @param scene Defines the scene to register the component in
  62369. */
  62370. constructor(scene: Scene);
  62371. /**
  62372. * Registers the component in a given scene
  62373. */
  62374. register(): void;
  62375. /**
  62376. * Rebuilds the elements related to this component in case of
  62377. * context lost for instance.
  62378. */
  62379. rebuild(): void;
  62380. /**
  62381. * Adds all the elements from the container to the scene
  62382. * @param container the container holding the elements
  62383. */
  62384. addFromContainer(container: AbstractScene): void;
  62385. /**
  62386. * Removes all the elements in the container from the scene
  62387. * @param container contains the elements to remove
  62388. * @param dispose if the removed element should be disposed (default: false)
  62389. */
  62390. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  62391. /**
  62392. * Serializes the component data to the specified json object
  62393. * @param serializationObject The object to serialize to
  62394. */
  62395. serialize(serializationObject: any): void;
  62396. /**
  62397. * Disposes the component and the associated ressources.
  62398. */
  62399. dispose(): void;
  62400. private _draw;
  62401. }
  62402. }
  62403. declare module "babylonjs/LensFlares/index" {
  62404. export * from "babylonjs/LensFlares/lensFlare";
  62405. export * from "babylonjs/LensFlares/lensFlareSystem";
  62406. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  62407. }
  62408. declare module "babylonjs/Shaders/depth.fragment" {
  62409. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  62410. /** @hidden */
  62411. export var depthPixelShader: {
  62412. name: string;
  62413. shader: string;
  62414. };
  62415. }
  62416. declare module "babylonjs/Shaders/depth.vertex" {
  62417. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  62418. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  62419. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  62420. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  62421. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  62422. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  62423. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  62424. /** @hidden */
  62425. export var depthVertexShader: {
  62426. name: string;
  62427. shader: string;
  62428. };
  62429. }
  62430. declare module "babylonjs/Rendering/depthRenderer" {
  62431. import { Nullable } from "babylonjs/types";
  62432. import { SubMesh } from "babylonjs/Meshes/subMesh";
  62433. import { Scene } from "babylonjs/scene";
  62434. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  62435. import { Camera } from "babylonjs/Cameras/camera";
  62436. import "babylonjs/Shaders/depth.fragment";
  62437. import "babylonjs/Shaders/depth.vertex";
  62438. /**
  62439. * This represents a depth renderer in Babylon.
  62440. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  62441. */
  62442. export class DepthRenderer {
  62443. private _scene;
  62444. private _depthMap;
  62445. private _effect;
  62446. private readonly _storeNonLinearDepth;
  62447. private readonly _clearColor;
  62448. /** Get if the depth renderer is using packed depth or not */
  62449. readonly isPacked: boolean;
  62450. private _cachedDefines;
  62451. private _camera;
  62452. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  62453. enabled: boolean;
  62454. /**
  62455. * Specifiess that the depth renderer will only be used within
  62456. * the camera it is created for.
  62457. * This can help forcing its rendering during the camera processing.
  62458. */
  62459. useOnlyInActiveCamera: boolean;
  62460. /** @hidden */
  62461. static _SceneComponentInitialization: (scene: Scene) => void;
  62462. /**
  62463. * Instantiates a depth renderer
  62464. * @param scene The scene the renderer belongs to
  62465. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  62466. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  62467. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  62468. */
  62469. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  62470. /**
  62471. * Creates the depth rendering effect and checks if the effect is ready.
  62472. * @param subMesh The submesh to be used to render the depth map of
  62473. * @param useInstances If multiple world instances should be used
  62474. * @returns if the depth renderer is ready to render the depth map
  62475. */
  62476. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  62477. /**
  62478. * Gets the texture which the depth map will be written to.
  62479. * @returns The depth map texture
  62480. */
  62481. getDepthMap(): RenderTargetTexture;
  62482. /**
  62483. * Disposes of the depth renderer.
  62484. */
  62485. dispose(): void;
  62486. }
  62487. }
  62488. declare module "babylonjs/Shaders/minmaxRedux.fragment" {
  62489. /** @hidden */
  62490. export var minmaxReduxPixelShader: {
  62491. name: string;
  62492. shader: string;
  62493. };
  62494. }
  62495. declare module "babylonjs/Misc/minMaxReducer" {
  62496. import { Nullable } from "babylonjs/types";
  62497. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  62498. import { Camera } from "babylonjs/Cameras/camera";
  62499. import { Observer } from "babylonjs/Misc/observable";
  62500. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  62501. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  62502. import { Observable } from "babylonjs/Misc/observable";
  62503. import "babylonjs/Shaders/minmaxRedux.fragment";
  62504. /**
  62505. * This class computes a min/max reduction from a texture: it means it computes the minimum
  62506. * and maximum values from all values of the texture.
  62507. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  62508. * The source values are read from the red channel of the texture.
  62509. */
  62510. export class MinMaxReducer {
  62511. /**
  62512. * Observable triggered when the computation has been performed
  62513. */
  62514. onAfterReductionPerformed: Observable<{
  62515. min: number;
  62516. max: number;
  62517. }>;
  62518. protected _camera: Camera;
  62519. protected _sourceTexture: Nullable<RenderTargetTexture>;
  62520. protected _reductionSteps: Nullable<Array<PostProcess>>;
  62521. protected _postProcessManager: PostProcessManager;
  62522. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  62523. protected _forceFullscreenViewport: boolean;
  62524. /**
  62525. * Creates a min/max reducer
  62526. * @param camera The camera to use for the post processes
  62527. */
  62528. constructor(camera: Camera);
  62529. /**
  62530. * Gets the texture used to read the values from.
  62531. */
  62532. get sourceTexture(): Nullable<RenderTargetTexture>;
  62533. /**
  62534. * Sets the source texture to read the values from.
  62535. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  62536. * because in such textures '1' value must not be taken into account to compute the maximum
  62537. * as this value is used to clear the texture.
  62538. * Note that the computation is not activated by calling this function, you must call activate() for that!
  62539. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  62540. * @param depthRedux Indicates if the texture is a depth texture or not
  62541. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  62542. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  62543. */
  62544. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  62545. /**
  62546. * Defines the refresh rate of the computation.
  62547. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  62548. */
  62549. get refreshRate(): number;
  62550. set refreshRate(value: number);
  62551. protected _activated: boolean;
  62552. /**
  62553. * Gets the activation status of the reducer
  62554. */
  62555. get activated(): boolean;
  62556. /**
  62557. * Activates the reduction computation.
  62558. * When activated, the observers registered in onAfterReductionPerformed are
  62559. * called after the compuation is performed
  62560. */
  62561. activate(): void;
  62562. /**
  62563. * Deactivates the reduction computation.
  62564. */
  62565. deactivate(): void;
  62566. /**
  62567. * Disposes the min/max reducer
  62568. * @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.
  62569. */
  62570. dispose(disposeAll?: boolean): void;
  62571. }
  62572. }
  62573. declare module "babylonjs/Misc/depthReducer" {
  62574. import { Nullable } from "babylonjs/types";
  62575. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  62576. import { Camera } from "babylonjs/Cameras/camera";
  62577. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  62578. import { MinMaxReducer } from "babylonjs/Misc/minMaxReducer";
  62579. /**
  62580. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  62581. */
  62582. export class DepthReducer extends MinMaxReducer {
  62583. private _depthRenderer;
  62584. private _depthRendererId;
  62585. /**
  62586. * Gets the depth renderer used for the computation.
  62587. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  62588. */
  62589. get depthRenderer(): Nullable<DepthRenderer>;
  62590. /**
  62591. * Creates a depth reducer
  62592. * @param camera The camera used to render the depth texture
  62593. */
  62594. constructor(camera: Camera);
  62595. /**
  62596. * Sets the depth renderer to use to generate the depth map
  62597. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  62598. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  62599. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  62600. */
  62601. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  62602. /** @hidden */
  62603. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  62604. /**
  62605. * Activates the reduction computation.
  62606. * When activated, the observers registered in onAfterReductionPerformed are
  62607. * called after the compuation is performed
  62608. */
  62609. activate(): void;
  62610. /**
  62611. * Deactivates the reduction computation.
  62612. */
  62613. deactivate(): void;
  62614. /**
  62615. * Disposes the depth reducer
  62616. * @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.
  62617. */
  62618. dispose(disposeAll?: boolean): void;
  62619. }
  62620. }
  62621. declare module "babylonjs/Lights/Shadows/cascadedShadowGenerator" {
  62622. import { Nullable } from "babylonjs/types";
  62623. import { Scene } from "babylonjs/scene";
  62624. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  62625. import { SubMesh } from "babylonjs/Meshes/subMesh";
  62626. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62627. import { Effect } from "babylonjs/Materials/effect";
  62628. import "babylonjs/Shaders/shadowMap.fragment";
  62629. import "babylonjs/Shaders/shadowMap.vertex";
  62630. import "babylonjs/Shaders/depthBoxBlur.fragment";
  62631. import { ShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  62632. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  62633. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  62634. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  62635. /**
  62636. * A CSM implementation allowing casting shadows on large scenes.
  62637. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  62638. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  62639. */
  62640. export class CascadedShadowGenerator extends ShadowGenerator {
  62641. private static readonly frustumCornersNDCSpace;
  62642. /**
  62643. * Name of the CSM class
  62644. */
  62645. static CLASSNAME: string;
  62646. /**
  62647. * Defines the default number of cascades used by the CSM.
  62648. */
  62649. static readonly DEFAULT_CASCADES_COUNT: number;
  62650. /**
  62651. * Defines the minimum number of cascades used by the CSM.
  62652. */
  62653. static readonly MIN_CASCADES_COUNT: number;
  62654. /**
  62655. * Defines the maximum number of cascades used by the CSM.
  62656. */
  62657. static readonly MAX_CASCADES_COUNT: number;
  62658. protected _validateFilter(filter: number): number;
  62659. /**
  62660. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  62661. */
  62662. penumbraDarkness: number;
  62663. private _numCascades;
  62664. /**
  62665. * Gets or set the number of cascades used by the CSM.
  62666. */
  62667. get numCascades(): number;
  62668. set numCascades(value: number);
  62669. /**
  62670. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  62671. * The trade off is that you lose some precision in the shadow rendering when enabling this setting.
  62672. */
  62673. stabilizeCascades: boolean;
  62674. private _freezeShadowCastersBoundingInfo;
  62675. private _freezeShadowCastersBoundingInfoObservable;
  62676. /**
  62677. * Enables or disables the shadow casters bounding info computation.
  62678. * If your shadow casters don't move, you can disable this feature.
  62679. * If it is enabled, the bounding box computation is done every frame.
  62680. */
  62681. get freezeShadowCastersBoundingInfo(): boolean;
  62682. set freezeShadowCastersBoundingInfo(freeze: boolean);
  62683. private _scbiMin;
  62684. private _scbiMax;
  62685. protected _computeShadowCastersBoundingInfo(): void;
  62686. protected _shadowCastersBoundingInfo: BoundingInfo;
  62687. /**
  62688. * Gets or sets the shadow casters bounding info.
  62689. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  62690. * so that the system won't overwrite the bounds you provide
  62691. */
  62692. get shadowCastersBoundingInfo(): BoundingInfo;
  62693. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  62694. protected _breaksAreDirty: boolean;
  62695. protected _minDistance: number;
  62696. protected _maxDistance: number;
  62697. /**
  62698. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  62699. *
  62700. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  62701. * If you don't know these values, simply leave them to their defaults and don't call this function.
  62702. * @param min minimal distance for the breaks (default to 0.)
  62703. * @param max maximal distance for the breaks (default to 1.)
  62704. */
  62705. setMinMaxDistance(min: number, max: number): void;
  62706. /** Gets the minimal distance used in the cascade break computation */
  62707. get minDistance(): number;
  62708. /** Gets the maximal distance used in the cascade break computation */
  62709. get maxDistance(): number;
  62710. /**
  62711. * Gets the class name of that object
  62712. * @returns "CascadedShadowGenerator"
  62713. */
  62714. getClassName(): string;
  62715. private _cascadeMinExtents;
  62716. private _cascadeMaxExtents;
  62717. /**
  62718. * Gets a cascade minimum extents
  62719. * @param cascadeIndex index of the cascade
  62720. * @returns the minimum cascade extents
  62721. */
  62722. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  62723. /**
  62724. * Gets a cascade maximum extents
  62725. * @param cascadeIndex index of the cascade
  62726. * @returns the maximum cascade extents
  62727. */
  62728. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  62729. private _cascades;
  62730. private _currentLayer;
  62731. private _viewSpaceFrustumsZ;
  62732. private _viewMatrices;
  62733. private _projectionMatrices;
  62734. private _transformMatrices;
  62735. private _transformMatricesAsArray;
  62736. private _frustumLengths;
  62737. private _lightSizeUVCorrection;
  62738. private _depthCorrection;
  62739. private _frustumCornersWorldSpace;
  62740. private _frustumCenter;
  62741. private _shadowCameraPos;
  62742. private _shadowMaxZ;
  62743. /**
  62744. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  62745. * It defaults to camera.maxZ
  62746. */
  62747. get shadowMaxZ(): number;
  62748. /**
  62749. * Sets the shadow max z distance.
  62750. */
  62751. set shadowMaxZ(value: number);
  62752. protected _debug: boolean;
  62753. /**
  62754. * Gets or sets the debug flag.
  62755. * When enabled, the cascades are materialized by different colors on the screen.
  62756. */
  62757. get debug(): boolean;
  62758. set debug(dbg: boolean);
  62759. private _depthClamp;
  62760. /**
  62761. * Gets or sets the depth clamping value.
  62762. *
  62763. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  62764. * to account for the shadow casters far away.
  62765. *
  62766. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  62767. */
  62768. get depthClamp(): boolean;
  62769. set depthClamp(value: boolean);
  62770. private _cascadeBlendPercentage;
  62771. /**
  62772. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  62773. * It defaults to 0.1 (10% blending).
  62774. */
  62775. get cascadeBlendPercentage(): number;
  62776. set cascadeBlendPercentage(value: number);
  62777. private _lambda;
  62778. /**
  62779. * Gets or set the lambda parameter.
  62780. * This parameter is used to split the camera frustum and create the cascades.
  62781. * 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.
  62782. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  62783. */
  62784. get lambda(): number;
  62785. set lambda(value: number);
  62786. /**
  62787. * Gets the view matrix corresponding to a given cascade
  62788. * @param cascadeNum cascade to retrieve the view matrix from
  62789. * @returns the cascade view matrix
  62790. */
  62791. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  62792. /**
  62793. * Gets the projection matrix corresponding to a given cascade
  62794. * @param cascadeNum cascade to retrieve the projection matrix from
  62795. * @returns the cascade projection matrix
  62796. */
  62797. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  62798. /**
  62799. * Gets the transformation matrix corresponding to a given cascade
  62800. * @param cascadeNum cascade to retrieve the transformation matrix from
  62801. * @returns the cascade transformation matrix
  62802. */
  62803. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  62804. private _depthRenderer;
  62805. /**
  62806. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  62807. *
  62808. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  62809. *
  62810. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  62811. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  62812. * @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
  62813. */
  62814. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  62815. private _depthReducer;
  62816. private _autoCalcDepthBounds;
  62817. /**
  62818. * Gets or sets the autoCalcDepthBounds property.
  62819. *
  62820. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  62821. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  62822. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  62823. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  62824. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  62825. */
  62826. get autoCalcDepthBounds(): boolean;
  62827. set autoCalcDepthBounds(value: boolean);
  62828. /**
  62829. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  62830. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  62831. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  62832. * for setting the refresh rate on the renderer yourself!
  62833. */
  62834. get autoCalcDepthBoundsRefreshRate(): number;
  62835. set autoCalcDepthBoundsRefreshRate(value: number);
  62836. /**
  62837. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  62838. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  62839. * you change the camera near/far planes!
  62840. */
  62841. splitFrustum(): void;
  62842. private _splitFrustum;
  62843. private _computeMatrices;
  62844. private _computeFrustumInWorldSpace;
  62845. private _computeCascadeFrustum;
  62846. /**
  62847. * Support test.
  62848. */
  62849. static get IsSupported(): boolean;
  62850. /** @hidden */
  62851. static _SceneComponentInitialization: (scene: Scene) => void;
  62852. /**
  62853. * Creates a Cascaded Shadow Generator object.
  62854. * A ShadowGenerator is the required tool to use the shadows.
  62855. * Each directional light casting shadows needs to use its own ShadowGenerator.
  62856. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  62857. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  62858. * @param light The directional light object generating the shadows.
  62859. * @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.
  62860. */
  62861. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  62862. protected _initializeGenerator(): void;
  62863. protected _createTargetRenderTexture(): void;
  62864. protected _initializeShadowMap(): void;
  62865. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  62866. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  62867. /**
  62868. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  62869. * @param defines Defines of the material we want to update
  62870. * @param lightIndex Index of the light in the enabled light list of the material
  62871. */
  62872. prepareDefines(defines: any, lightIndex: number): void;
  62873. /**
  62874. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  62875. * defined in the generator but impacting the effect).
  62876. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  62877. * @param effect The effect we are binfing the information for
  62878. */
  62879. bindShadowLight(lightIndex: string, effect: Effect): void;
  62880. /**
  62881. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  62882. * (eq to view projection * shadow projection matrices)
  62883. * @returns The transform matrix used to create the shadow map
  62884. */
  62885. getTransformMatrix(): Matrix;
  62886. /**
  62887. * Disposes the ShadowGenerator.
  62888. * Returns nothing.
  62889. */
  62890. dispose(): void;
  62891. /**
  62892. * Serializes the shadow generator setup to a json object.
  62893. * @returns The serialized JSON object
  62894. */
  62895. serialize(): any;
  62896. /**
  62897. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  62898. * @param parsedShadowGenerator The JSON object to parse
  62899. * @param scene The scene to create the shadow map for
  62900. * @returns The parsed shadow generator
  62901. */
  62902. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  62903. }
  62904. }
  62905. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  62906. import { Scene } from "babylonjs/scene";
  62907. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  62908. import { AbstractScene } from "babylonjs/abstractScene";
  62909. /**
  62910. * Defines the shadow generator component responsible to manage any shadow generators
  62911. * in a given scene.
  62912. */
  62913. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  62914. /**
  62915. * The component name helpfull to identify the component in the list of scene components.
  62916. */
  62917. readonly name: string;
  62918. /**
  62919. * The scene the component belongs to.
  62920. */
  62921. scene: Scene;
  62922. /**
  62923. * Creates a new instance of the component for the given scene
  62924. * @param scene Defines the scene to register the component in
  62925. */
  62926. constructor(scene: Scene);
  62927. /**
  62928. * Registers the component in a given scene
  62929. */
  62930. register(): void;
  62931. /**
  62932. * Rebuilds the elements related to this component in case of
  62933. * context lost for instance.
  62934. */
  62935. rebuild(): void;
  62936. /**
  62937. * Serializes the component data to the specified json object
  62938. * @param serializationObject The object to serialize to
  62939. */
  62940. serialize(serializationObject: any): void;
  62941. /**
  62942. * Adds all the elements from the container to the scene
  62943. * @param container the container holding the elements
  62944. */
  62945. addFromContainer(container: AbstractScene): void;
  62946. /**
  62947. * Removes all the elements in the container from the scene
  62948. * @param container contains the elements to remove
  62949. * @param dispose if the removed element should be disposed (default: false)
  62950. */
  62951. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  62952. /**
  62953. * Rebuilds the elements related to this component in case of
  62954. * context lost for instance.
  62955. */
  62956. dispose(): void;
  62957. private _gatherRenderTargets;
  62958. }
  62959. }
  62960. declare module "babylonjs/Lights/Shadows/index" {
  62961. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  62962. export * from "babylonjs/Lights/Shadows/cascadedShadowGenerator";
  62963. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  62964. }
  62965. declare module "babylonjs/Lights/pointLight" {
  62966. import { Scene } from "babylonjs/scene";
  62967. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  62968. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62969. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  62970. import { Effect } from "babylonjs/Materials/effect";
  62971. /**
  62972. * A point light is a light defined by an unique point in world space.
  62973. * The light is emitted in every direction from this point.
  62974. * A good example of a point light is a standard light bulb.
  62975. * Documentation: https://doc.babylonjs.com/babylon101/lights
  62976. */
  62977. export class PointLight extends ShadowLight {
  62978. private _shadowAngle;
  62979. /**
  62980. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  62981. * This specifies what angle the shadow will use to be created.
  62982. *
  62983. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  62984. */
  62985. get shadowAngle(): number;
  62986. /**
  62987. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  62988. * This specifies what angle the shadow will use to be created.
  62989. *
  62990. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  62991. */
  62992. set shadowAngle(value: number);
  62993. /**
  62994. * Gets the direction if it has been set.
  62995. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  62996. */
  62997. get direction(): Vector3;
  62998. /**
  62999. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  63000. */
  63001. set direction(value: Vector3);
  63002. /**
  63003. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  63004. * A PointLight emits the light in every direction.
  63005. * It can cast shadows.
  63006. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  63007. * ```javascript
  63008. * var pointLight = new PointLight("pl", camera.position, scene);
  63009. * ```
  63010. * Documentation : https://doc.babylonjs.com/babylon101/lights
  63011. * @param name The light friendly name
  63012. * @param position The position of the point light in the scene
  63013. * @param scene The scene the lights belongs to
  63014. */
  63015. constructor(name: string, position: Vector3, scene: Scene);
  63016. /**
  63017. * Returns the string "PointLight"
  63018. * @returns the class name
  63019. */
  63020. getClassName(): string;
  63021. /**
  63022. * Returns the integer 0.
  63023. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  63024. */
  63025. getTypeID(): number;
  63026. /**
  63027. * Specifies wether or not the shadowmap should be a cube texture.
  63028. * @returns true if the shadowmap needs to be a cube texture.
  63029. */
  63030. needCube(): boolean;
  63031. /**
  63032. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  63033. * @param faceIndex The index of the face we are computed the direction to generate shadow
  63034. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  63035. */
  63036. getShadowDirection(faceIndex?: number): Vector3;
  63037. /**
  63038. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  63039. * - fov = PI / 2
  63040. * - aspect ratio : 1.0
  63041. * - z-near and far equal to the active camera minZ and maxZ.
  63042. * Returns the PointLight.
  63043. */
  63044. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  63045. protected _buildUniformLayout(): void;
  63046. /**
  63047. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  63048. * @param effect The effect to update
  63049. * @param lightIndex The index of the light in the effect to update
  63050. * @returns The point light
  63051. */
  63052. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  63053. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  63054. /**
  63055. * Prepares the list of defines specific to the light type.
  63056. * @param defines the list of defines
  63057. * @param lightIndex defines the index of the light for the effect
  63058. */
  63059. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  63060. }
  63061. }
  63062. declare module "babylonjs/Lights/index" {
  63063. export * from "babylonjs/Lights/light";
  63064. export * from "babylonjs/Lights/shadowLight";
  63065. export * from "babylonjs/Lights/Shadows/index";
  63066. export * from "babylonjs/Lights/directionalLight";
  63067. export * from "babylonjs/Lights/hemisphericLight";
  63068. export * from "babylonjs/Lights/pointLight";
  63069. export * from "babylonjs/Lights/spotLight";
  63070. }
  63071. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  63072. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  63073. /**
  63074. * Header information of HDR texture files.
  63075. */
  63076. export interface HDRInfo {
  63077. /**
  63078. * The height of the texture in pixels.
  63079. */
  63080. height: number;
  63081. /**
  63082. * The width of the texture in pixels.
  63083. */
  63084. width: number;
  63085. /**
  63086. * The index of the beginning of the data in the binary file.
  63087. */
  63088. dataPosition: number;
  63089. }
  63090. /**
  63091. * This groups tools to convert HDR texture to native colors array.
  63092. */
  63093. export class HDRTools {
  63094. private static Ldexp;
  63095. private static Rgbe2float;
  63096. private static readStringLine;
  63097. /**
  63098. * Reads header information from an RGBE texture stored in a native array.
  63099. * More information on this format are available here:
  63100. * https://en.wikipedia.org/wiki/RGBE_image_format
  63101. *
  63102. * @param uint8array The binary file stored in native array.
  63103. * @return The header information.
  63104. */
  63105. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  63106. /**
  63107. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  63108. * This RGBE texture needs to store the information as a panorama.
  63109. *
  63110. * More information on this format are available here:
  63111. * https://en.wikipedia.org/wiki/RGBE_image_format
  63112. *
  63113. * @param buffer The binary file stored in an array buffer.
  63114. * @param size The expected size of the extracted cubemap.
  63115. * @return The Cube Map information.
  63116. */
  63117. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  63118. /**
  63119. * Returns the pixels data extracted from an RGBE texture.
  63120. * This pixels will be stored left to right up to down in the R G B order in one array.
  63121. *
  63122. * More information on this format are available here:
  63123. * https://en.wikipedia.org/wiki/RGBE_image_format
  63124. *
  63125. * @param uint8array The binary file stored in an array buffer.
  63126. * @param hdrInfo The header information of the file.
  63127. * @return The pixels data in RGB right to left up to down order.
  63128. */
  63129. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  63130. private static RGBE_ReadPixels_RLE;
  63131. private static RGBE_ReadPixels_NOT_RLE;
  63132. }
  63133. }
  63134. declare module "babylonjs/Materials/effectRenderer" {
  63135. import { Nullable } from "babylonjs/types";
  63136. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  63137. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  63138. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  63139. import { Viewport } from "babylonjs/Maths/math.viewport";
  63140. import { Observable } from "babylonjs/Misc/observable";
  63141. import { Effect } from "babylonjs/Materials/effect";
  63142. import "babylonjs/Shaders/postprocess.vertex";
  63143. /**
  63144. * Effect Render Options
  63145. */
  63146. export interface IEffectRendererOptions {
  63147. /**
  63148. * Defines the vertices positions.
  63149. */
  63150. positions?: number[];
  63151. /**
  63152. * Defines the indices.
  63153. */
  63154. indices?: number[];
  63155. }
  63156. /**
  63157. * Helper class to render one or more effects.
  63158. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  63159. */
  63160. export class EffectRenderer {
  63161. private engine;
  63162. private static _DefaultOptions;
  63163. private _vertexBuffers;
  63164. private _indexBuffer;
  63165. private _fullscreenViewport;
  63166. /**
  63167. * Creates an effect renderer
  63168. * @param engine the engine to use for rendering
  63169. * @param options defines the options of the effect renderer
  63170. */
  63171. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  63172. /**
  63173. * Sets the current viewport in normalized coordinates 0-1
  63174. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  63175. */
  63176. setViewport(viewport?: Viewport): void;
  63177. /**
  63178. * Binds the embedded attributes buffer to the effect.
  63179. * @param effect Defines the effect to bind the attributes for
  63180. */
  63181. bindBuffers(effect: Effect): void;
  63182. /**
  63183. * Sets the current effect wrapper to use during draw.
  63184. * The effect needs to be ready before calling this api.
  63185. * This also sets the default full screen position attribute.
  63186. * @param effectWrapper Defines the effect to draw with
  63187. */
  63188. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  63189. /**
  63190. * Restores engine states
  63191. */
  63192. restoreStates(): void;
  63193. /**
  63194. * Draws a full screen quad.
  63195. */
  63196. draw(): void;
  63197. private isRenderTargetTexture;
  63198. /**
  63199. * renders one or more effects to a specified texture
  63200. * @param effectWrapper the effect to renderer
  63201. * @param outputTexture texture to draw to, if null it will render to the screen.
  63202. */
  63203. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  63204. /**
  63205. * Disposes of the effect renderer
  63206. */
  63207. dispose(): void;
  63208. }
  63209. /**
  63210. * Options to create an EffectWrapper
  63211. */
  63212. interface EffectWrapperCreationOptions {
  63213. /**
  63214. * Engine to use to create the effect
  63215. */
  63216. engine: ThinEngine;
  63217. /**
  63218. * Fragment shader for the effect
  63219. */
  63220. fragmentShader: string;
  63221. /**
  63222. * Use the shader store instead of direct source code
  63223. */
  63224. useShaderStore?: boolean;
  63225. /**
  63226. * Vertex shader for the effect
  63227. */
  63228. vertexShader?: string;
  63229. /**
  63230. * Attributes to use in the shader
  63231. */
  63232. attributeNames?: Array<string>;
  63233. /**
  63234. * Uniforms to use in the shader
  63235. */
  63236. uniformNames?: Array<string>;
  63237. /**
  63238. * Texture sampler names to use in the shader
  63239. */
  63240. samplerNames?: Array<string>;
  63241. /**
  63242. * Defines to use in the shader
  63243. */
  63244. defines?: Array<string>;
  63245. /**
  63246. * Callback when effect is compiled
  63247. */
  63248. onCompiled?: Nullable<(effect: Effect) => void>;
  63249. /**
  63250. * The friendly name of the effect displayed in Spector.
  63251. */
  63252. name?: string;
  63253. }
  63254. /**
  63255. * Wraps an effect to be used for rendering
  63256. */
  63257. export class EffectWrapper {
  63258. /**
  63259. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  63260. */
  63261. onApplyObservable: Observable<{}>;
  63262. /**
  63263. * The underlying effect
  63264. */
  63265. effect: Effect;
  63266. /**
  63267. * Creates an effect to be renderer
  63268. * @param creationOptions options to create the effect
  63269. */
  63270. constructor(creationOptions: EffectWrapperCreationOptions);
  63271. /**
  63272. * Disposes of the effect wrapper
  63273. */
  63274. dispose(): void;
  63275. }
  63276. }
  63277. declare module "babylonjs/Shaders/hdrFiltering.vertex" {
  63278. /** @hidden */
  63279. export var hdrFilteringVertexShader: {
  63280. name: string;
  63281. shader: string;
  63282. };
  63283. }
  63284. declare module "babylonjs/Shaders/hdrFiltering.fragment" {
  63285. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  63286. import "babylonjs/Shaders/ShadersInclude/importanceSampling";
  63287. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  63288. import "babylonjs/Shaders/ShadersInclude/hdrFilteringFunctions";
  63289. /** @hidden */
  63290. export var hdrFilteringPixelShader: {
  63291. name: string;
  63292. shader: string;
  63293. };
  63294. }
  63295. declare module "babylonjs/Materials/Textures/Filtering/hdrFiltering" {
  63296. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  63297. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  63298. import { Nullable } from "babylonjs/types";
  63299. import "babylonjs/Shaders/hdrFiltering.vertex";
  63300. import "babylonjs/Shaders/hdrFiltering.fragment";
  63301. /**
  63302. * Options for texture filtering
  63303. */
  63304. interface IHDRFilteringOptions {
  63305. /**
  63306. * Scales pixel intensity for the input HDR map.
  63307. */
  63308. hdrScale?: number;
  63309. /**
  63310. * Quality of the filter. Should be `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` for prefiltering
  63311. */
  63312. quality?: number;
  63313. }
  63314. /**
  63315. * Filters HDR maps to get correct renderings of PBR reflections
  63316. */
  63317. export class HDRFiltering {
  63318. private _engine;
  63319. private _effectRenderer;
  63320. private _effectWrapper;
  63321. private _lodGenerationOffset;
  63322. private _lodGenerationScale;
  63323. /**
  63324. * Quality switch for prefiltering. Should be set to `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` unless
  63325. * you care about baking speed.
  63326. */
  63327. quality: number;
  63328. /**
  63329. * Scales pixel intensity for the input HDR map.
  63330. */
  63331. hdrScale: number;
  63332. /**
  63333. * Instantiates HDR filter for reflection maps
  63334. *
  63335. * @param engine Thin engine
  63336. * @param options Options
  63337. */
  63338. constructor(engine: ThinEngine, options?: IHDRFilteringOptions);
  63339. private _createRenderTarget;
  63340. private _prefilterInternal;
  63341. private _createEffect;
  63342. /**
  63343. * Get a value indicating if the filter is ready to be used
  63344. * @param texture Texture to filter
  63345. * @returns true if the filter is ready
  63346. */
  63347. isReady(texture: BaseTexture): boolean;
  63348. /**
  63349. * Prefilters a cube texture to have mipmap levels representing roughness values.
  63350. * Prefiltering will be invoked at the end of next rendering pass.
  63351. * This has to be done once the map is loaded, and has not been prefiltered by a third party software.
  63352. * See http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf for more information
  63353. * @param texture Texture to filter
  63354. * @param onFinished Callback when filtering is done
  63355. * @return Promise called when prefiltering is done
  63356. */
  63357. prefilter(texture: BaseTexture, onFinished?: Nullable<() => void>): Promise<unknown> | undefined;
  63358. }
  63359. }
  63360. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  63361. import { Nullable } from "babylonjs/types";
  63362. import { Scene } from "babylonjs/scene";
  63363. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  63364. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  63365. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  63366. import "babylonjs/Engines/Extensions/engine.rawTexture";
  63367. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  63368. /**
  63369. * This represents a texture coming from an HDR input.
  63370. *
  63371. * The only supported format is currently panorama picture stored in RGBE format.
  63372. * Example of such files can be found on HDRLib: http://hdrlib.com/
  63373. */
  63374. export class HDRCubeTexture extends BaseTexture {
  63375. private static _facesMapping;
  63376. private _generateHarmonics;
  63377. private _noMipmap;
  63378. private _prefilterOnLoad;
  63379. private _textureMatrix;
  63380. private _size;
  63381. private _onLoad;
  63382. private _onError;
  63383. /**
  63384. * The texture URL.
  63385. */
  63386. url: string;
  63387. protected _isBlocking: boolean;
  63388. /**
  63389. * Sets wether or not the texture is blocking during loading.
  63390. */
  63391. set isBlocking(value: boolean);
  63392. /**
  63393. * Gets wether or not the texture is blocking during loading.
  63394. */
  63395. get isBlocking(): boolean;
  63396. protected _rotationY: number;
  63397. /**
  63398. * Sets texture matrix rotation angle around Y axis in radians.
  63399. */
  63400. set rotationY(value: number);
  63401. /**
  63402. * Gets texture matrix rotation angle around Y axis radians.
  63403. */
  63404. get rotationY(): number;
  63405. /**
  63406. * Gets or sets the center of the bounding box associated with the cube texture
  63407. * It must define where the camera used to render the texture was set
  63408. */
  63409. boundingBoxPosition: Vector3;
  63410. private _boundingBoxSize;
  63411. /**
  63412. * Gets or sets the size of the bounding box associated with the cube texture
  63413. * When defined, the cubemap will switch to local mode
  63414. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  63415. * @example https://www.babylonjs-playground.com/#RNASML
  63416. */
  63417. set boundingBoxSize(value: Vector3);
  63418. get boundingBoxSize(): Vector3;
  63419. /**
  63420. * Instantiates an HDRTexture from the following parameters.
  63421. *
  63422. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  63423. * @param sceneOrEngine The scene or engine the texture will be used in
  63424. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  63425. * @param noMipmap Forces to not generate the mipmap if true
  63426. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  63427. * @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)
  63428. * @param prefilterOnLoad Prefilters HDR texture to allow use of this texture as a PBR reflection texture.
  63429. */
  63430. 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>);
  63431. /**
  63432. * Get the current class name of the texture useful for serialization or dynamic coding.
  63433. * @returns "HDRCubeTexture"
  63434. */
  63435. getClassName(): string;
  63436. /**
  63437. * Occurs when the file is raw .hdr file.
  63438. */
  63439. private loadTexture;
  63440. clone(): HDRCubeTexture;
  63441. delayLoad(): void;
  63442. /**
  63443. * Get the texture reflection matrix used to rotate/transform the reflection.
  63444. * @returns the reflection matrix
  63445. */
  63446. getReflectionTextureMatrix(): Matrix;
  63447. /**
  63448. * Set the texture reflection matrix used to rotate/transform the reflection.
  63449. * @param value Define the reflection matrix to set
  63450. */
  63451. setReflectionTextureMatrix(value: Matrix): void;
  63452. /**
  63453. * Parses a JSON representation of an HDR Texture in order to create the texture
  63454. * @param parsedTexture Define the JSON representation
  63455. * @param scene Define the scene the texture should be created in
  63456. * @param rootUrl Define the root url in case we need to load relative dependencies
  63457. * @returns the newly created texture after parsing
  63458. */
  63459. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  63460. serialize(): any;
  63461. }
  63462. }
  63463. declare module "babylonjs/Physics/physicsEngine" {
  63464. import { Nullable } from "babylonjs/types";
  63465. import { Vector3 } from "babylonjs/Maths/math.vector";
  63466. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  63467. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  63468. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  63469. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  63470. /**
  63471. * Class used to control physics engine
  63472. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  63473. */
  63474. export class PhysicsEngine implements IPhysicsEngine {
  63475. private _physicsPlugin;
  63476. /**
  63477. * Global value used to control the smallest number supported by the simulation
  63478. */
  63479. static Epsilon: number;
  63480. private _impostors;
  63481. private _joints;
  63482. private _subTimeStep;
  63483. /**
  63484. * Gets the gravity vector used by the simulation
  63485. */
  63486. gravity: Vector3;
  63487. /**
  63488. * Factory used to create the default physics plugin.
  63489. * @returns The default physics plugin
  63490. */
  63491. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  63492. /**
  63493. * Creates a new Physics Engine
  63494. * @param gravity defines the gravity vector used by the simulation
  63495. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  63496. */
  63497. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  63498. /**
  63499. * Sets the gravity vector used by the simulation
  63500. * @param gravity defines the gravity vector to use
  63501. */
  63502. setGravity(gravity: Vector3): void;
  63503. /**
  63504. * Set the time step of the physics engine.
  63505. * Default is 1/60.
  63506. * To slow it down, enter 1/600 for example.
  63507. * To speed it up, 1/30
  63508. * @param newTimeStep defines the new timestep to apply to this world.
  63509. */
  63510. setTimeStep(newTimeStep?: number): void;
  63511. /**
  63512. * Get the time step of the physics engine.
  63513. * @returns the current time step
  63514. */
  63515. getTimeStep(): number;
  63516. /**
  63517. * Set the sub time step of the physics engine.
  63518. * Default is 0 meaning there is no sub steps
  63519. * To increase physics resolution precision, set a small value (like 1 ms)
  63520. * @param subTimeStep defines the new sub timestep used for physics resolution.
  63521. */
  63522. setSubTimeStep(subTimeStep?: number): void;
  63523. /**
  63524. * Get the sub time step of the physics engine.
  63525. * @returns the current sub time step
  63526. */
  63527. getSubTimeStep(): number;
  63528. /**
  63529. * Release all resources
  63530. */
  63531. dispose(): void;
  63532. /**
  63533. * Gets the name of the current physics plugin
  63534. * @returns the name of the plugin
  63535. */
  63536. getPhysicsPluginName(): string;
  63537. /**
  63538. * Adding a new impostor for the impostor tracking.
  63539. * This will be done by the impostor itself.
  63540. * @param impostor the impostor to add
  63541. */
  63542. addImpostor(impostor: PhysicsImpostor): void;
  63543. /**
  63544. * Remove an impostor from the engine.
  63545. * This impostor and its mesh will not longer be updated by the physics engine.
  63546. * @param impostor the impostor to remove
  63547. */
  63548. removeImpostor(impostor: PhysicsImpostor): void;
  63549. /**
  63550. * Add a joint to the physics engine
  63551. * @param mainImpostor defines the main impostor to which the joint is added.
  63552. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  63553. * @param joint defines the joint that will connect both impostors.
  63554. */
  63555. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  63556. /**
  63557. * Removes a joint from the simulation
  63558. * @param mainImpostor defines the impostor used with the joint
  63559. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  63560. * @param joint defines the joint to remove
  63561. */
  63562. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  63563. /**
  63564. * Called by the scene. No need to call it.
  63565. * @param delta defines the timespam between frames
  63566. */
  63567. _step(delta: number): void;
  63568. /**
  63569. * Gets the current plugin used to run the simulation
  63570. * @returns current plugin
  63571. */
  63572. getPhysicsPlugin(): IPhysicsEnginePlugin;
  63573. /**
  63574. * Gets the list of physic impostors
  63575. * @returns an array of PhysicsImpostor
  63576. */
  63577. getImpostors(): Array<PhysicsImpostor>;
  63578. /**
  63579. * Gets the impostor for a physics enabled object
  63580. * @param object defines the object impersonated by the impostor
  63581. * @returns the PhysicsImpostor or null if not found
  63582. */
  63583. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  63584. /**
  63585. * Gets the impostor for a physics body object
  63586. * @param body defines physics body used by the impostor
  63587. * @returns the PhysicsImpostor or null if not found
  63588. */
  63589. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  63590. /**
  63591. * Does a raycast in the physics world
  63592. * @param from when should the ray start?
  63593. * @param to when should the ray end?
  63594. * @returns PhysicsRaycastResult
  63595. */
  63596. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  63597. }
  63598. }
  63599. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  63600. import { Nullable } from "babylonjs/types";
  63601. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  63602. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63603. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  63604. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  63605. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  63606. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  63607. /** @hidden */
  63608. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  63609. private _useDeltaForWorldStep;
  63610. world: any;
  63611. name: string;
  63612. private _physicsMaterials;
  63613. private _fixedTimeStep;
  63614. private _cannonRaycastResult;
  63615. private _raycastResult;
  63616. private _physicsBodysToRemoveAfterStep;
  63617. private _firstFrame;
  63618. BJSCANNON: any;
  63619. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  63620. setGravity(gravity: Vector3): void;
  63621. setTimeStep(timeStep: number): void;
  63622. getTimeStep(): number;
  63623. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  63624. private _removeMarkedPhysicsBodiesFromWorld;
  63625. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  63626. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  63627. generatePhysicsBody(impostor: PhysicsImpostor): void;
  63628. private _processChildMeshes;
  63629. removePhysicsBody(impostor: PhysicsImpostor): void;
  63630. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  63631. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  63632. private _addMaterial;
  63633. private _checkWithEpsilon;
  63634. private _createShape;
  63635. private _createHeightmap;
  63636. private _minus90X;
  63637. private _plus90X;
  63638. private _tmpPosition;
  63639. private _tmpDeltaPosition;
  63640. private _tmpUnityRotation;
  63641. private _updatePhysicsBodyTransformation;
  63642. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  63643. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  63644. isSupported(): boolean;
  63645. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  63646. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  63647. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  63648. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  63649. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  63650. getBodyMass(impostor: PhysicsImpostor): number;
  63651. getBodyFriction(impostor: PhysicsImpostor): number;
  63652. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  63653. getBodyRestitution(impostor: PhysicsImpostor): number;
  63654. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  63655. sleepBody(impostor: PhysicsImpostor): void;
  63656. wakeUpBody(impostor: PhysicsImpostor): void;
  63657. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  63658. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  63659. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  63660. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  63661. getRadius(impostor: PhysicsImpostor): number;
  63662. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  63663. dispose(): void;
  63664. private _extendNamespace;
  63665. /**
  63666. * Does a raycast in the physics world
  63667. * @param from when should the ray start?
  63668. * @param to when should the ray end?
  63669. * @returns PhysicsRaycastResult
  63670. */
  63671. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  63672. }
  63673. }
  63674. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  63675. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  63676. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  63677. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  63678. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63679. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  63680. import { Nullable } from "babylonjs/types";
  63681. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  63682. /** @hidden */
  63683. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  63684. private _useDeltaForWorldStep;
  63685. world: any;
  63686. name: string;
  63687. BJSOIMO: any;
  63688. private _raycastResult;
  63689. private _fixedTimeStep;
  63690. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, oimoInjection?: any);
  63691. setGravity(gravity: Vector3): void;
  63692. setTimeStep(timeStep: number): void;
  63693. getTimeStep(): number;
  63694. private _tmpImpostorsArray;
  63695. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  63696. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  63697. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  63698. generatePhysicsBody(impostor: PhysicsImpostor): void;
  63699. private _tmpPositionVector;
  63700. removePhysicsBody(impostor: PhysicsImpostor): void;
  63701. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  63702. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  63703. isSupported(): boolean;
  63704. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  63705. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  63706. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  63707. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  63708. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  63709. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  63710. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  63711. getBodyMass(impostor: PhysicsImpostor): number;
  63712. getBodyFriction(impostor: PhysicsImpostor): number;
  63713. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  63714. getBodyRestitution(impostor: PhysicsImpostor): number;
  63715. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  63716. sleepBody(impostor: PhysicsImpostor): void;
  63717. wakeUpBody(impostor: PhysicsImpostor): void;
  63718. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  63719. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  63720. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  63721. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  63722. getRadius(impostor: PhysicsImpostor): number;
  63723. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  63724. dispose(): void;
  63725. /**
  63726. * Does a raycast in the physics world
  63727. * @param from when should the ray start?
  63728. * @param to when should the ray end?
  63729. * @returns PhysicsRaycastResult
  63730. */
  63731. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  63732. }
  63733. }
  63734. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  63735. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  63736. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  63737. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  63738. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  63739. import { Nullable } from "babylonjs/types";
  63740. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63741. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  63742. /**
  63743. * AmmoJS Physics plugin
  63744. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  63745. * @see https://github.com/kripken/ammo.js/
  63746. */
  63747. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  63748. private _useDeltaForWorldStep;
  63749. /**
  63750. * Reference to the Ammo library
  63751. */
  63752. bjsAMMO: any;
  63753. /**
  63754. * Created ammoJS world which physics bodies are added to
  63755. */
  63756. world: any;
  63757. /**
  63758. * Name of the plugin
  63759. */
  63760. name: string;
  63761. private _timeStep;
  63762. private _fixedTimeStep;
  63763. private _maxSteps;
  63764. private _tmpQuaternion;
  63765. private _tmpAmmoTransform;
  63766. private _tmpAmmoQuaternion;
  63767. private _tmpAmmoConcreteContactResultCallback;
  63768. private _collisionConfiguration;
  63769. private _dispatcher;
  63770. private _overlappingPairCache;
  63771. private _solver;
  63772. private _softBodySolver;
  63773. private _tmpAmmoVectorA;
  63774. private _tmpAmmoVectorB;
  63775. private _tmpAmmoVectorC;
  63776. private _tmpAmmoVectorD;
  63777. private _tmpContactCallbackResult;
  63778. private _tmpAmmoVectorRCA;
  63779. private _tmpAmmoVectorRCB;
  63780. private _raycastResult;
  63781. private static readonly DISABLE_COLLISION_FLAG;
  63782. private static readonly KINEMATIC_FLAG;
  63783. private static readonly DISABLE_DEACTIVATION_FLAG;
  63784. /**
  63785. * Initializes the ammoJS plugin
  63786. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  63787. * @param ammoInjection can be used to inject your own ammo reference
  63788. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  63789. */
  63790. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  63791. /**
  63792. * Sets the gravity of the physics world (m/(s^2))
  63793. * @param gravity Gravity to set
  63794. */
  63795. setGravity(gravity: Vector3): void;
  63796. /**
  63797. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  63798. * @param timeStep timestep to use in seconds
  63799. */
  63800. setTimeStep(timeStep: number): void;
  63801. /**
  63802. * 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)
  63803. * @param fixedTimeStep fixedTimeStep to use in seconds
  63804. */
  63805. setFixedTimeStep(fixedTimeStep: number): void;
  63806. /**
  63807. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  63808. * @param maxSteps the maximum number of steps by the physics engine per frame
  63809. */
  63810. setMaxSteps(maxSteps: number): void;
  63811. /**
  63812. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  63813. * @returns the current timestep in seconds
  63814. */
  63815. getTimeStep(): number;
  63816. /**
  63817. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  63818. */
  63819. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  63820. private _isImpostorInContact;
  63821. private _isImpostorPairInContact;
  63822. private _stepSimulation;
  63823. /**
  63824. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  63825. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  63826. * After the step the babylon meshes are set to the position of the physics imposters
  63827. * @param delta amount of time to step forward
  63828. * @param impostors array of imposters to update before/after the step
  63829. */
  63830. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  63831. /**
  63832. * Update babylon mesh to match physics world object
  63833. * @param impostor imposter to match
  63834. */
  63835. private _afterSoftStep;
  63836. /**
  63837. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  63838. * @param impostor imposter to match
  63839. */
  63840. private _ropeStep;
  63841. /**
  63842. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  63843. * @param impostor imposter to match
  63844. */
  63845. private _softbodyOrClothStep;
  63846. private _tmpMatrix;
  63847. /**
  63848. * Applies an impulse on the imposter
  63849. * @param impostor imposter to apply impulse to
  63850. * @param force amount of force to be applied to the imposter
  63851. * @param contactPoint the location to apply the impulse on the imposter
  63852. */
  63853. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  63854. /**
  63855. * Applies a force on the imposter
  63856. * @param impostor imposter to apply force
  63857. * @param force amount of force to be applied to the imposter
  63858. * @param contactPoint the location to apply the force on the imposter
  63859. */
  63860. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  63861. /**
  63862. * Creates a physics body using the plugin
  63863. * @param impostor the imposter to create the physics body on
  63864. */
  63865. generatePhysicsBody(impostor: PhysicsImpostor): void;
  63866. /**
  63867. * Removes the physics body from the imposter and disposes of the body's memory
  63868. * @param impostor imposter to remove the physics body from
  63869. */
  63870. removePhysicsBody(impostor: PhysicsImpostor): void;
  63871. /**
  63872. * Generates a joint
  63873. * @param impostorJoint the imposter joint to create the joint with
  63874. */
  63875. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  63876. /**
  63877. * Removes a joint
  63878. * @param impostorJoint the imposter joint to remove the joint from
  63879. */
  63880. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  63881. private _addMeshVerts;
  63882. /**
  63883. * Initialise the soft body vertices to match its object's (mesh) vertices
  63884. * Softbody vertices (nodes) are in world space and to match this
  63885. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  63886. * @param impostor to create the softbody for
  63887. */
  63888. private _softVertexData;
  63889. /**
  63890. * Create an impostor's soft body
  63891. * @param impostor to create the softbody for
  63892. */
  63893. private _createSoftbody;
  63894. /**
  63895. * Create cloth for an impostor
  63896. * @param impostor to create the softbody for
  63897. */
  63898. private _createCloth;
  63899. /**
  63900. * Create rope for an impostor
  63901. * @param impostor to create the softbody for
  63902. */
  63903. private _createRope;
  63904. /**
  63905. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  63906. * @param impostor to create the custom physics shape for
  63907. */
  63908. private _createCustom;
  63909. private _addHullVerts;
  63910. private _createShape;
  63911. /**
  63912. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  63913. * @param impostor imposter containing the physics body and babylon object
  63914. */
  63915. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  63916. /**
  63917. * Sets the babylon object's position/rotation from the physics body's position/rotation
  63918. * @param impostor imposter containing the physics body and babylon object
  63919. * @param newPosition new position
  63920. * @param newRotation new rotation
  63921. */
  63922. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  63923. /**
  63924. * If this plugin is supported
  63925. * @returns true if its supported
  63926. */
  63927. isSupported(): boolean;
  63928. /**
  63929. * Sets the linear velocity of the physics body
  63930. * @param impostor imposter to set the velocity on
  63931. * @param velocity velocity to set
  63932. */
  63933. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  63934. /**
  63935. * Sets the angular velocity of the physics body
  63936. * @param impostor imposter to set the velocity on
  63937. * @param velocity velocity to set
  63938. */
  63939. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  63940. /**
  63941. * gets the linear velocity
  63942. * @param impostor imposter to get linear velocity from
  63943. * @returns linear velocity
  63944. */
  63945. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  63946. /**
  63947. * gets the angular velocity
  63948. * @param impostor imposter to get angular velocity from
  63949. * @returns angular velocity
  63950. */
  63951. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  63952. /**
  63953. * Sets the mass of physics body
  63954. * @param impostor imposter to set the mass on
  63955. * @param mass mass to set
  63956. */
  63957. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  63958. /**
  63959. * Gets the mass of the physics body
  63960. * @param impostor imposter to get the mass from
  63961. * @returns mass
  63962. */
  63963. getBodyMass(impostor: PhysicsImpostor): number;
  63964. /**
  63965. * Gets friction of the impostor
  63966. * @param impostor impostor to get friction from
  63967. * @returns friction value
  63968. */
  63969. getBodyFriction(impostor: PhysicsImpostor): number;
  63970. /**
  63971. * Sets friction of the impostor
  63972. * @param impostor impostor to set friction on
  63973. * @param friction friction value
  63974. */
  63975. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  63976. /**
  63977. * Gets restitution of the impostor
  63978. * @param impostor impostor to get restitution from
  63979. * @returns restitution value
  63980. */
  63981. getBodyRestitution(impostor: PhysicsImpostor): number;
  63982. /**
  63983. * Sets resitution of the impostor
  63984. * @param impostor impostor to set resitution on
  63985. * @param restitution resitution value
  63986. */
  63987. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  63988. /**
  63989. * Gets pressure inside the impostor
  63990. * @param impostor impostor to get pressure from
  63991. * @returns pressure value
  63992. */
  63993. getBodyPressure(impostor: PhysicsImpostor): number;
  63994. /**
  63995. * Sets pressure inside a soft body impostor
  63996. * Cloth and rope must remain 0 pressure
  63997. * @param impostor impostor to set pressure on
  63998. * @param pressure pressure value
  63999. */
  64000. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  64001. /**
  64002. * Gets stiffness of the impostor
  64003. * @param impostor impostor to get stiffness from
  64004. * @returns pressure value
  64005. */
  64006. getBodyStiffness(impostor: PhysicsImpostor): number;
  64007. /**
  64008. * Sets stiffness of the impostor
  64009. * @param impostor impostor to set stiffness on
  64010. * @param stiffness stiffness value from 0 to 1
  64011. */
  64012. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  64013. /**
  64014. * Gets velocityIterations of the impostor
  64015. * @param impostor impostor to get velocity iterations from
  64016. * @returns velocityIterations value
  64017. */
  64018. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  64019. /**
  64020. * Sets velocityIterations of the impostor
  64021. * @param impostor impostor to set velocity iterations on
  64022. * @param velocityIterations velocityIterations value
  64023. */
  64024. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  64025. /**
  64026. * Gets positionIterations of the impostor
  64027. * @param impostor impostor to get position iterations from
  64028. * @returns positionIterations value
  64029. */
  64030. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  64031. /**
  64032. * Sets positionIterations of the impostor
  64033. * @param impostor impostor to set position on
  64034. * @param positionIterations positionIterations value
  64035. */
  64036. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  64037. /**
  64038. * Append an anchor to a cloth object
  64039. * @param impostor is the cloth impostor to add anchor to
  64040. * @param otherImpostor is the rigid impostor to anchor to
  64041. * @param width ratio across width from 0 to 1
  64042. * @param height ratio up height from 0 to 1
  64043. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  64044. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  64045. */
  64046. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  64047. /**
  64048. * Append an hook to a rope object
  64049. * @param impostor is the rope impostor to add hook to
  64050. * @param otherImpostor is the rigid impostor to hook to
  64051. * @param length ratio along the rope from 0 to 1
  64052. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  64053. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  64054. */
  64055. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  64056. /**
  64057. * Sleeps the physics body and stops it from being active
  64058. * @param impostor impostor to sleep
  64059. */
  64060. sleepBody(impostor: PhysicsImpostor): void;
  64061. /**
  64062. * Activates the physics body
  64063. * @param impostor impostor to activate
  64064. */
  64065. wakeUpBody(impostor: PhysicsImpostor): void;
  64066. /**
  64067. * Updates the distance parameters of the joint
  64068. * @param joint joint to update
  64069. * @param maxDistance maximum distance of the joint
  64070. * @param minDistance minimum distance of the joint
  64071. */
  64072. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  64073. /**
  64074. * Sets a motor on the joint
  64075. * @param joint joint to set motor on
  64076. * @param speed speed of the motor
  64077. * @param maxForce maximum force of the motor
  64078. * @param motorIndex index of the motor
  64079. */
  64080. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  64081. /**
  64082. * Sets the motors limit
  64083. * @param joint joint to set limit on
  64084. * @param upperLimit upper limit
  64085. * @param lowerLimit lower limit
  64086. */
  64087. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  64088. /**
  64089. * Syncs the position and rotation of a mesh with the impostor
  64090. * @param mesh mesh to sync
  64091. * @param impostor impostor to update the mesh with
  64092. */
  64093. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  64094. /**
  64095. * Gets the radius of the impostor
  64096. * @param impostor impostor to get radius from
  64097. * @returns the radius
  64098. */
  64099. getRadius(impostor: PhysicsImpostor): number;
  64100. /**
  64101. * Gets the box size of the impostor
  64102. * @param impostor impostor to get box size from
  64103. * @param result the resulting box size
  64104. */
  64105. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  64106. /**
  64107. * Disposes of the impostor
  64108. */
  64109. dispose(): void;
  64110. /**
  64111. * Does a raycast in the physics world
  64112. * @param from when should the ray start?
  64113. * @param to when should the ray end?
  64114. * @returns PhysicsRaycastResult
  64115. */
  64116. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  64117. }
  64118. }
  64119. declare module "babylonjs/Probes/reflectionProbe" {
  64120. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  64121. import { Vector3 } from "babylonjs/Maths/math.vector";
  64122. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64123. import { Nullable } from "babylonjs/types";
  64124. import { Scene } from "babylonjs/scene";
  64125. module "babylonjs/abstractScene" {
  64126. interface AbstractScene {
  64127. /**
  64128. * The list of reflection probes added to the scene
  64129. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  64130. */
  64131. reflectionProbes: Array<ReflectionProbe>;
  64132. /**
  64133. * Removes the given reflection probe from this scene.
  64134. * @param toRemove The reflection probe to remove
  64135. * @returns The index of the removed reflection probe
  64136. */
  64137. removeReflectionProbe(toRemove: ReflectionProbe): number;
  64138. /**
  64139. * Adds the given reflection probe to this scene.
  64140. * @param newReflectionProbe The reflection probe to add
  64141. */
  64142. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  64143. }
  64144. }
  64145. /**
  64146. * Class used to generate realtime reflection / refraction cube textures
  64147. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  64148. */
  64149. export class ReflectionProbe {
  64150. /** defines the name of the probe */
  64151. name: string;
  64152. private _scene;
  64153. private _renderTargetTexture;
  64154. private _projectionMatrix;
  64155. private _viewMatrix;
  64156. private _target;
  64157. private _add;
  64158. private _attachedMesh;
  64159. private _invertYAxis;
  64160. /** Gets or sets probe position (center of the cube map) */
  64161. position: Vector3;
  64162. /**
  64163. * Creates a new reflection probe
  64164. * @param name defines the name of the probe
  64165. * @param size defines the texture resolution (for each face)
  64166. * @param scene defines the hosting scene
  64167. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  64168. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  64169. */
  64170. constructor(
  64171. /** defines the name of the probe */
  64172. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  64173. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  64174. get samples(): number;
  64175. set samples(value: number);
  64176. /** Gets or sets the refresh rate to use (on every frame by default) */
  64177. get refreshRate(): number;
  64178. set refreshRate(value: number);
  64179. /**
  64180. * Gets the hosting scene
  64181. * @returns a Scene
  64182. */
  64183. getScene(): Scene;
  64184. /** Gets the internal CubeTexture used to render to */
  64185. get cubeTexture(): RenderTargetTexture;
  64186. /** Gets the list of meshes to render */
  64187. get renderList(): Nullable<AbstractMesh[]>;
  64188. /**
  64189. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  64190. * @param mesh defines the mesh to attach to
  64191. */
  64192. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  64193. /**
  64194. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  64195. * @param renderingGroupId The rendering group id corresponding to its index
  64196. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  64197. */
  64198. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  64199. /**
  64200. * Clean all associated resources
  64201. */
  64202. dispose(): void;
  64203. /**
  64204. * Converts the reflection probe information to a readable string for debug purpose.
  64205. * @param fullDetails Supports for multiple levels of logging within scene loading
  64206. * @returns the human readable reflection probe info
  64207. */
  64208. toString(fullDetails?: boolean): string;
  64209. /**
  64210. * Get the class name of the relfection probe.
  64211. * @returns "ReflectionProbe"
  64212. */
  64213. getClassName(): string;
  64214. /**
  64215. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  64216. * @returns The JSON representation of the texture
  64217. */
  64218. serialize(): any;
  64219. /**
  64220. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  64221. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  64222. * @param scene Define the scene the parsed reflection probe should be instantiated in
  64223. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  64224. * @returns The parsed reflection probe if successful
  64225. */
  64226. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  64227. }
  64228. }
  64229. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  64230. /** @hidden */
  64231. export var _BabylonLoaderRegistered: boolean;
  64232. /**
  64233. * Helps setting up some configuration for the babylon file loader.
  64234. */
  64235. export class BabylonFileLoaderConfiguration {
  64236. /**
  64237. * The loader does not allow injecting custom physix engine into the plugins.
  64238. * Unfortunately in ES6, we need to manually inject them into the plugin.
  64239. * So you could set this variable to your engine import to make it work.
  64240. */
  64241. static LoaderInjectedPhysicsEngine: any;
  64242. }
  64243. }
  64244. declare module "babylonjs/Loading/Plugins/index" {
  64245. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  64246. }
  64247. declare module "babylonjs/Loading/index" {
  64248. export * from "babylonjs/Loading/loadingScreen";
  64249. export * from "babylonjs/Loading/Plugins/index";
  64250. export * from "babylonjs/Loading/sceneLoader";
  64251. export * from "babylonjs/Loading/sceneLoaderFlags";
  64252. }
  64253. declare module "babylonjs/Materials/Background/index" {
  64254. export * from "babylonjs/Materials/Background/backgroundMaterial";
  64255. }
  64256. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  64257. import { Scene } from "babylonjs/scene";
  64258. import { Color3 } from "babylonjs/Maths/math.color";
  64259. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  64260. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  64261. /**
  64262. * The Physically based simple base material of BJS.
  64263. *
  64264. * This enables better naming and convention enforcements on top of the pbrMaterial.
  64265. * It is used as the base class for both the specGloss and metalRough conventions.
  64266. */
  64267. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  64268. /**
  64269. * Number of Simultaneous lights allowed on the material.
  64270. */
  64271. maxSimultaneousLights: number;
  64272. /**
  64273. * If sets to true, disables all the lights affecting the material.
  64274. */
  64275. disableLighting: boolean;
  64276. /**
  64277. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  64278. */
  64279. environmentTexture: BaseTexture;
  64280. /**
  64281. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  64282. */
  64283. invertNormalMapX: boolean;
  64284. /**
  64285. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  64286. */
  64287. invertNormalMapY: boolean;
  64288. /**
  64289. * Normal map used in the model.
  64290. */
  64291. normalTexture: BaseTexture;
  64292. /**
  64293. * Emissivie color used to self-illuminate the model.
  64294. */
  64295. emissiveColor: Color3;
  64296. /**
  64297. * Emissivie texture used to self-illuminate the model.
  64298. */
  64299. emissiveTexture: BaseTexture;
  64300. /**
  64301. * Occlusion Channel Strenght.
  64302. */
  64303. occlusionStrength: number;
  64304. /**
  64305. * Occlusion Texture of the material (adding extra occlusion effects).
  64306. */
  64307. occlusionTexture: BaseTexture;
  64308. /**
  64309. * Defines the alpha limits in alpha test mode.
  64310. */
  64311. alphaCutOff: number;
  64312. /**
  64313. * Gets the current double sided mode.
  64314. */
  64315. get doubleSided(): boolean;
  64316. /**
  64317. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  64318. */
  64319. set doubleSided(value: boolean);
  64320. /**
  64321. * Stores the pre-calculated light information of a mesh in a texture.
  64322. */
  64323. lightmapTexture: BaseTexture;
  64324. /**
  64325. * If true, the light map contains occlusion information instead of lighting info.
  64326. */
  64327. useLightmapAsShadowmap: boolean;
  64328. /**
  64329. * Instantiates a new PBRMaterial instance.
  64330. *
  64331. * @param name The material name
  64332. * @param scene The scene the material will be use in.
  64333. */
  64334. constructor(name: string, scene: Scene);
  64335. getClassName(): string;
  64336. }
  64337. }
  64338. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  64339. import { Scene } from "babylonjs/scene";
  64340. import { Color3 } from "babylonjs/Maths/math.color";
  64341. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  64342. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  64343. /**
  64344. * The PBR material of BJS following the metal roughness convention.
  64345. *
  64346. * This fits to the PBR convention in the GLTF definition:
  64347. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  64348. */
  64349. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  64350. /**
  64351. * The base color has two different interpretations depending on the value of metalness.
  64352. * When the material is a metal, the base color is the specific measured reflectance value
  64353. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  64354. * of the material.
  64355. */
  64356. baseColor: Color3;
  64357. /**
  64358. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  64359. * well as opacity information in the alpha channel.
  64360. */
  64361. baseTexture: BaseTexture;
  64362. /**
  64363. * Specifies the metallic scalar value of the material.
  64364. * Can also be used to scale the metalness values of the metallic texture.
  64365. */
  64366. metallic: number;
  64367. /**
  64368. * Specifies the roughness scalar value of the material.
  64369. * Can also be used to scale the roughness values of the metallic texture.
  64370. */
  64371. roughness: number;
  64372. /**
  64373. * Texture containing both the metallic value in the B channel and the
  64374. * roughness value in the G channel to keep better precision.
  64375. */
  64376. metallicRoughnessTexture: BaseTexture;
  64377. /**
  64378. * Instantiates a new PBRMetalRoughnessMaterial instance.
  64379. *
  64380. * @param name The material name
  64381. * @param scene The scene the material will be use in.
  64382. */
  64383. constructor(name: string, scene: Scene);
  64384. /**
  64385. * Return the currrent class name of the material.
  64386. */
  64387. getClassName(): string;
  64388. /**
  64389. * Makes a duplicate of the current material.
  64390. * @param name - name to use for the new material.
  64391. */
  64392. clone(name: string): PBRMetallicRoughnessMaterial;
  64393. /**
  64394. * Serialize the material to a parsable JSON object.
  64395. */
  64396. serialize(): any;
  64397. /**
  64398. * Parses a JSON object correponding to the serialize function.
  64399. */
  64400. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  64401. }
  64402. }
  64403. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  64404. import { Scene } from "babylonjs/scene";
  64405. import { Color3 } from "babylonjs/Maths/math.color";
  64406. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  64407. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  64408. /**
  64409. * The PBR material of BJS following the specular glossiness convention.
  64410. *
  64411. * This fits to the PBR convention in the GLTF definition:
  64412. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  64413. */
  64414. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  64415. /**
  64416. * Specifies the diffuse color of the material.
  64417. */
  64418. diffuseColor: Color3;
  64419. /**
  64420. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  64421. * channel.
  64422. */
  64423. diffuseTexture: BaseTexture;
  64424. /**
  64425. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  64426. */
  64427. specularColor: Color3;
  64428. /**
  64429. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  64430. */
  64431. glossiness: number;
  64432. /**
  64433. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  64434. */
  64435. specularGlossinessTexture: BaseTexture;
  64436. /**
  64437. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  64438. *
  64439. * @param name The material name
  64440. * @param scene The scene the material will be use in.
  64441. */
  64442. constructor(name: string, scene: Scene);
  64443. /**
  64444. * Return the currrent class name of the material.
  64445. */
  64446. getClassName(): string;
  64447. /**
  64448. * Makes a duplicate of the current material.
  64449. * @param name - name to use for the new material.
  64450. */
  64451. clone(name: string): PBRSpecularGlossinessMaterial;
  64452. /**
  64453. * Serialize the material to a parsable JSON object.
  64454. */
  64455. serialize(): any;
  64456. /**
  64457. * Parses a JSON object correponding to the serialize function.
  64458. */
  64459. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  64460. }
  64461. }
  64462. declare module "babylonjs/Materials/PBR/index" {
  64463. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  64464. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  64465. export * from "babylonjs/Materials/PBR/pbrMaterial";
  64466. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  64467. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  64468. }
  64469. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  64470. import { Nullable } from "babylonjs/types";
  64471. import { Scene } from "babylonjs/scene";
  64472. import { Matrix } from "babylonjs/Maths/math.vector";
  64473. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  64474. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  64475. import "babylonjs/Engines/Extensions/engine.rawTexture";
  64476. /**
  64477. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  64478. * It can help converting any input color in a desired output one. This can then be used to create effects
  64479. * from sepia, black and white to sixties or futuristic rendering...
  64480. *
  64481. * The only supported format is currently 3dl.
  64482. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  64483. */
  64484. export class ColorGradingTexture extends BaseTexture {
  64485. /**
  64486. * The texture URL.
  64487. */
  64488. url: string;
  64489. /**
  64490. * Empty line regex stored for GC.
  64491. */
  64492. private static _noneEmptyLineRegex;
  64493. private _textureMatrix;
  64494. private _onLoad;
  64495. /**
  64496. * Instantiates a ColorGradingTexture from the following parameters.
  64497. *
  64498. * @param url The location of the color gradind data (currently only supporting 3dl)
  64499. * @param sceneOrEngine The scene or engine the texture will be used in
  64500. * @param onLoad defines a callback triggered when the texture has been loaded
  64501. */
  64502. constructor(url: string, sceneOrEngine: Scene | ThinEngine, onLoad?: Nullable<() => void>);
  64503. /**
  64504. * Fires the onload event from the constructor if requested.
  64505. */
  64506. private _triggerOnLoad;
  64507. /**
  64508. * Returns the texture matrix used in most of the material.
  64509. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  64510. */
  64511. getTextureMatrix(): Matrix;
  64512. /**
  64513. * Occurs when the file being loaded is a .3dl LUT file.
  64514. */
  64515. private load3dlTexture;
  64516. /**
  64517. * Starts the loading process of the texture.
  64518. */
  64519. private loadTexture;
  64520. /**
  64521. * Clones the color gradind texture.
  64522. */
  64523. clone(): ColorGradingTexture;
  64524. /**
  64525. * Called during delayed load for textures.
  64526. */
  64527. delayLoad(): void;
  64528. /**
  64529. * Parses a color grading texture serialized by Babylon.
  64530. * @param parsedTexture The texture information being parsedTexture
  64531. * @param scene The scene to load the texture in
  64532. * @param rootUrl The root url of the data assets to load
  64533. * @return A color gradind texture
  64534. */
  64535. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  64536. /**
  64537. * Serializes the LUT texture to json format.
  64538. */
  64539. serialize(): any;
  64540. }
  64541. }
  64542. declare module "babylonjs/Materials/Textures/equiRectangularCubeTexture" {
  64543. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  64544. import { Scene } from "babylonjs/scene";
  64545. import { Nullable } from "babylonjs/types";
  64546. import "babylonjs/Engines/Extensions/engine.rawTexture";
  64547. /**
  64548. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  64549. */
  64550. export class EquiRectangularCubeTexture extends BaseTexture {
  64551. /** The six faces of the cube. */
  64552. private static _FacesMapping;
  64553. private _noMipmap;
  64554. private _onLoad;
  64555. private _onError;
  64556. /** The size of the cubemap. */
  64557. private _size;
  64558. /** The buffer of the image. */
  64559. private _buffer;
  64560. /** The width of the input image. */
  64561. private _width;
  64562. /** The height of the input image. */
  64563. private _height;
  64564. /** The URL to the image. */
  64565. url: string;
  64566. /**
  64567. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  64568. * @param url The location of the image
  64569. * @param scene The scene the texture will be used in
  64570. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  64571. * @param noMipmap Forces to not generate the mipmap if true
  64572. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  64573. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  64574. * @param onLoad — defines a callback called when texture is loaded
  64575. * @param onError — defines a callback called if there is an error
  64576. */
  64577. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  64578. /**
  64579. * Load the image data, by putting the image on a canvas and extracting its buffer.
  64580. */
  64581. private loadImage;
  64582. /**
  64583. * Convert the image buffer into a cubemap and create a CubeTexture.
  64584. */
  64585. private loadTexture;
  64586. /**
  64587. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  64588. * @param buffer The ArrayBuffer that should be converted.
  64589. * @returns The buffer as Float32Array.
  64590. */
  64591. private getFloat32ArrayFromArrayBuffer;
  64592. /**
  64593. * Get the current class name of the texture useful for serialization or dynamic coding.
  64594. * @returns "EquiRectangularCubeTexture"
  64595. */
  64596. getClassName(): string;
  64597. /**
  64598. * Create a clone of the current EquiRectangularCubeTexture and return it.
  64599. * @returns A clone of the current EquiRectangularCubeTexture.
  64600. */
  64601. clone(): EquiRectangularCubeTexture;
  64602. }
  64603. }
  64604. declare module "babylonjs/Materials/Textures/htmlElementTexture" {
  64605. import { Nullable } from "babylonjs/types";
  64606. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  64607. import { Matrix } from "babylonjs/Maths/math.vector";
  64608. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  64609. import "babylonjs/Engines/Extensions/engine.videoTexture";
  64610. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  64611. import { Scene } from "babylonjs/scene";
  64612. /**
  64613. * Defines the options related to the creation of an HtmlElementTexture
  64614. */
  64615. export interface IHtmlElementTextureOptions {
  64616. /**
  64617. * Defines wether mip maps should be created or not.
  64618. */
  64619. generateMipMaps?: boolean;
  64620. /**
  64621. * Defines the sampling mode of the texture.
  64622. */
  64623. samplingMode?: number;
  64624. /**
  64625. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  64626. */
  64627. engine: Nullable<ThinEngine>;
  64628. /**
  64629. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  64630. */
  64631. scene: Nullable<Scene>;
  64632. }
  64633. /**
  64634. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  64635. * To be as efficient as possible depending on your constraints nothing aside the first upload
  64636. * is automatically managed.
  64637. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  64638. * in your application.
  64639. *
  64640. * As the update is not automatic, you need to call them manually.
  64641. */
  64642. export class HtmlElementTexture extends BaseTexture {
  64643. /**
  64644. * The texture URL.
  64645. */
  64646. element: HTMLVideoElement | HTMLCanvasElement;
  64647. private static readonly DefaultOptions;
  64648. private _textureMatrix;
  64649. private _isVideo;
  64650. private _generateMipMaps;
  64651. private _samplingMode;
  64652. /**
  64653. * Instantiates a HtmlElementTexture from the following parameters.
  64654. *
  64655. * @param name Defines the name of the texture
  64656. * @param element Defines the video or canvas the texture is filled with
  64657. * @param options Defines the other none mandatory texture creation options
  64658. */
  64659. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  64660. private _createInternalTexture;
  64661. /**
  64662. * Returns the texture matrix used in most of the material.
  64663. */
  64664. getTextureMatrix(): Matrix;
  64665. /**
  64666. * Updates the content of the texture.
  64667. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  64668. */
  64669. update(invertY?: Nullable<boolean>): void;
  64670. }
  64671. }
  64672. declare module "babylonjs/Misc/tga" {
  64673. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  64674. /**
  64675. * Based on jsTGALoader - Javascript loader for TGA file
  64676. * By Vincent Thibault
  64677. * @see http://blog.robrowser.com/javascript-tga-loader.html
  64678. */
  64679. export class TGATools {
  64680. private static _TYPE_INDEXED;
  64681. private static _TYPE_RGB;
  64682. private static _TYPE_GREY;
  64683. private static _TYPE_RLE_INDEXED;
  64684. private static _TYPE_RLE_RGB;
  64685. private static _TYPE_RLE_GREY;
  64686. private static _ORIGIN_MASK;
  64687. private static _ORIGIN_SHIFT;
  64688. private static _ORIGIN_BL;
  64689. private static _ORIGIN_BR;
  64690. private static _ORIGIN_UL;
  64691. private static _ORIGIN_UR;
  64692. /**
  64693. * Gets the header of a TGA file
  64694. * @param data defines the TGA data
  64695. * @returns the header
  64696. */
  64697. static GetTGAHeader(data: Uint8Array): any;
  64698. /**
  64699. * Uploads TGA content to a Babylon Texture
  64700. * @hidden
  64701. */
  64702. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  64703. /** @hidden */
  64704. 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;
  64705. /** @hidden */
  64706. 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;
  64707. /** @hidden */
  64708. 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;
  64709. /** @hidden */
  64710. 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;
  64711. /** @hidden */
  64712. 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;
  64713. /** @hidden */
  64714. 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;
  64715. }
  64716. }
  64717. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  64718. import { Nullable } from "babylonjs/types";
  64719. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  64720. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  64721. /**
  64722. * Implementation of the TGA Texture Loader.
  64723. * @hidden
  64724. */
  64725. export class _TGATextureLoader implements IInternalTextureLoader {
  64726. /**
  64727. * Defines wether the loader supports cascade loading the different faces.
  64728. */
  64729. readonly supportCascades: boolean;
  64730. /**
  64731. * This returns if the loader support the current file information.
  64732. * @param extension defines the file extension of the file being loaded
  64733. * @returns true if the loader can load the specified file
  64734. */
  64735. canLoad(extension: string): boolean;
  64736. /**
  64737. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  64738. * @param data contains the texture data
  64739. * @param texture defines the BabylonJS internal texture
  64740. * @param createPolynomials will be true if polynomials have been requested
  64741. * @param onLoad defines the callback to trigger once the texture is ready
  64742. * @param onError defines the callback to trigger in case of error
  64743. */
  64744. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  64745. /**
  64746. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  64747. * @param data contains the texture data
  64748. * @param texture defines the BabylonJS internal texture
  64749. * @param callback defines the method to call once ready to upload
  64750. */
  64751. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  64752. }
  64753. }
  64754. declare module "babylonjs/Misc/basis" {
  64755. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  64756. /**
  64757. * Info about the .basis files
  64758. */
  64759. class BasisFileInfo {
  64760. /**
  64761. * If the file has alpha
  64762. */
  64763. hasAlpha: boolean;
  64764. /**
  64765. * Info about each image of the basis file
  64766. */
  64767. images: Array<{
  64768. levels: Array<{
  64769. width: number;
  64770. height: number;
  64771. transcodedPixels: ArrayBufferView;
  64772. }>;
  64773. }>;
  64774. }
  64775. /**
  64776. * Result of transcoding a basis file
  64777. */
  64778. class TranscodeResult {
  64779. /**
  64780. * Info about the .basis file
  64781. */
  64782. fileInfo: BasisFileInfo;
  64783. /**
  64784. * Format to use when loading the file
  64785. */
  64786. format: number;
  64787. }
  64788. /**
  64789. * Configuration options for the Basis transcoder
  64790. */
  64791. export class BasisTranscodeConfiguration {
  64792. /**
  64793. * Supported compression formats used to determine the supported output format of the transcoder
  64794. */
  64795. supportedCompressionFormats?: {
  64796. /**
  64797. * etc1 compression format
  64798. */
  64799. etc1?: boolean;
  64800. /**
  64801. * s3tc compression format
  64802. */
  64803. s3tc?: boolean;
  64804. /**
  64805. * pvrtc compression format
  64806. */
  64807. pvrtc?: boolean;
  64808. /**
  64809. * etc2 compression format
  64810. */
  64811. etc2?: boolean;
  64812. };
  64813. /**
  64814. * If mipmap levels should be loaded for transcoded images (Default: true)
  64815. */
  64816. loadMipmapLevels?: boolean;
  64817. /**
  64818. * Index of a single image to load (Default: all images)
  64819. */
  64820. loadSingleImage?: number;
  64821. }
  64822. /**
  64823. * Used to load .Basis files
  64824. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  64825. */
  64826. export class BasisTools {
  64827. private static _IgnoreSupportedFormats;
  64828. /**
  64829. * URL to use when loading the basis transcoder
  64830. */
  64831. static JSModuleURL: string;
  64832. /**
  64833. * URL to use when loading the wasm module for the transcoder
  64834. */
  64835. static WasmModuleURL: string;
  64836. /**
  64837. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  64838. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  64839. * @returns internal format corresponding to the Basis format
  64840. */
  64841. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  64842. private static _WorkerPromise;
  64843. private static _Worker;
  64844. private static _actionId;
  64845. private static _CreateWorkerAsync;
  64846. /**
  64847. * Transcodes a loaded image file to compressed pixel data
  64848. * @param data image data to transcode
  64849. * @param config configuration options for the transcoding
  64850. * @returns a promise resulting in the transcoded image
  64851. */
  64852. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  64853. /**
  64854. * Loads a texture from the transcode result
  64855. * @param texture texture load to
  64856. * @param transcodeResult the result of transcoding the basis file to load from
  64857. */
  64858. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  64859. }
  64860. }
  64861. declare module "babylonjs/Materials/Textures/Loaders/basisTextureLoader" {
  64862. import { Nullable } from "babylonjs/types";
  64863. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  64864. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  64865. /**
  64866. * Loader for .basis file format
  64867. */
  64868. export class _BasisTextureLoader implements IInternalTextureLoader {
  64869. /**
  64870. * Defines whether the loader supports cascade loading the different faces.
  64871. */
  64872. readonly supportCascades: boolean;
  64873. /**
  64874. * This returns if the loader support the current file information.
  64875. * @param extension defines the file extension of the file being loaded
  64876. * @returns true if the loader can load the specified file
  64877. */
  64878. canLoad(extension: string): boolean;
  64879. /**
  64880. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  64881. * @param data contains the texture data
  64882. * @param texture defines the BabylonJS internal texture
  64883. * @param createPolynomials will be true if polynomials have been requested
  64884. * @param onLoad defines the callback to trigger once the texture is ready
  64885. * @param onError defines the callback to trigger in case of error
  64886. */
  64887. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  64888. /**
  64889. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  64890. * @param data contains the texture data
  64891. * @param texture defines the BabylonJS internal texture
  64892. * @param callback defines the method to call once ready to upload
  64893. */
  64894. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  64895. }
  64896. }
  64897. declare module "babylonjs/Materials/Textures/Loaders/index" {
  64898. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  64899. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  64900. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  64901. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  64902. export * from "babylonjs/Materials/Textures/Loaders/basisTextureLoader";
  64903. }
  64904. declare module "babylonjs/Materials/Textures/Packer/frame" {
  64905. import { Vector2 } from "babylonjs/Maths/math.vector";
  64906. /**
  64907. * Defines the basic options interface of a TexturePacker Frame
  64908. */
  64909. export interface ITexturePackerFrame {
  64910. /**
  64911. * The frame ID
  64912. */
  64913. id: number;
  64914. /**
  64915. * The frames Scale
  64916. */
  64917. scale: Vector2;
  64918. /**
  64919. * The Frames offset
  64920. */
  64921. offset: Vector2;
  64922. }
  64923. /**
  64924. * This is a support class for frame Data on texture packer sets.
  64925. */
  64926. export class TexturePackerFrame implements ITexturePackerFrame {
  64927. /**
  64928. * The frame ID
  64929. */
  64930. id: number;
  64931. /**
  64932. * The frames Scale
  64933. */
  64934. scale: Vector2;
  64935. /**
  64936. * The Frames offset
  64937. */
  64938. offset: Vector2;
  64939. /**
  64940. * Initializes a texture package frame.
  64941. * @param id The numerical frame identifier
  64942. * @param scale Scalar Vector2 for UV frame
  64943. * @param offset Vector2 for the frame position in UV units.
  64944. * @returns TexturePackerFrame
  64945. */
  64946. constructor(id: number, scale: Vector2, offset: Vector2);
  64947. }
  64948. }
  64949. declare module "babylonjs/Materials/Textures/Packer/packer" {
  64950. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64951. import { Scene } from "babylonjs/scene";
  64952. import { Nullable } from "babylonjs/types";
  64953. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  64954. import { TexturePackerFrame } from "babylonjs/Materials/Textures/Packer/frame";
  64955. /**
  64956. * Defines the basic options interface of a TexturePacker
  64957. */
  64958. export interface ITexturePackerOptions {
  64959. /**
  64960. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  64961. */
  64962. map?: string[];
  64963. /**
  64964. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  64965. */
  64966. uvsIn?: string;
  64967. /**
  64968. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  64969. */
  64970. uvsOut?: string;
  64971. /**
  64972. * number representing the layout style. Defaults to LAYOUT_STRIP
  64973. */
  64974. layout?: number;
  64975. /**
  64976. * number of columns if using custom column count layout(2). This defaults to 4.
  64977. */
  64978. colnum?: number;
  64979. /**
  64980. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  64981. */
  64982. updateInputMeshes?: boolean;
  64983. /**
  64984. * boolean flag to dispose all the source textures. Defaults to true.
  64985. */
  64986. disposeSources?: boolean;
  64987. /**
  64988. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  64989. */
  64990. fillBlanks?: boolean;
  64991. /**
  64992. * string value representing the context fill style color. Defaults to 'black'.
  64993. */
  64994. customFillColor?: string;
  64995. /**
  64996. * Width and Height Value of each Frame in the TexturePacker Sets
  64997. */
  64998. frameSize?: number;
  64999. /**
  65000. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  65001. */
  65002. paddingRatio?: number;
  65003. /**
  65004. * Number that declares the fill method for the padding gutter.
  65005. */
  65006. paddingMode?: number;
  65007. /**
  65008. * If in SUBUV_COLOR padding mode what color to use.
  65009. */
  65010. paddingColor?: Color3 | Color4;
  65011. }
  65012. /**
  65013. * Defines the basic interface of a TexturePacker JSON File
  65014. */
  65015. export interface ITexturePackerJSON {
  65016. /**
  65017. * The frame ID
  65018. */
  65019. name: string;
  65020. /**
  65021. * The base64 channel data
  65022. */
  65023. sets: any;
  65024. /**
  65025. * The options of the Packer
  65026. */
  65027. options: ITexturePackerOptions;
  65028. /**
  65029. * The frame data of the Packer
  65030. */
  65031. frames: Array<number>;
  65032. }
  65033. /**
  65034. * This is a support class that generates a series of packed texture sets.
  65035. * @see https://doc.babylonjs.com/babylon101/materials
  65036. */
  65037. export class TexturePacker {
  65038. /** Packer Layout Constant 0 */
  65039. static readonly LAYOUT_STRIP: number;
  65040. /** Packer Layout Constant 1 */
  65041. static readonly LAYOUT_POWER2: number;
  65042. /** Packer Layout Constant 2 */
  65043. static readonly LAYOUT_COLNUM: number;
  65044. /** Packer Layout Constant 0 */
  65045. static readonly SUBUV_WRAP: number;
  65046. /** Packer Layout Constant 1 */
  65047. static readonly SUBUV_EXTEND: number;
  65048. /** Packer Layout Constant 2 */
  65049. static readonly SUBUV_COLOR: number;
  65050. /** The Name of the Texture Package */
  65051. name: string;
  65052. /** The scene scope of the TexturePacker */
  65053. scene: Scene;
  65054. /** The Meshes to target */
  65055. meshes: AbstractMesh[];
  65056. /** Arguments passed with the Constructor */
  65057. options: ITexturePackerOptions;
  65058. /** The promise that is started upon initialization */
  65059. promise: Nullable<Promise<TexturePacker | string>>;
  65060. /** The Container object for the channel sets that are generated */
  65061. sets: object;
  65062. /** The Container array for the frames that are generated */
  65063. frames: TexturePackerFrame[];
  65064. /** The expected number of textures the system is parsing. */
  65065. private _expecting;
  65066. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  65067. private _paddingValue;
  65068. /**
  65069. * Initializes a texture package series from an array of meshes or a single mesh.
  65070. * @param name The name of the package
  65071. * @param meshes The target meshes to compose the package from
  65072. * @param options The arguments that texture packer should follow while building.
  65073. * @param scene The scene which the textures are scoped to.
  65074. * @returns TexturePacker
  65075. */
  65076. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  65077. /**
  65078. * Starts the package process
  65079. * @param resolve The promises resolution function
  65080. * @returns TexturePacker
  65081. */
  65082. private _createFrames;
  65083. /**
  65084. * Calculates the Size of the Channel Sets
  65085. * @returns Vector2
  65086. */
  65087. private _calculateSize;
  65088. /**
  65089. * Calculates the UV data for the frames.
  65090. * @param baseSize the base frameSize
  65091. * @param padding the base frame padding
  65092. * @param dtSize size of the Dynamic Texture for that channel
  65093. * @param dtUnits is 1/dtSize
  65094. * @param update flag to update the input meshes
  65095. */
  65096. private _calculateMeshUVFrames;
  65097. /**
  65098. * Calculates the frames Offset.
  65099. * @param index of the frame
  65100. * @returns Vector2
  65101. */
  65102. private _getFrameOffset;
  65103. /**
  65104. * Updates a Mesh to the frame data
  65105. * @param mesh that is the target
  65106. * @param frameID or the frame index
  65107. */
  65108. private _updateMeshUV;
  65109. /**
  65110. * Updates a Meshes materials to use the texture packer channels
  65111. * @param m is the mesh to target
  65112. * @param force all channels on the packer to be set.
  65113. */
  65114. private _updateTextureReferences;
  65115. /**
  65116. * Public method to set a Mesh to a frame
  65117. * @param m that is the target
  65118. * @param frameID or the frame index
  65119. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  65120. */
  65121. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  65122. /**
  65123. * Starts the async promise to compile the texture packer.
  65124. * @returns Promise<void>
  65125. */
  65126. processAsync(): Promise<void>;
  65127. /**
  65128. * Disposes all textures associated with this packer
  65129. */
  65130. dispose(): void;
  65131. /**
  65132. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  65133. * @param imageType is the image type to use.
  65134. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  65135. */
  65136. download(imageType?: string, quality?: number): void;
  65137. /**
  65138. * Public method to load a texturePacker JSON file.
  65139. * @param data of the JSON file in string format.
  65140. */
  65141. updateFromJSON(data: string): void;
  65142. }
  65143. }
  65144. declare module "babylonjs/Materials/Textures/Packer/index" {
  65145. export * from "babylonjs/Materials/Textures/Packer/packer";
  65146. export * from "babylonjs/Materials/Textures/Packer/frame";
  65147. }
  65148. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  65149. import { Scene } from "babylonjs/scene";
  65150. import { Texture } from "babylonjs/Materials/Textures/texture";
  65151. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  65152. /**
  65153. * 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.
  65154. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  65155. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  65156. */
  65157. export class CustomProceduralTexture extends ProceduralTexture {
  65158. private _animate;
  65159. private _time;
  65160. private _config;
  65161. private _texturePath;
  65162. /**
  65163. * Instantiates a new Custom Procedural Texture.
  65164. * 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.
  65165. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  65166. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  65167. * @param name Define the name of the texture
  65168. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  65169. * @param size Define the size of the texture to create
  65170. * @param scene Define the scene the texture belongs to
  65171. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  65172. * @param generateMipMaps Define if the texture should creates mip maps or not
  65173. */
  65174. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  65175. private _loadJson;
  65176. /**
  65177. * Is the texture ready to be used ? (rendered at least once)
  65178. * @returns true if ready, otherwise, false.
  65179. */
  65180. isReady(): boolean;
  65181. /**
  65182. * Render the texture to its associated render target.
  65183. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  65184. */
  65185. render(useCameraPostProcess?: boolean): void;
  65186. /**
  65187. * Update the list of dependant textures samplers in the shader.
  65188. */
  65189. updateTextures(): void;
  65190. /**
  65191. * Update the uniform values of the procedural texture in the shader.
  65192. */
  65193. updateShaderUniforms(): void;
  65194. /**
  65195. * Define if the texture animates or not.
  65196. */
  65197. get animate(): boolean;
  65198. set animate(value: boolean);
  65199. }
  65200. }
  65201. declare module "babylonjs/Shaders/noise.fragment" {
  65202. /** @hidden */
  65203. export var noisePixelShader: {
  65204. name: string;
  65205. shader: string;
  65206. };
  65207. }
  65208. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  65209. import { Nullable } from "babylonjs/types";
  65210. import { Scene } from "babylonjs/scene";
  65211. import { Texture } from "babylonjs/Materials/Textures/texture";
  65212. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  65213. import "babylonjs/Shaders/noise.fragment";
  65214. /**
  65215. * Class used to generate noise procedural textures
  65216. */
  65217. export class NoiseProceduralTexture extends ProceduralTexture {
  65218. /** Gets or sets the start time (default is 0) */
  65219. time: number;
  65220. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  65221. brightness: number;
  65222. /** Defines the number of octaves to process */
  65223. octaves: number;
  65224. /** Defines the level of persistence (0.8 by default) */
  65225. persistence: number;
  65226. /** Gets or sets animation speed factor (default is 1) */
  65227. animationSpeedFactor: number;
  65228. /**
  65229. * Creates a new NoiseProceduralTexture
  65230. * @param name defines the name fo the texture
  65231. * @param size defines the size of the texture (default is 256)
  65232. * @param scene defines the hosting scene
  65233. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  65234. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  65235. */
  65236. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  65237. private _updateShaderUniforms;
  65238. protected _getDefines(): string;
  65239. /** Generate the current state of the procedural texture */
  65240. render(useCameraPostProcess?: boolean): void;
  65241. /**
  65242. * Serializes this noise procedural texture
  65243. * @returns a serialized noise procedural texture object
  65244. */
  65245. serialize(): any;
  65246. /**
  65247. * Clone the texture.
  65248. * @returns the cloned texture
  65249. */
  65250. clone(): NoiseProceduralTexture;
  65251. /**
  65252. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  65253. * @param parsedTexture defines parsed texture data
  65254. * @param scene defines the current scene
  65255. * @param rootUrl defines the root URL containing noise procedural texture information
  65256. * @returns a parsed NoiseProceduralTexture
  65257. */
  65258. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  65259. }
  65260. }
  65261. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  65262. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  65263. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  65264. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  65265. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  65266. }
  65267. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  65268. import { Nullable } from "babylonjs/types";
  65269. import { Scene } from "babylonjs/scene";
  65270. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  65271. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  65272. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  65273. import "babylonjs/Engines/Extensions/engine.rawTexture";
  65274. /**
  65275. * Raw cube texture where the raw buffers are passed in
  65276. */
  65277. export class RawCubeTexture extends CubeTexture {
  65278. /**
  65279. * Creates a cube texture where the raw buffers are passed in.
  65280. * @param scene defines the scene the texture is attached to
  65281. * @param data defines the array of data to use to create each face
  65282. * @param size defines the size of the textures
  65283. * @param format defines the format of the data
  65284. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  65285. * @param generateMipMaps defines if the engine should generate the mip levels
  65286. * @param invertY defines if data must be stored with Y axis inverted
  65287. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  65288. * @param compression defines the compression used (null by default)
  65289. */
  65290. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  65291. /**
  65292. * Updates the raw cube texture.
  65293. * @param data defines the data to store
  65294. * @param format defines the data format
  65295. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  65296. * @param invertY defines if data must be stored with Y axis inverted
  65297. * @param compression defines the compression used (null by default)
  65298. * @param level defines which level of the texture to update
  65299. */
  65300. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  65301. /**
  65302. * Updates a raw cube texture with RGBD encoded data.
  65303. * @param data defines the array of data [mipmap][face] to use to create each face
  65304. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  65305. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  65306. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  65307. * @returns a promsie that resolves when the operation is complete
  65308. */
  65309. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  65310. /**
  65311. * Clones the raw cube texture.
  65312. * @return a new cube texture
  65313. */
  65314. clone(): CubeTexture;
  65315. /** @hidden */
  65316. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  65317. }
  65318. }
  65319. declare module "babylonjs/Materials/Textures/rawTexture2DArray" {
  65320. import { Scene } from "babylonjs/scene";
  65321. import { Texture } from "babylonjs/Materials/Textures/texture";
  65322. import "babylonjs/Engines/Extensions/engine.rawTexture";
  65323. /**
  65324. * Class used to store 2D array textures containing user data
  65325. */
  65326. export class RawTexture2DArray extends Texture {
  65327. /** Gets or sets the texture format to use */
  65328. format: number;
  65329. /**
  65330. * Create a new RawTexture2DArray
  65331. * @param data defines the data of the texture
  65332. * @param width defines the width of the texture
  65333. * @param height defines the height of the texture
  65334. * @param depth defines the number of layers of the texture
  65335. * @param format defines the texture format to use
  65336. * @param scene defines the hosting scene
  65337. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  65338. * @param invertY defines if texture must be stored with Y axis inverted
  65339. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  65340. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  65341. */
  65342. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  65343. /** Gets or sets the texture format to use */
  65344. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  65345. /**
  65346. * Update the texture with new data
  65347. * @param data defines the data to store in the texture
  65348. */
  65349. update(data: ArrayBufferView): void;
  65350. }
  65351. }
  65352. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  65353. import { Scene } from "babylonjs/scene";
  65354. import { Texture } from "babylonjs/Materials/Textures/texture";
  65355. import "babylonjs/Engines/Extensions/engine.rawTexture";
  65356. /**
  65357. * Class used to store 3D textures containing user data
  65358. */
  65359. export class RawTexture3D extends Texture {
  65360. /** Gets or sets the texture format to use */
  65361. format: number;
  65362. /**
  65363. * Create a new RawTexture3D
  65364. * @param data defines the data of the texture
  65365. * @param width defines the width of the texture
  65366. * @param height defines the height of the texture
  65367. * @param depth defines the depth of the texture
  65368. * @param format defines the texture format to use
  65369. * @param scene defines the hosting scene
  65370. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  65371. * @param invertY defines if texture must be stored with Y axis inverted
  65372. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  65373. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  65374. */
  65375. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  65376. /** Gets or sets the texture format to use */
  65377. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  65378. /**
  65379. * Update the texture with new data
  65380. * @param data defines the data to store in the texture
  65381. */
  65382. update(data: ArrayBufferView): void;
  65383. }
  65384. }
  65385. declare module "babylonjs/Materials/Textures/refractionTexture" {
  65386. import { Scene } from "babylonjs/scene";
  65387. import { Plane } from "babylonjs/Maths/math.plane";
  65388. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  65389. /**
  65390. * Creates a refraction texture used by refraction channel of the standard material.
  65391. * It is like a mirror but to see through a material.
  65392. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  65393. */
  65394. export class RefractionTexture extends RenderTargetTexture {
  65395. /**
  65396. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  65397. * 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.
  65398. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  65399. */
  65400. refractionPlane: Plane;
  65401. /**
  65402. * Define how deep under the surface we should see.
  65403. */
  65404. depth: number;
  65405. /**
  65406. * Creates a refraction texture used by refraction channel of the standard material.
  65407. * It is like a mirror but to see through a material.
  65408. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  65409. * @param name Define the texture name
  65410. * @param size Define the size of the underlying texture
  65411. * @param scene Define the scene the refraction belongs to
  65412. * @param generateMipMaps Define if we need to generate mips level for the refraction
  65413. */
  65414. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  65415. /**
  65416. * Clone the refraction texture.
  65417. * @returns the cloned texture
  65418. */
  65419. clone(): RefractionTexture;
  65420. /**
  65421. * Serialize the texture to a JSON representation you could use in Parse later on
  65422. * @returns the serialized JSON representation
  65423. */
  65424. serialize(): any;
  65425. }
  65426. }
  65427. declare module "babylonjs/Materials/Textures/index" {
  65428. export * from "babylonjs/Materials/Textures/baseTexture";
  65429. export * from "babylonjs/Materials/Textures/baseTexture.polynomial";
  65430. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  65431. export * from "babylonjs/Materials/Textures/cubeTexture";
  65432. export * from "babylonjs/Materials/Textures/dynamicTexture";
  65433. export * from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  65434. export * from "babylonjs/Materials/Textures/Filtering/hdrFiltering";
  65435. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  65436. export * from "babylonjs/Materials/Textures/htmlElementTexture";
  65437. export * from "babylonjs/Materials/Textures/internalTexture";
  65438. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  65439. export * from "babylonjs/Materials/Textures/Loaders/index";
  65440. export * from "babylonjs/Materials/Textures/mirrorTexture";
  65441. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  65442. export * from "babylonjs/Materials/Textures/Packer/index";
  65443. export * from "babylonjs/Materials/Textures/Procedurals/index";
  65444. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  65445. export * from "babylonjs/Materials/Textures/rawTexture";
  65446. export * from "babylonjs/Materials/Textures/rawTexture2DArray";
  65447. export * from "babylonjs/Materials/Textures/rawTexture3D";
  65448. export * from "babylonjs/Materials/Textures/refractionTexture";
  65449. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  65450. export * from "babylonjs/Materials/Textures/texture";
  65451. export * from "babylonjs/Materials/Textures/videoTexture";
  65452. }
  65453. declare module "babylonjs/Materials/Node/Enums/index" {
  65454. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  65455. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  65456. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode";
  65457. export * from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  65458. export * from "babylonjs/Materials/Node/Enums/nodeMaterialModes";
  65459. }
  65460. declare module "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock" {
  65461. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65462. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65463. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65464. import { Mesh } from "babylonjs/Meshes/mesh";
  65465. import { Effect } from "babylonjs/Materials/effect";
  65466. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65467. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  65468. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  65469. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  65470. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  65471. /**
  65472. * Block used to add support for vertex skinning (bones)
  65473. */
  65474. export class BonesBlock extends NodeMaterialBlock {
  65475. /**
  65476. * Creates a new BonesBlock
  65477. * @param name defines the block name
  65478. */
  65479. constructor(name: string);
  65480. /**
  65481. * Initialize the block and prepare the context for build
  65482. * @param state defines the state that will be used for the build
  65483. */
  65484. initialize(state: NodeMaterialBuildState): void;
  65485. /**
  65486. * Gets the current class name
  65487. * @returns the class name
  65488. */
  65489. getClassName(): string;
  65490. /**
  65491. * Gets the matrix indices input component
  65492. */
  65493. get matricesIndices(): NodeMaterialConnectionPoint;
  65494. /**
  65495. * Gets the matrix weights input component
  65496. */
  65497. get matricesWeights(): NodeMaterialConnectionPoint;
  65498. /**
  65499. * Gets the extra matrix indices input component
  65500. */
  65501. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  65502. /**
  65503. * Gets the extra matrix weights input component
  65504. */
  65505. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  65506. /**
  65507. * Gets the world input component
  65508. */
  65509. get world(): NodeMaterialConnectionPoint;
  65510. /**
  65511. * Gets the output component
  65512. */
  65513. get output(): NodeMaterialConnectionPoint;
  65514. autoConfigure(material: NodeMaterial): void;
  65515. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  65516. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  65517. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65518. protected _buildBlock(state: NodeMaterialBuildState): this;
  65519. }
  65520. }
  65521. declare module "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock" {
  65522. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65523. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65524. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65525. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65526. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  65527. import { SubMesh } from "babylonjs/Meshes/subMesh";
  65528. /**
  65529. * Block used to add support for instances
  65530. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  65531. */
  65532. export class InstancesBlock extends NodeMaterialBlock {
  65533. /**
  65534. * Creates a new InstancesBlock
  65535. * @param name defines the block name
  65536. */
  65537. constructor(name: string);
  65538. /**
  65539. * Gets the current class name
  65540. * @returns the class name
  65541. */
  65542. getClassName(): string;
  65543. /**
  65544. * Gets the first world row input component
  65545. */
  65546. get world0(): NodeMaterialConnectionPoint;
  65547. /**
  65548. * Gets the second world row input component
  65549. */
  65550. get world1(): NodeMaterialConnectionPoint;
  65551. /**
  65552. * Gets the third world row input component
  65553. */
  65554. get world2(): NodeMaterialConnectionPoint;
  65555. /**
  65556. * Gets the forth world row input component
  65557. */
  65558. get world3(): NodeMaterialConnectionPoint;
  65559. /**
  65560. * Gets the world input component
  65561. */
  65562. get world(): NodeMaterialConnectionPoint;
  65563. /**
  65564. * Gets the output component
  65565. */
  65566. get output(): NodeMaterialConnectionPoint;
  65567. /**
  65568. * Gets the isntanceID component
  65569. */
  65570. get instanceID(): NodeMaterialConnectionPoint;
  65571. autoConfigure(material: NodeMaterial): void;
  65572. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  65573. protected _buildBlock(state: NodeMaterialBuildState): this;
  65574. }
  65575. }
  65576. declare module "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock" {
  65577. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65578. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65579. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65580. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65581. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  65582. import { Effect } from "babylonjs/Materials/effect";
  65583. import { Mesh } from "babylonjs/Meshes/mesh";
  65584. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  65585. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  65586. /**
  65587. * Block used to add morph targets support to vertex shader
  65588. */
  65589. export class MorphTargetsBlock extends NodeMaterialBlock {
  65590. private _repeatableContentAnchor;
  65591. /**
  65592. * Create a new MorphTargetsBlock
  65593. * @param name defines the block name
  65594. */
  65595. constructor(name: string);
  65596. /**
  65597. * Gets the current class name
  65598. * @returns the class name
  65599. */
  65600. getClassName(): string;
  65601. /**
  65602. * Gets the position input component
  65603. */
  65604. get position(): NodeMaterialConnectionPoint;
  65605. /**
  65606. * Gets the normal input component
  65607. */
  65608. get normal(): NodeMaterialConnectionPoint;
  65609. /**
  65610. * Gets the tangent input component
  65611. */
  65612. get tangent(): NodeMaterialConnectionPoint;
  65613. /**
  65614. * Gets the tangent input component
  65615. */
  65616. get uv(): NodeMaterialConnectionPoint;
  65617. /**
  65618. * Gets the position output component
  65619. */
  65620. get positionOutput(): NodeMaterialConnectionPoint;
  65621. /**
  65622. * Gets the normal output component
  65623. */
  65624. get normalOutput(): NodeMaterialConnectionPoint;
  65625. /**
  65626. * Gets the tangent output component
  65627. */
  65628. get tangentOutput(): NodeMaterialConnectionPoint;
  65629. /**
  65630. * Gets the tangent output component
  65631. */
  65632. get uvOutput(): NodeMaterialConnectionPoint;
  65633. initialize(state: NodeMaterialBuildState): void;
  65634. autoConfigure(material: NodeMaterial): void;
  65635. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65636. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  65637. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  65638. protected _buildBlock(state: NodeMaterialBuildState): this;
  65639. }
  65640. }
  65641. declare module "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock" {
  65642. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65643. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65644. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65645. import { Nullable } from "babylonjs/types";
  65646. import { Scene } from "babylonjs/scene";
  65647. import { Effect } from "babylonjs/Materials/effect";
  65648. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  65649. import { Mesh } from "babylonjs/Meshes/mesh";
  65650. import { Light } from "babylonjs/Lights/light";
  65651. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65652. /**
  65653. * Block used to get data information from a light
  65654. */
  65655. export class LightInformationBlock extends NodeMaterialBlock {
  65656. private _lightDataUniformName;
  65657. private _lightColorUniformName;
  65658. private _lightTypeDefineName;
  65659. /**
  65660. * Gets or sets the light associated with this block
  65661. */
  65662. light: Nullable<Light>;
  65663. /**
  65664. * Creates a new LightInformationBlock
  65665. * @param name defines the block name
  65666. */
  65667. constructor(name: string);
  65668. /**
  65669. * Gets the current class name
  65670. * @returns the class name
  65671. */
  65672. getClassName(): string;
  65673. /**
  65674. * Gets the world position input component
  65675. */
  65676. get worldPosition(): NodeMaterialConnectionPoint;
  65677. /**
  65678. * Gets the direction output component
  65679. */
  65680. get direction(): NodeMaterialConnectionPoint;
  65681. /**
  65682. * Gets the direction output component
  65683. */
  65684. get color(): NodeMaterialConnectionPoint;
  65685. /**
  65686. * Gets the direction output component
  65687. */
  65688. get intensity(): NodeMaterialConnectionPoint;
  65689. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  65690. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65691. protected _buildBlock(state: NodeMaterialBuildState): this;
  65692. serialize(): any;
  65693. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65694. }
  65695. }
  65696. declare module "babylonjs/Materials/Node/Blocks/Vertex/index" {
  65697. export * from "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock";
  65698. export * from "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock";
  65699. export * from "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock";
  65700. export * from "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock";
  65701. export * from "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock";
  65702. }
  65703. declare module "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock" {
  65704. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65705. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65706. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65707. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65708. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  65709. import { Effect } from "babylonjs/Materials/effect";
  65710. import { Mesh } from "babylonjs/Meshes/mesh";
  65711. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  65712. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  65713. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  65714. /**
  65715. * Block used to add image processing support to fragment shader
  65716. */
  65717. export class ImageProcessingBlock extends NodeMaterialBlock {
  65718. /**
  65719. * Create a new ImageProcessingBlock
  65720. * @param name defines the block name
  65721. */
  65722. constructor(name: string);
  65723. /**
  65724. * Gets the current class name
  65725. * @returns the class name
  65726. */
  65727. getClassName(): string;
  65728. /**
  65729. * Gets the color input component
  65730. */
  65731. get color(): NodeMaterialConnectionPoint;
  65732. /**
  65733. * Gets the output component
  65734. */
  65735. get output(): NodeMaterialConnectionPoint;
  65736. /**
  65737. * Initialize the block and prepare the context for build
  65738. * @param state defines the state that will be used for the build
  65739. */
  65740. initialize(state: NodeMaterialBuildState): void;
  65741. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  65742. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65743. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  65744. protected _buildBlock(state: NodeMaterialBuildState): this;
  65745. }
  65746. }
  65747. declare module "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock" {
  65748. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65749. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65750. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65751. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  65752. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65753. import { Effect } from "babylonjs/Materials/effect";
  65754. import { Mesh } from "babylonjs/Meshes/mesh";
  65755. import { Scene } from "babylonjs/scene";
  65756. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  65757. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  65758. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  65759. /**
  65760. * Block used to pertub normals based on a normal map
  65761. */
  65762. export class PerturbNormalBlock extends NodeMaterialBlock {
  65763. private _tangentSpaceParameterName;
  65764. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  65765. invertX: boolean;
  65766. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  65767. invertY: boolean;
  65768. /**
  65769. * Create a new PerturbNormalBlock
  65770. * @param name defines the block name
  65771. */
  65772. constructor(name: string);
  65773. /**
  65774. * Gets the current class name
  65775. * @returns the class name
  65776. */
  65777. getClassName(): string;
  65778. /**
  65779. * Gets the world position input component
  65780. */
  65781. get worldPosition(): NodeMaterialConnectionPoint;
  65782. /**
  65783. * Gets the world normal input component
  65784. */
  65785. get worldNormal(): NodeMaterialConnectionPoint;
  65786. /**
  65787. * Gets the world tangent input component
  65788. */
  65789. get worldTangent(): NodeMaterialConnectionPoint;
  65790. /**
  65791. * Gets the uv input component
  65792. */
  65793. get uv(): NodeMaterialConnectionPoint;
  65794. /**
  65795. * Gets the normal map color input component
  65796. */
  65797. get normalMapColor(): NodeMaterialConnectionPoint;
  65798. /**
  65799. * Gets the strength input component
  65800. */
  65801. get strength(): NodeMaterialConnectionPoint;
  65802. /**
  65803. * Gets the output component
  65804. */
  65805. get output(): NodeMaterialConnectionPoint;
  65806. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65807. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  65808. autoConfigure(material: NodeMaterial): void;
  65809. protected _buildBlock(state: NodeMaterialBuildState): this;
  65810. protected _dumpPropertiesCode(): string;
  65811. serialize(): any;
  65812. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65813. }
  65814. }
  65815. declare module "babylonjs/Materials/Node/Blocks/Fragment/discardBlock" {
  65816. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65817. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65818. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65819. /**
  65820. * Block used to discard a pixel if a value is smaller than a cutoff
  65821. */
  65822. export class DiscardBlock extends NodeMaterialBlock {
  65823. /**
  65824. * Create a new DiscardBlock
  65825. * @param name defines the block name
  65826. */
  65827. constructor(name: string);
  65828. /**
  65829. * Gets the current class name
  65830. * @returns the class name
  65831. */
  65832. getClassName(): string;
  65833. /**
  65834. * Gets the color input component
  65835. */
  65836. get value(): NodeMaterialConnectionPoint;
  65837. /**
  65838. * Gets the cutoff input component
  65839. */
  65840. get cutoff(): NodeMaterialConnectionPoint;
  65841. protected _buildBlock(state: NodeMaterialBuildState): this;
  65842. }
  65843. }
  65844. declare module "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock" {
  65845. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65846. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65847. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65848. /**
  65849. * Block used to test if the fragment shader is front facing
  65850. */
  65851. export class FrontFacingBlock extends NodeMaterialBlock {
  65852. /**
  65853. * Creates a new FrontFacingBlock
  65854. * @param name defines the block name
  65855. */
  65856. constructor(name: string);
  65857. /**
  65858. * Gets the current class name
  65859. * @returns the class name
  65860. */
  65861. getClassName(): string;
  65862. /**
  65863. * Gets the output component
  65864. */
  65865. get output(): NodeMaterialConnectionPoint;
  65866. protected _buildBlock(state: NodeMaterialBuildState): this;
  65867. }
  65868. }
  65869. declare module "babylonjs/Materials/Node/Blocks/Fragment/derivativeBlock" {
  65870. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65871. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65872. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65873. /**
  65874. * Block used to get the derivative value on x and y of a given input
  65875. */
  65876. export class DerivativeBlock extends NodeMaterialBlock {
  65877. /**
  65878. * Create a new DerivativeBlock
  65879. * @param name defines the block name
  65880. */
  65881. constructor(name: string);
  65882. /**
  65883. * Gets the current class name
  65884. * @returns the class name
  65885. */
  65886. getClassName(): string;
  65887. /**
  65888. * Gets the input component
  65889. */
  65890. get input(): NodeMaterialConnectionPoint;
  65891. /**
  65892. * Gets the derivative output on x
  65893. */
  65894. get dx(): NodeMaterialConnectionPoint;
  65895. /**
  65896. * Gets the derivative output on y
  65897. */
  65898. get dy(): NodeMaterialConnectionPoint;
  65899. protected _buildBlock(state: NodeMaterialBuildState): this;
  65900. }
  65901. }
  65902. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragCoordBlock" {
  65903. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65904. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65905. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65906. /**
  65907. * Block used to make gl_FragCoord available
  65908. */
  65909. export class FragCoordBlock extends NodeMaterialBlock {
  65910. /**
  65911. * Creates a new FragCoordBlock
  65912. * @param name defines the block name
  65913. */
  65914. constructor(name: string);
  65915. /**
  65916. * Gets the current class name
  65917. * @returns the class name
  65918. */
  65919. getClassName(): string;
  65920. /**
  65921. * Gets the xy component
  65922. */
  65923. get xy(): NodeMaterialConnectionPoint;
  65924. /**
  65925. * Gets the xyz component
  65926. */
  65927. get xyz(): NodeMaterialConnectionPoint;
  65928. /**
  65929. * Gets the xyzw component
  65930. */
  65931. get xyzw(): NodeMaterialConnectionPoint;
  65932. /**
  65933. * Gets the x component
  65934. */
  65935. get x(): NodeMaterialConnectionPoint;
  65936. /**
  65937. * Gets the y component
  65938. */
  65939. get y(): NodeMaterialConnectionPoint;
  65940. /**
  65941. * Gets the z component
  65942. */
  65943. get z(): NodeMaterialConnectionPoint;
  65944. /**
  65945. * Gets the w component
  65946. */
  65947. get output(): NodeMaterialConnectionPoint;
  65948. protected writeOutputs(state: NodeMaterialBuildState): string;
  65949. protected _buildBlock(state: NodeMaterialBuildState): this;
  65950. }
  65951. }
  65952. declare module "babylonjs/Materials/Node/Blocks/Fragment/screenSizeBlock" {
  65953. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65954. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65955. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65956. import { Effect } from "babylonjs/Materials/effect";
  65957. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  65958. import { Mesh } from "babylonjs/Meshes/mesh";
  65959. /**
  65960. * Block used to get the screen sizes
  65961. */
  65962. export class ScreenSizeBlock extends NodeMaterialBlock {
  65963. private _varName;
  65964. private _scene;
  65965. /**
  65966. * Creates a new ScreenSizeBlock
  65967. * @param name defines the block name
  65968. */
  65969. constructor(name: string);
  65970. /**
  65971. * Gets the current class name
  65972. * @returns the class name
  65973. */
  65974. getClassName(): string;
  65975. /**
  65976. * Gets the xy component
  65977. */
  65978. get xy(): NodeMaterialConnectionPoint;
  65979. /**
  65980. * Gets the x component
  65981. */
  65982. get x(): NodeMaterialConnectionPoint;
  65983. /**
  65984. * Gets the y component
  65985. */
  65986. get y(): NodeMaterialConnectionPoint;
  65987. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  65988. protected writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  65989. protected _buildBlock(state: NodeMaterialBuildState): this;
  65990. }
  65991. }
  65992. declare module "babylonjs/Materials/Node/Blocks/Fragment/index" {
  65993. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock";
  65994. export * from "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock";
  65995. export * from "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock";
  65996. export * from "babylonjs/Materials/Node/Blocks/Fragment/discardBlock";
  65997. export * from "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock";
  65998. export * from "babylonjs/Materials/Node/Blocks/Fragment/derivativeBlock";
  65999. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragCoordBlock";
  66000. export * from "babylonjs/Materials/Node/Blocks/Fragment/screenSizeBlock";
  66001. }
  66002. declare module "babylonjs/Materials/Node/Blocks/Dual/fogBlock" {
  66003. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66004. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66005. import { Mesh } from "babylonjs/Meshes/mesh";
  66006. import { Effect } from "babylonjs/Materials/effect";
  66007. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66008. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66009. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  66010. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  66011. /**
  66012. * Block used to add support for scene fog
  66013. */
  66014. export class FogBlock extends NodeMaterialBlock {
  66015. private _fogDistanceName;
  66016. private _fogParameters;
  66017. /**
  66018. * Create a new FogBlock
  66019. * @param name defines the block name
  66020. */
  66021. constructor(name: string);
  66022. /**
  66023. * Gets the current class name
  66024. * @returns the class name
  66025. */
  66026. getClassName(): string;
  66027. /**
  66028. * Gets the world position input component
  66029. */
  66030. get worldPosition(): NodeMaterialConnectionPoint;
  66031. /**
  66032. * Gets the view input component
  66033. */
  66034. get view(): NodeMaterialConnectionPoint;
  66035. /**
  66036. * Gets the color input component
  66037. */
  66038. get input(): NodeMaterialConnectionPoint;
  66039. /**
  66040. * Gets the fog color input component
  66041. */
  66042. get fogColor(): NodeMaterialConnectionPoint;
  66043. /**
  66044. * Gets the output component
  66045. */
  66046. get output(): NodeMaterialConnectionPoint;
  66047. autoConfigure(material: NodeMaterial): void;
  66048. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66049. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  66050. protected _buildBlock(state: NodeMaterialBuildState): this;
  66051. }
  66052. }
  66053. declare module "babylonjs/Materials/Node/Blocks/Dual/lightBlock" {
  66054. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66055. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66056. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66057. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66058. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  66059. import { Effect } from "babylonjs/Materials/effect";
  66060. import { Mesh } from "babylonjs/Meshes/mesh";
  66061. import { Light } from "babylonjs/Lights/light";
  66062. import { Nullable } from "babylonjs/types";
  66063. import { Scene } from "babylonjs/scene";
  66064. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  66065. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  66066. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  66067. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  66068. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  66069. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  66070. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  66071. /**
  66072. * Block used to add light in the fragment shader
  66073. */
  66074. export class LightBlock extends NodeMaterialBlock {
  66075. private _lightId;
  66076. /**
  66077. * Gets or sets the light associated with this block
  66078. */
  66079. light: Nullable<Light>;
  66080. /**
  66081. * Create a new LightBlock
  66082. * @param name defines the block name
  66083. */
  66084. constructor(name: string);
  66085. /**
  66086. * Gets the current class name
  66087. * @returns the class name
  66088. */
  66089. getClassName(): string;
  66090. /**
  66091. * Gets the world position input component
  66092. */
  66093. get worldPosition(): NodeMaterialConnectionPoint;
  66094. /**
  66095. * Gets the world normal input component
  66096. */
  66097. get worldNormal(): NodeMaterialConnectionPoint;
  66098. /**
  66099. * Gets the camera (or eye) position component
  66100. */
  66101. get cameraPosition(): NodeMaterialConnectionPoint;
  66102. /**
  66103. * Gets the glossiness component
  66104. */
  66105. get glossiness(): NodeMaterialConnectionPoint;
  66106. /**
  66107. * Gets the glossinness power component
  66108. */
  66109. get glossPower(): NodeMaterialConnectionPoint;
  66110. /**
  66111. * Gets the diffuse color component
  66112. */
  66113. get diffuseColor(): NodeMaterialConnectionPoint;
  66114. /**
  66115. * Gets the specular color component
  66116. */
  66117. get specularColor(): NodeMaterialConnectionPoint;
  66118. /**
  66119. * Gets the diffuse output component
  66120. */
  66121. get diffuseOutput(): NodeMaterialConnectionPoint;
  66122. /**
  66123. * Gets the specular output component
  66124. */
  66125. get specularOutput(): NodeMaterialConnectionPoint;
  66126. /**
  66127. * Gets the shadow output component
  66128. */
  66129. get shadow(): NodeMaterialConnectionPoint;
  66130. autoConfigure(material: NodeMaterial): void;
  66131. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66132. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  66133. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  66134. private _injectVertexCode;
  66135. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  66136. serialize(): any;
  66137. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  66138. }
  66139. }
  66140. declare module "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock" {
  66141. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66142. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66143. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  66144. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  66145. /**
  66146. * Block used to read a reflection texture from a sampler
  66147. */
  66148. export class ReflectionTextureBlock extends ReflectionTextureBaseBlock {
  66149. /**
  66150. * Create a new ReflectionTextureBlock
  66151. * @param name defines the block name
  66152. */
  66153. constructor(name: string);
  66154. /**
  66155. * Gets the current class name
  66156. * @returns the class name
  66157. */
  66158. getClassName(): string;
  66159. /**
  66160. * Gets the world position input component
  66161. */
  66162. get position(): NodeMaterialConnectionPoint;
  66163. /**
  66164. * Gets the world position input component
  66165. */
  66166. get worldPosition(): NodeMaterialConnectionPoint;
  66167. /**
  66168. * Gets the world normal input component
  66169. */
  66170. get worldNormal(): NodeMaterialConnectionPoint;
  66171. /**
  66172. * Gets the world input component
  66173. */
  66174. get world(): NodeMaterialConnectionPoint;
  66175. /**
  66176. * Gets the camera (or eye) position component
  66177. */
  66178. get cameraPosition(): NodeMaterialConnectionPoint;
  66179. /**
  66180. * Gets the view input component
  66181. */
  66182. get view(): NodeMaterialConnectionPoint;
  66183. /**
  66184. * Gets the rgb output component
  66185. */
  66186. get rgb(): NodeMaterialConnectionPoint;
  66187. /**
  66188. * Gets the rgba output component
  66189. */
  66190. get rgba(): NodeMaterialConnectionPoint;
  66191. /**
  66192. * Gets the r output component
  66193. */
  66194. get r(): NodeMaterialConnectionPoint;
  66195. /**
  66196. * Gets the g output component
  66197. */
  66198. get g(): NodeMaterialConnectionPoint;
  66199. /**
  66200. * Gets the b output component
  66201. */
  66202. get b(): NodeMaterialConnectionPoint;
  66203. /**
  66204. * Gets the a output component
  66205. */
  66206. get a(): NodeMaterialConnectionPoint;
  66207. autoConfigure(material: NodeMaterial): void;
  66208. protected _buildBlock(state: NodeMaterialBuildState): this;
  66209. }
  66210. }
  66211. declare module "babylonjs/Materials/Node/Blocks/Dual/index" {
  66212. export * from "babylonjs/Materials/Node/Blocks/Dual/fogBlock";
  66213. export * from "babylonjs/Materials/Node/Blocks/Dual/lightBlock";
  66214. export * from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  66215. export * from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  66216. export * from "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock";
  66217. }
  66218. declare module "babylonjs/Materials/Node/Blocks/Input/index" {
  66219. export * from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  66220. export * from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  66221. }
  66222. declare module "babylonjs/Materials/Node/Blocks/addBlock" {
  66223. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66224. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66225. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66226. /**
  66227. * Block used to add 2 vectors
  66228. */
  66229. export class AddBlock extends NodeMaterialBlock {
  66230. /**
  66231. * Creates a new AddBlock
  66232. * @param name defines the block name
  66233. */
  66234. constructor(name: string);
  66235. /**
  66236. * Gets the current class name
  66237. * @returns the class name
  66238. */
  66239. getClassName(): string;
  66240. /**
  66241. * Gets the left operand input component
  66242. */
  66243. get left(): NodeMaterialConnectionPoint;
  66244. /**
  66245. * Gets the right operand input component
  66246. */
  66247. get right(): NodeMaterialConnectionPoint;
  66248. /**
  66249. * Gets the output component
  66250. */
  66251. get output(): NodeMaterialConnectionPoint;
  66252. protected _buildBlock(state: NodeMaterialBuildState): this;
  66253. }
  66254. }
  66255. declare module "babylonjs/Materials/Node/Blocks/scaleBlock" {
  66256. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66257. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66258. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66259. /**
  66260. * Block used to scale a vector by a float
  66261. */
  66262. export class ScaleBlock extends NodeMaterialBlock {
  66263. /**
  66264. * Creates a new ScaleBlock
  66265. * @param name defines the block name
  66266. */
  66267. constructor(name: string);
  66268. /**
  66269. * Gets the current class name
  66270. * @returns the class name
  66271. */
  66272. getClassName(): string;
  66273. /**
  66274. * Gets the input component
  66275. */
  66276. get input(): NodeMaterialConnectionPoint;
  66277. /**
  66278. * Gets the factor input component
  66279. */
  66280. get factor(): NodeMaterialConnectionPoint;
  66281. /**
  66282. * Gets the output component
  66283. */
  66284. get output(): NodeMaterialConnectionPoint;
  66285. protected _buildBlock(state: NodeMaterialBuildState): this;
  66286. }
  66287. }
  66288. declare module "babylonjs/Materials/Node/Blocks/clampBlock" {
  66289. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66290. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66291. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66292. import { Scene } from "babylonjs/scene";
  66293. /**
  66294. * Block used to clamp a float
  66295. */
  66296. export class ClampBlock extends NodeMaterialBlock {
  66297. /** Gets or sets the minimum range */
  66298. minimum: number;
  66299. /** Gets or sets the maximum range */
  66300. maximum: number;
  66301. /**
  66302. * Creates a new ClampBlock
  66303. * @param name defines the block name
  66304. */
  66305. constructor(name: string);
  66306. /**
  66307. * Gets the current class name
  66308. * @returns the class name
  66309. */
  66310. getClassName(): string;
  66311. /**
  66312. * Gets the value input component
  66313. */
  66314. get value(): NodeMaterialConnectionPoint;
  66315. /**
  66316. * Gets the output component
  66317. */
  66318. get output(): NodeMaterialConnectionPoint;
  66319. protected _buildBlock(state: NodeMaterialBuildState): this;
  66320. protected _dumpPropertiesCode(): string;
  66321. serialize(): any;
  66322. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  66323. }
  66324. }
  66325. declare module "babylonjs/Materials/Node/Blocks/crossBlock" {
  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 apply a cross product between 2 vectors
  66331. */
  66332. export class CrossBlock extends NodeMaterialBlock {
  66333. /**
  66334. * Creates a new CrossBlock
  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 left operand input component
  66345. */
  66346. get left(): NodeMaterialConnectionPoint;
  66347. /**
  66348. * Gets the right operand input component
  66349. */
  66350. get right(): NodeMaterialConnectionPoint;
  66351. /**
  66352. * Gets the output component
  66353. */
  66354. get output(): NodeMaterialConnectionPoint;
  66355. protected _buildBlock(state: NodeMaterialBuildState): this;
  66356. }
  66357. }
  66358. declare module "babylonjs/Materials/Node/Blocks/dotBlock" {
  66359. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66360. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66361. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66362. /**
  66363. * Block used to apply a dot product between 2 vectors
  66364. */
  66365. export class DotBlock extends NodeMaterialBlock {
  66366. /**
  66367. * Creates a new DotBlock
  66368. * @param name defines the block name
  66369. */
  66370. constructor(name: string);
  66371. /**
  66372. * Gets the current class name
  66373. * @returns the class name
  66374. */
  66375. getClassName(): string;
  66376. /**
  66377. * Gets the left operand input component
  66378. */
  66379. get left(): NodeMaterialConnectionPoint;
  66380. /**
  66381. * Gets the right operand input component
  66382. */
  66383. get right(): NodeMaterialConnectionPoint;
  66384. /**
  66385. * Gets the output component
  66386. */
  66387. get output(): NodeMaterialConnectionPoint;
  66388. protected _buildBlock(state: NodeMaterialBuildState): this;
  66389. }
  66390. }
  66391. declare module "babylonjs/Materials/Node/Blocks/normalizeBlock" {
  66392. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66393. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66394. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66395. /**
  66396. * Block used to normalize a vector
  66397. */
  66398. export class NormalizeBlock extends NodeMaterialBlock {
  66399. /**
  66400. * Creates a new NormalizeBlock
  66401. * @param name defines the block name
  66402. */
  66403. constructor(name: string);
  66404. /**
  66405. * Gets the current class name
  66406. * @returns the class name
  66407. */
  66408. getClassName(): string;
  66409. /**
  66410. * Gets the input component
  66411. */
  66412. get input(): NodeMaterialConnectionPoint;
  66413. /**
  66414. * Gets the output component
  66415. */
  66416. get output(): NodeMaterialConnectionPoint;
  66417. protected _buildBlock(state: NodeMaterialBuildState): this;
  66418. }
  66419. }
  66420. declare module "babylonjs/Materials/Node/Blocks/colorMergerBlock" {
  66421. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66422. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66423. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66424. /**
  66425. * Block used to create a Color3/4 out of individual inputs (one for each component)
  66426. */
  66427. export class ColorMergerBlock extends NodeMaterialBlock {
  66428. /**
  66429. * Create a new ColorMergerBlock
  66430. * @param name defines the block name
  66431. */
  66432. constructor(name: string);
  66433. /**
  66434. * Gets the current class name
  66435. * @returns the class name
  66436. */
  66437. getClassName(): string;
  66438. /**
  66439. * Gets the rgb component (input)
  66440. */
  66441. get rgbIn(): NodeMaterialConnectionPoint;
  66442. /**
  66443. * Gets the r component (input)
  66444. */
  66445. get r(): NodeMaterialConnectionPoint;
  66446. /**
  66447. * Gets the g component (input)
  66448. */
  66449. get g(): NodeMaterialConnectionPoint;
  66450. /**
  66451. * Gets the b component (input)
  66452. */
  66453. get b(): NodeMaterialConnectionPoint;
  66454. /**
  66455. * Gets the a component (input)
  66456. */
  66457. get a(): NodeMaterialConnectionPoint;
  66458. /**
  66459. * Gets the rgba component (output)
  66460. */
  66461. get rgba(): NodeMaterialConnectionPoint;
  66462. /**
  66463. * Gets the rgb component (output)
  66464. */
  66465. get rgbOut(): NodeMaterialConnectionPoint;
  66466. /**
  66467. * Gets the rgb component (output)
  66468. * @deprecated Please use rgbOut instead.
  66469. */
  66470. get rgb(): NodeMaterialConnectionPoint;
  66471. protected _buildBlock(state: NodeMaterialBuildState): this;
  66472. }
  66473. }
  66474. declare module "babylonjs/Materials/Node/Blocks/vectorSplitterBlock" {
  66475. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66476. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66477. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66478. /**
  66479. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  66480. */
  66481. export class VectorSplitterBlock extends NodeMaterialBlock {
  66482. /**
  66483. * Create a new VectorSplitterBlock
  66484. * @param name defines the block name
  66485. */
  66486. constructor(name: string);
  66487. /**
  66488. * Gets the current class name
  66489. * @returns the class name
  66490. */
  66491. getClassName(): string;
  66492. /**
  66493. * Gets the xyzw component (input)
  66494. */
  66495. get xyzw(): NodeMaterialConnectionPoint;
  66496. /**
  66497. * Gets the xyz component (input)
  66498. */
  66499. get xyzIn(): NodeMaterialConnectionPoint;
  66500. /**
  66501. * Gets the xy component (input)
  66502. */
  66503. get xyIn(): NodeMaterialConnectionPoint;
  66504. /**
  66505. * Gets the xyz component (output)
  66506. */
  66507. get xyzOut(): NodeMaterialConnectionPoint;
  66508. /**
  66509. * Gets the xy component (output)
  66510. */
  66511. get xyOut(): NodeMaterialConnectionPoint;
  66512. /**
  66513. * Gets the x component (output)
  66514. */
  66515. get x(): NodeMaterialConnectionPoint;
  66516. /**
  66517. * Gets the y component (output)
  66518. */
  66519. get y(): NodeMaterialConnectionPoint;
  66520. /**
  66521. * Gets the z component (output)
  66522. */
  66523. get z(): NodeMaterialConnectionPoint;
  66524. /**
  66525. * Gets the w component (output)
  66526. */
  66527. get w(): NodeMaterialConnectionPoint;
  66528. protected _inputRename(name: string): string;
  66529. protected _outputRename(name: string): string;
  66530. protected _buildBlock(state: NodeMaterialBuildState): this;
  66531. }
  66532. }
  66533. declare module "babylonjs/Materials/Node/Blocks/lerpBlock" {
  66534. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66535. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66536. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66537. /**
  66538. * Block used to lerp between 2 values
  66539. */
  66540. export class LerpBlock extends NodeMaterialBlock {
  66541. /**
  66542. * Creates a new LerpBlock
  66543. * @param name defines the block name
  66544. */
  66545. constructor(name: string);
  66546. /**
  66547. * Gets the current class name
  66548. * @returns the class name
  66549. */
  66550. getClassName(): string;
  66551. /**
  66552. * Gets the left operand input component
  66553. */
  66554. get left(): NodeMaterialConnectionPoint;
  66555. /**
  66556. * Gets the right operand input component
  66557. */
  66558. get right(): NodeMaterialConnectionPoint;
  66559. /**
  66560. * Gets the gradient operand input component
  66561. */
  66562. get gradient(): NodeMaterialConnectionPoint;
  66563. /**
  66564. * Gets the output component
  66565. */
  66566. get output(): NodeMaterialConnectionPoint;
  66567. protected _buildBlock(state: NodeMaterialBuildState): this;
  66568. }
  66569. }
  66570. declare module "babylonjs/Materials/Node/Blocks/divideBlock" {
  66571. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66572. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66573. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66574. /**
  66575. * Block used to divide 2 vectors
  66576. */
  66577. export class DivideBlock extends NodeMaterialBlock {
  66578. /**
  66579. * Creates a new DivideBlock
  66580. * @param name defines the block name
  66581. */
  66582. constructor(name: string);
  66583. /**
  66584. * Gets the current class name
  66585. * @returns the class name
  66586. */
  66587. getClassName(): string;
  66588. /**
  66589. * Gets the left operand input component
  66590. */
  66591. get left(): NodeMaterialConnectionPoint;
  66592. /**
  66593. * Gets the right operand input component
  66594. */
  66595. get right(): NodeMaterialConnectionPoint;
  66596. /**
  66597. * Gets the output component
  66598. */
  66599. get output(): NodeMaterialConnectionPoint;
  66600. protected _buildBlock(state: NodeMaterialBuildState): this;
  66601. }
  66602. }
  66603. declare module "babylonjs/Materials/Node/Blocks/subtractBlock" {
  66604. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66605. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66606. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66607. /**
  66608. * Block used to subtract 2 vectors
  66609. */
  66610. export class SubtractBlock extends NodeMaterialBlock {
  66611. /**
  66612. * Creates a new SubtractBlock
  66613. * @param name defines the block name
  66614. */
  66615. constructor(name: string);
  66616. /**
  66617. * Gets the current class name
  66618. * @returns the class name
  66619. */
  66620. getClassName(): string;
  66621. /**
  66622. * Gets the left operand input component
  66623. */
  66624. get left(): NodeMaterialConnectionPoint;
  66625. /**
  66626. * Gets the right operand input component
  66627. */
  66628. get right(): NodeMaterialConnectionPoint;
  66629. /**
  66630. * Gets the output component
  66631. */
  66632. get output(): NodeMaterialConnectionPoint;
  66633. protected _buildBlock(state: NodeMaterialBuildState): this;
  66634. }
  66635. }
  66636. declare module "babylonjs/Materials/Node/Blocks/stepBlock" {
  66637. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66638. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66639. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66640. /**
  66641. * Block used to step a value
  66642. */
  66643. export class StepBlock extends NodeMaterialBlock {
  66644. /**
  66645. * Creates a new StepBlock
  66646. * @param name defines the block name
  66647. */
  66648. constructor(name: string);
  66649. /**
  66650. * Gets the current class name
  66651. * @returns the class name
  66652. */
  66653. getClassName(): string;
  66654. /**
  66655. * Gets the value operand input component
  66656. */
  66657. get value(): NodeMaterialConnectionPoint;
  66658. /**
  66659. * Gets the edge operand input component
  66660. */
  66661. get edge(): NodeMaterialConnectionPoint;
  66662. /**
  66663. * Gets the output component
  66664. */
  66665. get output(): NodeMaterialConnectionPoint;
  66666. protected _buildBlock(state: NodeMaterialBuildState): this;
  66667. }
  66668. }
  66669. declare module "babylonjs/Materials/Node/Blocks/oneMinusBlock" {
  66670. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66671. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66672. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66673. /**
  66674. * Block used to get the opposite (1 - x) of a value
  66675. */
  66676. export class OneMinusBlock extends NodeMaterialBlock {
  66677. /**
  66678. * Creates a new OneMinusBlock
  66679. * @param name defines the block name
  66680. */
  66681. constructor(name: string);
  66682. /**
  66683. * Gets the current class name
  66684. * @returns the class name
  66685. */
  66686. getClassName(): string;
  66687. /**
  66688. * Gets the input component
  66689. */
  66690. get input(): NodeMaterialConnectionPoint;
  66691. /**
  66692. * Gets the output component
  66693. */
  66694. get output(): NodeMaterialConnectionPoint;
  66695. protected _buildBlock(state: NodeMaterialBuildState): this;
  66696. }
  66697. }
  66698. declare module "babylonjs/Materials/Node/Blocks/viewDirectionBlock" {
  66699. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66700. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66701. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66702. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  66703. /**
  66704. * Block used to get the view direction
  66705. */
  66706. export class ViewDirectionBlock extends NodeMaterialBlock {
  66707. /**
  66708. * Creates a new ViewDirectionBlock
  66709. * @param name defines the block name
  66710. */
  66711. constructor(name: string);
  66712. /**
  66713. * Gets the current class name
  66714. * @returns the class name
  66715. */
  66716. getClassName(): string;
  66717. /**
  66718. * Gets the world position component
  66719. */
  66720. get worldPosition(): NodeMaterialConnectionPoint;
  66721. /**
  66722. * Gets the camera position component
  66723. */
  66724. get cameraPosition(): NodeMaterialConnectionPoint;
  66725. /**
  66726. * Gets the output component
  66727. */
  66728. get output(): NodeMaterialConnectionPoint;
  66729. autoConfigure(material: NodeMaterial): void;
  66730. protected _buildBlock(state: NodeMaterialBuildState): this;
  66731. }
  66732. }
  66733. declare module "babylonjs/Materials/Node/Blocks/fresnelBlock" {
  66734. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66735. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66736. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66737. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  66738. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  66739. /**
  66740. * Block used to compute fresnel value
  66741. */
  66742. export class FresnelBlock extends NodeMaterialBlock {
  66743. /**
  66744. * Create a new FresnelBlock
  66745. * @param name defines the block name
  66746. */
  66747. constructor(name: string);
  66748. /**
  66749. * Gets the current class name
  66750. * @returns the class name
  66751. */
  66752. getClassName(): string;
  66753. /**
  66754. * Gets the world normal input component
  66755. */
  66756. get worldNormal(): NodeMaterialConnectionPoint;
  66757. /**
  66758. * Gets the view direction input component
  66759. */
  66760. get viewDirection(): NodeMaterialConnectionPoint;
  66761. /**
  66762. * Gets the bias input component
  66763. */
  66764. get bias(): NodeMaterialConnectionPoint;
  66765. /**
  66766. * Gets the camera (or eye) position component
  66767. */
  66768. get power(): NodeMaterialConnectionPoint;
  66769. /**
  66770. * Gets the fresnel output component
  66771. */
  66772. get fresnel(): NodeMaterialConnectionPoint;
  66773. autoConfigure(material: NodeMaterial): void;
  66774. protected _buildBlock(state: NodeMaterialBuildState): this;
  66775. }
  66776. }
  66777. declare module "babylonjs/Materials/Node/Blocks/maxBlock" {
  66778. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66779. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66780. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66781. /**
  66782. * Block used to get the max of 2 values
  66783. */
  66784. export class MaxBlock extends NodeMaterialBlock {
  66785. /**
  66786. * Creates a new MaxBlock
  66787. * @param name defines the block name
  66788. */
  66789. constructor(name: string);
  66790. /**
  66791. * Gets the current class name
  66792. * @returns the class name
  66793. */
  66794. getClassName(): string;
  66795. /**
  66796. * Gets the left operand input component
  66797. */
  66798. get left(): NodeMaterialConnectionPoint;
  66799. /**
  66800. * Gets the right operand input component
  66801. */
  66802. get right(): NodeMaterialConnectionPoint;
  66803. /**
  66804. * Gets the output component
  66805. */
  66806. get output(): NodeMaterialConnectionPoint;
  66807. protected _buildBlock(state: NodeMaterialBuildState): this;
  66808. }
  66809. }
  66810. declare module "babylonjs/Materials/Node/Blocks/minBlock" {
  66811. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66812. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66813. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66814. /**
  66815. * Block used to get the min of 2 values
  66816. */
  66817. export class MinBlock extends NodeMaterialBlock {
  66818. /**
  66819. * Creates a new MinBlock
  66820. * @param name defines the block name
  66821. */
  66822. constructor(name: string);
  66823. /**
  66824. * Gets the current class name
  66825. * @returns the class name
  66826. */
  66827. getClassName(): string;
  66828. /**
  66829. * Gets the left operand input component
  66830. */
  66831. get left(): NodeMaterialConnectionPoint;
  66832. /**
  66833. * Gets the right operand input component
  66834. */
  66835. get right(): NodeMaterialConnectionPoint;
  66836. /**
  66837. * Gets the output component
  66838. */
  66839. get output(): NodeMaterialConnectionPoint;
  66840. protected _buildBlock(state: NodeMaterialBuildState): this;
  66841. }
  66842. }
  66843. declare module "babylonjs/Materials/Node/Blocks/distanceBlock" {
  66844. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66845. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66846. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66847. /**
  66848. * Block used to get the distance between 2 values
  66849. */
  66850. export class DistanceBlock extends NodeMaterialBlock {
  66851. /**
  66852. * Creates a new DistanceBlock
  66853. * @param name defines the block name
  66854. */
  66855. constructor(name: string);
  66856. /**
  66857. * Gets the current class name
  66858. * @returns the class name
  66859. */
  66860. getClassName(): string;
  66861. /**
  66862. * Gets the left operand input component
  66863. */
  66864. get left(): NodeMaterialConnectionPoint;
  66865. /**
  66866. * Gets the right operand input component
  66867. */
  66868. get right(): NodeMaterialConnectionPoint;
  66869. /**
  66870. * Gets the output component
  66871. */
  66872. get output(): NodeMaterialConnectionPoint;
  66873. protected _buildBlock(state: NodeMaterialBuildState): this;
  66874. }
  66875. }
  66876. declare module "babylonjs/Materials/Node/Blocks/lengthBlock" {
  66877. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66878. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66879. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66880. /**
  66881. * Block used to get the length of a vector
  66882. */
  66883. export class LengthBlock extends NodeMaterialBlock {
  66884. /**
  66885. * Creates a new LengthBlock
  66886. * @param name defines the block name
  66887. */
  66888. constructor(name: string);
  66889. /**
  66890. * Gets the current class name
  66891. * @returns the class name
  66892. */
  66893. getClassName(): string;
  66894. /**
  66895. * Gets the value input component
  66896. */
  66897. get value(): NodeMaterialConnectionPoint;
  66898. /**
  66899. * Gets the output component
  66900. */
  66901. get output(): NodeMaterialConnectionPoint;
  66902. protected _buildBlock(state: NodeMaterialBuildState): this;
  66903. }
  66904. }
  66905. declare module "babylonjs/Materials/Node/Blocks/negateBlock" {
  66906. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66907. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66908. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66909. /**
  66910. * Block used to get negative version of a value (i.e. x * -1)
  66911. */
  66912. export class NegateBlock extends NodeMaterialBlock {
  66913. /**
  66914. * Creates a new NegateBlock
  66915. * @param name defines the block name
  66916. */
  66917. constructor(name: string);
  66918. /**
  66919. * Gets the current class name
  66920. * @returns the class name
  66921. */
  66922. getClassName(): string;
  66923. /**
  66924. * Gets the value input component
  66925. */
  66926. get value(): NodeMaterialConnectionPoint;
  66927. /**
  66928. * Gets the output component
  66929. */
  66930. get output(): NodeMaterialConnectionPoint;
  66931. protected _buildBlock(state: NodeMaterialBuildState): this;
  66932. }
  66933. }
  66934. declare module "babylonjs/Materials/Node/Blocks/powBlock" {
  66935. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66936. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66937. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66938. /**
  66939. * Block used to get the value of the first parameter raised to the power of the second
  66940. */
  66941. export class PowBlock extends NodeMaterialBlock {
  66942. /**
  66943. * Creates a new PowBlock
  66944. * @param name defines the block name
  66945. */
  66946. constructor(name: string);
  66947. /**
  66948. * Gets the current class name
  66949. * @returns the class name
  66950. */
  66951. getClassName(): string;
  66952. /**
  66953. * Gets the value operand input component
  66954. */
  66955. get value(): NodeMaterialConnectionPoint;
  66956. /**
  66957. * Gets the power operand input component
  66958. */
  66959. get power(): NodeMaterialConnectionPoint;
  66960. /**
  66961. * Gets the output component
  66962. */
  66963. get output(): NodeMaterialConnectionPoint;
  66964. protected _buildBlock(state: NodeMaterialBuildState): this;
  66965. }
  66966. }
  66967. declare module "babylonjs/Materials/Node/Blocks/randomNumberBlock" {
  66968. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66969. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66970. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66971. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  66972. /**
  66973. * Block used to get a random number
  66974. */
  66975. export class RandomNumberBlock extends NodeMaterialBlock {
  66976. /**
  66977. * Creates a new RandomNumberBlock
  66978. * @param name defines the block name
  66979. */
  66980. constructor(name: string);
  66981. /**
  66982. * Gets the current class name
  66983. * @returns the class name
  66984. */
  66985. getClassName(): string;
  66986. /**
  66987. * Gets the seed input component
  66988. */
  66989. get seed(): NodeMaterialConnectionPoint;
  66990. /**
  66991. * Gets the output component
  66992. */
  66993. get output(): NodeMaterialConnectionPoint;
  66994. protected _buildBlock(state: NodeMaterialBuildState): this;
  66995. }
  66996. }
  66997. declare module "babylonjs/Materials/Node/Blocks/arcTan2Block" {
  66998. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66999. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67000. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67001. /**
  67002. * Block used to compute arc tangent of 2 values
  67003. */
  67004. export class ArcTan2Block extends NodeMaterialBlock {
  67005. /**
  67006. * Creates a new ArcTan2Block
  67007. * @param name defines the block name
  67008. */
  67009. constructor(name: string);
  67010. /**
  67011. * Gets the current class name
  67012. * @returns the class name
  67013. */
  67014. getClassName(): string;
  67015. /**
  67016. * Gets the x operand input component
  67017. */
  67018. get x(): NodeMaterialConnectionPoint;
  67019. /**
  67020. * Gets the y operand input component
  67021. */
  67022. get y(): NodeMaterialConnectionPoint;
  67023. /**
  67024. * Gets the output component
  67025. */
  67026. get output(): NodeMaterialConnectionPoint;
  67027. protected _buildBlock(state: NodeMaterialBuildState): this;
  67028. }
  67029. }
  67030. declare module "babylonjs/Materials/Node/Blocks/smoothStepBlock" {
  67031. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67032. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67033. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67034. /**
  67035. * Block used to smooth step a value
  67036. */
  67037. export class SmoothStepBlock extends NodeMaterialBlock {
  67038. /**
  67039. * Creates a new SmoothStepBlock
  67040. * @param name defines the block name
  67041. */
  67042. constructor(name: string);
  67043. /**
  67044. * Gets the current class name
  67045. * @returns the class name
  67046. */
  67047. getClassName(): string;
  67048. /**
  67049. * Gets the value operand input component
  67050. */
  67051. get value(): NodeMaterialConnectionPoint;
  67052. /**
  67053. * Gets the first edge operand input component
  67054. */
  67055. get edge0(): NodeMaterialConnectionPoint;
  67056. /**
  67057. * Gets the second edge operand input component
  67058. */
  67059. get edge1(): NodeMaterialConnectionPoint;
  67060. /**
  67061. * Gets the output component
  67062. */
  67063. get output(): NodeMaterialConnectionPoint;
  67064. protected _buildBlock(state: NodeMaterialBuildState): this;
  67065. }
  67066. }
  67067. declare module "babylonjs/Materials/Node/Blocks/reciprocalBlock" {
  67068. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67069. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67070. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67071. /**
  67072. * Block used to get the reciprocal (1 / x) of a value
  67073. */
  67074. export class ReciprocalBlock extends NodeMaterialBlock {
  67075. /**
  67076. * Creates a new ReciprocalBlock
  67077. * @param name defines the block name
  67078. */
  67079. constructor(name: string);
  67080. /**
  67081. * Gets the current class name
  67082. * @returns the class name
  67083. */
  67084. getClassName(): string;
  67085. /**
  67086. * Gets the input component
  67087. */
  67088. get input(): NodeMaterialConnectionPoint;
  67089. /**
  67090. * Gets the output component
  67091. */
  67092. get output(): NodeMaterialConnectionPoint;
  67093. protected _buildBlock(state: NodeMaterialBuildState): this;
  67094. }
  67095. }
  67096. declare module "babylonjs/Materials/Node/Blocks/replaceColorBlock" {
  67097. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67098. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67099. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67100. /**
  67101. * Block used to replace a color by another one
  67102. */
  67103. export class ReplaceColorBlock extends NodeMaterialBlock {
  67104. /**
  67105. * Creates a new ReplaceColorBlock
  67106. * @param name defines the block name
  67107. */
  67108. constructor(name: string);
  67109. /**
  67110. * Gets the current class name
  67111. * @returns the class name
  67112. */
  67113. getClassName(): string;
  67114. /**
  67115. * Gets the value input component
  67116. */
  67117. get value(): NodeMaterialConnectionPoint;
  67118. /**
  67119. * Gets the reference input component
  67120. */
  67121. get reference(): NodeMaterialConnectionPoint;
  67122. /**
  67123. * Gets the distance input component
  67124. */
  67125. get distance(): NodeMaterialConnectionPoint;
  67126. /**
  67127. * Gets the replacement input component
  67128. */
  67129. get replacement(): NodeMaterialConnectionPoint;
  67130. /**
  67131. * Gets the output component
  67132. */
  67133. get output(): NodeMaterialConnectionPoint;
  67134. protected _buildBlock(state: NodeMaterialBuildState): this;
  67135. }
  67136. }
  67137. declare module "babylonjs/Materials/Node/Blocks/posterizeBlock" {
  67138. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67139. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67140. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67141. /**
  67142. * Block used to posterize a value
  67143. * @see https://en.wikipedia.org/wiki/Posterization
  67144. */
  67145. export class PosterizeBlock extends NodeMaterialBlock {
  67146. /**
  67147. * Creates a new PosterizeBlock
  67148. * @param name defines the block name
  67149. */
  67150. constructor(name: string);
  67151. /**
  67152. * Gets the current class name
  67153. * @returns the class name
  67154. */
  67155. getClassName(): string;
  67156. /**
  67157. * Gets the value input component
  67158. */
  67159. get value(): NodeMaterialConnectionPoint;
  67160. /**
  67161. * Gets the steps input component
  67162. */
  67163. get steps(): NodeMaterialConnectionPoint;
  67164. /**
  67165. * Gets the output component
  67166. */
  67167. get output(): NodeMaterialConnectionPoint;
  67168. protected _buildBlock(state: NodeMaterialBuildState): this;
  67169. }
  67170. }
  67171. declare module "babylonjs/Materials/Node/Blocks/waveBlock" {
  67172. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67173. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67174. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67175. import { Scene } from "babylonjs/scene";
  67176. /**
  67177. * Operations supported by the Wave block
  67178. */
  67179. export enum WaveBlockKind {
  67180. /** SawTooth */
  67181. SawTooth = 0,
  67182. /** Square */
  67183. Square = 1,
  67184. /** Triangle */
  67185. Triangle = 2
  67186. }
  67187. /**
  67188. * Block used to apply wave operation to floats
  67189. */
  67190. export class WaveBlock extends NodeMaterialBlock {
  67191. /**
  67192. * Gets or sets the kibnd of wave to be applied by the block
  67193. */
  67194. kind: WaveBlockKind;
  67195. /**
  67196. * Creates a new WaveBlock
  67197. * @param name defines the block name
  67198. */
  67199. constructor(name: string);
  67200. /**
  67201. * Gets the current class name
  67202. * @returns the class name
  67203. */
  67204. getClassName(): string;
  67205. /**
  67206. * Gets the input component
  67207. */
  67208. get input(): NodeMaterialConnectionPoint;
  67209. /**
  67210. * Gets the output component
  67211. */
  67212. get output(): NodeMaterialConnectionPoint;
  67213. protected _buildBlock(state: NodeMaterialBuildState): this;
  67214. serialize(): any;
  67215. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  67216. }
  67217. }
  67218. declare module "babylonjs/Materials/Node/Blocks/gradientBlock" {
  67219. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67220. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67221. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67222. import { Color3 } from "babylonjs/Maths/math.color";
  67223. import { Scene } from "babylonjs/scene";
  67224. import { Observable } from "babylonjs/Misc/observable";
  67225. /**
  67226. * Class used to store a color step for the GradientBlock
  67227. */
  67228. export class GradientBlockColorStep {
  67229. private _step;
  67230. /**
  67231. * Gets value indicating which step this color is associated with (between 0 and 1)
  67232. */
  67233. get step(): number;
  67234. /**
  67235. * Sets a value indicating which step this color is associated with (between 0 and 1)
  67236. */
  67237. set step(val: number);
  67238. private _color;
  67239. /**
  67240. * Gets the color associated with this step
  67241. */
  67242. get color(): Color3;
  67243. /**
  67244. * Sets the color associated with this step
  67245. */
  67246. set color(val: Color3);
  67247. /**
  67248. * Creates a new GradientBlockColorStep
  67249. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  67250. * @param color defines the color associated with this step
  67251. */
  67252. constructor(step: number, color: Color3);
  67253. }
  67254. /**
  67255. * Block used to return a color from a gradient based on an input value between 0 and 1
  67256. */
  67257. export class GradientBlock extends NodeMaterialBlock {
  67258. /**
  67259. * Gets or sets the list of color steps
  67260. */
  67261. colorSteps: GradientBlockColorStep[];
  67262. /** Gets an observable raised when the value is changed */
  67263. onValueChangedObservable: Observable<GradientBlock>;
  67264. /** calls observable when the value is changed*/
  67265. colorStepsUpdated(): void;
  67266. /**
  67267. * Creates a new GradientBlock
  67268. * @param name defines the block name
  67269. */
  67270. constructor(name: string);
  67271. /**
  67272. * Gets the current class name
  67273. * @returns the class name
  67274. */
  67275. getClassName(): string;
  67276. /**
  67277. * Gets the gradient input component
  67278. */
  67279. get gradient(): NodeMaterialConnectionPoint;
  67280. /**
  67281. * Gets the output component
  67282. */
  67283. get output(): NodeMaterialConnectionPoint;
  67284. private _writeColorConstant;
  67285. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  67286. serialize(): any;
  67287. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  67288. protected _dumpPropertiesCode(): string;
  67289. }
  67290. }
  67291. declare module "babylonjs/Materials/Node/Blocks/nLerpBlock" {
  67292. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67293. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67294. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67295. /**
  67296. * Block used to normalize lerp between 2 values
  67297. */
  67298. export class NLerpBlock extends NodeMaterialBlock {
  67299. /**
  67300. * Creates a new NLerpBlock
  67301. * @param name defines the block name
  67302. */
  67303. constructor(name: string);
  67304. /**
  67305. * Gets the current class name
  67306. * @returns the class name
  67307. */
  67308. getClassName(): string;
  67309. /**
  67310. * Gets the left operand input component
  67311. */
  67312. get left(): NodeMaterialConnectionPoint;
  67313. /**
  67314. * Gets the right operand input component
  67315. */
  67316. get right(): NodeMaterialConnectionPoint;
  67317. /**
  67318. * Gets the gradient operand input component
  67319. */
  67320. get gradient(): NodeMaterialConnectionPoint;
  67321. /**
  67322. * Gets the output component
  67323. */
  67324. get output(): NodeMaterialConnectionPoint;
  67325. protected _buildBlock(state: NodeMaterialBuildState): this;
  67326. }
  67327. }
  67328. declare module "babylonjs/Materials/Node/Blocks/worleyNoise3DBlock" {
  67329. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67330. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67331. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67332. import { Scene } from "babylonjs/scene";
  67333. /**
  67334. * block used to Generate a Worley Noise 3D Noise Pattern
  67335. */
  67336. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  67337. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  67338. manhattanDistance: boolean;
  67339. /**
  67340. * Creates a new WorleyNoise3DBlock
  67341. * @param name defines the block name
  67342. */
  67343. constructor(name: string);
  67344. /**
  67345. * Gets the current class name
  67346. * @returns the class name
  67347. */
  67348. getClassName(): string;
  67349. /**
  67350. * Gets the seed input component
  67351. */
  67352. get seed(): NodeMaterialConnectionPoint;
  67353. /**
  67354. * Gets the jitter input component
  67355. */
  67356. get jitter(): NodeMaterialConnectionPoint;
  67357. /**
  67358. * Gets the output component
  67359. */
  67360. get output(): NodeMaterialConnectionPoint;
  67361. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  67362. /**
  67363. * Exposes the properties to the UI?
  67364. */
  67365. protected _dumpPropertiesCode(): string;
  67366. /**
  67367. * Exposes the properties to the Seralize?
  67368. */
  67369. serialize(): any;
  67370. /**
  67371. * Exposes the properties to the deseralize?
  67372. */
  67373. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  67374. }
  67375. }
  67376. declare module "babylonjs/Materials/Node/Blocks/simplexPerlin3DBlock" {
  67377. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67378. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67379. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67380. /**
  67381. * block used to Generate a Simplex Perlin 3d Noise Pattern
  67382. */
  67383. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  67384. /**
  67385. * Creates a new SimplexPerlin3DBlock
  67386. * @param name defines the block name
  67387. */
  67388. constructor(name: string);
  67389. /**
  67390. * Gets the current class name
  67391. * @returns the class name
  67392. */
  67393. getClassName(): string;
  67394. /**
  67395. * Gets the seed operand input component
  67396. */
  67397. get seed(): NodeMaterialConnectionPoint;
  67398. /**
  67399. * Gets the output component
  67400. */
  67401. get output(): NodeMaterialConnectionPoint;
  67402. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  67403. }
  67404. }
  67405. declare module "babylonjs/Materials/Node/Blocks/normalBlendBlock" {
  67406. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67407. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67408. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67409. /**
  67410. * Block used to blend normals
  67411. */
  67412. export class NormalBlendBlock extends NodeMaterialBlock {
  67413. /**
  67414. * Creates a new NormalBlendBlock
  67415. * @param name defines the block name
  67416. */
  67417. constructor(name: string);
  67418. /**
  67419. * Gets the current class name
  67420. * @returns the class name
  67421. */
  67422. getClassName(): string;
  67423. /**
  67424. * Gets the first input component
  67425. */
  67426. get normalMap0(): NodeMaterialConnectionPoint;
  67427. /**
  67428. * Gets the second input component
  67429. */
  67430. get normalMap1(): NodeMaterialConnectionPoint;
  67431. /**
  67432. * Gets the output component
  67433. */
  67434. get output(): NodeMaterialConnectionPoint;
  67435. protected _buildBlock(state: NodeMaterialBuildState): this;
  67436. }
  67437. }
  67438. declare module "babylonjs/Materials/Node/Blocks/rotate2dBlock" {
  67439. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67440. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67441. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67442. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  67443. /**
  67444. * Block used to rotate a 2d vector by a given angle
  67445. */
  67446. export class Rotate2dBlock extends NodeMaterialBlock {
  67447. /**
  67448. * Creates a new Rotate2dBlock
  67449. * @param name defines the block name
  67450. */
  67451. constructor(name: string);
  67452. /**
  67453. * Gets the current class name
  67454. * @returns the class name
  67455. */
  67456. getClassName(): string;
  67457. /**
  67458. * Gets the input vector
  67459. */
  67460. get input(): NodeMaterialConnectionPoint;
  67461. /**
  67462. * Gets the input angle
  67463. */
  67464. get angle(): NodeMaterialConnectionPoint;
  67465. /**
  67466. * Gets the output component
  67467. */
  67468. get output(): NodeMaterialConnectionPoint;
  67469. autoConfigure(material: NodeMaterial): void;
  67470. protected _buildBlock(state: NodeMaterialBuildState): this;
  67471. }
  67472. }
  67473. declare module "babylonjs/Materials/Node/Blocks/reflectBlock" {
  67474. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67475. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67476. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67477. /**
  67478. * Block used to get the reflected vector from a direction and a normal
  67479. */
  67480. export class ReflectBlock extends NodeMaterialBlock {
  67481. /**
  67482. * Creates a new ReflectBlock
  67483. * @param name defines the block name
  67484. */
  67485. constructor(name: string);
  67486. /**
  67487. * Gets the current class name
  67488. * @returns the class name
  67489. */
  67490. getClassName(): string;
  67491. /**
  67492. * Gets the incident component
  67493. */
  67494. get incident(): NodeMaterialConnectionPoint;
  67495. /**
  67496. * Gets the normal component
  67497. */
  67498. get normal(): NodeMaterialConnectionPoint;
  67499. /**
  67500. * Gets the output component
  67501. */
  67502. get output(): NodeMaterialConnectionPoint;
  67503. protected _buildBlock(state: NodeMaterialBuildState): this;
  67504. }
  67505. }
  67506. declare module "babylonjs/Materials/Node/Blocks/refractBlock" {
  67507. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67508. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67509. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67510. /**
  67511. * Block used to get the refracted vector from a direction and a normal
  67512. */
  67513. export class RefractBlock extends NodeMaterialBlock {
  67514. /**
  67515. * Creates a new RefractBlock
  67516. * @param name defines the block name
  67517. */
  67518. constructor(name: string);
  67519. /**
  67520. * Gets the current class name
  67521. * @returns the class name
  67522. */
  67523. getClassName(): string;
  67524. /**
  67525. * Gets the incident component
  67526. */
  67527. get incident(): NodeMaterialConnectionPoint;
  67528. /**
  67529. * Gets the normal component
  67530. */
  67531. get normal(): NodeMaterialConnectionPoint;
  67532. /**
  67533. * Gets the index of refraction component
  67534. */
  67535. get ior(): NodeMaterialConnectionPoint;
  67536. /**
  67537. * Gets the output component
  67538. */
  67539. get output(): NodeMaterialConnectionPoint;
  67540. protected _buildBlock(state: NodeMaterialBuildState): this;
  67541. }
  67542. }
  67543. declare module "babylonjs/Materials/Node/Blocks/desaturateBlock" {
  67544. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67545. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67546. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67547. /**
  67548. * Block used to desaturate a color
  67549. */
  67550. export class DesaturateBlock extends NodeMaterialBlock {
  67551. /**
  67552. * Creates a new DesaturateBlock
  67553. * @param name defines the block name
  67554. */
  67555. constructor(name: string);
  67556. /**
  67557. * Gets the current class name
  67558. * @returns the class name
  67559. */
  67560. getClassName(): string;
  67561. /**
  67562. * Gets the color operand input component
  67563. */
  67564. get color(): NodeMaterialConnectionPoint;
  67565. /**
  67566. * Gets the level operand input component
  67567. */
  67568. get level(): NodeMaterialConnectionPoint;
  67569. /**
  67570. * Gets the output component
  67571. */
  67572. get output(): NodeMaterialConnectionPoint;
  67573. protected _buildBlock(state: NodeMaterialBuildState): this;
  67574. }
  67575. }
  67576. declare module "babylonjs/Materials/Node/Blocks/PBR/ambientOcclusionBlock" {
  67577. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67578. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67579. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67580. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  67581. import { Nullable } from "babylonjs/types";
  67582. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67583. import { Scene } from "babylonjs/scene";
  67584. /**
  67585. * Block used to implement the ambient occlusion module of the PBR material
  67586. */
  67587. export class AmbientOcclusionBlock extends NodeMaterialBlock {
  67588. /**
  67589. * Create a new AmbientOcclusionBlock
  67590. * @param name defines the block name
  67591. */
  67592. constructor(name: string);
  67593. /**
  67594. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  67595. */
  67596. useAmbientInGrayScale: boolean;
  67597. /**
  67598. * Initialize the block and prepare the context for build
  67599. * @param state defines the state that will be used for the build
  67600. */
  67601. initialize(state: NodeMaterialBuildState): void;
  67602. /**
  67603. * Gets the current class name
  67604. * @returns the class name
  67605. */
  67606. getClassName(): string;
  67607. /**
  67608. * Gets the texture input component
  67609. */
  67610. get texture(): NodeMaterialConnectionPoint;
  67611. /**
  67612. * Gets the texture intensity component
  67613. */
  67614. get intensity(): NodeMaterialConnectionPoint;
  67615. /**
  67616. * Gets the direct light intensity input component
  67617. */
  67618. get directLightIntensity(): NodeMaterialConnectionPoint;
  67619. /**
  67620. * Gets the ambient occlusion object output component
  67621. */
  67622. get ambientOcclusion(): NodeMaterialConnectionPoint;
  67623. /**
  67624. * Gets the main code of the block (fragment side)
  67625. * @param block instance of an AmbientOcclusionBlock or null if the code must be generated without an active ambient occlusion module
  67626. * @returns the shader code
  67627. */
  67628. static GetCode(block: Nullable<AmbientOcclusionBlock>): string;
  67629. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67630. protected _buildBlock(state: NodeMaterialBuildState): this;
  67631. protected _dumpPropertiesCode(): string;
  67632. serialize(): any;
  67633. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  67634. }
  67635. }
  67636. declare module "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock" {
  67637. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67638. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67639. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  67640. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  67641. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67642. import { Nullable } from "babylonjs/types";
  67643. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  67644. import { Mesh } from "babylonjs/Meshes/mesh";
  67645. import { SubMesh } from "babylonjs/Meshes/subMesh";
  67646. import { Effect } from "babylonjs/Materials/effect";
  67647. import { Scene } from "babylonjs/scene";
  67648. /**
  67649. * Block used to implement the reflection module of the PBR material
  67650. */
  67651. export class ReflectionBlock extends ReflectionTextureBaseBlock {
  67652. /** @hidden */
  67653. _defineLODReflectionAlpha: string;
  67654. /** @hidden */
  67655. _defineLinearSpecularReflection: string;
  67656. private _vEnvironmentIrradianceName;
  67657. /** @hidden */
  67658. _vReflectionMicrosurfaceInfosName: string;
  67659. /** @hidden */
  67660. _vReflectionInfosName: string;
  67661. /** @hidden */
  67662. _vReflectionFilteringInfoName: string;
  67663. private _scene;
  67664. /**
  67665. * The three properties below are set by the main PBR block prior to calling methods of this class.
  67666. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  67667. * It's less burden on the user side in the editor part.
  67668. */
  67669. /** @hidden */
  67670. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  67671. /** @hidden */
  67672. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  67673. /** @hidden */
  67674. cameraPositionConnectionPoint: NodeMaterialConnectionPoint;
  67675. /**
  67676. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  67677. * diffuse part of the IBL.
  67678. */
  67679. useSphericalHarmonics: boolean;
  67680. /**
  67681. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  67682. */
  67683. forceIrradianceInFragment: boolean;
  67684. /**
  67685. * Create a new ReflectionBlock
  67686. * @param name defines the block name
  67687. */
  67688. constructor(name: string);
  67689. /**
  67690. * Gets the current class name
  67691. * @returns the class name
  67692. */
  67693. getClassName(): string;
  67694. /**
  67695. * Gets the position input component
  67696. */
  67697. get position(): NodeMaterialConnectionPoint;
  67698. /**
  67699. * Gets the world position input component
  67700. */
  67701. get worldPosition(): NodeMaterialConnectionPoint;
  67702. /**
  67703. * Gets the world normal input component
  67704. */
  67705. get worldNormal(): NodeMaterialConnectionPoint;
  67706. /**
  67707. * Gets the world input component
  67708. */
  67709. get world(): NodeMaterialConnectionPoint;
  67710. /**
  67711. * Gets the camera (or eye) position component
  67712. */
  67713. get cameraPosition(): NodeMaterialConnectionPoint;
  67714. /**
  67715. * Gets the view input component
  67716. */
  67717. get view(): NodeMaterialConnectionPoint;
  67718. /**
  67719. * Gets the color input component
  67720. */
  67721. get color(): NodeMaterialConnectionPoint;
  67722. /**
  67723. * Gets the reflection object output component
  67724. */
  67725. get reflection(): NodeMaterialConnectionPoint;
  67726. /**
  67727. * Returns true if the block has a texture (either its own texture or the environment texture from the scene, if set)
  67728. */
  67729. get hasTexture(): boolean;
  67730. /**
  67731. * Gets the reflection color (either the name of the variable if the color input is connected, else a default value)
  67732. */
  67733. get reflectionColor(): string;
  67734. protected _getTexture(): Nullable<BaseTexture>;
  67735. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67736. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  67737. /**
  67738. * Gets the code to inject in the vertex shader
  67739. * @param state current state of the node material building
  67740. * @returns the shader code
  67741. */
  67742. handleVertexSide(state: NodeMaterialBuildState): string;
  67743. /**
  67744. * Gets the main code of the block (fragment side)
  67745. * @param state current state of the node material building
  67746. * @param normalVarName name of the existing variable corresponding to the normal
  67747. * @returns the shader code
  67748. */
  67749. getCode(state: NodeMaterialBuildState, normalVarName: string): string;
  67750. protected _buildBlock(state: NodeMaterialBuildState): this;
  67751. protected _dumpPropertiesCode(): string;
  67752. serialize(): any;
  67753. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  67754. }
  67755. }
  67756. declare module "babylonjs/Materials/Node/Blocks/PBR/sheenBlock" {
  67757. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67758. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67759. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67760. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  67761. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67762. import { ReflectionBlock } from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  67763. import { Scene } from "babylonjs/scene";
  67764. import { Nullable } from "babylonjs/types";
  67765. /**
  67766. * Block used to implement the sheen module of the PBR material
  67767. */
  67768. export class SheenBlock extends NodeMaterialBlock {
  67769. /**
  67770. * Create a new SheenBlock
  67771. * @param name defines the block name
  67772. */
  67773. constructor(name: string);
  67774. /**
  67775. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  67776. * It allows the strength of the sheen effect to not depend on the base color of the material,
  67777. * making it easier to setup and tweak the effect
  67778. */
  67779. albedoScaling: boolean;
  67780. /**
  67781. * Defines if the sheen is linked to the sheen color.
  67782. */
  67783. linkSheenWithAlbedo: boolean;
  67784. /**
  67785. * Initialize the block and prepare the context for build
  67786. * @param state defines the state that will be used for the build
  67787. */
  67788. initialize(state: NodeMaterialBuildState): void;
  67789. /**
  67790. * Gets the current class name
  67791. * @returns the class name
  67792. */
  67793. getClassName(): string;
  67794. /**
  67795. * Gets the intensity input component
  67796. */
  67797. get intensity(): NodeMaterialConnectionPoint;
  67798. /**
  67799. * Gets the color input component
  67800. */
  67801. get color(): NodeMaterialConnectionPoint;
  67802. /**
  67803. * Gets the roughness input component
  67804. */
  67805. get roughness(): NodeMaterialConnectionPoint;
  67806. /**
  67807. * Gets the sheen object output component
  67808. */
  67809. get sheen(): NodeMaterialConnectionPoint;
  67810. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67811. /**
  67812. * Gets the main code of the block (fragment side)
  67813. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  67814. * @returns the shader code
  67815. */
  67816. getCode(reflectionBlock: Nullable<ReflectionBlock>): string;
  67817. protected _buildBlock(state: NodeMaterialBuildState): this;
  67818. protected _dumpPropertiesCode(): string;
  67819. serialize(): any;
  67820. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  67821. }
  67822. }
  67823. declare module "babylonjs/Materials/Node/Blocks/PBR/reflectivityBlock" {
  67824. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  67825. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67826. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67827. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67828. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67829. import { Scene } from "babylonjs/scene";
  67830. import { Nullable } from "babylonjs/types";
  67831. import { Mesh } from "babylonjs/Meshes/mesh";
  67832. import { SubMesh } from "babylonjs/Meshes/subMesh";
  67833. import { Effect } from "babylonjs/Materials/effect";
  67834. /**
  67835. * Block used to implement the reflectivity module of the PBR material
  67836. */
  67837. export class ReflectivityBlock extends NodeMaterialBlock {
  67838. private _metallicReflectanceColor;
  67839. private _metallicF0Factor;
  67840. /** @hidden */
  67841. _vMetallicReflectanceFactorsName: string;
  67842. /**
  67843. * The property below is set by the main PBR block prior to calling methods of this class.
  67844. */
  67845. /** @hidden */
  67846. indexOfRefractionConnectionPoint: Nullable<NodeMaterialConnectionPoint>;
  67847. /**
  67848. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  67849. */
  67850. useAmbientOcclusionFromMetallicTextureRed: boolean;
  67851. /**
  67852. * Specifies if the metallic texture contains the metallness information in its blue channel.
  67853. */
  67854. useMetallnessFromMetallicTextureBlue: boolean;
  67855. /**
  67856. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  67857. */
  67858. useRoughnessFromMetallicTextureAlpha: boolean;
  67859. /**
  67860. * Specifies if the metallic texture contains the roughness information in its green channel.
  67861. */
  67862. useRoughnessFromMetallicTextureGreen: boolean;
  67863. /**
  67864. * Create a new ReflectivityBlock
  67865. * @param name defines the block name
  67866. */
  67867. constructor(name: string);
  67868. /**
  67869. * Initialize the block and prepare the context for build
  67870. * @param state defines the state that will be used for the build
  67871. */
  67872. initialize(state: NodeMaterialBuildState): void;
  67873. /**
  67874. * Gets the current class name
  67875. * @returns the class name
  67876. */
  67877. getClassName(): string;
  67878. /**
  67879. * Gets the metallic input component
  67880. */
  67881. get metallic(): NodeMaterialConnectionPoint;
  67882. /**
  67883. * Gets the roughness input component
  67884. */
  67885. get roughness(): NodeMaterialConnectionPoint;
  67886. /**
  67887. * Gets the texture input component
  67888. */
  67889. get texture(): NodeMaterialConnectionPoint;
  67890. /**
  67891. * Gets the reflectivity object output component
  67892. */
  67893. get reflectivity(): NodeMaterialConnectionPoint;
  67894. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  67895. /**
  67896. * Gets the main code of the block (fragment side)
  67897. * @param state current state of the node material building
  67898. * @param aoIntensityVarName name of the variable with the ambient occlusion intensity
  67899. * @returns the shader code
  67900. */
  67901. getCode(state: NodeMaterialBuildState, aoIntensityVarName: string): string;
  67902. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67903. protected _buildBlock(state: NodeMaterialBuildState): this;
  67904. protected _dumpPropertiesCode(): string;
  67905. serialize(): any;
  67906. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  67907. }
  67908. }
  67909. declare module "babylonjs/Materials/Node/Blocks/PBR/anisotropyBlock" {
  67910. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  67911. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67912. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67913. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67914. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67915. /**
  67916. * Block used to implement the anisotropy module of the PBR material
  67917. */
  67918. export class AnisotropyBlock extends NodeMaterialBlock {
  67919. /**
  67920. * The two properties below are set by the main PBR block prior to calling methods of this class.
  67921. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  67922. * It's less burden on the user side in the editor part.
  67923. */
  67924. /** @hidden */
  67925. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  67926. /** @hidden */
  67927. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  67928. /**
  67929. * Create a new AnisotropyBlock
  67930. * @param name defines the block name
  67931. */
  67932. constructor(name: string);
  67933. /**
  67934. * Initialize the block and prepare the context for build
  67935. * @param state defines the state that will be used for the build
  67936. */
  67937. initialize(state: NodeMaterialBuildState): void;
  67938. /**
  67939. * Gets the current class name
  67940. * @returns the class name
  67941. */
  67942. getClassName(): string;
  67943. /**
  67944. * Gets the intensity input component
  67945. */
  67946. get intensity(): NodeMaterialConnectionPoint;
  67947. /**
  67948. * Gets the direction input component
  67949. */
  67950. get direction(): NodeMaterialConnectionPoint;
  67951. /**
  67952. * Gets the texture input component
  67953. */
  67954. get texture(): NodeMaterialConnectionPoint;
  67955. /**
  67956. * Gets the uv input component
  67957. */
  67958. get uv(): NodeMaterialConnectionPoint;
  67959. /**
  67960. * Gets the worldTangent input component
  67961. */
  67962. get worldTangent(): NodeMaterialConnectionPoint;
  67963. /**
  67964. * Gets the anisotropy object output component
  67965. */
  67966. get anisotropy(): NodeMaterialConnectionPoint;
  67967. private _generateTBNSpace;
  67968. /**
  67969. * Gets the main code of the block (fragment side)
  67970. * @param state current state of the node material building
  67971. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  67972. * @returns the shader code
  67973. */
  67974. getCode(state: NodeMaterialBuildState, generateTBNSpace?: boolean): string;
  67975. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67976. protected _buildBlock(state: NodeMaterialBuildState): this;
  67977. }
  67978. }
  67979. declare module "babylonjs/Materials/Node/Blocks/PBR/clearCoatBlock" {
  67980. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67981. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67982. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67983. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  67984. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67985. import { ReflectionBlock } from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  67986. import { Nullable } from "babylonjs/types";
  67987. import { Mesh } from "babylonjs/Meshes/mesh";
  67988. import { SubMesh } from "babylonjs/Meshes/subMesh";
  67989. import { Effect } from "babylonjs/Materials/effect";
  67990. /**
  67991. * Block used to implement the clear coat module of the PBR material
  67992. */
  67993. export class ClearCoatBlock extends NodeMaterialBlock {
  67994. private _scene;
  67995. /**
  67996. * Create a new ClearCoatBlock
  67997. * @param name defines the block name
  67998. */
  67999. constructor(name: string);
  68000. /**
  68001. * Initialize the block and prepare the context for build
  68002. * @param state defines the state that will be used for the build
  68003. */
  68004. initialize(state: NodeMaterialBuildState): void;
  68005. /**
  68006. * Gets the current class name
  68007. * @returns the class name
  68008. */
  68009. getClassName(): string;
  68010. /**
  68011. * Gets the intensity input component
  68012. */
  68013. get intensity(): NodeMaterialConnectionPoint;
  68014. /**
  68015. * Gets the roughness input component
  68016. */
  68017. get roughness(): NodeMaterialConnectionPoint;
  68018. /**
  68019. * Gets the ior input component
  68020. */
  68021. get ior(): NodeMaterialConnectionPoint;
  68022. /**
  68023. * Gets the texture input component
  68024. */
  68025. get texture(): NodeMaterialConnectionPoint;
  68026. /**
  68027. * Gets the bump texture input component
  68028. */
  68029. get bumpTexture(): NodeMaterialConnectionPoint;
  68030. /**
  68031. * Gets the uv input component
  68032. */
  68033. get uv(): NodeMaterialConnectionPoint;
  68034. /**
  68035. * Gets the tint color input component
  68036. */
  68037. get tintColor(): NodeMaterialConnectionPoint;
  68038. /**
  68039. * Gets the tint "at distance" input component
  68040. */
  68041. get tintAtDistance(): NodeMaterialConnectionPoint;
  68042. /**
  68043. * Gets the tint thickness input component
  68044. */
  68045. get tintThickness(): NodeMaterialConnectionPoint;
  68046. /**
  68047. * Gets the world tangent input component
  68048. */
  68049. get worldTangent(): NodeMaterialConnectionPoint;
  68050. /**
  68051. * Gets the clear coat object output component
  68052. */
  68053. get clearcoat(): NodeMaterialConnectionPoint;
  68054. autoConfigure(material: NodeMaterial): void;
  68055. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  68056. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  68057. private _generateTBNSpace;
  68058. /**
  68059. * Gets the main code of the block (fragment side)
  68060. * @param state current state of the node material building
  68061. * @param ccBlock instance of a ClearCoatBlock or null if the code must be generated without an active clear coat module
  68062. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  68063. * @param worldPosVarName name of the variable holding the world position
  68064. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  68065. * @param vTBNAvailable indicate that the vTBN variable is already existing because it has already been generated by another block (PerturbNormal or Anisotropy)
  68066. * @param worldNormalVarName name of the variable holding the world normal
  68067. * @returns the shader code
  68068. */
  68069. static GetCode(state: NodeMaterialBuildState, ccBlock: Nullable<ClearCoatBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string, generateTBNSpace: boolean, vTBNAvailable: boolean, worldNormalVarName: string): string;
  68070. protected _buildBlock(state: NodeMaterialBuildState): this;
  68071. }
  68072. }
  68073. declare module "babylonjs/Materials/Node/Blocks/PBR/subSurfaceBlock" {
  68074. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68075. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68076. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68077. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  68078. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  68079. import { ReflectionBlock } from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  68080. import { Nullable } from "babylonjs/types";
  68081. /**
  68082. * Block used to implement the sub surface module of the PBR material
  68083. */
  68084. export class SubSurfaceBlock extends NodeMaterialBlock {
  68085. /**
  68086. * Create a new SubSurfaceBlock
  68087. * @param name defines the block name
  68088. */
  68089. constructor(name: string);
  68090. /**
  68091. * Stores the intensity of the different subsurface effects in the thickness texture.
  68092. * * the green channel is the translucency intensity.
  68093. * * the blue channel is the scattering intensity.
  68094. * * the alpha channel is the refraction intensity.
  68095. */
  68096. useMaskFromThicknessTexture: boolean;
  68097. /**
  68098. * Initialize the block and prepare the context for build
  68099. * @param state defines the state that will be used for the build
  68100. */
  68101. initialize(state: NodeMaterialBuildState): void;
  68102. /**
  68103. * Gets the current class name
  68104. * @returns the class name
  68105. */
  68106. getClassName(): string;
  68107. /**
  68108. * Gets the min thickness input component
  68109. */
  68110. get minThickness(): NodeMaterialConnectionPoint;
  68111. /**
  68112. * Gets the max thickness input component
  68113. */
  68114. get maxThickness(): NodeMaterialConnectionPoint;
  68115. /**
  68116. * Gets the thickness texture component
  68117. */
  68118. get thicknessTexture(): NodeMaterialConnectionPoint;
  68119. /**
  68120. * Gets the tint color input component
  68121. */
  68122. get tintColor(): NodeMaterialConnectionPoint;
  68123. /**
  68124. * Gets the translucency intensity input component
  68125. */
  68126. get translucencyIntensity(): NodeMaterialConnectionPoint;
  68127. /**
  68128. * Gets the translucency diffusion distance input component
  68129. */
  68130. get translucencyDiffusionDistance(): NodeMaterialConnectionPoint;
  68131. /**
  68132. * Gets the refraction object parameters
  68133. */
  68134. get refraction(): NodeMaterialConnectionPoint;
  68135. /**
  68136. * Gets the sub surface object output component
  68137. */
  68138. get subsurface(): NodeMaterialConnectionPoint;
  68139. autoConfigure(material: NodeMaterial): void;
  68140. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  68141. /**
  68142. * Gets the main code of the block (fragment side)
  68143. * @param state current state of the node material building
  68144. * @param ssBlock instance of a SubSurfaceBlock or null if the code must be generated without an active sub surface module
  68145. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  68146. * @param worldPosVarName name of the variable holding the world position
  68147. * @returns the shader code
  68148. */
  68149. static GetCode(state: NodeMaterialBuildState, ssBlock: Nullable<SubSurfaceBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string): string;
  68150. protected _buildBlock(state: NodeMaterialBuildState): this;
  68151. }
  68152. }
  68153. declare module "babylonjs/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock" {
  68154. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68155. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68156. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68157. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  68158. import { Light } from "babylonjs/Lights/light";
  68159. import { Nullable } from "babylonjs/types";
  68160. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  68161. import { Effect } from "babylonjs/Materials/effect";
  68162. import { Mesh } from "babylonjs/Meshes/mesh";
  68163. import { Scene } from "babylonjs/scene";
  68164. /**
  68165. * Block used to implement the PBR metallic/roughness model
  68166. */
  68167. export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
  68168. /**
  68169. * Gets or sets the light associated with this block
  68170. */
  68171. light: Nullable<Light>;
  68172. private _lightId;
  68173. private _scene;
  68174. private _environmentBRDFTexture;
  68175. private _environmentBrdfSamplerName;
  68176. private _vNormalWName;
  68177. private _invertNormalName;
  68178. /**
  68179. * Create a new ReflectionBlock
  68180. * @param name defines the block name
  68181. */
  68182. constructor(name: string);
  68183. /**
  68184. * Intensity of the direct lights e.g. the four lights available in your scene.
  68185. * This impacts both the direct diffuse and specular highlights.
  68186. */
  68187. directIntensity: number;
  68188. /**
  68189. * Intensity of the environment e.g. how much the environment will light the object
  68190. * either through harmonics for rough material or through the refelction for shiny ones.
  68191. */
  68192. environmentIntensity: number;
  68193. /**
  68194. * This is a special control allowing the reduction of the specular highlights coming from the
  68195. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  68196. */
  68197. specularIntensity: number;
  68198. /**
  68199. * Defines the falloff type used in this material.
  68200. * It by default is Physical.
  68201. */
  68202. lightFalloff: number;
  68203. /**
  68204. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  68205. */
  68206. useAlphaFromAlbedoTexture: boolean;
  68207. /**
  68208. * Specifies that alpha test should be used
  68209. */
  68210. useAlphaTest: boolean;
  68211. /**
  68212. * Defines the alpha limits in alpha test mode.
  68213. */
  68214. alphaTestCutoff: number;
  68215. /**
  68216. * Specifies that alpha blending should be used
  68217. */
  68218. useAlphaBlending: boolean;
  68219. /**
  68220. * Defines if the alpha value should be determined via the rgb values.
  68221. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  68222. */
  68223. opacityRGB: boolean;
  68224. /**
  68225. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  68226. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  68227. */
  68228. useRadianceOverAlpha: boolean;
  68229. /**
  68230. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most luminous ones).
  68231. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  68232. */
  68233. useSpecularOverAlpha: boolean;
  68234. /**
  68235. * Enables specular anti aliasing in the PBR shader.
  68236. * It will both interacts on the Geometry for analytical and IBL lighting.
  68237. * It also prefilter the roughness map based on the bump values.
  68238. */
  68239. enableSpecularAntiAliasing: boolean;
  68240. /**
  68241. * Enables realtime filtering on the texture.
  68242. */
  68243. realTimeFiltering: boolean;
  68244. /**
  68245. * Quality switch for realtime filtering
  68246. */
  68247. realTimeFilteringQuality: number;
  68248. /**
  68249. * Defines if the material uses energy conservation.
  68250. */
  68251. useEnergyConservation: boolean;
  68252. /**
  68253. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  68254. * too much the area relying on ambient texture to define their ambient occlusion.
  68255. */
  68256. useRadianceOcclusion: boolean;
  68257. /**
  68258. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  68259. * makes the reflect vector face the model (under horizon).
  68260. */
  68261. useHorizonOcclusion: boolean;
  68262. /**
  68263. * If set to true, no lighting calculations will be applied.
  68264. */
  68265. unlit: boolean;
  68266. /**
  68267. * Force normal to face away from face.
  68268. */
  68269. forceNormalForward: boolean;
  68270. /**
  68271. * Defines the material debug mode.
  68272. * It helps seeing only some components of the material while troubleshooting.
  68273. */
  68274. debugMode: number;
  68275. /**
  68276. * Specify from where on screen the debug mode should start.
  68277. * The value goes from -1 (full screen) to 1 (not visible)
  68278. * It helps with side by side comparison against the final render
  68279. * This defaults to 0
  68280. */
  68281. debugLimit: number;
  68282. /**
  68283. * As the default viewing range might not be enough (if the ambient is really small for instance)
  68284. * You can use the factor to better multiply the final value.
  68285. */
  68286. debugFactor: number;
  68287. /**
  68288. * Initialize the block and prepare the context for build
  68289. * @param state defines the state that will be used for the build
  68290. */
  68291. initialize(state: NodeMaterialBuildState): void;
  68292. /**
  68293. * Gets the current class name
  68294. * @returns the class name
  68295. */
  68296. getClassName(): string;
  68297. /**
  68298. * Gets the world position input component
  68299. */
  68300. get worldPosition(): NodeMaterialConnectionPoint;
  68301. /**
  68302. * Gets the world normal input component
  68303. */
  68304. get worldNormal(): NodeMaterialConnectionPoint;
  68305. /**
  68306. * Gets the perturbed normal input component
  68307. */
  68308. get perturbedNormal(): NodeMaterialConnectionPoint;
  68309. /**
  68310. * Gets the camera position input component
  68311. */
  68312. get cameraPosition(): NodeMaterialConnectionPoint;
  68313. /**
  68314. * Gets the base color input component
  68315. */
  68316. get baseColor(): NodeMaterialConnectionPoint;
  68317. /**
  68318. * Gets the opacity texture input component
  68319. */
  68320. get opacityTexture(): NodeMaterialConnectionPoint;
  68321. /**
  68322. * Gets the ambient color input component
  68323. */
  68324. get ambientColor(): NodeMaterialConnectionPoint;
  68325. /**
  68326. * Gets the reflectivity object parameters
  68327. */
  68328. get reflectivity(): NodeMaterialConnectionPoint;
  68329. /**
  68330. * Gets the ambient occlusion object parameters
  68331. */
  68332. get ambientOcclusion(): NodeMaterialConnectionPoint;
  68333. /**
  68334. * Gets the reflection object parameters
  68335. */
  68336. get reflection(): NodeMaterialConnectionPoint;
  68337. /**
  68338. * Gets the sheen object parameters
  68339. */
  68340. get sheen(): NodeMaterialConnectionPoint;
  68341. /**
  68342. * Gets the clear coat object parameters
  68343. */
  68344. get clearcoat(): NodeMaterialConnectionPoint;
  68345. /**
  68346. * Gets the sub surface object parameters
  68347. */
  68348. get subsurface(): NodeMaterialConnectionPoint;
  68349. /**
  68350. * Gets the anisotropy object parameters
  68351. */
  68352. get anisotropy(): NodeMaterialConnectionPoint;
  68353. /**
  68354. * Gets the ambient output component
  68355. */
  68356. get ambient(): NodeMaterialConnectionPoint;
  68357. /**
  68358. * Gets the diffuse output component
  68359. */
  68360. get diffuse(): NodeMaterialConnectionPoint;
  68361. /**
  68362. * Gets the specular output component
  68363. */
  68364. get specular(): NodeMaterialConnectionPoint;
  68365. /**
  68366. * Gets the sheen output component
  68367. */
  68368. get sheenDir(): NodeMaterialConnectionPoint;
  68369. /**
  68370. * Gets the clear coat output component
  68371. */
  68372. get clearcoatDir(): NodeMaterialConnectionPoint;
  68373. /**
  68374. * Gets the indirect diffuse output component
  68375. */
  68376. get diffuseIndirect(): NodeMaterialConnectionPoint;
  68377. /**
  68378. * Gets the indirect specular output component
  68379. */
  68380. get specularIndirect(): NodeMaterialConnectionPoint;
  68381. /**
  68382. * Gets the indirect sheen output component
  68383. */
  68384. get sheenIndirect(): NodeMaterialConnectionPoint;
  68385. /**
  68386. * Gets the indirect clear coat output component
  68387. */
  68388. get clearcoatIndirect(): NodeMaterialConnectionPoint;
  68389. /**
  68390. * Gets the refraction output component
  68391. */
  68392. get refraction(): NodeMaterialConnectionPoint;
  68393. /**
  68394. * Gets the global lighting output component
  68395. */
  68396. get lighting(): NodeMaterialConnectionPoint;
  68397. /**
  68398. * Gets the shadow output component
  68399. */
  68400. get shadow(): NodeMaterialConnectionPoint;
  68401. /**
  68402. * Gets the alpha output component
  68403. */
  68404. get alpha(): NodeMaterialConnectionPoint;
  68405. autoConfigure(material: NodeMaterial): void;
  68406. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  68407. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  68408. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  68409. private _injectVertexCode;
  68410. /**
  68411. * Gets the code corresponding to the albedo/opacity module
  68412. * @returns the shader code
  68413. */
  68414. getAlbedoOpacityCode(): string;
  68415. protected _buildBlock(state: NodeMaterialBuildState): this;
  68416. protected _dumpPropertiesCode(): string;
  68417. serialize(): any;
  68418. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  68419. }
  68420. }
  68421. declare module "babylonjs/Materials/Node/Blocks/PBR/index" {
  68422. export * from "babylonjs/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock";
  68423. export * from "babylonjs/Materials/Node/Blocks/PBR/sheenBlock";
  68424. export * from "babylonjs/Materials/Node/Blocks/PBR/ambientOcclusionBlock";
  68425. export * from "babylonjs/Materials/Node/Blocks/PBR/reflectivityBlock";
  68426. export * from "babylonjs/Materials/Node/Blocks/PBR/anisotropyBlock";
  68427. export * from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  68428. export * from "babylonjs/Materials/Node/Blocks/PBR/clearCoatBlock";
  68429. export * from "babylonjs/Materials/Node/Blocks/PBR/refractionBlock";
  68430. export * from "babylonjs/Materials/Node/Blocks/PBR/subSurfaceBlock";
  68431. }
  68432. declare module "babylonjs/Materials/Node/Blocks/Particle/index" {
  68433. export * from "babylonjs/Materials/Node/Blocks/Particle/particleTextureBlock";
  68434. export * from "babylonjs/Materials/Node/Blocks/Particle/particleRampGradientBlock";
  68435. export * from "babylonjs/Materials/Node/Blocks/Particle/particleBlendMultiplyBlock";
  68436. }
  68437. declare module "babylonjs/Materials/Node/Blocks/modBlock" {
  68438. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68439. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68440. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68441. /**
  68442. * Block used to compute value of one parameter modulo another
  68443. */
  68444. export class ModBlock extends NodeMaterialBlock {
  68445. /**
  68446. * Creates a new ModBlock
  68447. * @param name defines the block name
  68448. */
  68449. constructor(name: string);
  68450. /**
  68451. * Gets the current class name
  68452. * @returns the class name
  68453. */
  68454. getClassName(): string;
  68455. /**
  68456. * Gets the left operand input component
  68457. */
  68458. get left(): NodeMaterialConnectionPoint;
  68459. /**
  68460. * Gets the right operand input component
  68461. */
  68462. get right(): NodeMaterialConnectionPoint;
  68463. /**
  68464. * Gets the output component
  68465. */
  68466. get output(): NodeMaterialConnectionPoint;
  68467. protected _buildBlock(state: NodeMaterialBuildState): this;
  68468. }
  68469. }
  68470. declare module "babylonjs/Materials/Node/Blocks/index" {
  68471. export * from "babylonjs/Materials/Node/Blocks/Vertex/index";
  68472. export * from "babylonjs/Materials/Node/Blocks/Fragment/index";
  68473. export * from "babylonjs/Materials/Node/Blocks/Dual/index";
  68474. export * from "babylonjs/Materials/Node/Blocks/Input/index";
  68475. export * from "babylonjs/Materials/Node/Blocks/multiplyBlock";
  68476. export * from "babylonjs/Materials/Node/Blocks/addBlock";
  68477. export * from "babylonjs/Materials/Node/Blocks/scaleBlock";
  68478. export * from "babylonjs/Materials/Node/Blocks/clampBlock";
  68479. export * from "babylonjs/Materials/Node/Blocks/crossBlock";
  68480. export * from "babylonjs/Materials/Node/Blocks/dotBlock";
  68481. export * from "babylonjs/Materials/Node/Blocks/transformBlock";
  68482. export * from "babylonjs/Materials/Node/Blocks/remapBlock";
  68483. export * from "babylonjs/Materials/Node/Blocks/normalizeBlock";
  68484. export * from "babylonjs/Materials/Node/Blocks/trigonometryBlock";
  68485. export * from "babylonjs/Materials/Node/Blocks/colorMergerBlock";
  68486. export * from "babylonjs/Materials/Node/Blocks/vectorMergerBlock";
  68487. export * from "babylonjs/Materials/Node/Blocks/colorSplitterBlock";
  68488. export * from "babylonjs/Materials/Node/Blocks/vectorSplitterBlock";
  68489. export * from "babylonjs/Materials/Node/Blocks/lerpBlock";
  68490. export * from "babylonjs/Materials/Node/Blocks/divideBlock";
  68491. export * from "babylonjs/Materials/Node/Blocks/subtractBlock";
  68492. export * from "babylonjs/Materials/Node/Blocks/stepBlock";
  68493. export * from "babylonjs/Materials/Node/Blocks/oneMinusBlock";
  68494. export * from "babylonjs/Materials/Node/Blocks/viewDirectionBlock";
  68495. export * from "babylonjs/Materials/Node/Blocks/fresnelBlock";
  68496. export * from "babylonjs/Materials/Node/Blocks/maxBlock";
  68497. export * from "babylonjs/Materials/Node/Blocks/minBlock";
  68498. export * from "babylonjs/Materials/Node/Blocks/distanceBlock";
  68499. export * from "babylonjs/Materials/Node/Blocks/lengthBlock";
  68500. export * from "babylonjs/Materials/Node/Blocks/negateBlock";
  68501. export * from "babylonjs/Materials/Node/Blocks/powBlock";
  68502. export * from "babylonjs/Materials/Node/Blocks/randomNumberBlock";
  68503. export * from "babylonjs/Materials/Node/Blocks/arcTan2Block";
  68504. export * from "babylonjs/Materials/Node/Blocks/smoothStepBlock";
  68505. export * from "babylonjs/Materials/Node/Blocks/reciprocalBlock";
  68506. export * from "babylonjs/Materials/Node/Blocks/replaceColorBlock";
  68507. export * from "babylonjs/Materials/Node/Blocks/posterizeBlock";
  68508. export * from "babylonjs/Materials/Node/Blocks/waveBlock";
  68509. export * from "babylonjs/Materials/Node/Blocks/gradientBlock";
  68510. export * from "babylonjs/Materials/Node/Blocks/nLerpBlock";
  68511. export * from "babylonjs/Materials/Node/Blocks/worleyNoise3DBlock";
  68512. export * from "babylonjs/Materials/Node/Blocks/simplexPerlin3DBlock";
  68513. export * from "babylonjs/Materials/Node/Blocks/normalBlendBlock";
  68514. export * from "babylonjs/Materials/Node/Blocks/rotate2dBlock";
  68515. export * from "babylonjs/Materials/Node/Blocks/reflectBlock";
  68516. export * from "babylonjs/Materials/Node/Blocks/refractBlock";
  68517. export * from "babylonjs/Materials/Node/Blocks/desaturateBlock";
  68518. export * from "babylonjs/Materials/Node/Blocks/PBR/index";
  68519. export * from "babylonjs/Materials/Node/Blocks/Particle/index";
  68520. export * from "babylonjs/Materials/Node/Blocks/modBlock";
  68521. }
  68522. declare module "babylonjs/Materials/Node/Optimizers/index" {
  68523. export * from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  68524. }
  68525. declare module "babylonjs/Materials/Node/index" {
  68526. export * from "babylonjs/Materials/Node/Enums/index";
  68527. export * from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68528. export * from "babylonjs/Materials/Node/nodeMaterialBlock";
  68529. export * from "babylonjs/Materials/Node/nodeMaterial";
  68530. export * from "babylonjs/Materials/Node/Blocks/index";
  68531. export * from "babylonjs/Materials/Node/Optimizers/index";
  68532. export * from "babylonjs/Materials/Node/nodeMaterialDecorator";
  68533. }
  68534. declare module "babylonjs/Materials/index" {
  68535. export * from "babylonjs/Materials/Background/index";
  68536. export * from "babylonjs/Materials/colorCurves";
  68537. export * from "babylonjs/Materials/iEffectFallbacks";
  68538. export * from "babylonjs/Materials/effectFallbacks";
  68539. export * from "babylonjs/Materials/effect";
  68540. export * from "babylonjs/Materials/fresnelParameters";
  68541. export * from "babylonjs/Materials/imageProcessingConfiguration";
  68542. export * from "babylonjs/Materials/material";
  68543. export * from "babylonjs/Materials/materialDefines";
  68544. export * from "babylonjs/Materials/thinMaterialHelper";
  68545. export * from "babylonjs/Materials/materialHelper";
  68546. export * from "babylonjs/Materials/multiMaterial";
  68547. export * from "babylonjs/Materials/PBR/index";
  68548. export * from "babylonjs/Materials/pushMaterial";
  68549. export * from "babylonjs/Materials/shaderMaterial";
  68550. export * from "babylonjs/Materials/standardMaterial";
  68551. export * from "babylonjs/Materials/Textures/index";
  68552. export * from "babylonjs/Materials/uniformBuffer";
  68553. export * from "babylonjs/Materials/materialFlags";
  68554. export * from "babylonjs/Materials/Node/index";
  68555. export * from "babylonjs/Materials/effectRenderer";
  68556. export * from "babylonjs/Materials/shadowDepthWrapper";
  68557. }
  68558. declare module "babylonjs/Maths/index" {
  68559. export * from "babylonjs/Maths/math.scalar";
  68560. export * from "babylonjs/Maths/math";
  68561. export * from "babylonjs/Maths/sphericalPolynomial";
  68562. }
  68563. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  68564. import { IDisposable } from "babylonjs/scene";
  68565. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  68566. /**
  68567. * Configuration for Draco compression
  68568. */
  68569. export interface IDracoCompressionConfiguration {
  68570. /**
  68571. * Configuration for the decoder.
  68572. */
  68573. decoder: {
  68574. /**
  68575. * The url to the WebAssembly module.
  68576. */
  68577. wasmUrl?: string;
  68578. /**
  68579. * The url to the WebAssembly binary.
  68580. */
  68581. wasmBinaryUrl?: string;
  68582. /**
  68583. * The url to the fallback JavaScript module.
  68584. */
  68585. fallbackUrl?: string;
  68586. };
  68587. }
  68588. /**
  68589. * Draco compression (https://google.github.io/draco/)
  68590. *
  68591. * This class wraps the Draco module.
  68592. *
  68593. * **Encoder**
  68594. *
  68595. * The encoder is not currently implemented.
  68596. *
  68597. * **Decoder**
  68598. *
  68599. * 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.
  68600. *
  68601. * To update the configuration, use the following code:
  68602. * ```javascript
  68603. * DracoCompression.Configuration = {
  68604. * decoder: {
  68605. * wasmUrl: "<url to the WebAssembly library>",
  68606. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  68607. * fallbackUrl: "<url to the fallback JavaScript library>",
  68608. * }
  68609. * };
  68610. * ```
  68611. *
  68612. * 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.
  68613. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  68614. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  68615. *
  68616. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  68617. * ```javascript
  68618. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  68619. * ```
  68620. *
  68621. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  68622. */
  68623. export class DracoCompression implements IDisposable {
  68624. private _workerPoolPromise?;
  68625. private _decoderModulePromise?;
  68626. /**
  68627. * The configuration. Defaults to the following urls:
  68628. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  68629. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  68630. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  68631. */
  68632. static Configuration: IDracoCompressionConfiguration;
  68633. /**
  68634. * Returns true if the decoder configuration is available.
  68635. */
  68636. static get DecoderAvailable(): boolean;
  68637. /**
  68638. * Default number of workers to create when creating the draco compression object.
  68639. */
  68640. static DefaultNumWorkers: number;
  68641. private static GetDefaultNumWorkers;
  68642. private static _Default;
  68643. /**
  68644. * Default instance for the draco compression object.
  68645. */
  68646. static get Default(): DracoCompression;
  68647. /**
  68648. * Constructor
  68649. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  68650. */
  68651. constructor(numWorkers?: number);
  68652. /**
  68653. * Stop all async operations and release resources.
  68654. */
  68655. dispose(): void;
  68656. /**
  68657. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  68658. * @returns a promise that resolves when ready
  68659. */
  68660. whenReadyAsync(): Promise<void>;
  68661. /**
  68662. * Decode Draco compressed mesh data to vertex data.
  68663. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  68664. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  68665. * @returns A promise that resolves with the decoded vertex data
  68666. */
  68667. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  68668. [kind: string]: number;
  68669. }): Promise<VertexData>;
  68670. }
  68671. }
  68672. declare module "babylonjs/Meshes/Compression/index" {
  68673. export * from "babylonjs/Meshes/Compression/dracoCompression";
  68674. }
  68675. declare module "babylonjs/Meshes/csg" {
  68676. import { Nullable } from "babylonjs/types";
  68677. import { Scene } from "babylonjs/scene";
  68678. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  68679. import { Mesh } from "babylonjs/Meshes/mesh";
  68680. import { Material } from "babylonjs/Materials/material";
  68681. /**
  68682. * Class for building Constructive Solid Geometry
  68683. */
  68684. export class CSG {
  68685. private polygons;
  68686. /**
  68687. * The world matrix
  68688. */
  68689. matrix: Matrix;
  68690. /**
  68691. * Stores the position
  68692. */
  68693. position: Vector3;
  68694. /**
  68695. * Stores the rotation
  68696. */
  68697. rotation: Vector3;
  68698. /**
  68699. * Stores the rotation quaternion
  68700. */
  68701. rotationQuaternion: Nullable<Quaternion>;
  68702. /**
  68703. * Stores the scaling vector
  68704. */
  68705. scaling: Vector3;
  68706. /**
  68707. * Convert the Mesh to CSG
  68708. * @param mesh The Mesh to convert to CSG
  68709. * @returns A new CSG from the Mesh
  68710. */
  68711. static FromMesh(mesh: Mesh): CSG;
  68712. /**
  68713. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  68714. * @param polygons Polygons used to construct a CSG solid
  68715. */
  68716. private static FromPolygons;
  68717. /**
  68718. * Clones, or makes a deep copy, of the CSG
  68719. * @returns A new CSG
  68720. */
  68721. clone(): CSG;
  68722. /**
  68723. * Unions this CSG with another CSG
  68724. * @param csg The CSG to union against this CSG
  68725. * @returns The unioned CSG
  68726. */
  68727. union(csg: CSG): CSG;
  68728. /**
  68729. * Unions this CSG with another CSG in place
  68730. * @param csg The CSG to union against this CSG
  68731. */
  68732. unionInPlace(csg: CSG): void;
  68733. /**
  68734. * Subtracts this CSG with another CSG
  68735. * @param csg The CSG to subtract against this CSG
  68736. * @returns A new CSG
  68737. */
  68738. subtract(csg: CSG): CSG;
  68739. /**
  68740. * Subtracts this CSG with another CSG in place
  68741. * @param csg The CSG to subtact against this CSG
  68742. */
  68743. subtractInPlace(csg: CSG): void;
  68744. /**
  68745. * Intersect this CSG with another CSG
  68746. * @param csg The CSG to intersect against this CSG
  68747. * @returns A new CSG
  68748. */
  68749. intersect(csg: CSG): CSG;
  68750. /**
  68751. * Intersects this CSG with another CSG in place
  68752. * @param csg The CSG to intersect against this CSG
  68753. */
  68754. intersectInPlace(csg: CSG): void;
  68755. /**
  68756. * Return a new CSG solid with solid and empty space switched. This solid is
  68757. * not modified.
  68758. * @returns A new CSG solid with solid and empty space switched
  68759. */
  68760. inverse(): CSG;
  68761. /**
  68762. * Inverses the CSG in place
  68763. */
  68764. inverseInPlace(): void;
  68765. /**
  68766. * This is used to keep meshes transformations so they can be restored
  68767. * when we build back a Babylon Mesh
  68768. * NB : All CSG operations are performed in world coordinates
  68769. * @param csg The CSG to copy the transform attributes from
  68770. * @returns This CSG
  68771. */
  68772. copyTransformAttributes(csg: CSG): CSG;
  68773. /**
  68774. * Build Raw mesh from CSG
  68775. * Coordinates here are in world space
  68776. * @param name The name of the mesh geometry
  68777. * @param scene The Scene
  68778. * @param keepSubMeshes Specifies if the submeshes should be kept
  68779. * @returns A new Mesh
  68780. */
  68781. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  68782. /**
  68783. * Build Mesh from CSG taking material and transforms into account
  68784. * @param name The name of the Mesh
  68785. * @param material The material of the Mesh
  68786. * @param scene The Scene
  68787. * @param keepSubMeshes Specifies if submeshes should be kept
  68788. * @returns The new Mesh
  68789. */
  68790. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  68791. }
  68792. }
  68793. declare module "babylonjs/Meshes/trailMesh" {
  68794. import { Mesh } from "babylonjs/Meshes/mesh";
  68795. import { Scene } from "babylonjs/scene";
  68796. import { TransformNode } from "babylonjs/Meshes/transformNode";
  68797. /**
  68798. * Class used to create a trail following a mesh
  68799. */
  68800. export class TrailMesh extends Mesh {
  68801. private _generator;
  68802. private _autoStart;
  68803. private _running;
  68804. private _diameter;
  68805. private _length;
  68806. private _sectionPolygonPointsCount;
  68807. private _sectionVectors;
  68808. private _sectionNormalVectors;
  68809. private _beforeRenderObserver;
  68810. /**
  68811. * @constructor
  68812. * @param name The value used by scene.getMeshByName() to do a lookup.
  68813. * @param generator The mesh or transform node to generate a trail.
  68814. * @param scene The scene to add this mesh to.
  68815. * @param diameter Diameter of trailing mesh. Default is 1.
  68816. * @param length Length of trailing mesh. Default is 60.
  68817. * @param autoStart Automatically start trailing mesh. Default true.
  68818. */
  68819. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  68820. /**
  68821. * "TrailMesh"
  68822. * @returns "TrailMesh"
  68823. */
  68824. getClassName(): string;
  68825. private _createMesh;
  68826. /**
  68827. * Start trailing mesh.
  68828. */
  68829. start(): void;
  68830. /**
  68831. * Stop trailing mesh.
  68832. */
  68833. stop(): void;
  68834. /**
  68835. * Update trailing mesh geometry.
  68836. */
  68837. update(): void;
  68838. /**
  68839. * Returns a new TrailMesh object.
  68840. * @param name is a string, the name given to the new mesh
  68841. * @param newGenerator use new generator object for cloned trail mesh
  68842. * @returns a new mesh
  68843. */
  68844. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  68845. /**
  68846. * Serializes this trail mesh
  68847. * @param serializationObject object to write serialization to
  68848. */
  68849. serialize(serializationObject: any): void;
  68850. /**
  68851. * Parses a serialized trail mesh
  68852. * @param parsedMesh the serialized mesh
  68853. * @param scene the scene to create the trail mesh in
  68854. * @returns the created trail mesh
  68855. */
  68856. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  68857. }
  68858. }
  68859. declare module "babylonjs/Meshes/Builders/tiledBoxBuilder" {
  68860. import { Nullable } from "babylonjs/types";
  68861. import { Scene } from "babylonjs/scene";
  68862. import { Vector4 } from "babylonjs/Maths/math.vector";
  68863. import { Color4 } from "babylonjs/Maths/math.color";
  68864. import { Mesh } from "babylonjs/Meshes/mesh";
  68865. /**
  68866. * Class containing static functions to help procedurally build meshes
  68867. */
  68868. export class TiledBoxBuilder {
  68869. /**
  68870. * Creates a box mesh
  68871. * 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)
  68872. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  68873. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68874. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68875. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68876. * @param name defines the name of the mesh
  68877. * @param options defines the options used to create the mesh
  68878. * @param scene defines the hosting scene
  68879. * @returns the box mesh
  68880. */
  68881. static CreateTiledBox(name: string, options: {
  68882. pattern?: number;
  68883. width?: number;
  68884. height?: number;
  68885. depth?: number;
  68886. tileSize?: number;
  68887. tileWidth?: number;
  68888. tileHeight?: number;
  68889. alignHorizontal?: number;
  68890. alignVertical?: number;
  68891. faceUV?: Vector4[];
  68892. faceColors?: Color4[];
  68893. sideOrientation?: number;
  68894. updatable?: boolean;
  68895. }, scene?: Nullable<Scene>): Mesh;
  68896. }
  68897. }
  68898. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  68899. import { Vector4 } from "babylonjs/Maths/math.vector";
  68900. import { Mesh } from "babylonjs/Meshes/mesh";
  68901. /**
  68902. * Class containing static functions to help procedurally build meshes
  68903. */
  68904. export class TorusKnotBuilder {
  68905. /**
  68906. * Creates a torus knot mesh
  68907. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  68908. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  68909. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  68910. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  68911. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68912. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68913. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  68914. * @param name defines the name of the mesh
  68915. * @param options defines the options used to create the mesh
  68916. * @param scene defines the hosting scene
  68917. * @returns the torus knot mesh
  68918. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  68919. */
  68920. static CreateTorusKnot(name: string, options: {
  68921. radius?: number;
  68922. tube?: number;
  68923. radialSegments?: number;
  68924. tubularSegments?: number;
  68925. p?: number;
  68926. q?: number;
  68927. updatable?: boolean;
  68928. sideOrientation?: number;
  68929. frontUVs?: Vector4;
  68930. backUVs?: Vector4;
  68931. }, scene: any): Mesh;
  68932. }
  68933. }
  68934. declare module "babylonjs/Meshes/polygonMesh" {
  68935. import { Scene } from "babylonjs/scene";
  68936. import { Vector2 } from "babylonjs/Maths/math.vector";
  68937. import { Mesh } from "babylonjs/Meshes/mesh";
  68938. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  68939. import { Path2 } from "babylonjs/Maths/math.path";
  68940. /**
  68941. * Polygon
  68942. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  68943. */
  68944. export class Polygon {
  68945. /**
  68946. * Creates a rectangle
  68947. * @param xmin bottom X coord
  68948. * @param ymin bottom Y coord
  68949. * @param xmax top X coord
  68950. * @param ymax top Y coord
  68951. * @returns points that make the resulting rectation
  68952. */
  68953. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  68954. /**
  68955. * Creates a circle
  68956. * @param radius radius of circle
  68957. * @param cx scale in x
  68958. * @param cy scale in y
  68959. * @param numberOfSides number of sides that make up the circle
  68960. * @returns points that make the resulting circle
  68961. */
  68962. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  68963. /**
  68964. * Creates a polygon from input string
  68965. * @param input Input polygon data
  68966. * @returns the parsed points
  68967. */
  68968. static Parse(input: string): Vector2[];
  68969. /**
  68970. * Starts building a polygon from x and y coordinates
  68971. * @param x x coordinate
  68972. * @param y y coordinate
  68973. * @returns the started path2
  68974. */
  68975. static StartingAt(x: number, y: number): Path2;
  68976. }
  68977. /**
  68978. * Builds a polygon
  68979. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  68980. */
  68981. export class PolygonMeshBuilder {
  68982. private _points;
  68983. private _outlinepoints;
  68984. private _holes;
  68985. private _name;
  68986. private _scene;
  68987. private _epoints;
  68988. private _eholes;
  68989. private _addToepoint;
  68990. /**
  68991. * Babylon reference to the earcut plugin.
  68992. */
  68993. bjsEarcut: any;
  68994. /**
  68995. * Creates a PolygonMeshBuilder
  68996. * @param name name of the builder
  68997. * @param contours Path of the polygon
  68998. * @param scene scene to add to when creating the mesh
  68999. * @param earcutInjection can be used to inject your own earcut reference
  69000. */
  69001. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  69002. /**
  69003. * Adds a whole within the polygon
  69004. * @param hole Array of points defining the hole
  69005. * @returns this
  69006. */
  69007. addHole(hole: Vector2[]): PolygonMeshBuilder;
  69008. /**
  69009. * Creates the polygon
  69010. * @param updatable If the mesh should be updatable
  69011. * @param depth The depth of the mesh created
  69012. * @returns the created mesh
  69013. */
  69014. build(updatable?: boolean, depth?: number): Mesh;
  69015. /**
  69016. * Creates the polygon
  69017. * @param depth The depth of the mesh created
  69018. * @returns the created VertexData
  69019. */
  69020. buildVertexData(depth?: number): VertexData;
  69021. /**
  69022. * Adds a side to the polygon
  69023. * @param positions points that make the polygon
  69024. * @param normals normals of the polygon
  69025. * @param uvs uvs of the polygon
  69026. * @param indices indices of the polygon
  69027. * @param bounds bounds of the polygon
  69028. * @param points points of the polygon
  69029. * @param depth depth of the polygon
  69030. * @param flip flip of the polygon
  69031. */
  69032. private addSide;
  69033. }
  69034. }
  69035. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  69036. import { Scene } from "babylonjs/scene";
  69037. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  69038. import { Color4 } from "babylonjs/Maths/math.color";
  69039. import { Mesh } from "babylonjs/Meshes/mesh";
  69040. import { Nullable } from "babylonjs/types";
  69041. /**
  69042. * Class containing static functions to help procedurally build meshes
  69043. */
  69044. export class PolygonBuilder {
  69045. /**
  69046. * Creates a polygon mesh
  69047. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  69048. * * 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
  69049. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  69050. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69051. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  69052. * * Remember you can only change the shape positions, not their number when updating a polygon
  69053. * @param name defines the name of the mesh
  69054. * @param options defines the options used to create the mesh
  69055. * @param scene defines the hosting scene
  69056. * @param earcutInjection can be used to inject your own earcut reference
  69057. * @returns the polygon mesh
  69058. */
  69059. static CreatePolygon(name: string, options: {
  69060. shape: Vector3[];
  69061. holes?: Vector3[][];
  69062. depth?: number;
  69063. faceUV?: Vector4[];
  69064. faceColors?: Color4[];
  69065. updatable?: boolean;
  69066. sideOrientation?: number;
  69067. frontUVs?: Vector4;
  69068. backUVs?: Vector4;
  69069. wrap?: boolean;
  69070. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  69071. /**
  69072. * Creates an extruded polygon mesh, with depth in the Y direction.
  69073. * * 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)
  69074. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  69075. * @param name defines the name of the mesh
  69076. * @param options defines the options used to create the mesh
  69077. * @param scene defines the hosting scene
  69078. * @param earcutInjection can be used to inject your own earcut reference
  69079. * @returns the polygon mesh
  69080. */
  69081. static ExtrudePolygon(name: string, options: {
  69082. shape: Vector3[];
  69083. holes?: Vector3[][];
  69084. depth?: number;
  69085. faceUV?: Vector4[];
  69086. faceColors?: Color4[];
  69087. updatable?: boolean;
  69088. sideOrientation?: number;
  69089. frontUVs?: Vector4;
  69090. backUVs?: Vector4;
  69091. wrap?: boolean;
  69092. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  69093. }
  69094. }
  69095. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  69096. import { Scene } from "babylonjs/scene";
  69097. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  69098. import { Mesh } from "babylonjs/Meshes/mesh";
  69099. import { Nullable } from "babylonjs/types";
  69100. /**
  69101. * Class containing static functions to help procedurally build meshes
  69102. */
  69103. export class LatheBuilder {
  69104. /**
  69105. * Creates lathe mesh.
  69106. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  69107. * * 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
  69108. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  69109. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  69110. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  69111. * * 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
  69112. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  69113. * * 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
  69114. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69115. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69116. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  69117. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69118. * @param name defines the name of the mesh
  69119. * @param options defines the options used to create the mesh
  69120. * @param scene defines the hosting scene
  69121. * @returns the lathe mesh
  69122. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  69123. */
  69124. static CreateLathe(name: string, options: {
  69125. shape: Vector3[];
  69126. radius?: number;
  69127. tessellation?: number;
  69128. clip?: number;
  69129. arc?: number;
  69130. closed?: boolean;
  69131. updatable?: boolean;
  69132. sideOrientation?: number;
  69133. frontUVs?: Vector4;
  69134. backUVs?: Vector4;
  69135. cap?: number;
  69136. invertUV?: boolean;
  69137. }, scene?: Nullable<Scene>): Mesh;
  69138. }
  69139. }
  69140. declare module "babylonjs/Meshes/Builders/tiledPlaneBuilder" {
  69141. import { Nullable } from "babylonjs/types";
  69142. import { Scene } from "babylonjs/scene";
  69143. import { Vector4 } from "babylonjs/Maths/math.vector";
  69144. import { Mesh } from "babylonjs/Meshes/mesh";
  69145. /**
  69146. * Class containing static functions to help procedurally build meshes
  69147. */
  69148. export class TiledPlaneBuilder {
  69149. /**
  69150. * Creates a tiled plane mesh
  69151. * * The parameter `pattern` will, depending on value, do nothing or
  69152. * * * flip (reflect about central vertical) alternate tiles across and up
  69153. * * * flip every tile on alternate rows
  69154. * * * rotate (180 degs) alternate tiles across and up
  69155. * * * rotate every tile on alternate rows
  69156. * * * flip and rotate alternate tiles across and up
  69157. * * * flip and rotate every tile on alternate rows
  69158. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  69159. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  69160. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69161. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  69162. * * 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)
  69163. * * 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)
  69164. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  69165. * @param name defines the name of the mesh
  69166. * @param options defines the options used to create the mesh
  69167. * @param scene defines the hosting scene
  69168. * @returns the box mesh
  69169. */
  69170. static CreateTiledPlane(name: string, options: {
  69171. pattern?: number;
  69172. tileSize?: number;
  69173. tileWidth?: number;
  69174. tileHeight?: number;
  69175. size?: number;
  69176. width?: number;
  69177. height?: number;
  69178. alignHorizontal?: number;
  69179. alignVertical?: number;
  69180. sideOrientation?: number;
  69181. frontUVs?: Vector4;
  69182. backUVs?: Vector4;
  69183. updatable?: boolean;
  69184. }, scene?: Nullable<Scene>): Mesh;
  69185. }
  69186. }
  69187. declare module "babylonjs/Meshes/Builders/tubeBuilder" {
  69188. import { Nullable } from "babylonjs/types";
  69189. import { Scene } from "babylonjs/scene";
  69190. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  69191. import { Mesh } from "babylonjs/Meshes/mesh";
  69192. /**
  69193. * Class containing static functions to help procedurally build meshes
  69194. */
  69195. export class TubeBuilder {
  69196. /**
  69197. * Creates a tube mesh.
  69198. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  69199. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  69200. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  69201. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  69202. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  69203. * * 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)
  69204. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  69205. * * 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
  69206. * * 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
  69207. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69208. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69209. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  69210. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69211. * @param name defines the name of the mesh
  69212. * @param options defines the options used to create the mesh
  69213. * @param scene defines the hosting scene
  69214. * @returns the tube mesh
  69215. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  69216. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  69217. */
  69218. static CreateTube(name: string, options: {
  69219. path: Vector3[];
  69220. radius?: number;
  69221. tessellation?: number;
  69222. radiusFunction?: {
  69223. (i: number, distance: number): number;
  69224. };
  69225. cap?: number;
  69226. arc?: number;
  69227. updatable?: boolean;
  69228. sideOrientation?: number;
  69229. frontUVs?: Vector4;
  69230. backUVs?: Vector4;
  69231. instance?: Mesh;
  69232. invertUV?: boolean;
  69233. }, scene?: Nullable<Scene>): Mesh;
  69234. }
  69235. }
  69236. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  69237. import { Scene } from "babylonjs/scene";
  69238. import { Vector4 } from "babylonjs/Maths/math.vector";
  69239. import { Mesh } from "babylonjs/Meshes/mesh";
  69240. import { Nullable } from "babylonjs/types";
  69241. /**
  69242. * Class containing static functions to help procedurally build meshes
  69243. */
  69244. export class IcoSphereBuilder {
  69245. /**
  69246. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  69247. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  69248. * * 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`)
  69249. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  69250. * * 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
  69251. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69252. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69253. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69254. * @param name defines the name of the mesh
  69255. * @param options defines the options used to create the mesh
  69256. * @param scene defines the hosting scene
  69257. * @returns the icosahedron mesh
  69258. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  69259. */
  69260. static CreateIcoSphere(name: string, options: {
  69261. radius?: number;
  69262. radiusX?: number;
  69263. radiusY?: number;
  69264. radiusZ?: number;
  69265. flat?: boolean;
  69266. subdivisions?: number;
  69267. sideOrientation?: number;
  69268. frontUVs?: Vector4;
  69269. backUVs?: Vector4;
  69270. updatable?: boolean;
  69271. }, scene?: Nullable<Scene>): Mesh;
  69272. }
  69273. }
  69274. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  69275. import { Vector3 } from "babylonjs/Maths/math.vector";
  69276. import { Mesh } from "babylonjs/Meshes/mesh";
  69277. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  69278. /**
  69279. * Class containing static functions to help procedurally build meshes
  69280. */
  69281. export class DecalBuilder {
  69282. /**
  69283. * Creates a decal mesh.
  69284. * 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
  69285. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  69286. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  69287. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  69288. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  69289. * @param name defines the name of the mesh
  69290. * @param sourceMesh defines the mesh where the decal must be applied
  69291. * @param options defines the options used to create the mesh
  69292. * @param scene defines the hosting scene
  69293. * @returns the decal mesh
  69294. * @see https://doc.babylonjs.com/how_to/decals
  69295. */
  69296. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  69297. position?: Vector3;
  69298. normal?: Vector3;
  69299. size?: Vector3;
  69300. angle?: number;
  69301. }): Mesh;
  69302. }
  69303. }
  69304. declare module "babylonjs/Meshes/meshBuilder" {
  69305. import { ICreateCapsuleOptions } from "babylonjs/Meshes/Builders/capsuleBuilder";
  69306. import { Vector4, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  69307. import { Nullable } from "babylonjs/types";
  69308. import { Scene } from "babylonjs/scene";
  69309. import { Mesh } from "babylonjs/Meshes/mesh";
  69310. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  69311. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  69312. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  69313. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  69314. import { Plane } from "babylonjs/Maths/math.plane";
  69315. /**
  69316. * Class containing static functions to help procedurally build meshes
  69317. */
  69318. export class MeshBuilder {
  69319. /**
  69320. * Creates a box mesh
  69321. * * The parameter `size` sets the size (float) of each box side (default 1)
  69322. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  69323. * * 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)
  69324. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  69325. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69326. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69327. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69328. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  69329. * @param name defines the name of the mesh
  69330. * @param options defines the options used to create the mesh
  69331. * @param scene defines the hosting scene
  69332. * @returns the box mesh
  69333. */
  69334. static CreateBox(name: string, options: {
  69335. size?: number;
  69336. width?: number;
  69337. height?: number;
  69338. depth?: number;
  69339. faceUV?: Vector4[];
  69340. faceColors?: Color4[];
  69341. sideOrientation?: number;
  69342. frontUVs?: Vector4;
  69343. backUVs?: Vector4;
  69344. wrap?: boolean;
  69345. topBaseAt?: number;
  69346. bottomBaseAt?: number;
  69347. updatable?: boolean;
  69348. }, scene?: Nullable<Scene>): Mesh;
  69349. /**
  69350. * Creates a tiled box mesh
  69351. * * faceTiles sets the pattern, tile size and number of tiles for a face
  69352. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69353. * @param name defines the name of the mesh
  69354. * @param options defines the options used to create the mesh
  69355. * @param scene defines the hosting scene
  69356. * @returns the tiled box mesh
  69357. */
  69358. static CreateTiledBox(name: string, options: {
  69359. pattern?: number;
  69360. size?: number;
  69361. width?: number;
  69362. height?: number;
  69363. depth: number;
  69364. tileSize?: number;
  69365. tileWidth?: number;
  69366. tileHeight?: number;
  69367. faceUV?: Vector4[];
  69368. faceColors?: Color4[];
  69369. alignHorizontal?: number;
  69370. alignVertical?: number;
  69371. sideOrientation?: number;
  69372. updatable?: boolean;
  69373. }, scene?: Nullable<Scene>): Mesh;
  69374. /**
  69375. * Creates a sphere mesh
  69376. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  69377. * * 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`)
  69378. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  69379. * * 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
  69380. * * 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)
  69381. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69382. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69383. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69384. * @param name defines the name of the mesh
  69385. * @param options defines the options used to create the mesh
  69386. * @param scene defines the hosting scene
  69387. * @returns the sphere mesh
  69388. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  69389. */
  69390. static CreateSphere(name: string, options: {
  69391. segments?: number;
  69392. diameter?: number;
  69393. diameterX?: number;
  69394. diameterY?: number;
  69395. diameterZ?: number;
  69396. arc?: number;
  69397. slice?: number;
  69398. sideOrientation?: number;
  69399. frontUVs?: Vector4;
  69400. backUVs?: Vector4;
  69401. updatable?: boolean;
  69402. }, scene?: Nullable<Scene>): Mesh;
  69403. /**
  69404. * Creates a plane polygonal mesh. By default, this is a disc
  69405. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  69406. * * 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
  69407. * * 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
  69408. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69409. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69410. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69411. * @param name defines the name of the mesh
  69412. * @param options defines the options used to create the mesh
  69413. * @param scene defines the hosting scene
  69414. * @returns the plane polygonal mesh
  69415. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  69416. */
  69417. static CreateDisc(name: string, options: {
  69418. radius?: number;
  69419. tessellation?: number;
  69420. arc?: number;
  69421. updatable?: boolean;
  69422. sideOrientation?: number;
  69423. frontUVs?: Vector4;
  69424. backUVs?: Vector4;
  69425. }, scene?: Nullable<Scene>): Mesh;
  69426. /**
  69427. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  69428. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  69429. * * 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`)
  69430. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  69431. * * 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
  69432. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69433. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69434. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69435. * @param name defines the name of the mesh
  69436. * @param options defines the options used to create the mesh
  69437. * @param scene defines the hosting scene
  69438. * @returns the icosahedron mesh
  69439. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  69440. */
  69441. static CreateIcoSphere(name: string, options: {
  69442. radius?: number;
  69443. radiusX?: number;
  69444. radiusY?: number;
  69445. radiusZ?: number;
  69446. flat?: boolean;
  69447. subdivisions?: number;
  69448. sideOrientation?: number;
  69449. frontUVs?: Vector4;
  69450. backUVs?: Vector4;
  69451. updatable?: boolean;
  69452. }, scene?: Nullable<Scene>): Mesh;
  69453. /**
  69454. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  69455. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  69456. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  69457. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  69458. * * 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
  69459. * * 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
  69460. * * 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
  69461. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69462. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69463. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  69464. * * 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
  69465. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  69466. * * 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
  69467. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  69468. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69469. * @param name defines the name of the mesh
  69470. * @param options defines the options used to create the mesh
  69471. * @param scene defines the hosting scene
  69472. * @returns the ribbon mesh
  69473. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  69474. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  69475. */
  69476. static CreateRibbon(name: string, options: {
  69477. pathArray: Vector3[][];
  69478. closeArray?: boolean;
  69479. closePath?: boolean;
  69480. offset?: number;
  69481. updatable?: boolean;
  69482. sideOrientation?: number;
  69483. frontUVs?: Vector4;
  69484. backUVs?: Vector4;
  69485. instance?: Mesh;
  69486. invertUV?: boolean;
  69487. uvs?: Vector2[];
  69488. colors?: Color4[];
  69489. }, scene?: Nullable<Scene>): Mesh;
  69490. /**
  69491. * Creates a cylinder or a cone mesh
  69492. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  69493. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  69494. * * 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.
  69495. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  69496. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  69497. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  69498. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  69499. * * 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).
  69500. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  69501. * * 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).
  69502. * * 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
  69503. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  69504. * * 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
  69505. * * 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.
  69506. * * If `enclose` is false, a ring surface is one element.
  69507. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  69508. * * 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
  69509. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69510. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69511. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  69512. * @param name defines the name of the mesh
  69513. * @param options defines the options used to create the mesh
  69514. * @param scene defines the hosting scene
  69515. * @returns the cylinder mesh
  69516. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  69517. */
  69518. static CreateCylinder(name: string, options: {
  69519. height?: number;
  69520. diameterTop?: number;
  69521. diameterBottom?: number;
  69522. diameter?: number;
  69523. tessellation?: number;
  69524. subdivisions?: number;
  69525. arc?: number;
  69526. faceColors?: Color4[];
  69527. faceUV?: Vector4[];
  69528. updatable?: boolean;
  69529. hasRings?: boolean;
  69530. enclose?: boolean;
  69531. cap?: number;
  69532. sideOrientation?: number;
  69533. frontUVs?: Vector4;
  69534. backUVs?: Vector4;
  69535. }, scene?: Nullable<Scene>): Mesh;
  69536. /**
  69537. * Creates a torus mesh
  69538. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  69539. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  69540. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  69541. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69542. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69543. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  69544. * @param name defines the name of the mesh
  69545. * @param options defines the options used to create the mesh
  69546. * @param scene defines the hosting scene
  69547. * @returns the torus mesh
  69548. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  69549. */
  69550. static CreateTorus(name: string, options: {
  69551. diameter?: number;
  69552. thickness?: number;
  69553. tessellation?: number;
  69554. updatable?: boolean;
  69555. sideOrientation?: number;
  69556. frontUVs?: Vector4;
  69557. backUVs?: Vector4;
  69558. }, scene?: Nullable<Scene>): Mesh;
  69559. /**
  69560. * Creates a torus knot mesh
  69561. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  69562. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  69563. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  69564. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  69565. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69566. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69567. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  69568. * @param name defines the name of the mesh
  69569. * @param options defines the options used to create the mesh
  69570. * @param scene defines the hosting scene
  69571. * @returns the torus knot mesh
  69572. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  69573. */
  69574. static CreateTorusKnot(name: string, options: {
  69575. radius?: number;
  69576. tube?: number;
  69577. radialSegments?: number;
  69578. tubularSegments?: number;
  69579. p?: number;
  69580. q?: number;
  69581. updatable?: boolean;
  69582. sideOrientation?: number;
  69583. frontUVs?: Vector4;
  69584. backUVs?: Vector4;
  69585. }, scene?: Nullable<Scene>): Mesh;
  69586. /**
  69587. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  69588. * * 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
  69589. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  69590. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  69591. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  69592. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  69593. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  69594. * * 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
  69595. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  69596. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69597. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  69598. * @param name defines the name of the new line system
  69599. * @param options defines the options used to create the line system
  69600. * @param scene defines the hosting scene
  69601. * @returns a new line system mesh
  69602. */
  69603. static CreateLineSystem(name: string, options: {
  69604. lines: Vector3[][];
  69605. updatable?: boolean;
  69606. instance?: Nullable<LinesMesh>;
  69607. colors?: Nullable<Color4[][]>;
  69608. useVertexAlpha?: boolean;
  69609. }, scene: Nullable<Scene>): LinesMesh;
  69610. /**
  69611. * Creates a line mesh
  69612. * 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
  69613. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  69614. * * The parameter `points` is an array successive Vector3
  69615. * * 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
  69616. * * The optional parameter `colors` is an array of successive Color4, one per line point
  69617. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  69618. * * When updating an instance, remember that only point positions can change, not the number of points
  69619. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69620. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  69621. * @param name defines the name of the new line system
  69622. * @param options defines the options used to create the line system
  69623. * @param scene defines the hosting scene
  69624. * @returns a new line mesh
  69625. */
  69626. static CreateLines(name: string, options: {
  69627. points: Vector3[];
  69628. updatable?: boolean;
  69629. instance?: Nullable<LinesMesh>;
  69630. colors?: Color4[];
  69631. useVertexAlpha?: boolean;
  69632. }, scene?: Nullable<Scene>): LinesMesh;
  69633. /**
  69634. * Creates a dashed line mesh
  69635. * * 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
  69636. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  69637. * * The parameter `points` is an array successive Vector3
  69638. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  69639. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  69640. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  69641. * * 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
  69642. * * When updating an instance, remember that only point positions can change, not the number of points
  69643. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69644. * @param name defines the name of the mesh
  69645. * @param options defines the options used to create the mesh
  69646. * @param scene defines the hosting scene
  69647. * @returns the dashed line mesh
  69648. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  69649. */
  69650. static CreateDashedLines(name: string, options: {
  69651. points: Vector3[];
  69652. dashSize?: number;
  69653. gapSize?: number;
  69654. dashNb?: number;
  69655. updatable?: boolean;
  69656. instance?: LinesMesh;
  69657. }, scene?: Nullable<Scene>): LinesMesh;
  69658. /**
  69659. * 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.
  69660. * * 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.
  69661. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  69662. * * 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.
  69663. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  69664. * * 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
  69665. * * 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
  69666. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  69667. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69668. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69669. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  69670. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  69671. * @param name defines the name of the mesh
  69672. * @param options defines the options used to create the mesh
  69673. * @param scene defines the hosting scene
  69674. * @returns the extruded shape mesh
  69675. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  69676. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  69677. */
  69678. static ExtrudeShape(name: string, options: {
  69679. shape: Vector3[];
  69680. path: Vector3[];
  69681. scale?: number;
  69682. rotation?: number;
  69683. cap?: number;
  69684. updatable?: boolean;
  69685. sideOrientation?: number;
  69686. frontUVs?: Vector4;
  69687. backUVs?: Vector4;
  69688. instance?: Mesh;
  69689. invertUV?: boolean;
  69690. }, scene?: Nullable<Scene>): Mesh;
  69691. /**
  69692. * Creates an custom extruded shape mesh.
  69693. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  69694. * * 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.
  69695. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  69696. * * 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
  69697. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  69698. * * 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
  69699. * * It must returns a float value that will be the scale value applied to the shape on each path point
  69700. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  69701. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  69702. * * 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
  69703. * * 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
  69704. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  69705. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69706. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69707. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  69708. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69709. * @param name defines the name of the mesh
  69710. * @param options defines the options used to create the mesh
  69711. * @param scene defines the hosting scene
  69712. * @returns the custom extruded shape mesh
  69713. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  69714. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  69715. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  69716. */
  69717. static ExtrudeShapeCustom(name: string, options: {
  69718. shape: Vector3[];
  69719. path: Vector3[];
  69720. scaleFunction?: any;
  69721. rotationFunction?: any;
  69722. ribbonCloseArray?: boolean;
  69723. ribbonClosePath?: boolean;
  69724. cap?: number;
  69725. updatable?: boolean;
  69726. sideOrientation?: number;
  69727. frontUVs?: Vector4;
  69728. backUVs?: Vector4;
  69729. instance?: Mesh;
  69730. invertUV?: boolean;
  69731. }, scene?: Nullable<Scene>): Mesh;
  69732. /**
  69733. * Creates lathe mesh.
  69734. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  69735. * * 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
  69736. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  69737. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  69738. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  69739. * * 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
  69740. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  69741. * * 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
  69742. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69743. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69744. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  69745. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69746. * @param name defines the name of the mesh
  69747. * @param options defines the options used to create the mesh
  69748. * @param scene defines the hosting scene
  69749. * @returns the lathe mesh
  69750. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  69751. */
  69752. static CreateLathe(name: string, options: {
  69753. shape: Vector3[];
  69754. radius?: number;
  69755. tessellation?: number;
  69756. clip?: number;
  69757. arc?: number;
  69758. closed?: boolean;
  69759. updatable?: boolean;
  69760. sideOrientation?: number;
  69761. frontUVs?: Vector4;
  69762. backUVs?: Vector4;
  69763. cap?: number;
  69764. invertUV?: boolean;
  69765. }, scene?: Nullable<Scene>): Mesh;
  69766. /**
  69767. * Creates a tiled plane mesh
  69768. * * You can set a limited pattern arrangement with the tiles
  69769. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69770. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69771. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69772. * @param name defines the name of the mesh
  69773. * @param options defines the options used to create the mesh
  69774. * @param scene defines the hosting scene
  69775. * @returns the plane mesh
  69776. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  69777. */
  69778. static CreateTiledPlane(name: string, options: {
  69779. pattern?: number;
  69780. tileSize?: number;
  69781. tileWidth?: number;
  69782. tileHeight?: number;
  69783. size?: number;
  69784. width?: number;
  69785. height?: number;
  69786. alignHorizontal?: number;
  69787. alignVertical?: number;
  69788. sideOrientation?: number;
  69789. frontUVs?: Vector4;
  69790. backUVs?: Vector4;
  69791. updatable?: boolean;
  69792. }, scene?: Nullable<Scene>): Mesh;
  69793. /**
  69794. * Creates a plane mesh
  69795. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  69796. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  69797. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  69798. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69799. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69800. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69801. * @param name defines the name of the mesh
  69802. * @param options defines the options used to create the mesh
  69803. * @param scene defines the hosting scene
  69804. * @returns the plane mesh
  69805. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  69806. */
  69807. static CreatePlane(name: string, options: {
  69808. size?: number;
  69809. width?: number;
  69810. height?: number;
  69811. sideOrientation?: number;
  69812. frontUVs?: Vector4;
  69813. backUVs?: Vector4;
  69814. updatable?: boolean;
  69815. sourcePlane?: Plane;
  69816. }, scene?: Nullable<Scene>): Mesh;
  69817. /**
  69818. * Creates a ground mesh
  69819. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  69820. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  69821. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69822. * @param name defines the name of the mesh
  69823. * @param options defines the options used to create the mesh
  69824. * @param scene defines the hosting scene
  69825. * @returns the ground mesh
  69826. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  69827. */
  69828. static CreateGround(name: string, options: {
  69829. width?: number;
  69830. height?: number;
  69831. subdivisions?: number;
  69832. subdivisionsX?: number;
  69833. subdivisionsY?: number;
  69834. updatable?: boolean;
  69835. }, scene?: Nullable<Scene>): Mesh;
  69836. /**
  69837. * Creates a tiled ground mesh
  69838. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  69839. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  69840. * * 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
  69841. * * 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
  69842. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  69843. * @param name defines the name of the mesh
  69844. * @param options defines the options used to create the mesh
  69845. * @param scene defines the hosting scene
  69846. * @returns the tiled ground mesh
  69847. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  69848. */
  69849. static CreateTiledGround(name: string, options: {
  69850. xmin: number;
  69851. zmin: number;
  69852. xmax: number;
  69853. zmax: number;
  69854. subdivisions?: {
  69855. w: number;
  69856. h: number;
  69857. };
  69858. precision?: {
  69859. w: number;
  69860. h: number;
  69861. };
  69862. updatable?: boolean;
  69863. }, scene?: Nullable<Scene>): Mesh;
  69864. /**
  69865. * Creates a ground mesh from a height map
  69866. * * The parameter `url` sets the URL of the height map image resource.
  69867. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  69868. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  69869. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  69870. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  69871. * * 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.
  69872. * * 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).
  69873. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  69874. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  69875. * @param name defines the name of the mesh
  69876. * @param url defines the url to the height map
  69877. * @param options defines the options used to create the mesh
  69878. * @param scene defines the hosting scene
  69879. * @returns the ground mesh
  69880. * @see https://doc.babylonjs.com/babylon101/height_map
  69881. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  69882. */
  69883. static CreateGroundFromHeightMap(name: string, url: string, options: {
  69884. width?: number;
  69885. height?: number;
  69886. subdivisions?: number;
  69887. minHeight?: number;
  69888. maxHeight?: number;
  69889. colorFilter?: Color3;
  69890. alphaFilter?: number;
  69891. updatable?: boolean;
  69892. onReady?: (mesh: GroundMesh) => void;
  69893. }, scene?: Nullable<Scene>): GroundMesh;
  69894. /**
  69895. * Creates a polygon mesh
  69896. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  69897. * * 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
  69898. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  69899. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69900. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  69901. * * Remember you can only change the shape positions, not their number when updating a polygon
  69902. * @param name defines the name of the mesh
  69903. * @param options defines the options used to create the mesh
  69904. * @param scene defines the hosting scene
  69905. * @param earcutInjection can be used to inject your own earcut reference
  69906. * @returns the polygon mesh
  69907. */
  69908. static CreatePolygon(name: string, options: {
  69909. shape: Vector3[];
  69910. holes?: Vector3[][];
  69911. depth?: number;
  69912. faceUV?: Vector4[];
  69913. faceColors?: Color4[];
  69914. updatable?: boolean;
  69915. sideOrientation?: number;
  69916. frontUVs?: Vector4;
  69917. backUVs?: Vector4;
  69918. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  69919. /**
  69920. * Creates an extruded polygon mesh, with depth in the Y direction.
  69921. * * 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)
  69922. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  69923. * @param name defines the name of the mesh
  69924. * @param options defines the options used to create the mesh
  69925. * @param scene defines the hosting scene
  69926. * @param earcutInjection can be used to inject your own earcut reference
  69927. * @returns the polygon mesh
  69928. */
  69929. static ExtrudePolygon(name: string, options: {
  69930. shape: Vector3[];
  69931. holes?: Vector3[][];
  69932. depth?: number;
  69933. faceUV?: Vector4[];
  69934. faceColors?: Color4[];
  69935. updatable?: boolean;
  69936. sideOrientation?: number;
  69937. frontUVs?: Vector4;
  69938. backUVs?: Vector4;
  69939. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  69940. /**
  69941. * Creates a tube mesh.
  69942. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  69943. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  69944. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  69945. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  69946. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  69947. * * 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)
  69948. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  69949. * * 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
  69950. * * 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
  69951. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69952. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69953. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  69954. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69955. * @param name defines the name of the mesh
  69956. * @param options defines the options used to create the mesh
  69957. * @param scene defines the hosting scene
  69958. * @returns the tube mesh
  69959. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  69960. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  69961. */
  69962. static CreateTube(name: string, options: {
  69963. path: Vector3[];
  69964. radius?: number;
  69965. tessellation?: number;
  69966. radiusFunction?: {
  69967. (i: number, distance: number): number;
  69968. };
  69969. cap?: number;
  69970. arc?: number;
  69971. updatable?: boolean;
  69972. sideOrientation?: number;
  69973. frontUVs?: Vector4;
  69974. backUVs?: Vector4;
  69975. instance?: Mesh;
  69976. invertUV?: boolean;
  69977. }, scene?: Nullable<Scene>): Mesh;
  69978. /**
  69979. * Creates a polyhedron mesh
  69980. * * 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
  69981. * * The parameter `size` (positive float, default 1) sets the polygon size
  69982. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  69983. * * 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`
  69984. * * 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
  69985. * * 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)`)
  69986. * * 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
  69987. * * 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
  69988. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69989. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69990. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69991. * @param name defines the name of the mesh
  69992. * @param options defines the options used to create the mesh
  69993. * @param scene defines the hosting scene
  69994. * @returns the polyhedron mesh
  69995. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  69996. */
  69997. static CreatePolyhedron(name: string, options: {
  69998. type?: number;
  69999. size?: number;
  70000. sizeX?: number;
  70001. sizeY?: number;
  70002. sizeZ?: number;
  70003. custom?: any;
  70004. faceUV?: Vector4[];
  70005. faceColors?: Color4[];
  70006. flat?: boolean;
  70007. updatable?: boolean;
  70008. sideOrientation?: number;
  70009. frontUVs?: Vector4;
  70010. backUVs?: Vector4;
  70011. }, scene?: Nullable<Scene>): Mesh;
  70012. /**
  70013. * Creates a decal mesh.
  70014. * 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
  70015. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  70016. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  70017. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  70018. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  70019. * @param name defines the name of the mesh
  70020. * @param sourceMesh defines the mesh where the decal must be applied
  70021. * @param options defines the options used to create the mesh
  70022. * @param scene defines the hosting scene
  70023. * @returns the decal mesh
  70024. * @see https://doc.babylonjs.com/how_to/decals
  70025. */
  70026. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  70027. position?: Vector3;
  70028. normal?: Vector3;
  70029. size?: Vector3;
  70030. angle?: number;
  70031. }): Mesh;
  70032. /**
  70033. * Creates a Capsule Mesh
  70034. * @param name defines the name of the mesh.
  70035. * @param options the constructors options used to shape the mesh.
  70036. * @param scene defines the scene the mesh is scoped to.
  70037. * @returns the capsule mesh
  70038. * @see https://doc.babylonjs.com/how_to/capsule_shape
  70039. */
  70040. static CreateCapsule(name: string, options?: ICreateCapsuleOptions, scene?: Nullable<Scene>): Mesh;
  70041. }
  70042. }
  70043. declare module "babylonjs/Meshes/meshSimplification" {
  70044. import { Mesh } from "babylonjs/Meshes/mesh";
  70045. /**
  70046. * A simplifier interface for future simplification implementations
  70047. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  70048. */
  70049. export interface ISimplifier {
  70050. /**
  70051. * Simplification of a given mesh according to the given settings.
  70052. * Since this requires computation, it is assumed that the function runs async.
  70053. * @param settings The settings of the simplification, including quality and distance
  70054. * @param successCallback A callback that will be called after the mesh was simplified.
  70055. * @param errorCallback in case of an error, this callback will be called. optional.
  70056. */
  70057. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  70058. }
  70059. /**
  70060. * Expected simplification settings.
  70061. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  70062. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  70063. */
  70064. export interface ISimplificationSettings {
  70065. /**
  70066. * Gets or sets the expected quality
  70067. */
  70068. quality: number;
  70069. /**
  70070. * Gets or sets the distance when this optimized version should be used
  70071. */
  70072. distance: number;
  70073. /**
  70074. * Gets an already optimized mesh
  70075. */
  70076. optimizeMesh?: boolean;
  70077. }
  70078. /**
  70079. * Class used to specify simplification options
  70080. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  70081. */
  70082. export class SimplificationSettings implements ISimplificationSettings {
  70083. /** expected quality */
  70084. quality: number;
  70085. /** distance when this optimized version should be used */
  70086. distance: number;
  70087. /** already optimized mesh */
  70088. optimizeMesh?: boolean | undefined;
  70089. /**
  70090. * Creates a SimplificationSettings
  70091. * @param quality expected quality
  70092. * @param distance distance when this optimized version should be used
  70093. * @param optimizeMesh already optimized mesh
  70094. */
  70095. constructor(
  70096. /** expected quality */
  70097. quality: number,
  70098. /** distance when this optimized version should be used */
  70099. distance: number,
  70100. /** already optimized mesh */
  70101. optimizeMesh?: boolean | undefined);
  70102. }
  70103. /**
  70104. * Interface used to define a simplification task
  70105. */
  70106. export interface ISimplificationTask {
  70107. /**
  70108. * Array of settings
  70109. */
  70110. settings: Array<ISimplificationSettings>;
  70111. /**
  70112. * Simplification type
  70113. */
  70114. simplificationType: SimplificationType;
  70115. /**
  70116. * Mesh to simplify
  70117. */
  70118. mesh: Mesh;
  70119. /**
  70120. * Callback called on success
  70121. */
  70122. successCallback?: () => void;
  70123. /**
  70124. * Defines if parallel processing can be used
  70125. */
  70126. parallelProcessing: boolean;
  70127. }
  70128. /**
  70129. * Queue used to order the simplification tasks
  70130. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  70131. */
  70132. export class SimplificationQueue {
  70133. private _simplificationArray;
  70134. /**
  70135. * Gets a boolean indicating that the process is still running
  70136. */
  70137. running: boolean;
  70138. /**
  70139. * Creates a new queue
  70140. */
  70141. constructor();
  70142. /**
  70143. * Adds a new simplification task
  70144. * @param task defines a task to add
  70145. */
  70146. addTask(task: ISimplificationTask): void;
  70147. /**
  70148. * Execute next task
  70149. */
  70150. executeNext(): void;
  70151. /**
  70152. * Execute a simplification task
  70153. * @param task defines the task to run
  70154. */
  70155. runSimplification(task: ISimplificationTask): void;
  70156. private getSimplifier;
  70157. }
  70158. /**
  70159. * The implemented types of simplification
  70160. * At the moment only Quadratic Error Decimation is implemented
  70161. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  70162. */
  70163. export enum SimplificationType {
  70164. /** Quadratic error decimation */
  70165. QUADRATIC = 0
  70166. }
  70167. /**
  70168. * An implementation of the Quadratic Error simplification algorithm.
  70169. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  70170. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  70171. * @author RaananW
  70172. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  70173. */
  70174. export class QuadraticErrorSimplification implements ISimplifier {
  70175. private _mesh;
  70176. private triangles;
  70177. private vertices;
  70178. private references;
  70179. private _reconstructedMesh;
  70180. /** Gets or sets the number pf sync interations */
  70181. syncIterations: number;
  70182. /** Gets or sets the aggressiveness of the simplifier */
  70183. aggressiveness: number;
  70184. /** Gets or sets the number of allowed iterations for decimation */
  70185. decimationIterations: number;
  70186. /** Gets or sets the espilon to use for bounding box computation */
  70187. boundingBoxEpsilon: number;
  70188. /**
  70189. * Creates a new QuadraticErrorSimplification
  70190. * @param _mesh defines the target mesh
  70191. */
  70192. constructor(_mesh: Mesh);
  70193. /**
  70194. * Simplification of a given mesh according to the given settings.
  70195. * Since this requires computation, it is assumed that the function runs async.
  70196. * @param settings The settings of the simplification, including quality and distance
  70197. * @param successCallback A callback that will be called after the mesh was simplified.
  70198. */
  70199. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  70200. private runDecimation;
  70201. private initWithMesh;
  70202. private init;
  70203. private reconstructMesh;
  70204. private initDecimatedMesh;
  70205. private isFlipped;
  70206. private updateTriangles;
  70207. private identifyBorder;
  70208. private updateMesh;
  70209. private vertexError;
  70210. private calculateError;
  70211. }
  70212. }
  70213. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  70214. import { Scene } from "babylonjs/scene";
  70215. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  70216. import { ISceneComponent } from "babylonjs/sceneComponent";
  70217. module "babylonjs/scene" {
  70218. interface Scene {
  70219. /** @hidden (Backing field) */
  70220. _simplificationQueue: SimplificationQueue;
  70221. /**
  70222. * Gets or sets the simplification queue attached to the scene
  70223. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  70224. */
  70225. simplificationQueue: SimplificationQueue;
  70226. }
  70227. }
  70228. module "babylonjs/Meshes/mesh" {
  70229. interface Mesh {
  70230. /**
  70231. * Simplify the mesh according to the given array of settings.
  70232. * Function will return immediately and will simplify async
  70233. * @param settings a collection of simplification settings
  70234. * @param parallelProcessing should all levels calculate parallel or one after the other
  70235. * @param simplificationType the type of simplification to run
  70236. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  70237. * @returns the current mesh
  70238. */
  70239. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  70240. }
  70241. }
  70242. /**
  70243. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  70244. * created in a scene
  70245. */
  70246. export class SimplicationQueueSceneComponent implements ISceneComponent {
  70247. /**
  70248. * The component name helpfull to identify the component in the list of scene components.
  70249. */
  70250. readonly name: string;
  70251. /**
  70252. * The scene the component belongs to.
  70253. */
  70254. scene: Scene;
  70255. /**
  70256. * Creates a new instance of the component for the given scene
  70257. * @param scene Defines the scene to register the component in
  70258. */
  70259. constructor(scene: Scene);
  70260. /**
  70261. * Registers the component in a given scene
  70262. */
  70263. register(): void;
  70264. /**
  70265. * Rebuilds the elements related to this component in case of
  70266. * context lost for instance.
  70267. */
  70268. rebuild(): void;
  70269. /**
  70270. * Disposes the component and the associated ressources
  70271. */
  70272. dispose(): void;
  70273. private _beforeCameraUpdate;
  70274. }
  70275. }
  70276. declare module "babylonjs/Meshes/Builders/index" {
  70277. export * from "babylonjs/Meshes/Builders/boxBuilder";
  70278. export * from "babylonjs/Meshes/Builders/tiledBoxBuilder";
  70279. export * from "babylonjs/Meshes/Builders/discBuilder";
  70280. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  70281. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  70282. export * from "babylonjs/Meshes/Builders/hemisphereBuilder";
  70283. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  70284. export * from "babylonjs/Meshes/Builders/torusBuilder";
  70285. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  70286. export * from "babylonjs/Meshes/Builders/linesBuilder";
  70287. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  70288. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  70289. export * from "babylonjs/Meshes/Builders/latheBuilder";
  70290. export * from "babylonjs/Meshes/Builders/planeBuilder";
  70291. export * from "babylonjs/Meshes/Builders/tiledPlaneBuilder";
  70292. export * from "babylonjs/Meshes/Builders/groundBuilder";
  70293. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  70294. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  70295. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  70296. export * from "babylonjs/Meshes/Builders/decalBuilder";
  70297. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  70298. export * from "babylonjs/Meshes/Builders/capsuleBuilder";
  70299. }
  70300. declare module "babylonjs/Meshes/thinInstanceMesh" {
  70301. import { Nullable, DeepImmutableObject } from "babylonjs/types";
  70302. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  70303. import { Matrix } from "babylonjs/Maths/math.vector";
  70304. module "babylonjs/Meshes/mesh" {
  70305. interface Mesh {
  70306. /**
  70307. * Gets or sets a boolean defining if we want picking to pick thin instances as well
  70308. */
  70309. thinInstanceEnablePicking: boolean;
  70310. /**
  70311. * Creates a new thin instance
  70312. * @param matrix the matrix or array of matrices (position, rotation, scale) of the thin instance(s) to create
  70313. * @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
  70314. * @returns the thin instance index number. If you pass an array of matrices, other instance indexes are index+1, index+2, etc
  70315. */
  70316. thinInstanceAdd(matrix: DeepImmutableObject<Matrix> | Array<DeepImmutableObject<Matrix>>, refresh: boolean): number;
  70317. /**
  70318. * Adds the transformation (matrix) of the current mesh as a thin instance
  70319. * @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
  70320. * @returns the thin instance index number
  70321. */
  70322. thinInstanceAddSelf(refresh: boolean): number;
  70323. /**
  70324. * Registers a custom attribute to be used with thin instances
  70325. * @param kind name of the attribute
  70326. * @param stride size in floats of the attribute
  70327. */
  70328. thinInstanceRegisterAttribute(kind: string, stride: number): void;
  70329. /**
  70330. * Sets the matrix of a thin instance
  70331. * @param index index of the thin instance
  70332. * @param matrix matrix to set
  70333. * @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
  70334. */
  70335. thinInstanceSetMatrixAt(index: number, matrix: DeepImmutableObject<Matrix>, refresh: boolean): void;
  70336. /**
  70337. * Sets the value of a custom attribute for a thin instance
  70338. * @param kind name of the attribute
  70339. * @param index index of the thin instance
  70340. * @param value value to set
  70341. * @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
  70342. */
  70343. thinInstanceSetAttributeAt(kind: string, index: number, value: Array<number>, refresh: boolean): void;
  70344. /**
  70345. * 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.
  70346. */
  70347. thinInstanceCount: number;
  70348. /**
  70349. * Sets a buffer to be used with thin instances. This method is a faster way to setup multiple instances than calling thinInstanceAdd repeatedly
  70350. * @param kind name of the attribute. Use "matrix" to setup the buffer of matrices
  70351. * @param buffer buffer to set
  70352. * @param stride size in floats of each value of the buffer
  70353. * @param staticBuffer indicates that the buffer is static, so that you won't change it after it is set (better performances - false by default)
  70354. */
  70355. thinInstanceSetBuffer(kind: string, buffer: Nullable<Float32Array>, stride: number, staticBuffer: boolean): void;
  70356. /**
  70357. * Gets the list of world matrices
  70358. * @return an array containing all the world matrices from the thin instances
  70359. */
  70360. thinInstanceGetWorldMatrices(): Matrix[];
  70361. /**
  70362. * Synchronize the gpu buffers with a thin instance buffer. Call this method if you update later on the buffers passed to thinInstanceSetBuffer
  70363. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  70364. */
  70365. thinInstanceBufferUpdated(kind: string): void;
  70366. /**
  70367. * Applies a partial update to a buffer directly on the GPU
  70368. * Note that the buffer located on the CPU is NOT updated! It's up to you to update it (or not) with the same data you pass to this method
  70369. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  70370. * @param data the data to set in the GPU buffer
  70371. * @param offset the offset in the GPU buffer where to update the data
  70372. */
  70373. thinInstancePartialBufferUpdate(kind: string, data: Float32Array, offset: number): void;
  70374. /**
  70375. * Refreshes the bounding info, taking into account all the thin instances defined
  70376. * @param forceRefreshParentInfo true to force recomputing the mesh bounding info and use it to compute the aggregated bounding info
  70377. */
  70378. thinInstanceRefreshBoundingInfo(forceRefreshParentInfo: boolean): void;
  70379. /** @hidden */
  70380. _thinInstanceInitializeUserStorage(): void;
  70381. /** @hidden */
  70382. _thinInstanceUpdateBufferSize(kind: string, numInstances: number): void;
  70383. /** @hidden */
  70384. _userThinInstanceBuffersStorage: {
  70385. data: {
  70386. [key: string]: Float32Array;
  70387. };
  70388. sizes: {
  70389. [key: string]: number;
  70390. };
  70391. vertexBuffers: {
  70392. [key: string]: Nullable<VertexBuffer>;
  70393. };
  70394. strides: {
  70395. [key: string]: number;
  70396. };
  70397. };
  70398. }
  70399. }
  70400. }
  70401. declare module "babylonjs/Meshes/index" {
  70402. export * from "babylonjs/Meshes/abstractMesh";
  70403. export * from "babylonjs/Meshes/buffer";
  70404. export * from "babylonjs/Meshes/Compression/index";
  70405. export * from "babylonjs/Meshes/csg";
  70406. export * from "babylonjs/Meshes/geometry";
  70407. export * from "babylonjs/Meshes/groundMesh";
  70408. export * from "babylonjs/Meshes/trailMesh";
  70409. export * from "babylonjs/Meshes/instancedMesh";
  70410. export * from "babylonjs/Meshes/linesMesh";
  70411. export * from "babylonjs/Meshes/mesh";
  70412. export * from "babylonjs/Meshes/mesh.vertexData";
  70413. export * from "babylonjs/Meshes/meshBuilder";
  70414. export * from "babylonjs/Meshes/meshSimplification";
  70415. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  70416. export * from "babylonjs/Meshes/polygonMesh";
  70417. export * from "babylonjs/Meshes/subMesh";
  70418. export * from "babylonjs/Meshes/meshLODLevel";
  70419. export * from "babylonjs/Meshes/transformNode";
  70420. export * from "babylonjs/Meshes/Builders/index";
  70421. export * from "babylonjs/Meshes/dataBuffer";
  70422. export * from "babylonjs/Meshes/WebGL/webGLDataBuffer";
  70423. import "babylonjs/Meshes/thinInstanceMesh";
  70424. export * from "babylonjs/Meshes/thinInstanceMesh";
  70425. }
  70426. declare module "babylonjs/Morph/index" {
  70427. export * from "babylonjs/Morph/morphTarget";
  70428. export * from "babylonjs/Morph/morphTargetManager";
  70429. }
  70430. declare module "babylonjs/Navigation/INavigationEngine" {
  70431. import { TransformNode } from "babylonjs/Meshes/transformNode";
  70432. import { Vector3 } from "babylonjs/Maths/math";
  70433. import { Mesh } from "babylonjs/Meshes/mesh";
  70434. import { Scene } from "babylonjs/scene";
  70435. /**
  70436. * Navigation plugin interface to add navigation constrained by a navigation mesh
  70437. */
  70438. export interface INavigationEnginePlugin {
  70439. /**
  70440. * plugin name
  70441. */
  70442. name: string;
  70443. /**
  70444. * Creates a navigation mesh
  70445. * @param meshes array of all the geometry used to compute the navigatio mesh
  70446. * @param parameters bunch of parameters used to filter geometry
  70447. */
  70448. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  70449. /**
  70450. * Create a navigation mesh debug mesh
  70451. * @param scene is where the mesh will be added
  70452. * @returns debug display mesh
  70453. */
  70454. createDebugNavMesh(scene: Scene): Mesh;
  70455. /**
  70456. * Get a navigation mesh constrained position, closest to the parameter position
  70457. * @param position world position
  70458. * @returns the closest point to position constrained by the navigation mesh
  70459. */
  70460. getClosestPoint(position: Vector3): Vector3;
  70461. /**
  70462. * Get a navigation mesh constrained position, closest to the parameter position
  70463. * @param position world position
  70464. * @param result output the closest point to position constrained by the navigation mesh
  70465. */
  70466. getClosestPointToRef(position: Vector3, result: Vector3): void;
  70467. /**
  70468. * Get a navigation mesh constrained position, within a particular radius
  70469. * @param position world position
  70470. * @param maxRadius the maximum distance to the constrained world position
  70471. * @returns the closest point to position constrained by the navigation mesh
  70472. */
  70473. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  70474. /**
  70475. * Get a navigation mesh constrained position, within a particular radius
  70476. * @param position world position
  70477. * @param maxRadius the maximum distance to the constrained world position
  70478. * @param result output the closest point to position constrained by the navigation mesh
  70479. */
  70480. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  70481. /**
  70482. * Compute the final position from a segment made of destination-position
  70483. * @param position world position
  70484. * @param destination world position
  70485. * @returns the resulting point along the navmesh
  70486. */
  70487. moveAlong(position: Vector3, destination: Vector3): Vector3;
  70488. /**
  70489. * Compute the final position from a segment made of destination-position
  70490. * @param position world position
  70491. * @param destination world position
  70492. * @param result output the resulting point along the navmesh
  70493. */
  70494. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  70495. /**
  70496. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  70497. * @param start world position
  70498. * @param end world position
  70499. * @returns array containing world position composing the path
  70500. */
  70501. computePath(start: Vector3, end: Vector3): Vector3[];
  70502. /**
  70503. * If this plugin is supported
  70504. * @returns true if plugin is supported
  70505. */
  70506. isSupported(): boolean;
  70507. /**
  70508. * Create a new Crowd so you can add agents
  70509. * @param maxAgents the maximum agent count in the crowd
  70510. * @param maxAgentRadius the maximum radius an agent can have
  70511. * @param scene to attach the crowd to
  70512. * @returns the crowd you can add agents to
  70513. */
  70514. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  70515. /**
  70516. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  70517. * The queries will try to find a solution within those bounds
  70518. * default is (1,1,1)
  70519. * @param extent x,y,z value that define the extent around the queries point of reference
  70520. */
  70521. setDefaultQueryExtent(extent: Vector3): void;
  70522. /**
  70523. * Get the Bounding box extent specified by setDefaultQueryExtent
  70524. * @returns the box extent values
  70525. */
  70526. getDefaultQueryExtent(): Vector3;
  70527. /**
  70528. * build the navmesh from a previously saved state using getNavmeshData
  70529. * @param data the Uint8Array returned by getNavmeshData
  70530. */
  70531. buildFromNavmeshData(data: Uint8Array): void;
  70532. /**
  70533. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  70534. * @returns data the Uint8Array that can be saved and reused
  70535. */
  70536. getNavmeshData(): Uint8Array;
  70537. /**
  70538. * Get the Bounding box extent result specified by setDefaultQueryExtent
  70539. * @param result output the box extent values
  70540. */
  70541. getDefaultQueryExtentToRef(result: Vector3): void;
  70542. /**
  70543. * Release all resources
  70544. */
  70545. dispose(): void;
  70546. }
  70547. /**
  70548. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  70549. */
  70550. export interface ICrowd {
  70551. /**
  70552. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  70553. * You can attach anything to that node. The node position is updated in the scene update tick.
  70554. * @param pos world position that will be constrained by the navigation mesh
  70555. * @param parameters agent parameters
  70556. * @param transform hooked to the agent that will be update by the scene
  70557. * @returns agent index
  70558. */
  70559. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  70560. /**
  70561. * Returns the agent position in world space
  70562. * @param index agent index returned by addAgent
  70563. * @returns world space position
  70564. */
  70565. getAgentPosition(index: number): Vector3;
  70566. /**
  70567. * Gets the agent position result in world space
  70568. * @param index agent index returned by addAgent
  70569. * @param result output world space position
  70570. */
  70571. getAgentPositionToRef(index: number, result: Vector3): void;
  70572. /**
  70573. * Gets the agent velocity in world space
  70574. * @param index agent index returned by addAgent
  70575. * @returns world space velocity
  70576. */
  70577. getAgentVelocity(index: number): Vector3;
  70578. /**
  70579. * Gets the agent velocity result in world space
  70580. * @param index agent index returned by addAgent
  70581. * @param result output world space velocity
  70582. */
  70583. getAgentVelocityToRef(index: number, result: Vector3): void;
  70584. /**
  70585. * remove a particular agent previously created
  70586. * @param index agent index returned by addAgent
  70587. */
  70588. removeAgent(index: number): void;
  70589. /**
  70590. * get the list of all agents attached to this crowd
  70591. * @returns list of agent indices
  70592. */
  70593. getAgents(): number[];
  70594. /**
  70595. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  70596. * @param deltaTime in seconds
  70597. */
  70598. update(deltaTime: number): void;
  70599. /**
  70600. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  70601. * @param index agent index returned by addAgent
  70602. * @param destination targeted world position
  70603. */
  70604. agentGoto(index: number, destination: Vector3): void;
  70605. /**
  70606. * Teleport the agent to a new position
  70607. * @param index agent index returned by addAgent
  70608. * @param destination targeted world position
  70609. */
  70610. agentTeleport(index: number, destination: Vector3): void;
  70611. /**
  70612. * Update agent parameters
  70613. * @param index agent index returned by addAgent
  70614. * @param parameters agent parameters
  70615. */
  70616. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  70617. /**
  70618. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  70619. * The queries will try to find a solution within those bounds
  70620. * default is (1,1,1)
  70621. * @param extent x,y,z value that define the extent around the queries point of reference
  70622. */
  70623. setDefaultQueryExtent(extent: Vector3): void;
  70624. /**
  70625. * Get the Bounding box extent specified by setDefaultQueryExtent
  70626. * @returns the box extent values
  70627. */
  70628. getDefaultQueryExtent(): Vector3;
  70629. /**
  70630. * Get the Bounding box extent result specified by setDefaultQueryExtent
  70631. * @param result output the box extent values
  70632. */
  70633. getDefaultQueryExtentToRef(result: Vector3): void;
  70634. /**
  70635. * Release all resources
  70636. */
  70637. dispose(): void;
  70638. }
  70639. /**
  70640. * Configures an agent
  70641. */
  70642. export interface IAgentParameters {
  70643. /**
  70644. * Agent radius. [Limit: >= 0]
  70645. */
  70646. radius: number;
  70647. /**
  70648. * Agent height. [Limit: > 0]
  70649. */
  70650. height: number;
  70651. /**
  70652. * Maximum allowed acceleration. [Limit: >= 0]
  70653. */
  70654. maxAcceleration: number;
  70655. /**
  70656. * Maximum allowed speed. [Limit: >= 0]
  70657. */
  70658. maxSpeed: number;
  70659. /**
  70660. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  70661. */
  70662. collisionQueryRange: number;
  70663. /**
  70664. * The path visibility optimization range. [Limit: > 0]
  70665. */
  70666. pathOptimizationRange: number;
  70667. /**
  70668. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  70669. */
  70670. separationWeight: number;
  70671. }
  70672. /**
  70673. * Configures the navigation mesh creation
  70674. */
  70675. export interface INavMeshParameters {
  70676. /**
  70677. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  70678. */
  70679. cs: number;
  70680. /**
  70681. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  70682. */
  70683. ch: number;
  70684. /**
  70685. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  70686. */
  70687. walkableSlopeAngle: number;
  70688. /**
  70689. * Minimum floor to 'ceiling' height that will still allow the floor area to
  70690. * be considered walkable. [Limit: >= 3] [Units: vx]
  70691. */
  70692. walkableHeight: number;
  70693. /**
  70694. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  70695. */
  70696. walkableClimb: number;
  70697. /**
  70698. * The distance to erode/shrink the walkable area of the heightfield away from
  70699. * obstructions. [Limit: >=0] [Units: vx]
  70700. */
  70701. walkableRadius: number;
  70702. /**
  70703. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  70704. */
  70705. maxEdgeLen: number;
  70706. /**
  70707. * The maximum distance a simplfied contour's border edges should deviate
  70708. * the original raw contour. [Limit: >=0] [Units: vx]
  70709. */
  70710. maxSimplificationError: number;
  70711. /**
  70712. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  70713. */
  70714. minRegionArea: number;
  70715. /**
  70716. * Any regions with a span count smaller than this value will, if possible,
  70717. * be merged with larger regions. [Limit: >=0] [Units: vx]
  70718. */
  70719. mergeRegionArea: number;
  70720. /**
  70721. * The maximum number of vertices allowed for polygons generated during the
  70722. * contour to polygon conversion process. [Limit: >= 3]
  70723. */
  70724. maxVertsPerPoly: number;
  70725. /**
  70726. * Sets the sampling distance to use when generating the detail mesh.
  70727. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  70728. */
  70729. detailSampleDist: number;
  70730. /**
  70731. * The maximum distance the detail mesh surface should deviate from heightfield
  70732. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  70733. */
  70734. detailSampleMaxError: number;
  70735. }
  70736. }
  70737. declare module "babylonjs/Navigation/Plugins/recastJSPlugin" {
  70738. import { INavigationEnginePlugin, ICrowd, IAgentParameters, INavMeshParameters } from "babylonjs/Navigation/INavigationEngine";
  70739. import { Mesh } from "babylonjs/Meshes/mesh";
  70740. import { Scene } from "babylonjs/scene";
  70741. import { Vector3 } from "babylonjs/Maths/math";
  70742. import { TransformNode } from "babylonjs/Meshes/transformNode";
  70743. /**
  70744. * RecastJS navigation plugin
  70745. */
  70746. export class RecastJSPlugin implements INavigationEnginePlugin {
  70747. /**
  70748. * Reference to the Recast library
  70749. */
  70750. bjsRECAST: any;
  70751. /**
  70752. * plugin name
  70753. */
  70754. name: string;
  70755. /**
  70756. * the first navmesh created. We might extend this to support multiple navmeshes
  70757. */
  70758. navMesh: any;
  70759. /**
  70760. * Initializes the recastJS plugin
  70761. * @param recastInjection can be used to inject your own recast reference
  70762. */
  70763. constructor(recastInjection?: any);
  70764. /**
  70765. * Creates a navigation mesh
  70766. * @param meshes array of all the geometry used to compute the navigatio mesh
  70767. * @param parameters bunch of parameters used to filter geometry
  70768. */
  70769. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  70770. /**
  70771. * Create a navigation mesh debug mesh
  70772. * @param scene is where the mesh will be added
  70773. * @returns debug display mesh
  70774. */
  70775. createDebugNavMesh(scene: Scene): Mesh;
  70776. /**
  70777. * Get a navigation mesh constrained position, closest to the parameter position
  70778. * @param position world position
  70779. * @returns the closest point to position constrained by the navigation mesh
  70780. */
  70781. getClosestPoint(position: Vector3): Vector3;
  70782. /**
  70783. * Get a navigation mesh constrained position, closest to the parameter position
  70784. * @param position world position
  70785. * @param result output the closest point to position constrained by the navigation mesh
  70786. */
  70787. getClosestPointToRef(position: Vector3, result: Vector3): void;
  70788. /**
  70789. * Get a navigation mesh constrained position, within a particular radius
  70790. * @param position world position
  70791. * @param maxRadius the maximum distance to the constrained world position
  70792. * @returns the closest point to position constrained by the navigation mesh
  70793. */
  70794. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  70795. /**
  70796. * Get a navigation mesh constrained position, within a particular radius
  70797. * @param position world position
  70798. * @param maxRadius the maximum distance to the constrained world position
  70799. * @param result output the closest point to position constrained by the navigation mesh
  70800. */
  70801. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  70802. /**
  70803. * Compute the final position from a segment made of destination-position
  70804. * @param position world position
  70805. * @param destination world position
  70806. * @returns the resulting point along the navmesh
  70807. */
  70808. moveAlong(position: Vector3, destination: Vector3): Vector3;
  70809. /**
  70810. * Compute the final position from a segment made of destination-position
  70811. * @param position world position
  70812. * @param destination world position
  70813. * @param result output the resulting point along the navmesh
  70814. */
  70815. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  70816. /**
  70817. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  70818. * @param start world position
  70819. * @param end world position
  70820. * @returns array containing world position composing the path
  70821. */
  70822. computePath(start: Vector3, end: Vector3): Vector3[];
  70823. /**
  70824. * Create a new Crowd so you can add agents
  70825. * @param maxAgents the maximum agent count in the crowd
  70826. * @param maxAgentRadius the maximum radius an agent can have
  70827. * @param scene to attach the crowd to
  70828. * @returns the crowd you can add agents to
  70829. */
  70830. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  70831. /**
  70832. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  70833. * The queries will try to find a solution within those bounds
  70834. * default is (1,1,1)
  70835. * @param extent x,y,z value that define the extent around the queries point of reference
  70836. */
  70837. setDefaultQueryExtent(extent: Vector3): void;
  70838. /**
  70839. * Get the Bounding box extent specified by setDefaultQueryExtent
  70840. * @returns the box extent values
  70841. */
  70842. getDefaultQueryExtent(): Vector3;
  70843. /**
  70844. * build the navmesh from a previously saved state using getNavmeshData
  70845. * @param data the Uint8Array returned by getNavmeshData
  70846. */
  70847. buildFromNavmeshData(data: Uint8Array): void;
  70848. /**
  70849. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  70850. * @returns data the Uint8Array that can be saved and reused
  70851. */
  70852. getNavmeshData(): Uint8Array;
  70853. /**
  70854. * Get the Bounding box extent result specified by setDefaultQueryExtent
  70855. * @param result output the box extent values
  70856. */
  70857. getDefaultQueryExtentToRef(result: Vector3): void;
  70858. /**
  70859. * Disposes
  70860. */
  70861. dispose(): void;
  70862. /**
  70863. * If this plugin is supported
  70864. * @returns true if plugin is supported
  70865. */
  70866. isSupported(): boolean;
  70867. }
  70868. /**
  70869. * Recast detour crowd implementation
  70870. */
  70871. export class RecastJSCrowd implements ICrowd {
  70872. /**
  70873. * Recast/detour plugin
  70874. */
  70875. bjsRECASTPlugin: RecastJSPlugin;
  70876. /**
  70877. * Link to the detour crowd
  70878. */
  70879. recastCrowd: any;
  70880. /**
  70881. * One transform per agent
  70882. */
  70883. transforms: TransformNode[];
  70884. /**
  70885. * All agents created
  70886. */
  70887. agents: number[];
  70888. /**
  70889. * Link to the scene is kept to unregister the crowd from the scene
  70890. */
  70891. private _scene;
  70892. /**
  70893. * Observer for crowd updates
  70894. */
  70895. private _onBeforeAnimationsObserver;
  70896. /**
  70897. * Constructor
  70898. * @param plugin recastJS plugin
  70899. * @param maxAgents the maximum agent count in the crowd
  70900. * @param maxAgentRadius the maximum radius an agent can have
  70901. * @param scene to attach the crowd to
  70902. * @returns the crowd you can add agents to
  70903. */
  70904. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  70905. /**
  70906. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  70907. * You can attach anything to that node. The node position is updated in the scene update tick.
  70908. * @param pos world position that will be constrained by the navigation mesh
  70909. * @param parameters agent parameters
  70910. * @param transform hooked to the agent that will be update by the scene
  70911. * @returns agent index
  70912. */
  70913. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  70914. /**
  70915. * Returns the agent position in world space
  70916. * @param index agent index returned by addAgent
  70917. * @returns world space position
  70918. */
  70919. getAgentPosition(index: number): Vector3;
  70920. /**
  70921. * Returns the agent position result in world space
  70922. * @param index agent index returned by addAgent
  70923. * @param result output world space position
  70924. */
  70925. getAgentPositionToRef(index: number, result: Vector3): void;
  70926. /**
  70927. * Returns the agent velocity in world space
  70928. * @param index agent index returned by addAgent
  70929. * @returns world space velocity
  70930. */
  70931. getAgentVelocity(index: number): Vector3;
  70932. /**
  70933. * Returns the agent velocity result in world space
  70934. * @param index agent index returned by addAgent
  70935. * @param result output world space velocity
  70936. */
  70937. getAgentVelocityToRef(index: number, result: Vector3): void;
  70938. /**
  70939. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  70940. * @param index agent index returned by addAgent
  70941. * @param destination targeted world position
  70942. */
  70943. agentGoto(index: number, destination: Vector3): void;
  70944. /**
  70945. * Teleport the agent to a new position
  70946. * @param index agent index returned by addAgent
  70947. * @param destination targeted world position
  70948. */
  70949. agentTeleport(index: number, destination: Vector3): void;
  70950. /**
  70951. * Update agent parameters
  70952. * @param index agent index returned by addAgent
  70953. * @param parameters agent parameters
  70954. */
  70955. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  70956. /**
  70957. * remove a particular agent previously created
  70958. * @param index agent index returned by addAgent
  70959. */
  70960. removeAgent(index: number): void;
  70961. /**
  70962. * get the list of all agents attached to this crowd
  70963. * @returns list of agent indices
  70964. */
  70965. getAgents(): number[];
  70966. /**
  70967. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  70968. * @param deltaTime in seconds
  70969. */
  70970. update(deltaTime: number): void;
  70971. /**
  70972. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  70973. * The queries will try to find a solution within those bounds
  70974. * default is (1,1,1)
  70975. * @param extent x,y,z value that define the extent around the queries point of reference
  70976. */
  70977. setDefaultQueryExtent(extent: Vector3): void;
  70978. /**
  70979. * Get the Bounding box extent specified by setDefaultQueryExtent
  70980. * @returns the box extent values
  70981. */
  70982. getDefaultQueryExtent(): Vector3;
  70983. /**
  70984. * Get the Bounding box extent result specified by setDefaultQueryExtent
  70985. * @param result output the box extent values
  70986. */
  70987. getDefaultQueryExtentToRef(result: Vector3): void;
  70988. /**
  70989. * Release all resources
  70990. */
  70991. dispose(): void;
  70992. }
  70993. }
  70994. declare module "babylonjs/Navigation/Plugins/index" {
  70995. export * from "babylonjs/Navigation/Plugins/recastJSPlugin";
  70996. }
  70997. declare module "babylonjs/Navigation/index" {
  70998. export * from "babylonjs/Navigation/INavigationEngine";
  70999. export * from "babylonjs/Navigation/Plugins/index";
  71000. }
  71001. declare module "babylonjs/Offline/database" {
  71002. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  71003. /**
  71004. * Class used to enable access to IndexedDB
  71005. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  71006. */
  71007. export class Database implements IOfflineProvider {
  71008. private _callbackManifestChecked;
  71009. private _currentSceneUrl;
  71010. private _db;
  71011. private _enableSceneOffline;
  71012. private _enableTexturesOffline;
  71013. private _manifestVersionFound;
  71014. private _mustUpdateRessources;
  71015. private _hasReachedQuota;
  71016. private _isSupported;
  71017. private _idbFactory;
  71018. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  71019. private static IsUASupportingBlobStorage;
  71020. /**
  71021. * Gets a boolean indicating if Database storate is enabled (off by default)
  71022. */
  71023. static IDBStorageEnabled: boolean;
  71024. /**
  71025. * Gets a boolean indicating if scene must be saved in the database
  71026. */
  71027. get enableSceneOffline(): boolean;
  71028. /**
  71029. * Gets a boolean indicating if textures must be saved in the database
  71030. */
  71031. get enableTexturesOffline(): boolean;
  71032. /**
  71033. * Creates a new Database
  71034. * @param urlToScene defines the url to load the scene
  71035. * @param callbackManifestChecked defines the callback to use when manifest is checked
  71036. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  71037. */
  71038. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  71039. private static _ParseURL;
  71040. private static _ReturnFullUrlLocation;
  71041. private _checkManifestFile;
  71042. /**
  71043. * Open the database and make it available
  71044. * @param successCallback defines the callback to call on success
  71045. * @param errorCallback defines the callback to call on error
  71046. */
  71047. open(successCallback: () => void, errorCallback: () => void): void;
  71048. /**
  71049. * Loads an image from the database
  71050. * @param url defines the url to load from
  71051. * @param image defines the target DOM image
  71052. */
  71053. loadImage(url: string, image: HTMLImageElement): void;
  71054. private _loadImageFromDBAsync;
  71055. private _saveImageIntoDBAsync;
  71056. private _checkVersionFromDB;
  71057. private _loadVersionFromDBAsync;
  71058. private _saveVersionIntoDBAsync;
  71059. /**
  71060. * Loads a file from database
  71061. * @param url defines the URL to load from
  71062. * @param sceneLoaded defines a callback to call on success
  71063. * @param progressCallBack defines a callback to call when progress changed
  71064. * @param errorCallback defines a callback to call on error
  71065. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  71066. */
  71067. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  71068. private _loadFileAsync;
  71069. private _saveFileAsync;
  71070. /**
  71071. * Validates if xhr data is correct
  71072. * @param xhr defines the request to validate
  71073. * @param dataType defines the expected data type
  71074. * @returns true if data is correct
  71075. */
  71076. private static _ValidateXHRData;
  71077. }
  71078. }
  71079. declare module "babylonjs/Offline/index" {
  71080. export * from "babylonjs/Offline/database";
  71081. export * from "babylonjs/Offline/IOfflineProvider";
  71082. }
  71083. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  71084. /** @hidden */
  71085. export var gpuUpdateParticlesPixelShader: {
  71086. name: string;
  71087. shader: string;
  71088. };
  71089. }
  71090. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  71091. /** @hidden */
  71092. export var gpuUpdateParticlesVertexShader: {
  71093. name: string;
  71094. shader: string;
  71095. };
  71096. }
  71097. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  71098. /** @hidden */
  71099. export var clipPlaneFragmentDeclaration2: {
  71100. name: string;
  71101. shader: string;
  71102. };
  71103. }
  71104. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  71105. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  71106. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  71107. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  71108. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  71109. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  71110. /** @hidden */
  71111. export var gpuRenderParticlesPixelShader: {
  71112. name: string;
  71113. shader: string;
  71114. };
  71115. }
  71116. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  71117. /** @hidden */
  71118. export var clipPlaneVertexDeclaration2: {
  71119. name: string;
  71120. shader: string;
  71121. };
  71122. }
  71123. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  71124. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  71125. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  71126. /** @hidden */
  71127. export var gpuRenderParticlesVertexShader: {
  71128. name: string;
  71129. shader: string;
  71130. };
  71131. }
  71132. declare module "babylonjs/Particles/gpuParticleSystem" {
  71133. import { Nullable } from "babylonjs/types";
  71134. import { Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  71135. import { Observable } from "babylonjs/Misc/observable";
  71136. import { Matrix } from "babylonjs/Maths/math.vector";
  71137. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  71138. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  71139. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  71140. import { IDisposable } from "babylonjs/scene";
  71141. import { Effect } from "babylonjs/Materials/effect";
  71142. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  71143. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  71144. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  71145. import { Scene } from "babylonjs/scene";
  71146. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  71147. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  71148. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  71149. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  71150. /**
  71151. * This represents a GPU particle system in Babylon
  71152. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  71153. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  71154. */
  71155. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  71156. /**
  71157. * The layer mask we are rendering the particles through.
  71158. */
  71159. layerMask: number;
  71160. private _capacity;
  71161. private _activeCount;
  71162. private _currentActiveCount;
  71163. private _accumulatedCount;
  71164. private _renderEffect;
  71165. private _updateEffect;
  71166. private _buffer0;
  71167. private _buffer1;
  71168. private _spriteBuffer;
  71169. private _updateVAO;
  71170. private _renderVAO;
  71171. private _targetIndex;
  71172. private _sourceBuffer;
  71173. private _targetBuffer;
  71174. private _currentRenderId;
  71175. private _started;
  71176. private _stopped;
  71177. private _timeDelta;
  71178. private _randomTexture;
  71179. private _randomTexture2;
  71180. private _attributesStrideSize;
  71181. private _updateEffectOptions;
  71182. private _randomTextureSize;
  71183. private _actualFrame;
  71184. private _customEffect;
  71185. private readonly _rawTextureWidth;
  71186. /**
  71187. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  71188. */
  71189. static get IsSupported(): boolean;
  71190. /**
  71191. * An event triggered when the system is disposed.
  71192. */
  71193. onDisposeObservable: Observable<IParticleSystem>;
  71194. /**
  71195. * Gets the maximum number of particles active at the same time.
  71196. * @returns The max number of active particles.
  71197. */
  71198. getCapacity(): number;
  71199. /**
  71200. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  71201. * to override the particles.
  71202. */
  71203. forceDepthWrite: boolean;
  71204. /**
  71205. * Gets or set the number of active particles
  71206. */
  71207. get activeParticleCount(): number;
  71208. set activeParticleCount(value: number);
  71209. private _preWarmDone;
  71210. /**
  71211. * Specifies if the particles are updated in emitter local space or world space.
  71212. */
  71213. isLocal: boolean;
  71214. /** Gets or sets a matrix to use to compute projection */
  71215. defaultProjectionMatrix: Matrix;
  71216. /**
  71217. * Is this system ready to be used/rendered
  71218. * @return true if the system is ready
  71219. */
  71220. isReady(): boolean;
  71221. /**
  71222. * Gets if the system has been started. (Note: this will still be true after stop is called)
  71223. * @returns True if it has been started, otherwise false.
  71224. */
  71225. isStarted(): boolean;
  71226. /**
  71227. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  71228. * @returns True if it has been stopped, otherwise false.
  71229. */
  71230. isStopped(): boolean;
  71231. /**
  71232. * Gets a boolean indicating that the system is stopping
  71233. * @returns true if the system is currently stopping
  71234. */
  71235. isStopping(): boolean;
  71236. /**
  71237. * Gets the number of particles active at the same time.
  71238. * @returns The number of active particles.
  71239. */
  71240. getActiveCount(): number;
  71241. /**
  71242. * Starts the particle system and begins to emit
  71243. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  71244. */
  71245. start(delay?: number): void;
  71246. /**
  71247. * Stops the particle system.
  71248. */
  71249. stop(): void;
  71250. /**
  71251. * Remove all active particles
  71252. */
  71253. reset(): void;
  71254. /**
  71255. * Returns the string "GPUParticleSystem"
  71256. * @returns a string containing the class name
  71257. */
  71258. getClassName(): string;
  71259. /**
  71260. * Gets the custom effect used to render the particles
  71261. * @param blendMode Blend mode for which the effect should be retrieved
  71262. * @returns The effect
  71263. */
  71264. getCustomEffect(blendMode?: number): Nullable<Effect>;
  71265. /**
  71266. * Sets the custom effect used to render the particles
  71267. * @param effect The effect to set
  71268. * @param blendMode Blend mode for which the effect should be set
  71269. */
  71270. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  71271. /** @hidden */
  71272. protected _onBeforeDrawParticlesObservable: Nullable<Observable<Nullable<Effect>>>;
  71273. /**
  71274. * Observable that will be called just before the particles are drawn
  71275. */
  71276. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  71277. /**
  71278. * Gets the name of the particle vertex shader
  71279. */
  71280. get vertexShaderName(): string;
  71281. private _colorGradientsTexture;
  71282. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  71283. /**
  71284. * Adds a new color gradient
  71285. * @param gradient defines the gradient to use (between 0 and 1)
  71286. * @param color1 defines the color to affect to the specified gradient
  71287. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  71288. * @returns the current particle system
  71289. */
  71290. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  71291. private _refreshColorGradient;
  71292. /** Force the system to rebuild all gradients that need to be resync */
  71293. forceRefreshGradients(): void;
  71294. /**
  71295. * Remove a specific color gradient
  71296. * @param gradient defines the gradient to remove
  71297. * @returns the current particle system
  71298. */
  71299. removeColorGradient(gradient: number): GPUParticleSystem;
  71300. private _angularSpeedGradientsTexture;
  71301. private _sizeGradientsTexture;
  71302. private _velocityGradientsTexture;
  71303. private _limitVelocityGradientsTexture;
  71304. private _dragGradientsTexture;
  71305. private _addFactorGradient;
  71306. /**
  71307. * Adds a new size gradient
  71308. * @param gradient defines the gradient to use (between 0 and 1)
  71309. * @param factor defines the size factor to affect to the specified gradient
  71310. * @returns the current particle system
  71311. */
  71312. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  71313. /**
  71314. * Remove a specific size gradient
  71315. * @param gradient defines the gradient to remove
  71316. * @returns the current particle system
  71317. */
  71318. removeSizeGradient(gradient: number): GPUParticleSystem;
  71319. private _refreshFactorGradient;
  71320. /**
  71321. * Adds a new angular speed gradient
  71322. * @param gradient defines the gradient to use (between 0 and 1)
  71323. * @param factor defines the angular speed to affect to the specified gradient
  71324. * @returns the current particle system
  71325. */
  71326. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  71327. /**
  71328. * Remove a specific angular speed gradient
  71329. * @param gradient defines the gradient to remove
  71330. * @returns the current particle system
  71331. */
  71332. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  71333. /**
  71334. * Adds a new velocity gradient
  71335. * @param gradient defines the gradient to use (between 0 and 1)
  71336. * @param factor defines the velocity to affect to the specified gradient
  71337. * @returns the current particle system
  71338. */
  71339. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  71340. /**
  71341. * Remove a specific velocity gradient
  71342. * @param gradient defines the gradient to remove
  71343. * @returns the current particle system
  71344. */
  71345. removeVelocityGradient(gradient: number): GPUParticleSystem;
  71346. /**
  71347. * Adds a new limit velocity gradient
  71348. * @param gradient defines the gradient to use (between 0 and 1)
  71349. * @param factor defines the limit velocity value to affect to the specified gradient
  71350. * @returns the current particle system
  71351. */
  71352. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  71353. /**
  71354. * Remove a specific limit velocity gradient
  71355. * @param gradient defines the gradient to remove
  71356. * @returns the current particle system
  71357. */
  71358. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  71359. /**
  71360. * Adds a new drag gradient
  71361. * @param gradient defines the gradient to use (between 0 and 1)
  71362. * @param factor defines the drag value to affect to the specified gradient
  71363. * @returns the current particle system
  71364. */
  71365. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  71366. /**
  71367. * Remove a specific drag gradient
  71368. * @param gradient defines the gradient to remove
  71369. * @returns the current particle system
  71370. */
  71371. removeDragGradient(gradient: number): GPUParticleSystem;
  71372. /**
  71373. * Not supported by GPUParticleSystem
  71374. * @param gradient defines the gradient to use (between 0 and 1)
  71375. * @param factor defines the emit rate value to affect to the specified gradient
  71376. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  71377. * @returns the current particle system
  71378. */
  71379. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  71380. /**
  71381. * Not supported by GPUParticleSystem
  71382. * @param gradient defines the gradient to remove
  71383. * @returns the current particle system
  71384. */
  71385. removeEmitRateGradient(gradient: number): IParticleSystem;
  71386. /**
  71387. * Not supported by GPUParticleSystem
  71388. * @param gradient defines the gradient to use (between 0 and 1)
  71389. * @param factor defines the start size value to affect to the specified gradient
  71390. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  71391. * @returns the current particle system
  71392. */
  71393. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  71394. /**
  71395. * Not supported by GPUParticleSystem
  71396. * @param gradient defines the gradient to remove
  71397. * @returns the current particle system
  71398. */
  71399. removeStartSizeGradient(gradient: number): IParticleSystem;
  71400. /**
  71401. * Not supported by GPUParticleSystem
  71402. * @param gradient defines the gradient to use (between 0 and 1)
  71403. * @param min defines the color remap minimal range
  71404. * @param max defines the color remap maximal range
  71405. * @returns the current particle system
  71406. */
  71407. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  71408. /**
  71409. * Not supported by GPUParticleSystem
  71410. * @param gradient defines the gradient to remove
  71411. * @returns the current particle system
  71412. */
  71413. removeColorRemapGradient(): IParticleSystem;
  71414. /**
  71415. * Not supported by GPUParticleSystem
  71416. * @param gradient defines the gradient to use (between 0 and 1)
  71417. * @param min defines the alpha remap minimal range
  71418. * @param max defines the alpha remap maximal range
  71419. * @returns the current particle system
  71420. */
  71421. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  71422. /**
  71423. * Not supported by GPUParticleSystem
  71424. * @param gradient defines the gradient to remove
  71425. * @returns the current particle system
  71426. */
  71427. removeAlphaRemapGradient(): IParticleSystem;
  71428. /**
  71429. * Not supported by GPUParticleSystem
  71430. * @param gradient defines the gradient to use (between 0 and 1)
  71431. * @param color defines the color to affect to the specified gradient
  71432. * @returns the current particle system
  71433. */
  71434. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  71435. /**
  71436. * Not supported by GPUParticleSystem
  71437. * @param gradient defines the gradient to remove
  71438. * @returns the current particle system
  71439. */
  71440. removeRampGradient(): IParticleSystem;
  71441. /**
  71442. * Not supported by GPUParticleSystem
  71443. * @returns the list of ramp gradients
  71444. */
  71445. getRampGradients(): Nullable<Array<Color3Gradient>>;
  71446. /**
  71447. * Not supported by GPUParticleSystem
  71448. * Gets or sets a boolean indicating that ramp gradients must be used
  71449. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  71450. */
  71451. get useRampGradients(): boolean;
  71452. set useRampGradients(value: boolean);
  71453. /**
  71454. * Not supported by GPUParticleSystem
  71455. * @param gradient defines the gradient to use (between 0 and 1)
  71456. * @param factor defines the life time factor to affect to the specified gradient
  71457. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  71458. * @returns the current particle system
  71459. */
  71460. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  71461. /**
  71462. * Not supported by GPUParticleSystem
  71463. * @param gradient defines the gradient to remove
  71464. * @returns the current particle system
  71465. */
  71466. removeLifeTimeGradient(gradient: number): IParticleSystem;
  71467. /**
  71468. * Instantiates a GPU particle system.
  71469. * 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.
  71470. * @param name The name of the particle system
  71471. * @param options The options used to create the system
  71472. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  71473. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  71474. * @param customEffect a custom effect used to change the way particles are rendered by default
  71475. */
  71476. constructor(name: string, options: Partial<{
  71477. capacity: number;
  71478. randomTextureSize: number;
  71479. }>, sceneOrEngine: Scene | ThinEngine, isAnimationSheetEnabled?: boolean, customEffect?: Nullable<Effect>);
  71480. protected _reset(): void;
  71481. private _createUpdateVAO;
  71482. private _createRenderVAO;
  71483. private _initialize;
  71484. /** @hidden */
  71485. _recreateUpdateEffect(): void;
  71486. private _getEffect;
  71487. /**
  71488. * Fill the defines array according to the current settings of the particle system
  71489. * @param defines Array to be updated
  71490. * @param blendMode blend mode to take into account when updating the array
  71491. */
  71492. fillDefines(defines: Array<string>, blendMode?: number): void;
  71493. /**
  71494. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  71495. * @param uniforms Uniforms array to fill
  71496. * @param attributes Attributes array to fill
  71497. * @param samplers Samplers array to fill
  71498. */
  71499. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  71500. /** @hidden */
  71501. _recreateRenderEffect(): Effect;
  71502. /**
  71503. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  71504. * @param preWarm defines if we are in the pre-warmimg phase
  71505. */
  71506. animate(preWarm?: boolean): void;
  71507. private _createFactorGradientTexture;
  71508. private _createSizeGradientTexture;
  71509. private _createAngularSpeedGradientTexture;
  71510. private _createVelocityGradientTexture;
  71511. private _createLimitVelocityGradientTexture;
  71512. private _createDragGradientTexture;
  71513. private _createColorGradientTexture;
  71514. /**
  71515. * Renders the particle system in its current state
  71516. * @param preWarm defines if the system should only update the particles but not render them
  71517. * @returns the current number of particles
  71518. */
  71519. render(preWarm?: boolean): number;
  71520. /**
  71521. * Rebuilds the particle system
  71522. */
  71523. rebuild(): void;
  71524. private _releaseBuffers;
  71525. private _releaseVAOs;
  71526. /**
  71527. * Disposes the particle system and free the associated resources
  71528. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  71529. */
  71530. dispose(disposeTexture?: boolean): void;
  71531. /**
  71532. * Clones the particle system.
  71533. * @param name The name of the cloned object
  71534. * @param newEmitter The new emitter to use
  71535. * @returns the cloned particle system
  71536. */
  71537. clone(name: string, newEmitter: any): GPUParticleSystem;
  71538. /**
  71539. * Serializes the particle system to a JSON object
  71540. * @param serializeTexture defines if the texture must be serialized as well
  71541. * @returns the JSON object
  71542. */
  71543. serialize(serializeTexture?: boolean): any;
  71544. /**
  71545. * Parses a JSON object to create a GPU particle system.
  71546. * @param parsedParticleSystem The JSON object to parse
  71547. * @param sceneOrEngine The scene or the engine to create the particle system in
  71548. * @param rootUrl The root url to use to load external dependencies like texture
  71549. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  71550. * @returns the parsed GPU particle system
  71551. */
  71552. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  71553. }
  71554. }
  71555. declare module "babylonjs/Particles/particleSystemSet" {
  71556. import { Nullable } from "babylonjs/types";
  71557. import { Color3 } from "babylonjs/Maths/math.color";
  71558. import { TransformNode } from "babylonjs/Meshes/transformNode";
  71559. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  71560. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  71561. import { Scene, IDisposable } from "babylonjs/scene";
  71562. /**
  71563. * Represents a set of particle systems working together to create a specific effect
  71564. */
  71565. export class ParticleSystemSet implements IDisposable {
  71566. /**
  71567. * Gets or sets base Assets URL
  71568. */
  71569. static BaseAssetsUrl: string;
  71570. private _emitterCreationOptions;
  71571. private _emitterNode;
  71572. /**
  71573. * Gets the particle system list
  71574. */
  71575. systems: IParticleSystem[];
  71576. /**
  71577. * Gets the emitter node used with this set
  71578. */
  71579. get emitterNode(): Nullable<TransformNode>;
  71580. /**
  71581. * Creates a new emitter mesh as a sphere
  71582. * @param options defines the options used to create the sphere
  71583. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  71584. * @param scene defines the hosting scene
  71585. */
  71586. setEmitterAsSphere(options: {
  71587. diameter: number;
  71588. segments: number;
  71589. color: Color3;
  71590. }, renderingGroupId: number, scene: Scene): void;
  71591. /**
  71592. * Starts all particle systems of the set
  71593. * @param emitter defines an optional mesh to use as emitter for the particle systems
  71594. */
  71595. start(emitter?: AbstractMesh): void;
  71596. /**
  71597. * Release all associated resources
  71598. */
  71599. dispose(): void;
  71600. /**
  71601. * Serialize the set into a JSON compatible object
  71602. * @param serializeTexture defines if the texture must be serialized as well
  71603. * @returns a JSON compatible representation of the set
  71604. */
  71605. serialize(serializeTexture?: boolean): any;
  71606. /**
  71607. * Parse a new ParticleSystemSet from a serialized source
  71608. * @param data defines a JSON compatible representation of the set
  71609. * @param scene defines the hosting scene
  71610. * @param gpu defines if we want GPU particles or CPU particles
  71611. * @returns a new ParticleSystemSet
  71612. */
  71613. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  71614. }
  71615. }
  71616. declare module "babylonjs/Particles/particleHelper" {
  71617. import { Nullable } from "babylonjs/types";
  71618. import { Scene } from "babylonjs/scene";
  71619. import { Vector3 } from "babylonjs/Maths/math.vector";
  71620. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  71621. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  71622. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  71623. /**
  71624. * This class is made for on one-liner static method to help creating particle system set.
  71625. */
  71626. export class ParticleHelper {
  71627. /**
  71628. * Gets or sets base Assets URL
  71629. */
  71630. static BaseAssetsUrl: string;
  71631. /** Define the Url to load snippets */
  71632. static SnippetUrl: string;
  71633. /**
  71634. * Create a default particle system that you can tweak
  71635. * @param emitter defines the emitter to use
  71636. * @param capacity defines the system capacity (default is 500 particles)
  71637. * @param scene defines the hosting scene
  71638. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  71639. * @returns the new Particle system
  71640. */
  71641. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  71642. /**
  71643. * This is the main static method (one-liner) of this helper to create different particle systems
  71644. * @param type This string represents the type to the particle system to create
  71645. * @param scene The scene where the particle system should live
  71646. * @param gpu If the system will use gpu
  71647. * @returns the ParticleSystemSet created
  71648. */
  71649. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  71650. /**
  71651. * Static function used to export a particle system to a ParticleSystemSet variable.
  71652. * Please note that the emitter shape is not exported
  71653. * @param systems defines the particle systems to export
  71654. * @returns the created particle system set
  71655. */
  71656. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  71657. /**
  71658. * Creates a particle system from a snippet saved in a remote file
  71659. * @param name defines the name of the particle system to create (can be null or empty to use the one from the json data)
  71660. * @param url defines the url to load from
  71661. * @param scene defines the hosting scene
  71662. * @param gpu If the system will use gpu
  71663. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  71664. * @returns a promise that will resolve to the new particle system
  71665. */
  71666. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  71667. /**
  71668. * Creates a particle system from a snippet saved by the particle system editor
  71669. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  71670. * @param scene defines the hosting scene
  71671. * @param gpu If the system will use gpu
  71672. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  71673. * @returns a promise that will resolve to the new particle system
  71674. */
  71675. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  71676. }
  71677. }
  71678. declare module "babylonjs/Particles/particleSystemComponent" {
  71679. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  71680. import { Effect } from "babylonjs/Materials/effect";
  71681. import "babylonjs/Shaders/particles.vertex";
  71682. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  71683. module "babylonjs/Engines/engine" {
  71684. interface Engine {
  71685. /**
  71686. * Create an effect to use with particle systems.
  71687. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration, except if you pass
  71688. * the particle system for which you want to create a custom effect in the last parameter
  71689. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  71690. * @param uniformsNames defines a list of attribute names
  71691. * @param samplers defines an array of string used to represent textures
  71692. * @param defines defines the string containing the defines to use to compile the shaders
  71693. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  71694. * @param onCompiled defines a function to call when the effect creation is successful
  71695. * @param onError defines a function to call when the effect creation has failed
  71696. * @param particleSystem the particle system you want to create the effect for
  71697. * @returns the new Effect
  71698. */
  71699. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, particleSystem?: IParticleSystem): Effect;
  71700. }
  71701. }
  71702. module "babylonjs/Meshes/mesh" {
  71703. interface Mesh {
  71704. /**
  71705. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  71706. * @returns an array of IParticleSystem
  71707. */
  71708. getEmittedParticleSystems(): IParticleSystem[];
  71709. /**
  71710. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  71711. * @returns an array of IParticleSystem
  71712. */
  71713. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  71714. }
  71715. }
  71716. }
  71717. declare module "babylonjs/Particles/pointsCloudSystem" {
  71718. import { Color4 } from "babylonjs/Maths/math";
  71719. import { Mesh } from "babylonjs/Meshes/mesh";
  71720. import { Scene, IDisposable } from "babylonjs/scene";
  71721. import { CloudPoint } from "babylonjs/Particles/cloudPoint";
  71722. /** Defines the 4 color options */
  71723. export enum PointColor {
  71724. /** color value */
  71725. Color = 2,
  71726. /** uv value */
  71727. UV = 1,
  71728. /** random value */
  71729. Random = 0,
  71730. /** stated value */
  71731. Stated = 3
  71732. }
  71733. /**
  71734. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  71735. * 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.
  71736. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  71737. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  71738. *
  71739. * Full documentation here : TO BE ENTERED
  71740. */
  71741. export class PointsCloudSystem implements IDisposable {
  71742. /**
  71743. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  71744. * Example : var p = SPS.particles[i];
  71745. */
  71746. particles: CloudPoint[];
  71747. /**
  71748. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  71749. */
  71750. nbParticles: number;
  71751. /**
  71752. * This a counter for your own usage. It's not set by any SPS functions.
  71753. */
  71754. counter: number;
  71755. /**
  71756. * The PCS name. This name is also given to the underlying mesh.
  71757. */
  71758. name: string;
  71759. /**
  71760. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  71761. */
  71762. mesh: Mesh;
  71763. /**
  71764. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  71765. * Please read :
  71766. */
  71767. vars: any;
  71768. /**
  71769. * @hidden
  71770. */
  71771. _size: number;
  71772. private _scene;
  71773. private _promises;
  71774. private _positions;
  71775. private _indices;
  71776. private _normals;
  71777. private _colors;
  71778. private _uvs;
  71779. private _indices32;
  71780. private _positions32;
  71781. private _colors32;
  71782. private _uvs32;
  71783. private _updatable;
  71784. private _isVisibilityBoxLocked;
  71785. private _alwaysVisible;
  71786. private _groups;
  71787. private _groupCounter;
  71788. private _computeParticleColor;
  71789. private _computeParticleTexture;
  71790. private _computeParticleRotation;
  71791. private _computeBoundingBox;
  71792. private _isReady;
  71793. /**
  71794. * Creates a PCS (Points Cloud System) object
  71795. * @param name (String) is the PCS name, this will be the underlying mesh name
  71796. * @param pointSize (number) is the size for each point
  71797. * @param scene (Scene) is the scene in which the PCS is added
  71798. * @param options defines the options of the PCS e.g.
  71799. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  71800. */
  71801. constructor(name: string, pointSize: number, scene: Scene, options?: {
  71802. updatable?: boolean;
  71803. });
  71804. /**
  71805. * Builds the PCS underlying mesh. Returns a standard Mesh.
  71806. * If no points were added to the PCS, the returned mesh is just a single point.
  71807. * @returns a promise for the created mesh
  71808. */
  71809. buildMeshAsync(): Promise<Mesh>;
  71810. /**
  71811. * @hidden
  71812. */
  71813. private _buildMesh;
  71814. private _addParticle;
  71815. private _randomUnitVector;
  71816. private _getColorIndicesForCoord;
  71817. private _setPointsColorOrUV;
  71818. private _colorFromTexture;
  71819. private _calculateDensity;
  71820. /**
  71821. * Adds points to the PCS in random positions within a unit sphere
  71822. * @param nb (positive integer) the number of particles to be created from this model
  71823. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  71824. * @returns the number of groups in the system
  71825. */
  71826. addPoints(nb: number, pointFunction?: any): number;
  71827. /**
  71828. * Adds points to the PCS from the surface of the model shape
  71829. * @param mesh is any Mesh object that will be used as a surface model for the points
  71830. * @param nb (positive integer) the number of particles to be created from this model
  71831. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  71832. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  71833. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  71834. * @returns the number of groups in the system
  71835. */
  71836. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  71837. /**
  71838. * Adds points to the PCS inside the model shape
  71839. * @param mesh is any Mesh object that will be used as a surface model for the points
  71840. * @param nb (positive integer) the number of particles to be created from this model
  71841. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  71842. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  71843. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  71844. * @returns the number of groups in the system
  71845. */
  71846. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  71847. /**
  71848. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  71849. * This method calls `updateParticle()` for each particle of the SPS.
  71850. * For an animated SPS, it is usually called within the render loop.
  71851. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  71852. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  71853. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  71854. * @returns the PCS.
  71855. */
  71856. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  71857. /**
  71858. * Disposes the PCS.
  71859. */
  71860. dispose(): void;
  71861. /**
  71862. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  71863. * doc :
  71864. * @returns the PCS.
  71865. */
  71866. refreshVisibleSize(): PointsCloudSystem;
  71867. /**
  71868. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  71869. * @param size the size (float) of the visibility box
  71870. * note : this doesn't lock the PCS mesh bounding box.
  71871. * doc :
  71872. */
  71873. setVisibilityBox(size: number): void;
  71874. /**
  71875. * Gets whether the PCS is always visible or not
  71876. * doc :
  71877. */
  71878. get isAlwaysVisible(): boolean;
  71879. /**
  71880. * Sets the PCS as always visible or not
  71881. * doc :
  71882. */
  71883. set isAlwaysVisible(val: boolean);
  71884. /**
  71885. * Tells to `setParticles()` to compute the particle rotations or not
  71886. * Default value : false. The PCS is faster when it's set to false
  71887. * Note : particle rotations are only applied to parent particles
  71888. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  71889. */
  71890. set computeParticleRotation(val: boolean);
  71891. /**
  71892. * Tells to `setParticles()` to compute the particle colors or not.
  71893. * Default value : true. The PCS is faster when it's set to false.
  71894. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  71895. */
  71896. set computeParticleColor(val: boolean);
  71897. set computeParticleTexture(val: boolean);
  71898. /**
  71899. * Gets if `setParticles()` computes the particle colors or not.
  71900. * Default value : false. The PCS is faster when it's set to false.
  71901. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  71902. */
  71903. get computeParticleColor(): boolean;
  71904. /**
  71905. * Gets if `setParticles()` computes the particle textures or not.
  71906. * Default value : false. The PCS is faster when it's set to false.
  71907. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  71908. */
  71909. get computeParticleTexture(): boolean;
  71910. /**
  71911. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  71912. */
  71913. set computeBoundingBox(val: boolean);
  71914. /**
  71915. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  71916. */
  71917. get computeBoundingBox(): boolean;
  71918. /**
  71919. * This function does nothing. It may be overwritten to set all the particle first values.
  71920. * The PCS doesn't call this function, you may have to call it by your own.
  71921. * doc :
  71922. */
  71923. initParticles(): void;
  71924. /**
  71925. * This function does nothing. It may be overwritten to recycle a particle
  71926. * The PCS doesn't call this function, you can to call it
  71927. * doc :
  71928. * @param particle The particle to recycle
  71929. * @returns the recycled particle
  71930. */
  71931. recycleParticle(particle: CloudPoint): CloudPoint;
  71932. /**
  71933. * Updates a particle : this function should be overwritten by the user.
  71934. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  71935. * doc :
  71936. * @example : just set a particle position or velocity and recycle conditions
  71937. * @param particle The particle to update
  71938. * @returns the updated particle
  71939. */
  71940. updateParticle(particle: CloudPoint): CloudPoint;
  71941. /**
  71942. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  71943. * This does nothing and may be overwritten by the user.
  71944. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  71945. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  71946. * @param update the boolean update value actually passed to setParticles()
  71947. */
  71948. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  71949. /**
  71950. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  71951. * This will be passed three parameters.
  71952. * This does nothing and may be overwritten by the user.
  71953. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  71954. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  71955. * @param update the boolean update value actually passed to setParticles()
  71956. */
  71957. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  71958. }
  71959. }
  71960. declare module "babylonjs/Particles/cloudPoint" {
  71961. import { Nullable } from "babylonjs/types";
  71962. import { Color4, Vector2, Vector3, Matrix, Quaternion } from "babylonjs/Maths/math";
  71963. import { Mesh } from "babylonjs/Meshes/mesh";
  71964. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  71965. import { PointsCloudSystem } from "babylonjs/Particles/pointsCloudSystem";
  71966. /**
  71967. * Represents one particle of a points cloud system.
  71968. */
  71969. export class CloudPoint {
  71970. /**
  71971. * particle global index
  71972. */
  71973. idx: number;
  71974. /**
  71975. * The color of the particle
  71976. */
  71977. color: Nullable<Color4>;
  71978. /**
  71979. * The world space position of the particle.
  71980. */
  71981. position: Vector3;
  71982. /**
  71983. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  71984. */
  71985. rotation: Vector3;
  71986. /**
  71987. * The world space rotation quaternion of the particle.
  71988. */
  71989. rotationQuaternion: Nullable<Quaternion>;
  71990. /**
  71991. * The uv of the particle.
  71992. */
  71993. uv: Nullable<Vector2>;
  71994. /**
  71995. * The current speed of the particle.
  71996. */
  71997. velocity: Vector3;
  71998. /**
  71999. * The pivot point in the particle local space.
  72000. */
  72001. pivot: Vector3;
  72002. /**
  72003. * Must the particle be translated from its pivot point in its local space ?
  72004. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  72005. * Default : false
  72006. */
  72007. translateFromPivot: boolean;
  72008. /**
  72009. * Index of this particle in the global "positions" array (Internal use)
  72010. * @hidden
  72011. */
  72012. _pos: number;
  72013. /**
  72014. * @hidden Index of this particle in the global "indices" array (Internal use)
  72015. */
  72016. _ind: number;
  72017. /**
  72018. * Group this particle belongs to
  72019. */
  72020. _group: PointsGroup;
  72021. /**
  72022. * Group id of this particle
  72023. */
  72024. groupId: number;
  72025. /**
  72026. * Index of the particle in its group id (Internal use)
  72027. */
  72028. idxInGroup: number;
  72029. /**
  72030. * @hidden Particle BoundingInfo object (Internal use)
  72031. */
  72032. _boundingInfo: BoundingInfo;
  72033. /**
  72034. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  72035. */
  72036. _pcs: PointsCloudSystem;
  72037. /**
  72038. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  72039. */
  72040. _stillInvisible: boolean;
  72041. /**
  72042. * @hidden Last computed particle rotation matrix
  72043. */
  72044. _rotationMatrix: number[];
  72045. /**
  72046. * Parent particle Id, if any.
  72047. * Default null.
  72048. */
  72049. parentId: Nullable<number>;
  72050. /**
  72051. * @hidden Internal global position in the PCS.
  72052. */
  72053. _globalPosition: Vector3;
  72054. /**
  72055. * Creates a Point Cloud object.
  72056. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  72057. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  72058. * @param group (PointsGroup) is the group the particle belongs to
  72059. * @param groupId (integer) is the group identifier in the PCS.
  72060. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  72061. * @param pcs defines the PCS it is associated to
  72062. */
  72063. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  72064. /**
  72065. * get point size
  72066. */
  72067. get size(): Vector3;
  72068. /**
  72069. * Set point size
  72070. */
  72071. set size(scale: Vector3);
  72072. /**
  72073. * Legacy support, changed quaternion to rotationQuaternion
  72074. */
  72075. get quaternion(): Nullable<Quaternion>;
  72076. /**
  72077. * Legacy support, changed quaternion to rotationQuaternion
  72078. */
  72079. set quaternion(q: Nullable<Quaternion>);
  72080. /**
  72081. * Returns a boolean. True if the particle intersects a mesh, else false
  72082. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  72083. * @param target is the object (point or mesh) what the intersection is computed against
  72084. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  72085. * @returns true if it intersects
  72086. */
  72087. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  72088. /**
  72089. * get the rotation matrix of the particle
  72090. * @hidden
  72091. */
  72092. getRotationMatrix(m: Matrix): void;
  72093. }
  72094. /**
  72095. * Represents a group of points in a points cloud system
  72096. * * PCS internal tool, don't use it manually.
  72097. */
  72098. export class PointsGroup {
  72099. /**
  72100. * The group id
  72101. * @hidden
  72102. */
  72103. groupID: number;
  72104. /**
  72105. * image data for group (internal use)
  72106. * @hidden
  72107. */
  72108. _groupImageData: Nullable<ArrayBufferView>;
  72109. /**
  72110. * Image Width (internal use)
  72111. * @hidden
  72112. */
  72113. _groupImgWidth: number;
  72114. /**
  72115. * Image Height (internal use)
  72116. * @hidden
  72117. */
  72118. _groupImgHeight: number;
  72119. /**
  72120. * Custom position function (internal use)
  72121. * @hidden
  72122. */
  72123. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  72124. /**
  72125. * density per facet for surface points
  72126. * @hidden
  72127. */
  72128. _groupDensity: number[];
  72129. /**
  72130. * Only when points are colored by texture carries pointer to texture list array
  72131. * @hidden
  72132. */
  72133. _textureNb: number;
  72134. /**
  72135. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  72136. * PCS internal tool, don't use it manually.
  72137. * @hidden
  72138. */
  72139. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  72140. }
  72141. }
  72142. declare module "babylonjs/Particles/index" {
  72143. export * from "babylonjs/Particles/baseParticleSystem";
  72144. export * from "babylonjs/Particles/EmitterTypes/index";
  72145. export * from "babylonjs/Particles/gpuParticleSystem";
  72146. export * from "babylonjs/Particles/IParticleSystem";
  72147. export * from "babylonjs/Particles/particle";
  72148. export * from "babylonjs/Particles/particleHelper";
  72149. export * from "babylonjs/Particles/particleSystem";
  72150. import "babylonjs/Particles/particleSystemComponent";
  72151. export * from "babylonjs/Particles/particleSystemComponent";
  72152. export * from "babylonjs/Particles/particleSystemSet";
  72153. export * from "babylonjs/Particles/solidParticle";
  72154. export * from "babylonjs/Particles/solidParticleSystem";
  72155. export * from "babylonjs/Particles/cloudPoint";
  72156. export * from "babylonjs/Particles/pointsCloudSystem";
  72157. export * from "babylonjs/Particles/subEmitter";
  72158. }
  72159. declare module "babylonjs/Physics/physicsEngineComponent" {
  72160. import { Nullable } from "babylonjs/types";
  72161. import { Observable, Observer } from "babylonjs/Misc/observable";
  72162. import { Vector3 } from "babylonjs/Maths/math.vector";
  72163. import { Mesh } from "babylonjs/Meshes/mesh";
  72164. import { ISceneComponent } from "babylonjs/sceneComponent";
  72165. import { Scene } from "babylonjs/scene";
  72166. import { Node } from "babylonjs/node";
  72167. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  72168. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  72169. module "babylonjs/scene" {
  72170. interface Scene {
  72171. /** @hidden (Backing field) */
  72172. _physicsEngine: Nullable<IPhysicsEngine>;
  72173. /** @hidden */
  72174. _physicsTimeAccumulator: number;
  72175. /**
  72176. * Gets the current physics engine
  72177. * @returns a IPhysicsEngine or null if none attached
  72178. */
  72179. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  72180. /**
  72181. * Enables physics to the current scene
  72182. * @param gravity defines the scene's gravity for the physics engine
  72183. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  72184. * @return a boolean indicating if the physics engine was initialized
  72185. */
  72186. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  72187. /**
  72188. * Disables and disposes the physics engine associated with the scene
  72189. */
  72190. disablePhysicsEngine(): void;
  72191. /**
  72192. * Gets a boolean indicating if there is an active physics engine
  72193. * @returns a boolean indicating if there is an active physics engine
  72194. */
  72195. isPhysicsEnabled(): boolean;
  72196. /**
  72197. * Deletes a physics compound impostor
  72198. * @param compound defines the compound to delete
  72199. */
  72200. deleteCompoundImpostor(compound: any): void;
  72201. /**
  72202. * An event triggered when physic simulation is about to be run
  72203. */
  72204. onBeforePhysicsObservable: Observable<Scene>;
  72205. /**
  72206. * An event triggered when physic simulation has been done
  72207. */
  72208. onAfterPhysicsObservable: Observable<Scene>;
  72209. }
  72210. }
  72211. module "babylonjs/Meshes/abstractMesh" {
  72212. interface AbstractMesh {
  72213. /** @hidden */
  72214. _physicsImpostor: Nullable<PhysicsImpostor>;
  72215. /**
  72216. * Gets or sets impostor used for physic simulation
  72217. * @see https://doc.babylonjs.com/features/physics_engine
  72218. */
  72219. physicsImpostor: Nullable<PhysicsImpostor>;
  72220. /**
  72221. * Gets the current physics impostor
  72222. * @see https://doc.babylonjs.com/features/physics_engine
  72223. * @returns a physics impostor or null
  72224. */
  72225. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  72226. /** Apply a physic impulse to the mesh
  72227. * @param force defines the force to apply
  72228. * @param contactPoint defines where to apply the force
  72229. * @returns the current mesh
  72230. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  72231. */
  72232. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  72233. /**
  72234. * Creates a physic joint between two meshes
  72235. * @param otherMesh defines the other mesh to use
  72236. * @param pivot1 defines the pivot to use on this mesh
  72237. * @param pivot2 defines the pivot to use on the other mesh
  72238. * @param options defines additional options (can be plugin dependent)
  72239. * @returns the current mesh
  72240. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  72241. */
  72242. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  72243. /** @hidden */
  72244. _disposePhysicsObserver: Nullable<Observer<Node>>;
  72245. }
  72246. }
  72247. /**
  72248. * Defines the physics engine scene component responsible to manage a physics engine
  72249. */
  72250. export class PhysicsEngineSceneComponent implements ISceneComponent {
  72251. /**
  72252. * The component name helpful to identify the component in the list of scene components.
  72253. */
  72254. readonly name: string;
  72255. /**
  72256. * The scene the component belongs to.
  72257. */
  72258. scene: Scene;
  72259. /**
  72260. * Creates a new instance of the component for the given scene
  72261. * @param scene Defines the scene to register the component in
  72262. */
  72263. constructor(scene: Scene);
  72264. /**
  72265. * Registers the component in a given scene
  72266. */
  72267. register(): void;
  72268. /**
  72269. * Rebuilds the elements related to this component in case of
  72270. * context lost for instance.
  72271. */
  72272. rebuild(): void;
  72273. /**
  72274. * Disposes the component and the associated ressources
  72275. */
  72276. dispose(): void;
  72277. }
  72278. }
  72279. declare module "babylonjs/Physics/physicsHelper" {
  72280. import { Nullable } from "babylonjs/types";
  72281. import { Vector3 } from "babylonjs/Maths/math.vector";
  72282. import { Mesh } from "babylonjs/Meshes/mesh";
  72283. import { Scene } from "babylonjs/scene";
  72284. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  72285. /**
  72286. * A helper for physics simulations
  72287. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72288. */
  72289. export class PhysicsHelper {
  72290. private _scene;
  72291. private _physicsEngine;
  72292. /**
  72293. * Initializes the Physics helper
  72294. * @param scene Babylon.js scene
  72295. */
  72296. constructor(scene: Scene);
  72297. /**
  72298. * Applies a radial explosion impulse
  72299. * @param origin the origin of the explosion
  72300. * @param radiusOrEventOptions the radius or the options of radial explosion
  72301. * @param strength the explosion strength
  72302. * @param falloff possible options: Constant & Linear. Defaults to Constant
  72303. * @returns A physics radial explosion event, or null
  72304. */
  72305. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  72306. /**
  72307. * Applies a radial explosion force
  72308. * @param origin the origin of the explosion
  72309. * @param radiusOrEventOptions the radius or the options of radial explosion
  72310. * @param strength the explosion strength
  72311. * @param falloff possible options: Constant & Linear. Defaults to Constant
  72312. * @returns A physics radial explosion event, or null
  72313. */
  72314. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  72315. /**
  72316. * Creates a gravitational field
  72317. * @param origin the origin of the explosion
  72318. * @param radiusOrEventOptions the radius or the options of radial explosion
  72319. * @param strength the explosion strength
  72320. * @param falloff possible options: Constant & Linear. Defaults to Constant
  72321. * @returns A physics gravitational field event, or null
  72322. */
  72323. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  72324. /**
  72325. * Creates a physics updraft event
  72326. * @param origin the origin of the updraft
  72327. * @param radiusOrEventOptions the radius or the options of the updraft
  72328. * @param strength the strength of the updraft
  72329. * @param height the height of the updraft
  72330. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  72331. * @returns A physics updraft event, or null
  72332. */
  72333. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  72334. /**
  72335. * Creates a physics vortex event
  72336. * @param origin the of the vortex
  72337. * @param radiusOrEventOptions the radius or the options of the vortex
  72338. * @param strength the strength of the vortex
  72339. * @param height the height of the vortex
  72340. * @returns a Physics vortex event, or null
  72341. * A physics vortex event or null
  72342. */
  72343. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  72344. }
  72345. /**
  72346. * Represents a physics radial explosion event
  72347. */
  72348. class PhysicsRadialExplosionEvent {
  72349. private _scene;
  72350. private _options;
  72351. private _sphere;
  72352. private _dataFetched;
  72353. /**
  72354. * Initializes a radial explosioin event
  72355. * @param _scene BabylonJS scene
  72356. * @param _options The options for the vortex event
  72357. */
  72358. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  72359. /**
  72360. * Returns the data related to the radial explosion event (sphere).
  72361. * @returns The radial explosion event data
  72362. */
  72363. getData(): PhysicsRadialExplosionEventData;
  72364. /**
  72365. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  72366. * @param impostor A physics imposter
  72367. * @param origin the origin of the explosion
  72368. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  72369. */
  72370. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  72371. /**
  72372. * Triggers affecterd impostors callbacks
  72373. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  72374. */
  72375. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  72376. /**
  72377. * Disposes the sphere.
  72378. * @param force Specifies if the sphere should be disposed by force
  72379. */
  72380. dispose(force?: boolean): void;
  72381. /*** Helpers ***/
  72382. private _prepareSphere;
  72383. private _intersectsWithSphere;
  72384. }
  72385. /**
  72386. * Represents a gravitational field event
  72387. */
  72388. class PhysicsGravitationalFieldEvent {
  72389. private _physicsHelper;
  72390. private _scene;
  72391. private _origin;
  72392. private _options;
  72393. private _tickCallback;
  72394. private _sphere;
  72395. private _dataFetched;
  72396. /**
  72397. * Initializes the physics gravitational field event
  72398. * @param _physicsHelper A physics helper
  72399. * @param _scene BabylonJS scene
  72400. * @param _origin The origin position of the gravitational field event
  72401. * @param _options The options for the vortex event
  72402. */
  72403. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  72404. /**
  72405. * Returns the data related to the gravitational field event (sphere).
  72406. * @returns A gravitational field event
  72407. */
  72408. getData(): PhysicsGravitationalFieldEventData;
  72409. /**
  72410. * Enables the gravitational field.
  72411. */
  72412. enable(): void;
  72413. /**
  72414. * Disables the gravitational field.
  72415. */
  72416. disable(): void;
  72417. /**
  72418. * Disposes the sphere.
  72419. * @param force The force to dispose from the gravitational field event
  72420. */
  72421. dispose(force?: boolean): void;
  72422. private _tick;
  72423. }
  72424. /**
  72425. * Represents a physics updraft event
  72426. */
  72427. class PhysicsUpdraftEvent {
  72428. private _scene;
  72429. private _origin;
  72430. private _options;
  72431. private _physicsEngine;
  72432. private _originTop;
  72433. private _originDirection;
  72434. private _tickCallback;
  72435. private _cylinder;
  72436. private _cylinderPosition;
  72437. private _dataFetched;
  72438. /**
  72439. * Initializes the physics updraft event
  72440. * @param _scene BabylonJS scene
  72441. * @param _origin The origin position of the updraft
  72442. * @param _options The options for the updraft event
  72443. */
  72444. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  72445. /**
  72446. * Returns the data related to the updraft event (cylinder).
  72447. * @returns A physics updraft event
  72448. */
  72449. getData(): PhysicsUpdraftEventData;
  72450. /**
  72451. * Enables the updraft.
  72452. */
  72453. enable(): void;
  72454. /**
  72455. * Disables the updraft.
  72456. */
  72457. disable(): void;
  72458. /**
  72459. * Disposes the cylinder.
  72460. * @param force Specifies if the updraft should be disposed by force
  72461. */
  72462. dispose(force?: boolean): void;
  72463. private getImpostorHitData;
  72464. private _tick;
  72465. /*** Helpers ***/
  72466. private _prepareCylinder;
  72467. private _intersectsWithCylinder;
  72468. }
  72469. /**
  72470. * Represents a physics vortex event
  72471. */
  72472. class PhysicsVortexEvent {
  72473. private _scene;
  72474. private _origin;
  72475. private _options;
  72476. private _physicsEngine;
  72477. private _originTop;
  72478. private _tickCallback;
  72479. private _cylinder;
  72480. private _cylinderPosition;
  72481. private _dataFetched;
  72482. /**
  72483. * Initializes the physics vortex event
  72484. * @param _scene The BabylonJS scene
  72485. * @param _origin The origin position of the vortex
  72486. * @param _options The options for the vortex event
  72487. */
  72488. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  72489. /**
  72490. * Returns the data related to the vortex event (cylinder).
  72491. * @returns The physics vortex event data
  72492. */
  72493. getData(): PhysicsVortexEventData;
  72494. /**
  72495. * Enables the vortex.
  72496. */
  72497. enable(): void;
  72498. /**
  72499. * Disables the cortex.
  72500. */
  72501. disable(): void;
  72502. /**
  72503. * Disposes the sphere.
  72504. * @param force
  72505. */
  72506. dispose(force?: boolean): void;
  72507. private getImpostorHitData;
  72508. private _tick;
  72509. /*** Helpers ***/
  72510. private _prepareCylinder;
  72511. private _intersectsWithCylinder;
  72512. }
  72513. /**
  72514. * Options fot the radial explosion event
  72515. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72516. */
  72517. export class PhysicsRadialExplosionEventOptions {
  72518. /**
  72519. * The radius of the sphere for the radial explosion.
  72520. */
  72521. radius: number;
  72522. /**
  72523. * The strenth of the explosion.
  72524. */
  72525. strength: number;
  72526. /**
  72527. * The strenght of the force in correspondence to the distance of the affected object
  72528. */
  72529. falloff: PhysicsRadialImpulseFalloff;
  72530. /**
  72531. * Sphere options for the radial explosion.
  72532. */
  72533. sphere: {
  72534. segments: number;
  72535. diameter: number;
  72536. };
  72537. /**
  72538. * Sphere options for the radial explosion.
  72539. */
  72540. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  72541. }
  72542. /**
  72543. * Options fot the updraft event
  72544. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72545. */
  72546. export class PhysicsUpdraftEventOptions {
  72547. /**
  72548. * The radius of the cylinder for the vortex
  72549. */
  72550. radius: number;
  72551. /**
  72552. * The strenth of the updraft.
  72553. */
  72554. strength: number;
  72555. /**
  72556. * The height of the cylinder for the updraft.
  72557. */
  72558. height: number;
  72559. /**
  72560. * The mode for the the updraft.
  72561. */
  72562. updraftMode: PhysicsUpdraftMode;
  72563. }
  72564. /**
  72565. * Options fot the vortex event
  72566. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72567. */
  72568. export class PhysicsVortexEventOptions {
  72569. /**
  72570. * The radius of the cylinder for the vortex
  72571. */
  72572. radius: number;
  72573. /**
  72574. * The strenth of the vortex.
  72575. */
  72576. strength: number;
  72577. /**
  72578. * The height of the cylinder for the vortex.
  72579. */
  72580. height: number;
  72581. /**
  72582. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  72583. */
  72584. centripetalForceThreshold: number;
  72585. /**
  72586. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  72587. */
  72588. centripetalForceMultiplier: number;
  72589. /**
  72590. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  72591. */
  72592. centrifugalForceMultiplier: number;
  72593. /**
  72594. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  72595. */
  72596. updraftForceMultiplier: number;
  72597. }
  72598. /**
  72599. * The strenght of the force in correspondence to the distance of the affected object
  72600. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72601. */
  72602. export enum PhysicsRadialImpulseFalloff {
  72603. /** Defines that impulse is constant in strength across it's whole radius */
  72604. Constant = 0,
  72605. /** Defines that impulse gets weaker if it's further from the origin */
  72606. Linear = 1
  72607. }
  72608. /**
  72609. * The strength of the force in correspondence to the distance of the affected object
  72610. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72611. */
  72612. export enum PhysicsUpdraftMode {
  72613. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  72614. Center = 0,
  72615. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  72616. Perpendicular = 1
  72617. }
  72618. /**
  72619. * Interface for a physics hit data
  72620. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72621. */
  72622. export interface PhysicsHitData {
  72623. /**
  72624. * The force applied at the contact point
  72625. */
  72626. force: Vector3;
  72627. /**
  72628. * The contact point
  72629. */
  72630. contactPoint: Vector3;
  72631. /**
  72632. * The distance from the origin to the contact point
  72633. */
  72634. distanceFromOrigin: number;
  72635. }
  72636. /**
  72637. * Interface for radial explosion event data
  72638. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72639. */
  72640. export interface PhysicsRadialExplosionEventData {
  72641. /**
  72642. * A sphere used for the radial explosion event
  72643. */
  72644. sphere: Mesh;
  72645. }
  72646. /**
  72647. * Interface for gravitational field event data
  72648. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72649. */
  72650. export interface PhysicsGravitationalFieldEventData {
  72651. /**
  72652. * A sphere mesh used for the gravitational field event
  72653. */
  72654. sphere: Mesh;
  72655. }
  72656. /**
  72657. * Interface for updraft event data
  72658. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72659. */
  72660. export interface PhysicsUpdraftEventData {
  72661. /**
  72662. * A cylinder used for the updraft event
  72663. */
  72664. cylinder: Mesh;
  72665. }
  72666. /**
  72667. * Interface for vortex event data
  72668. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72669. */
  72670. export interface PhysicsVortexEventData {
  72671. /**
  72672. * A cylinder used for the vortex event
  72673. */
  72674. cylinder: Mesh;
  72675. }
  72676. /**
  72677. * Interface for an affected physics impostor
  72678. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72679. */
  72680. export interface PhysicsAffectedImpostorWithData {
  72681. /**
  72682. * The impostor affected by the effect
  72683. */
  72684. impostor: PhysicsImpostor;
  72685. /**
  72686. * The data about the hit/horce from the explosion
  72687. */
  72688. hitData: PhysicsHitData;
  72689. }
  72690. }
  72691. declare module "babylonjs/Physics/Plugins/index" {
  72692. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  72693. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  72694. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  72695. }
  72696. declare module "babylonjs/Physics/index" {
  72697. export * from "babylonjs/Physics/IPhysicsEngine";
  72698. export * from "babylonjs/Physics/physicsEngine";
  72699. export * from "babylonjs/Physics/physicsEngineComponent";
  72700. export * from "babylonjs/Physics/physicsHelper";
  72701. export * from "babylonjs/Physics/physicsImpostor";
  72702. export * from "babylonjs/Physics/physicsJoint";
  72703. export * from "babylonjs/Physics/Plugins/index";
  72704. }
  72705. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  72706. /** @hidden */
  72707. export var blackAndWhitePixelShader: {
  72708. name: string;
  72709. shader: string;
  72710. };
  72711. }
  72712. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  72713. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72714. import { Camera } from "babylonjs/Cameras/camera";
  72715. import { Engine } from "babylonjs/Engines/engine";
  72716. import "babylonjs/Shaders/blackAndWhite.fragment";
  72717. import { Nullable } from "babylonjs/types";
  72718. import { Scene } from "babylonjs/scene";
  72719. /**
  72720. * Post process used to render in black and white
  72721. */
  72722. export class BlackAndWhitePostProcess extends PostProcess {
  72723. /**
  72724. * Linear about to convert he result to black and white (default: 1)
  72725. */
  72726. degree: number;
  72727. /**
  72728. * Gets a string identifying the name of the class
  72729. * @returns "BlackAndWhitePostProcess" string
  72730. */
  72731. getClassName(): string;
  72732. /**
  72733. * Creates a black and white post process
  72734. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  72735. * @param name The name of the effect.
  72736. * @param options The required width/height ratio to downsize to before computing the render pass.
  72737. * @param camera The camera to apply the render pass to.
  72738. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72739. * @param engine The engine which the post process will be applied. (default: current engine)
  72740. * @param reusable If the post process can be reused on the same frame. (default: false)
  72741. */
  72742. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  72743. /** @hidden */
  72744. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlackAndWhitePostProcess>;
  72745. }
  72746. }
  72747. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  72748. import { Nullable } from "babylonjs/types";
  72749. import { Camera } from "babylonjs/Cameras/camera";
  72750. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  72751. import { Engine } from "babylonjs/Engines/engine";
  72752. /**
  72753. * This represents a set of one or more post processes in Babylon.
  72754. * A post process can be used to apply a shader to a texture after it is rendered.
  72755. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  72756. */
  72757. export class PostProcessRenderEffect {
  72758. private _postProcesses;
  72759. private _getPostProcesses;
  72760. private _singleInstance;
  72761. private _cameras;
  72762. private _indicesForCamera;
  72763. /**
  72764. * Name of the effect
  72765. * @hidden
  72766. */
  72767. _name: string;
  72768. /**
  72769. * Instantiates a post process render effect.
  72770. * A post process can be used to apply a shader to a texture after it is rendered.
  72771. * @param engine The engine the effect is tied to
  72772. * @param name The name of the effect
  72773. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  72774. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  72775. */
  72776. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  72777. /**
  72778. * Checks if all the post processes in the effect are supported.
  72779. */
  72780. get isSupported(): boolean;
  72781. /**
  72782. * Updates the current state of the effect
  72783. * @hidden
  72784. */
  72785. _update(): void;
  72786. /**
  72787. * Attaches the effect on cameras
  72788. * @param cameras The camera to attach to.
  72789. * @hidden
  72790. */
  72791. _attachCameras(cameras: Camera): void;
  72792. /**
  72793. * Attaches the effect on cameras
  72794. * @param cameras The camera to attach to.
  72795. * @hidden
  72796. */
  72797. _attachCameras(cameras: Camera[]): void;
  72798. /**
  72799. * Detaches the effect on cameras
  72800. * @param cameras The camera to detatch from.
  72801. * @hidden
  72802. */
  72803. _detachCameras(cameras: Camera): void;
  72804. /**
  72805. * Detatches the effect on cameras
  72806. * @param cameras The camera to detatch from.
  72807. * @hidden
  72808. */
  72809. _detachCameras(cameras: Camera[]): void;
  72810. /**
  72811. * Enables the effect on given cameras
  72812. * @param cameras The camera to enable.
  72813. * @hidden
  72814. */
  72815. _enable(cameras: Camera): void;
  72816. /**
  72817. * Enables the effect on given cameras
  72818. * @param cameras The camera to enable.
  72819. * @hidden
  72820. */
  72821. _enable(cameras: Nullable<Camera[]>): void;
  72822. /**
  72823. * Disables the effect on the given cameras
  72824. * @param cameras The camera to disable.
  72825. * @hidden
  72826. */
  72827. _disable(cameras: Camera): void;
  72828. /**
  72829. * Disables the effect on the given cameras
  72830. * @param cameras The camera to disable.
  72831. * @hidden
  72832. */
  72833. _disable(cameras: Nullable<Camera[]>): void;
  72834. /**
  72835. * Gets a list of the post processes contained in the effect.
  72836. * @param camera The camera to get the post processes on.
  72837. * @returns The list of the post processes in the effect.
  72838. */
  72839. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  72840. }
  72841. }
  72842. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  72843. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  72844. /** @hidden */
  72845. export var extractHighlightsPixelShader: {
  72846. name: string;
  72847. shader: string;
  72848. };
  72849. }
  72850. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  72851. import { Nullable } from "babylonjs/types";
  72852. import { Camera } from "babylonjs/Cameras/camera";
  72853. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72854. import { Engine } from "babylonjs/Engines/engine";
  72855. import "babylonjs/Shaders/extractHighlights.fragment";
  72856. /**
  72857. * 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.
  72858. */
  72859. export class ExtractHighlightsPostProcess extends PostProcess {
  72860. /**
  72861. * The luminance threshold, pixels below this value will be set to black.
  72862. */
  72863. threshold: number;
  72864. /** @hidden */
  72865. _exposure: number;
  72866. /**
  72867. * Post process which has the input texture to be used when performing highlight extraction
  72868. * @hidden
  72869. */
  72870. _inputPostProcess: Nullable<PostProcess>;
  72871. /**
  72872. * Gets a string identifying the name of the class
  72873. * @returns "ExtractHighlightsPostProcess" string
  72874. */
  72875. getClassName(): string;
  72876. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  72877. }
  72878. }
  72879. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  72880. /** @hidden */
  72881. export var bloomMergePixelShader: {
  72882. name: string;
  72883. shader: string;
  72884. };
  72885. }
  72886. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  72887. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72888. import { Nullable } from "babylonjs/types";
  72889. import { Engine } from "babylonjs/Engines/engine";
  72890. import { Camera } from "babylonjs/Cameras/camera";
  72891. import "babylonjs/Shaders/bloomMerge.fragment";
  72892. /**
  72893. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  72894. */
  72895. export class BloomMergePostProcess extends PostProcess {
  72896. /** Weight of the bloom to be added to the original input. */
  72897. weight: number;
  72898. /**
  72899. * Gets a string identifying the name of the class
  72900. * @returns "BloomMergePostProcess" string
  72901. */
  72902. getClassName(): string;
  72903. /**
  72904. * Creates a new instance of @see BloomMergePostProcess
  72905. * @param name The name of the effect.
  72906. * @param originalFromInput Post process which's input will be used for the merge.
  72907. * @param blurred Blurred highlights post process which's output will be used.
  72908. * @param weight Weight of the bloom to be added to the original input.
  72909. * @param options The required width/height ratio to downsize to before computing the render pass.
  72910. * @param camera The camera to apply the render pass to.
  72911. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72912. * @param engine The engine which the post process will be applied. (default: current engine)
  72913. * @param reusable If the post process can be reused on the same frame. (default: false)
  72914. * @param textureType Type of textures used when performing the post process. (default: 0)
  72915. * @param blockCompilation If compilation of the shader should not be done in the constructor. The updateEffect method can be used to compile the shader at a later time. (default: false)
  72916. */
  72917. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  72918. /** Weight of the bloom to be added to the original input. */
  72919. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  72920. }
  72921. }
  72922. declare module "babylonjs/PostProcesses/bloomEffect" {
  72923. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  72924. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  72925. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  72926. import { Camera } from "babylonjs/Cameras/camera";
  72927. import { Scene } from "babylonjs/scene";
  72928. /**
  72929. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  72930. */
  72931. export class BloomEffect extends PostProcessRenderEffect {
  72932. private bloomScale;
  72933. /**
  72934. * @hidden Internal
  72935. */
  72936. _effects: Array<PostProcess>;
  72937. /**
  72938. * @hidden Internal
  72939. */
  72940. _downscale: ExtractHighlightsPostProcess;
  72941. private _blurX;
  72942. private _blurY;
  72943. private _merge;
  72944. /**
  72945. * The luminance threshold to find bright areas of the image to bloom.
  72946. */
  72947. get threshold(): number;
  72948. set threshold(value: number);
  72949. /**
  72950. * The strength of the bloom.
  72951. */
  72952. get weight(): number;
  72953. set weight(value: number);
  72954. /**
  72955. * Specifies the size of the bloom blur kernel, relative to the final output size
  72956. */
  72957. get kernel(): number;
  72958. set kernel(value: number);
  72959. /**
  72960. * Creates a new instance of @see BloomEffect
  72961. * @param scene The scene the effect belongs to.
  72962. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  72963. * @param bloomKernel The size of the kernel to be used when applying the blur.
  72964. * @param bloomWeight The the strength of bloom.
  72965. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  72966. * @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)
  72967. */
  72968. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  72969. /**
  72970. * Disposes each of the internal effects for a given camera.
  72971. * @param camera The camera to dispose the effect on.
  72972. */
  72973. disposeEffects(camera: Camera): void;
  72974. /**
  72975. * @hidden Internal
  72976. */
  72977. _updateEffects(): void;
  72978. /**
  72979. * Internal
  72980. * @returns if all the contained post processes are ready.
  72981. * @hidden
  72982. */
  72983. _isReady(): boolean;
  72984. }
  72985. }
  72986. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  72987. /** @hidden */
  72988. export var chromaticAberrationPixelShader: {
  72989. name: string;
  72990. shader: string;
  72991. };
  72992. }
  72993. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  72994. import { Vector2 } from "babylonjs/Maths/math.vector";
  72995. import { Nullable } from "babylonjs/types";
  72996. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72997. import { Camera } from "babylonjs/Cameras/camera";
  72998. import { Engine } from "babylonjs/Engines/engine";
  72999. import "babylonjs/Shaders/chromaticAberration.fragment";
  73000. import { Scene } from "babylonjs/scene";
  73001. /**
  73002. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  73003. */
  73004. export class ChromaticAberrationPostProcess extends PostProcess {
  73005. /**
  73006. * The amount of seperation of rgb channels (default: 30)
  73007. */
  73008. aberrationAmount: number;
  73009. /**
  73010. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  73011. */
  73012. radialIntensity: number;
  73013. /**
  73014. * 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))
  73015. */
  73016. direction: Vector2;
  73017. /**
  73018. * 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))
  73019. */
  73020. centerPosition: Vector2;
  73021. /** The width of the screen to apply the effect on */
  73022. screenWidth: number;
  73023. /** The height of the screen to apply the effect on */
  73024. screenHeight: number;
  73025. /**
  73026. * Gets a string identifying the name of the class
  73027. * @returns "ChromaticAberrationPostProcess" string
  73028. */
  73029. getClassName(): string;
  73030. /**
  73031. * Creates a new instance ChromaticAberrationPostProcess
  73032. * @param name The name of the effect.
  73033. * @param screenWidth The width of the screen to apply the effect on.
  73034. * @param screenHeight The height of the screen to apply the effect on.
  73035. * @param options The required width/height ratio to downsize to before computing the render pass.
  73036. * @param camera The camera to apply the render pass to.
  73037. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73038. * @param engine The engine which the post process will be applied. (default: current engine)
  73039. * @param reusable If the post process can be reused on the same frame. (default: false)
  73040. * @param textureType Type of textures used when performing the post process. (default: 0)
  73041. * @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)
  73042. */
  73043. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  73044. /** @hidden */
  73045. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ChromaticAberrationPostProcess>;
  73046. }
  73047. }
  73048. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  73049. /** @hidden */
  73050. export var circleOfConfusionPixelShader: {
  73051. name: string;
  73052. shader: string;
  73053. };
  73054. }
  73055. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  73056. import { Nullable } from "babylonjs/types";
  73057. import { Engine } from "babylonjs/Engines/engine";
  73058. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73059. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  73060. import { Camera } from "babylonjs/Cameras/camera";
  73061. import "babylonjs/Shaders/circleOfConfusion.fragment";
  73062. /**
  73063. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  73064. */
  73065. export class CircleOfConfusionPostProcess extends PostProcess {
  73066. /**
  73067. * 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.
  73068. */
  73069. lensSize: number;
  73070. /**
  73071. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  73072. */
  73073. fStop: number;
  73074. /**
  73075. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  73076. */
  73077. focusDistance: number;
  73078. /**
  73079. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  73080. */
  73081. focalLength: number;
  73082. /**
  73083. * Gets a string identifying the name of the class
  73084. * @returns "CircleOfConfusionPostProcess" string
  73085. */
  73086. getClassName(): string;
  73087. private _depthTexture;
  73088. /**
  73089. * Creates a new instance CircleOfConfusionPostProcess
  73090. * @param name The name of the effect.
  73091. * @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.
  73092. * @param options The required width/height ratio to downsize to before computing the render pass.
  73093. * @param camera The camera to apply the render pass to.
  73094. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73095. * @param engine The engine which the post process will be applied. (default: current engine)
  73096. * @param reusable If the post process can be reused on the same frame. (default: false)
  73097. * @param textureType Type of textures used when performing the post process. (default: 0)
  73098. * @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)
  73099. */
  73100. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  73101. /**
  73102. * 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.
  73103. */
  73104. set depthTexture(value: RenderTargetTexture);
  73105. }
  73106. }
  73107. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  73108. /** @hidden */
  73109. export var colorCorrectionPixelShader: {
  73110. name: string;
  73111. shader: string;
  73112. };
  73113. }
  73114. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  73115. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73116. import { Engine } from "babylonjs/Engines/engine";
  73117. import { Camera } from "babylonjs/Cameras/camera";
  73118. import "babylonjs/Shaders/colorCorrection.fragment";
  73119. import { Nullable } from "babylonjs/types";
  73120. import { Scene } from "babylonjs/scene";
  73121. /**
  73122. *
  73123. * This post-process allows the modification of rendered colors by using
  73124. * a 'look-up table' (LUT). This effect is also called Color Grading.
  73125. *
  73126. * The object needs to be provided an url to a texture containing the color
  73127. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  73128. * Use an image editing software to tweak the LUT to match your needs.
  73129. *
  73130. * For an example of a color LUT, see here:
  73131. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  73132. * For explanations on color grading, see here:
  73133. * @see http://udn.epicgames.com/Three/ColorGrading.html
  73134. *
  73135. */
  73136. export class ColorCorrectionPostProcess extends PostProcess {
  73137. private _colorTableTexture;
  73138. /**
  73139. * Gets the color table url used to create the LUT texture
  73140. */
  73141. colorTableUrl: string;
  73142. /**
  73143. * Gets a string identifying the name of the class
  73144. * @returns "ColorCorrectionPostProcess" string
  73145. */
  73146. getClassName(): string;
  73147. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  73148. /** @hidden */
  73149. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ColorCorrectionPostProcess>;
  73150. }
  73151. }
  73152. declare module "babylonjs/Shaders/convolution.fragment" {
  73153. /** @hidden */
  73154. export var convolutionPixelShader: {
  73155. name: string;
  73156. shader: string;
  73157. };
  73158. }
  73159. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  73160. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73161. import { Nullable } from "babylonjs/types";
  73162. import { Camera } from "babylonjs/Cameras/camera";
  73163. import { Engine } from "babylonjs/Engines/engine";
  73164. import "babylonjs/Shaders/convolution.fragment";
  73165. import { Scene } from "babylonjs/scene";
  73166. /**
  73167. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  73168. * input texture to perform effects such as edge detection or sharpening
  73169. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  73170. */
  73171. export class ConvolutionPostProcess extends PostProcess {
  73172. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  73173. kernel: number[];
  73174. /**
  73175. * Gets a string identifying the name of the class
  73176. * @returns "ConvolutionPostProcess" string
  73177. */
  73178. getClassName(): string;
  73179. /**
  73180. * Creates a new instance ConvolutionPostProcess
  73181. * @param name The name of the effect.
  73182. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  73183. * @param options The required width/height ratio to downsize to before computing the render pass.
  73184. * @param camera The camera to apply the render pass to.
  73185. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73186. * @param engine The engine which the post process will be applied. (default: current engine)
  73187. * @param reusable If the post process can be reused on the same frame. (default: false)
  73188. * @param textureType Type of textures used when performing the post process. (default: 0)
  73189. */
  73190. constructor(name: string, kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  73191. /** @hidden */
  73192. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ConvolutionPostProcess>;
  73193. /**
  73194. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  73195. */
  73196. static EdgeDetect0Kernel: number[];
  73197. /**
  73198. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  73199. */
  73200. static EdgeDetect1Kernel: number[];
  73201. /**
  73202. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  73203. */
  73204. static EdgeDetect2Kernel: number[];
  73205. /**
  73206. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  73207. */
  73208. static SharpenKernel: number[];
  73209. /**
  73210. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  73211. */
  73212. static EmbossKernel: number[];
  73213. /**
  73214. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  73215. */
  73216. static GaussianKernel: number[];
  73217. }
  73218. }
  73219. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  73220. import { Nullable } from "babylonjs/types";
  73221. import { Vector2 } from "babylonjs/Maths/math.vector";
  73222. import { Camera } from "babylonjs/Cameras/camera";
  73223. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73224. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  73225. import { Engine } from "babylonjs/Engines/engine";
  73226. import { Scene } from "babylonjs/scene";
  73227. /**
  73228. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  73229. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  73230. * based on samples that have a large difference in distance than the center pixel.
  73231. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  73232. */
  73233. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  73234. /**
  73235. * The direction the blur should be applied
  73236. */
  73237. direction: Vector2;
  73238. /**
  73239. * Gets a string identifying the name of the class
  73240. * @returns "DepthOfFieldBlurPostProcess" string
  73241. */
  73242. getClassName(): string;
  73243. /**
  73244. * Creates a new instance CircleOfConfusionPostProcess
  73245. * @param name The name of the effect.
  73246. * @param scene The scene the effect belongs to.
  73247. * @param direction The direction the blur should be applied.
  73248. * @param kernel The size of the kernel used to blur.
  73249. * @param options The required width/height ratio to downsize to before computing the render pass.
  73250. * @param camera The camera to apply the render pass to.
  73251. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  73252. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  73253. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73254. * @param engine The engine which the post process will be applied. (default: current engine)
  73255. * @param reusable If the post process can be reused on the same frame. (default: false)
  73256. * @param textureType Type of textures used when performing the post process. (default: 0)
  73257. * @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)
  73258. */
  73259. 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);
  73260. }
  73261. }
  73262. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  73263. /** @hidden */
  73264. export var depthOfFieldMergePixelShader: {
  73265. name: string;
  73266. shader: string;
  73267. };
  73268. }
  73269. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  73270. import { Nullable } from "babylonjs/types";
  73271. import { Camera } from "babylonjs/Cameras/camera";
  73272. import { Effect } from "babylonjs/Materials/effect";
  73273. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73274. import { Engine } from "babylonjs/Engines/engine";
  73275. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  73276. /**
  73277. * Options to be set when merging outputs from the default pipeline.
  73278. */
  73279. export class DepthOfFieldMergePostProcessOptions {
  73280. /**
  73281. * The original image to merge on top of
  73282. */
  73283. originalFromInput: PostProcess;
  73284. /**
  73285. * Parameters to perform the merge of the depth of field effect
  73286. */
  73287. depthOfField?: {
  73288. circleOfConfusion: PostProcess;
  73289. blurSteps: Array<PostProcess>;
  73290. };
  73291. /**
  73292. * Parameters to perform the merge of bloom effect
  73293. */
  73294. bloom?: {
  73295. blurred: PostProcess;
  73296. weight: number;
  73297. };
  73298. }
  73299. /**
  73300. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  73301. */
  73302. export class DepthOfFieldMergePostProcess extends PostProcess {
  73303. private blurSteps;
  73304. /**
  73305. * Gets a string identifying the name of the class
  73306. * @returns "DepthOfFieldMergePostProcess" string
  73307. */
  73308. getClassName(): string;
  73309. /**
  73310. * Creates a new instance of DepthOfFieldMergePostProcess
  73311. * @param name The name of the effect.
  73312. * @param originalFromInput Post process which's input will be used for the merge.
  73313. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  73314. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  73315. * @param options The required width/height ratio to downsize to before computing the render pass.
  73316. * @param camera The camera to apply the render pass to.
  73317. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73318. * @param engine The engine which the post process will be applied. (default: current engine)
  73319. * @param reusable If the post process can be reused on the same frame. (default: false)
  73320. * @param textureType Type of textures used when performing the post process. (default: 0)
  73321. * @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)
  73322. */
  73323. 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);
  73324. /**
  73325. * Updates the effect with the current post process compile time values and recompiles the shader.
  73326. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  73327. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  73328. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  73329. * @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
  73330. * @param onCompiled Called when the shader has been compiled.
  73331. * @param onError Called if there is an error when compiling a shader.
  73332. */
  73333. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  73334. }
  73335. }
  73336. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  73337. import { Nullable } from "babylonjs/types";
  73338. import { Camera } from "babylonjs/Cameras/camera";
  73339. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  73340. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  73341. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  73342. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  73343. import { Scene } from "babylonjs/scene";
  73344. /**
  73345. * Specifies the level of max blur that should be applied when using the depth of field effect
  73346. */
  73347. export enum DepthOfFieldEffectBlurLevel {
  73348. /**
  73349. * Subtle blur
  73350. */
  73351. Low = 0,
  73352. /**
  73353. * Medium blur
  73354. */
  73355. Medium = 1,
  73356. /**
  73357. * Large blur
  73358. */
  73359. High = 2
  73360. }
  73361. /**
  73362. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  73363. */
  73364. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  73365. private _circleOfConfusion;
  73366. /**
  73367. * @hidden Internal, blurs from high to low
  73368. */
  73369. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  73370. private _depthOfFieldBlurY;
  73371. private _dofMerge;
  73372. /**
  73373. * @hidden Internal post processes in depth of field effect
  73374. */
  73375. _effects: Array<PostProcess>;
  73376. /**
  73377. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  73378. */
  73379. set focalLength(value: number);
  73380. get focalLength(): number;
  73381. /**
  73382. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  73383. */
  73384. set fStop(value: number);
  73385. get fStop(): number;
  73386. /**
  73387. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  73388. */
  73389. set focusDistance(value: number);
  73390. get focusDistance(): number;
  73391. /**
  73392. * 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.
  73393. */
  73394. set lensSize(value: number);
  73395. get lensSize(): number;
  73396. /**
  73397. * Creates a new instance DepthOfFieldEffect
  73398. * @param scene The scene the effect belongs to.
  73399. * @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.
  73400. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  73401. * @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)
  73402. */
  73403. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  73404. /**
  73405. * Get the current class name of the current effet
  73406. * @returns "DepthOfFieldEffect"
  73407. */
  73408. getClassName(): string;
  73409. /**
  73410. * 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.
  73411. */
  73412. set depthTexture(value: RenderTargetTexture);
  73413. /**
  73414. * Disposes each of the internal effects for a given camera.
  73415. * @param camera The camera to dispose the effect on.
  73416. */
  73417. disposeEffects(camera: Camera): void;
  73418. /**
  73419. * @hidden Internal
  73420. */
  73421. _updateEffects(): void;
  73422. /**
  73423. * Internal
  73424. * @returns if all the contained post processes are ready.
  73425. * @hidden
  73426. */
  73427. _isReady(): boolean;
  73428. }
  73429. }
  73430. declare module "babylonjs/Shaders/displayPass.fragment" {
  73431. /** @hidden */
  73432. export var displayPassPixelShader: {
  73433. name: string;
  73434. shader: string;
  73435. };
  73436. }
  73437. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  73438. import { Nullable } from "babylonjs/types";
  73439. import { Camera } from "babylonjs/Cameras/camera";
  73440. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73441. import { Engine } from "babylonjs/Engines/engine";
  73442. import "babylonjs/Shaders/displayPass.fragment";
  73443. import { Scene } from "babylonjs/scene";
  73444. /**
  73445. * DisplayPassPostProcess which produces an output the same as it's input
  73446. */
  73447. export class DisplayPassPostProcess extends PostProcess {
  73448. /**
  73449. * Gets a string identifying the name of the class
  73450. * @returns "DisplayPassPostProcess" string
  73451. */
  73452. getClassName(): string;
  73453. /**
  73454. * Creates the DisplayPassPostProcess
  73455. * @param name The name of the effect.
  73456. * @param options The required width/height ratio to downsize to before computing the render pass.
  73457. * @param camera The camera to apply the render pass to.
  73458. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73459. * @param engine The engine which the post process will be applied. (default: current engine)
  73460. * @param reusable If the post process can be reused on the same frame. (default: false)
  73461. */
  73462. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  73463. /** @hidden */
  73464. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<DisplayPassPostProcess>;
  73465. }
  73466. }
  73467. declare module "babylonjs/Shaders/filter.fragment" {
  73468. /** @hidden */
  73469. export var filterPixelShader: {
  73470. name: string;
  73471. shader: string;
  73472. };
  73473. }
  73474. declare module "babylonjs/PostProcesses/filterPostProcess" {
  73475. import { Nullable } from "babylonjs/types";
  73476. import { Matrix } from "babylonjs/Maths/math.vector";
  73477. import { Camera } from "babylonjs/Cameras/camera";
  73478. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73479. import { Engine } from "babylonjs/Engines/engine";
  73480. import "babylonjs/Shaders/filter.fragment";
  73481. import { Scene } from "babylonjs/scene";
  73482. /**
  73483. * Applies a kernel filter to the image
  73484. */
  73485. export class FilterPostProcess extends PostProcess {
  73486. /** The matrix to be applied to the image */
  73487. kernelMatrix: Matrix;
  73488. /**
  73489. * Gets a string identifying the name of the class
  73490. * @returns "FilterPostProcess" string
  73491. */
  73492. getClassName(): string;
  73493. /**
  73494. *
  73495. * @param name The name of the effect.
  73496. * @param kernelMatrix The matrix to be applied to the image
  73497. * @param options The required width/height ratio to downsize to before computing the render pass.
  73498. * @param camera The camera to apply the render pass to.
  73499. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73500. * @param engine The engine which the post process will be applied. (default: current engine)
  73501. * @param reusable If the post process can be reused on the same frame. (default: false)
  73502. */
  73503. constructor(name: string, kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  73504. /** @hidden */
  73505. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<FilterPostProcess>;
  73506. }
  73507. }
  73508. declare module "babylonjs/Shaders/fxaa.fragment" {
  73509. /** @hidden */
  73510. export var fxaaPixelShader: {
  73511. name: string;
  73512. shader: string;
  73513. };
  73514. }
  73515. declare module "babylonjs/Shaders/fxaa.vertex" {
  73516. /** @hidden */
  73517. export var fxaaVertexShader: {
  73518. name: string;
  73519. shader: string;
  73520. };
  73521. }
  73522. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  73523. import { Nullable } from "babylonjs/types";
  73524. import { Camera } from "babylonjs/Cameras/camera";
  73525. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73526. import { Engine } from "babylonjs/Engines/engine";
  73527. import "babylonjs/Shaders/fxaa.fragment";
  73528. import "babylonjs/Shaders/fxaa.vertex";
  73529. import { Scene } from "babylonjs/scene";
  73530. /**
  73531. * Fxaa post process
  73532. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  73533. */
  73534. export class FxaaPostProcess extends PostProcess {
  73535. /**
  73536. * Gets a string identifying the name of the class
  73537. * @returns "FxaaPostProcess" string
  73538. */
  73539. getClassName(): string;
  73540. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  73541. private _getDefines;
  73542. /** @hidden */
  73543. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): FxaaPostProcess;
  73544. }
  73545. }
  73546. declare module "babylonjs/Shaders/grain.fragment" {
  73547. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  73548. /** @hidden */
  73549. export var grainPixelShader: {
  73550. name: string;
  73551. shader: string;
  73552. };
  73553. }
  73554. declare module "babylonjs/PostProcesses/grainPostProcess" {
  73555. import { Nullable } from "babylonjs/types";
  73556. import { Camera } from "babylonjs/Cameras/camera";
  73557. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73558. import { Engine } from "babylonjs/Engines/engine";
  73559. import "babylonjs/Shaders/grain.fragment";
  73560. import { Scene } from "babylonjs/scene";
  73561. /**
  73562. * The GrainPostProcess adds noise to the image at mid luminance levels
  73563. */
  73564. export class GrainPostProcess extends PostProcess {
  73565. /**
  73566. * The intensity of the grain added (default: 30)
  73567. */
  73568. intensity: number;
  73569. /**
  73570. * If the grain should be randomized on every frame
  73571. */
  73572. animated: boolean;
  73573. /**
  73574. * Gets a string identifying the name of the class
  73575. * @returns "GrainPostProcess" string
  73576. */
  73577. getClassName(): string;
  73578. /**
  73579. * Creates a new instance of @see GrainPostProcess
  73580. * @param name The name of the effect.
  73581. * @param options The required width/height ratio to downsize to before computing the render pass.
  73582. * @param camera The camera to apply the render pass to.
  73583. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73584. * @param engine The engine which the post process will be applied. (default: current engine)
  73585. * @param reusable If the post process can be reused on the same frame. (default: false)
  73586. * @param textureType Type of textures used when performing the post process. (default: 0)
  73587. * @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)
  73588. */
  73589. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  73590. /** @hidden */
  73591. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): GrainPostProcess;
  73592. }
  73593. }
  73594. declare module "babylonjs/Shaders/highlights.fragment" {
  73595. /** @hidden */
  73596. export var highlightsPixelShader: {
  73597. name: string;
  73598. shader: string;
  73599. };
  73600. }
  73601. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  73602. import { Nullable } from "babylonjs/types";
  73603. import { Camera } from "babylonjs/Cameras/camera";
  73604. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73605. import { Engine } from "babylonjs/Engines/engine";
  73606. import "babylonjs/Shaders/highlights.fragment";
  73607. /**
  73608. * Extracts highlights from the image
  73609. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  73610. */
  73611. export class HighlightsPostProcess extends PostProcess {
  73612. /**
  73613. * Gets a string identifying the name of the class
  73614. * @returns "HighlightsPostProcess" string
  73615. */
  73616. getClassName(): string;
  73617. /**
  73618. * Extracts highlights from the image
  73619. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  73620. * @param name The name of the effect.
  73621. * @param options The required width/height ratio to downsize to before computing the render pass.
  73622. * @param camera The camera to apply the render pass to.
  73623. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73624. * @param engine The engine which the post process will be applied. (default: current engine)
  73625. * @param reusable If the post process can be reused on the same frame. (default: false)
  73626. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  73627. */
  73628. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  73629. }
  73630. }
  73631. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  73632. /** @hidden */
  73633. export var mrtFragmentDeclaration: {
  73634. name: string;
  73635. shader: string;
  73636. };
  73637. }
  73638. declare module "babylonjs/Shaders/geometry.fragment" {
  73639. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  73640. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  73641. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  73642. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  73643. /** @hidden */
  73644. export var geometryPixelShader: {
  73645. name: string;
  73646. shader: string;
  73647. };
  73648. }
  73649. declare module "babylonjs/Shaders/geometry.vertex" {
  73650. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  73651. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  73652. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  73653. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  73654. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  73655. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  73656. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  73657. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  73658. /** @hidden */
  73659. export var geometryVertexShader: {
  73660. name: string;
  73661. shader: string;
  73662. };
  73663. }
  73664. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  73665. import { Matrix } from "babylonjs/Maths/math.vector";
  73666. import { SubMesh } from "babylonjs/Meshes/subMesh";
  73667. import { Mesh } from "babylonjs/Meshes/mesh";
  73668. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  73669. import { Effect } from "babylonjs/Materials/effect";
  73670. import { Scene } from "babylonjs/scene";
  73671. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  73672. import "babylonjs/Shaders/geometry.fragment";
  73673. import "babylonjs/Shaders/geometry.vertex";
  73674. /** @hidden */
  73675. interface ISavedTransformationMatrix {
  73676. world: Matrix;
  73677. viewProjection: Matrix;
  73678. }
  73679. /**
  73680. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  73681. */
  73682. export class GeometryBufferRenderer {
  73683. /**
  73684. * Constant used to retrieve the position texture index in the G-Buffer textures array
  73685. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  73686. */
  73687. static readonly POSITION_TEXTURE_TYPE: number;
  73688. /**
  73689. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  73690. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  73691. */
  73692. static readonly VELOCITY_TEXTURE_TYPE: number;
  73693. /**
  73694. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  73695. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  73696. */
  73697. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  73698. /**
  73699. * Dictionary used to store the previous transformation matrices of each rendered mesh
  73700. * in order to compute objects velocities when enableVelocity is set to "true"
  73701. * @hidden
  73702. */
  73703. _previousTransformationMatrices: {
  73704. [index: number]: ISavedTransformationMatrix;
  73705. };
  73706. /**
  73707. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  73708. * in order to compute objects velocities when enableVelocity is set to "true"
  73709. * @hidden
  73710. */
  73711. _previousBonesTransformationMatrices: {
  73712. [index: number]: Float32Array;
  73713. };
  73714. /**
  73715. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  73716. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  73717. */
  73718. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  73719. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  73720. renderTransparentMeshes: boolean;
  73721. private _scene;
  73722. private _resizeObserver;
  73723. private _multiRenderTarget;
  73724. private _ratio;
  73725. private _enablePosition;
  73726. private _enableVelocity;
  73727. private _enableReflectivity;
  73728. private _positionIndex;
  73729. private _velocityIndex;
  73730. private _reflectivityIndex;
  73731. protected _effect: Effect;
  73732. protected _cachedDefines: string;
  73733. /**
  73734. * Set the render list (meshes to be rendered) used in the G buffer.
  73735. */
  73736. set renderList(meshes: Mesh[]);
  73737. /**
  73738. * Gets wether or not G buffer are supported by the running hardware.
  73739. * This requires draw buffer supports
  73740. */
  73741. get isSupported(): boolean;
  73742. /**
  73743. * Returns the index of the given texture type in the G-Buffer textures array
  73744. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  73745. * @returns the index of the given texture type in the G-Buffer textures array
  73746. */
  73747. getTextureIndex(textureType: number): number;
  73748. /**
  73749. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  73750. */
  73751. get enablePosition(): boolean;
  73752. /**
  73753. * Sets whether or not objects positions are enabled for the G buffer.
  73754. */
  73755. set enablePosition(enable: boolean);
  73756. /**
  73757. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  73758. */
  73759. get enableVelocity(): boolean;
  73760. /**
  73761. * Sets wether or not objects velocities are enabled for the G buffer.
  73762. */
  73763. set enableVelocity(enable: boolean);
  73764. /**
  73765. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  73766. */
  73767. get enableReflectivity(): boolean;
  73768. /**
  73769. * Sets wether or not objects roughness are enabled for the G buffer.
  73770. */
  73771. set enableReflectivity(enable: boolean);
  73772. /**
  73773. * Gets the scene associated with the buffer.
  73774. */
  73775. get scene(): Scene;
  73776. /**
  73777. * Gets the ratio used by the buffer during its creation.
  73778. * How big is the buffer related to the main canvas.
  73779. */
  73780. get ratio(): number;
  73781. /** @hidden */
  73782. static _SceneComponentInitialization: (scene: Scene) => void;
  73783. /**
  73784. * Creates a new G Buffer for the scene
  73785. * @param scene The scene the buffer belongs to
  73786. * @param ratio How big is the buffer related to the main canvas.
  73787. */
  73788. constructor(scene: Scene, ratio?: number);
  73789. /**
  73790. * Checks wether everything is ready to render a submesh to the G buffer.
  73791. * @param subMesh the submesh to check readiness for
  73792. * @param useInstances is the mesh drawn using instance or not
  73793. * @returns true if ready otherwise false
  73794. */
  73795. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  73796. /**
  73797. * Gets the current underlying G Buffer.
  73798. * @returns the buffer
  73799. */
  73800. getGBuffer(): MultiRenderTarget;
  73801. /**
  73802. * Gets the number of samples used to render the buffer (anti aliasing).
  73803. */
  73804. get samples(): number;
  73805. /**
  73806. * Sets the number of samples used to render the buffer (anti aliasing).
  73807. */
  73808. set samples(value: number);
  73809. /**
  73810. * Disposes the renderer and frees up associated resources.
  73811. */
  73812. dispose(): void;
  73813. protected _createRenderTargets(): void;
  73814. private _copyBonesTransformationMatrices;
  73815. }
  73816. }
  73817. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  73818. import { Nullable } from "babylonjs/types";
  73819. import { Scene } from "babylonjs/scene";
  73820. import { ISceneComponent } from "babylonjs/sceneComponent";
  73821. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  73822. module "babylonjs/scene" {
  73823. interface Scene {
  73824. /** @hidden (Backing field) */
  73825. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  73826. /**
  73827. * Gets or Sets the current geometry buffer associated to the scene.
  73828. */
  73829. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  73830. /**
  73831. * Enables a GeometryBufferRender and associates it with the scene
  73832. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  73833. * @returns the GeometryBufferRenderer
  73834. */
  73835. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  73836. /**
  73837. * Disables the GeometryBufferRender associated with the scene
  73838. */
  73839. disableGeometryBufferRenderer(): void;
  73840. }
  73841. }
  73842. /**
  73843. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  73844. * in several rendering techniques.
  73845. */
  73846. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  73847. /**
  73848. * The component name helpful to identify the component in the list of scene components.
  73849. */
  73850. readonly name: string;
  73851. /**
  73852. * The scene the component belongs to.
  73853. */
  73854. scene: Scene;
  73855. /**
  73856. * Creates a new instance of the component for the given scene
  73857. * @param scene Defines the scene to register the component in
  73858. */
  73859. constructor(scene: Scene);
  73860. /**
  73861. * Registers the component in a given scene
  73862. */
  73863. register(): void;
  73864. /**
  73865. * Rebuilds the elements related to this component in case of
  73866. * context lost for instance.
  73867. */
  73868. rebuild(): void;
  73869. /**
  73870. * Disposes the component and the associated ressources
  73871. */
  73872. dispose(): void;
  73873. private _gatherRenderTargets;
  73874. }
  73875. }
  73876. declare module "babylonjs/Shaders/motionBlur.fragment" {
  73877. /** @hidden */
  73878. export var motionBlurPixelShader: {
  73879. name: string;
  73880. shader: string;
  73881. };
  73882. }
  73883. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  73884. import { Nullable } from "babylonjs/types";
  73885. import { Camera } from "babylonjs/Cameras/camera";
  73886. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73887. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  73888. import "babylonjs/Animations/animatable";
  73889. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  73890. import "babylonjs/Shaders/motionBlur.fragment";
  73891. import { Engine } from "babylonjs/Engines/engine";
  73892. import { Scene } from "babylonjs/scene";
  73893. /**
  73894. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  73895. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  73896. * As an example, all you have to do is to create the post-process:
  73897. * var mb = new BABYLON.MotionBlurPostProcess(
  73898. * 'mb', // The name of the effect.
  73899. * scene, // The scene containing the objects to blur according to their velocity.
  73900. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  73901. * camera // The camera to apply the render pass to.
  73902. * );
  73903. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  73904. */
  73905. export class MotionBlurPostProcess extends PostProcess {
  73906. /**
  73907. * Defines how much the image is blurred by the movement. Default value is equal to 1
  73908. */
  73909. motionStrength: number;
  73910. /**
  73911. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  73912. */
  73913. get motionBlurSamples(): number;
  73914. /**
  73915. * Sets the number of iterations to be used for motion blur quality
  73916. */
  73917. set motionBlurSamples(samples: number);
  73918. private _motionBlurSamples;
  73919. private _geometryBufferRenderer;
  73920. /**
  73921. * Gets a string identifying the name of the class
  73922. * @returns "MotionBlurPostProcess" string
  73923. */
  73924. getClassName(): string;
  73925. /**
  73926. * Creates a new instance MotionBlurPostProcess
  73927. * @param name The name of the effect.
  73928. * @param scene The scene containing the objects to blur according to their velocity.
  73929. * @param options The required width/height ratio to downsize to before computing the render pass.
  73930. * @param camera The camera to apply the render pass to.
  73931. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73932. * @param engine The engine which the post process will be applied. (default: current engine)
  73933. * @param reusable If the post process can be reused on the same frame. (default: false)
  73934. * @param textureType Type of textures used when performing the post process. (default: 0)
  73935. * @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)
  73936. */
  73937. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  73938. /**
  73939. * Excludes the given skinned mesh from computing bones velocities.
  73940. * 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.
  73941. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  73942. */
  73943. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  73944. /**
  73945. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  73946. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  73947. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  73948. */
  73949. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  73950. /**
  73951. * Disposes the post process.
  73952. * @param camera The camera to dispose the post process on.
  73953. */
  73954. dispose(camera?: Camera): void;
  73955. /** @hidden */
  73956. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<MotionBlurPostProcess>;
  73957. }
  73958. }
  73959. declare module "babylonjs/Shaders/refraction.fragment" {
  73960. /** @hidden */
  73961. export var refractionPixelShader: {
  73962. name: string;
  73963. shader: string;
  73964. };
  73965. }
  73966. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  73967. import { Color3 } from "babylonjs/Maths/math.color";
  73968. import { Camera } from "babylonjs/Cameras/camera";
  73969. import { Texture } from "babylonjs/Materials/Textures/texture";
  73970. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73971. import { Engine } from "babylonjs/Engines/engine";
  73972. import "babylonjs/Shaders/refraction.fragment";
  73973. import { Scene } from "babylonjs/scene";
  73974. /**
  73975. * Post process which applies a refractin texture
  73976. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  73977. */
  73978. export class RefractionPostProcess extends PostProcess {
  73979. private _refTexture;
  73980. private _ownRefractionTexture;
  73981. /** the base color of the refraction (used to taint the rendering) */
  73982. color: Color3;
  73983. /** simulated refraction depth */
  73984. depth: number;
  73985. /** the coefficient of the base color (0 to remove base color tainting) */
  73986. colorLevel: number;
  73987. /** Gets the url used to load the refraction texture */
  73988. refractionTextureUrl: string;
  73989. /**
  73990. * Gets or sets the refraction texture
  73991. * Please note that you are responsible for disposing the texture if you set it manually
  73992. */
  73993. get refractionTexture(): Texture;
  73994. set refractionTexture(value: Texture);
  73995. /**
  73996. * Gets a string identifying the name of the class
  73997. * @returns "RefractionPostProcess" string
  73998. */
  73999. getClassName(): string;
  74000. /**
  74001. * Initializes the RefractionPostProcess
  74002. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  74003. * @param name The name of the effect.
  74004. * @param refractionTextureUrl Url of the refraction texture to use
  74005. * @param color the base color of the refraction (used to taint the rendering)
  74006. * @param depth simulated refraction depth
  74007. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  74008. * @param camera The camera to apply the render pass to.
  74009. * @param options The required width/height ratio to downsize to before computing the render pass.
  74010. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74011. * @param engine The engine which the post process will be applied. (default: current engine)
  74012. * @param reusable If the post process can be reused on the same frame. (default: false)
  74013. */
  74014. constructor(name: string, refractionTextureUrl: string, color: Color3, depth: number, colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  74015. /**
  74016. * Disposes of the post process
  74017. * @param camera Camera to dispose post process on
  74018. */
  74019. dispose(camera: Camera): void;
  74020. /** @hidden */
  74021. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): RefractionPostProcess;
  74022. }
  74023. }
  74024. declare module "babylonjs/Shaders/sharpen.fragment" {
  74025. /** @hidden */
  74026. export var sharpenPixelShader: {
  74027. name: string;
  74028. shader: string;
  74029. };
  74030. }
  74031. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  74032. import { Nullable } from "babylonjs/types";
  74033. import { Camera } from "babylonjs/Cameras/camera";
  74034. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  74035. import "babylonjs/Shaders/sharpen.fragment";
  74036. import { Engine } from "babylonjs/Engines/engine";
  74037. import { Scene } from "babylonjs/scene";
  74038. /**
  74039. * The SharpenPostProcess applies a sharpen kernel to every pixel
  74040. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  74041. */
  74042. export class SharpenPostProcess extends PostProcess {
  74043. /**
  74044. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  74045. */
  74046. colorAmount: number;
  74047. /**
  74048. * How much sharpness should be applied (default: 0.3)
  74049. */
  74050. edgeAmount: number;
  74051. /**
  74052. * Gets a string identifying the name of the class
  74053. * @returns "SharpenPostProcess" string
  74054. */
  74055. getClassName(): string;
  74056. /**
  74057. * Creates a new instance ConvolutionPostProcess
  74058. * @param name The name of the effect.
  74059. * @param options The required width/height ratio to downsize to before computing the render pass.
  74060. * @param camera The camera to apply the render pass to.
  74061. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74062. * @param engine The engine which the post process will be applied. (default: current engine)
  74063. * @param reusable If the post process can be reused on the same frame. (default: false)
  74064. * @param textureType Type of textures used when performing the post process. (default: 0)
  74065. * @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)
  74066. */
  74067. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  74068. /** @hidden */
  74069. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): SharpenPostProcess;
  74070. }
  74071. }
  74072. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  74073. import { Nullable } from "babylonjs/types";
  74074. import { Camera } from "babylonjs/Cameras/camera";
  74075. import { Engine } from "babylonjs/Engines/engine";
  74076. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  74077. import { IInspectable } from "babylonjs/Misc/iInspectable";
  74078. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  74079. /**
  74080. * PostProcessRenderPipeline
  74081. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  74082. */
  74083. export class PostProcessRenderPipeline {
  74084. private engine;
  74085. private _renderEffects;
  74086. private _renderEffectsForIsolatedPass;
  74087. /**
  74088. * List of inspectable custom properties (used by the Inspector)
  74089. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  74090. */
  74091. inspectableCustomProperties: IInspectable[];
  74092. /**
  74093. * @hidden
  74094. */
  74095. protected _cameras: Camera[];
  74096. /** @hidden */
  74097. _name: string;
  74098. /**
  74099. * Gets pipeline name
  74100. */
  74101. get name(): string;
  74102. /** Gets the list of attached cameras */
  74103. get cameras(): Camera[];
  74104. /**
  74105. * Initializes a PostProcessRenderPipeline
  74106. * @param engine engine to add the pipeline to
  74107. * @param name name of the pipeline
  74108. */
  74109. constructor(engine: Engine, name: string);
  74110. /**
  74111. * Gets the class name
  74112. * @returns "PostProcessRenderPipeline"
  74113. */
  74114. getClassName(): string;
  74115. /**
  74116. * If all the render effects in the pipeline are supported
  74117. */
  74118. get isSupported(): boolean;
  74119. /**
  74120. * Adds an effect to the pipeline
  74121. * @param renderEffect the effect to add
  74122. */
  74123. addEffect(renderEffect: PostProcessRenderEffect): void;
  74124. /** @hidden */
  74125. _rebuild(): void;
  74126. /** @hidden */
  74127. _enableEffect(renderEffectName: string, cameras: Camera): void;
  74128. /** @hidden */
  74129. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  74130. /** @hidden */
  74131. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  74132. /** @hidden */
  74133. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  74134. /** @hidden */
  74135. _attachCameras(cameras: Camera, unique: boolean): void;
  74136. /** @hidden */
  74137. _attachCameras(cameras: Camera[], unique: boolean): void;
  74138. /** @hidden */
  74139. _detachCameras(cameras: Camera): void;
  74140. /** @hidden */
  74141. _detachCameras(cameras: Nullable<Camera[]>): void;
  74142. /** @hidden */
  74143. _update(): void;
  74144. /** @hidden */
  74145. _reset(): void;
  74146. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  74147. /**
  74148. * Sets the required values to the prepass renderer.
  74149. * @param prePassRenderer defines the prepass renderer to setup.
  74150. * @returns true if the pre pass is needed.
  74151. */
  74152. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  74153. /**
  74154. * Disposes of the pipeline
  74155. */
  74156. dispose(): void;
  74157. }
  74158. }
  74159. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  74160. import { Camera } from "babylonjs/Cameras/camera";
  74161. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  74162. /**
  74163. * PostProcessRenderPipelineManager class
  74164. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  74165. */
  74166. export class PostProcessRenderPipelineManager {
  74167. private _renderPipelines;
  74168. /**
  74169. * Initializes a PostProcessRenderPipelineManager
  74170. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  74171. */
  74172. constructor();
  74173. /**
  74174. * Gets the list of supported render pipelines
  74175. */
  74176. get supportedPipelines(): PostProcessRenderPipeline[];
  74177. /**
  74178. * Adds a pipeline to the manager
  74179. * @param renderPipeline The pipeline to add
  74180. */
  74181. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  74182. /**
  74183. * Attaches a camera to the pipeline
  74184. * @param renderPipelineName The name of the pipeline to attach to
  74185. * @param cameras the camera to attach
  74186. * @param unique if the camera can be attached multiple times to the pipeline
  74187. */
  74188. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  74189. /**
  74190. * Detaches a camera from the pipeline
  74191. * @param renderPipelineName The name of the pipeline to detach from
  74192. * @param cameras the camera to detach
  74193. */
  74194. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  74195. /**
  74196. * Enables an effect by name on a pipeline
  74197. * @param renderPipelineName the name of the pipeline to enable the effect in
  74198. * @param renderEffectName the name of the effect to enable
  74199. * @param cameras the cameras that the effect should be enabled on
  74200. */
  74201. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  74202. /**
  74203. * Disables an effect by name on a pipeline
  74204. * @param renderPipelineName the name of the pipeline to disable the effect in
  74205. * @param renderEffectName the name of the effect to disable
  74206. * @param cameras the cameras that the effect should be disabled on
  74207. */
  74208. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  74209. /**
  74210. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  74211. */
  74212. update(): void;
  74213. /** @hidden */
  74214. _rebuild(): void;
  74215. /**
  74216. * Disposes of the manager and pipelines
  74217. */
  74218. dispose(): void;
  74219. }
  74220. }
  74221. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  74222. import { ISceneComponent } from "babylonjs/sceneComponent";
  74223. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  74224. import { Scene } from "babylonjs/scene";
  74225. module "babylonjs/scene" {
  74226. interface Scene {
  74227. /** @hidden (Backing field) */
  74228. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  74229. /**
  74230. * Gets the postprocess render pipeline manager
  74231. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  74232. * @see https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  74233. */
  74234. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  74235. }
  74236. }
  74237. /**
  74238. * Defines the Render Pipeline scene component responsible to rendering pipelines
  74239. */
  74240. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  74241. /**
  74242. * The component name helpfull to identify the component in the list of scene components.
  74243. */
  74244. readonly name: string;
  74245. /**
  74246. * The scene the component belongs to.
  74247. */
  74248. scene: Scene;
  74249. /**
  74250. * Creates a new instance of the component for the given scene
  74251. * @param scene Defines the scene to register the component in
  74252. */
  74253. constructor(scene: Scene);
  74254. /**
  74255. * Registers the component in a given scene
  74256. */
  74257. register(): void;
  74258. /**
  74259. * Rebuilds the elements related to this component in case of
  74260. * context lost for instance.
  74261. */
  74262. rebuild(): void;
  74263. /**
  74264. * Disposes the component and the associated ressources
  74265. */
  74266. dispose(): void;
  74267. private _gatherRenderTargets;
  74268. }
  74269. }
  74270. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  74271. import { Nullable } from "babylonjs/types";
  74272. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  74273. import { Camera } from "babylonjs/Cameras/camera";
  74274. import { IDisposable } from "babylonjs/scene";
  74275. import { GlowLayer } from "babylonjs/Layers/glowLayer";
  74276. import { Scene } from "babylonjs/scene";
  74277. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  74278. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  74279. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  74280. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  74281. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  74282. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  74283. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  74284. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  74285. import { Animation } from "babylonjs/Animations/animation";
  74286. /**
  74287. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  74288. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  74289. */
  74290. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  74291. private _scene;
  74292. private _camerasToBeAttached;
  74293. /**
  74294. * ID of the sharpen post process,
  74295. */
  74296. private readonly SharpenPostProcessId;
  74297. /**
  74298. * @ignore
  74299. * ID of the image processing post process;
  74300. */
  74301. readonly ImageProcessingPostProcessId: string;
  74302. /**
  74303. * @ignore
  74304. * ID of the Fast Approximate Anti-Aliasing post process;
  74305. */
  74306. readonly FxaaPostProcessId: string;
  74307. /**
  74308. * ID of the chromatic aberration post process,
  74309. */
  74310. private readonly ChromaticAberrationPostProcessId;
  74311. /**
  74312. * ID of the grain post process
  74313. */
  74314. private readonly GrainPostProcessId;
  74315. /**
  74316. * Sharpen post process which will apply a sharpen convolution to enhance edges
  74317. */
  74318. sharpen: SharpenPostProcess;
  74319. private _sharpenEffect;
  74320. private bloom;
  74321. /**
  74322. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  74323. */
  74324. depthOfField: DepthOfFieldEffect;
  74325. /**
  74326. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  74327. */
  74328. fxaa: FxaaPostProcess;
  74329. /**
  74330. * Image post processing pass used to perform operations such as tone mapping or color grading.
  74331. */
  74332. imageProcessing: ImageProcessingPostProcess;
  74333. /**
  74334. * Chromatic aberration post process which will shift rgb colors in the image
  74335. */
  74336. chromaticAberration: ChromaticAberrationPostProcess;
  74337. private _chromaticAberrationEffect;
  74338. /**
  74339. * Grain post process which add noise to the image
  74340. */
  74341. grain: GrainPostProcess;
  74342. private _grainEffect;
  74343. /**
  74344. * Glow post process which adds a glow to emissive areas of the image
  74345. */
  74346. private _glowLayer;
  74347. /**
  74348. * Animations which can be used to tweak settings over a period of time
  74349. */
  74350. animations: Animation[];
  74351. private _imageProcessingConfigurationObserver;
  74352. private _sharpenEnabled;
  74353. private _bloomEnabled;
  74354. private _depthOfFieldEnabled;
  74355. private _depthOfFieldBlurLevel;
  74356. private _fxaaEnabled;
  74357. private _imageProcessingEnabled;
  74358. private _defaultPipelineTextureType;
  74359. private _bloomScale;
  74360. private _chromaticAberrationEnabled;
  74361. private _grainEnabled;
  74362. private _buildAllowed;
  74363. /**
  74364. * Gets active scene
  74365. */
  74366. get scene(): Scene;
  74367. /**
  74368. * Enable or disable the sharpen process from the pipeline
  74369. */
  74370. set sharpenEnabled(enabled: boolean);
  74371. get sharpenEnabled(): boolean;
  74372. private _resizeObserver;
  74373. private _hardwareScaleLevel;
  74374. private _bloomKernel;
  74375. /**
  74376. * Specifies the size of the bloom blur kernel, relative to the final output size
  74377. */
  74378. get bloomKernel(): number;
  74379. set bloomKernel(value: number);
  74380. /**
  74381. * Specifies the weight of the bloom in the final rendering
  74382. */
  74383. private _bloomWeight;
  74384. /**
  74385. * Specifies the luma threshold for the area that will be blurred by the bloom
  74386. */
  74387. private _bloomThreshold;
  74388. private _hdr;
  74389. /**
  74390. * The strength of the bloom.
  74391. */
  74392. set bloomWeight(value: number);
  74393. get bloomWeight(): number;
  74394. /**
  74395. * The strength of the bloom.
  74396. */
  74397. set bloomThreshold(value: number);
  74398. get bloomThreshold(): number;
  74399. /**
  74400. * The scale of the bloom, lower value will provide better performance.
  74401. */
  74402. set bloomScale(value: number);
  74403. get bloomScale(): number;
  74404. /**
  74405. * Enable or disable the bloom from the pipeline
  74406. */
  74407. set bloomEnabled(enabled: boolean);
  74408. get bloomEnabled(): boolean;
  74409. private _rebuildBloom;
  74410. /**
  74411. * If the depth of field is enabled.
  74412. */
  74413. get depthOfFieldEnabled(): boolean;
  74414. set depthOfFieldEnabled(enabled: boolean);
  74415. /**
  74416. * Blur level of the depth of field effect. (Higher blur will effect performance)
  74417. */
  74418. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  74419. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  74420. /**
  74421. * If the anti aliasing is enabled.
  74422. */
  74423. set fxaaEnabled(enabled: boolean);
  74424. get fxaaEnabled(): boolean;
  74425. private _samples;
  74426. /**
  74427. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  74428. */
  74429. set samples(sampleCount: number);
  74430. get samples(): number;
  74431. /**
  74432. * If image processing is enabled.
  74433. */
  74434. set imageProcessingEnabled(enabled: boolean);
  74435. get imageProcessingEnabled(): boolean;
  74436. /**
  74437. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  74438. */
  74439. set glowLayerEnabled(enabled: boolean);
  74440. get glowLayerEnabled(): boolean;
  74441. /**
  74442. * Gets the glow layer (or null if not defined)
  74443. */
  74444. get glowLayer(): Nullable<GlowLayer>;
  74445. /**
  74446. * Enable or disable the chromaticAberration process from the pipeline
  74447. */
  74448. set chromaticAberrationEnabled(enabled: boolean);
  74449. get chromaticAberrationEnabled(): boolean;
  74450. /**
  74451. * Enable or disable the grain process from the pipeline
  74452. */
  74453. set grainEnabled(enabled: boolean);
  74454. get grainEnabled(): boolean;
  74455. /**
  74456. * @constructor
  74457. * @param name - The rendering pipeline name (default: "")
  74458. * @param hdr - If high dynamic range textures should be used (default: true)
  74459. * @param scene - The scene linked to this pipeline (default: the last created scene)
  74460. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  74461. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  74462. */
  74463. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  74464. /**
  74465. * Get the class name
  74466. * @returns "DefaultRenderingPipeline"
  74467. */
  74468. getClassName(): string;
  74469. /**
  74470. * Force the compilation of the entire pipeline.
  74471. */
  74472. prepare(): void;
  74473. private _hasCleared;
  74474. private _prevPostProcess;
  74475. private _prevPrevPostProcess;
  74476. private _setAutoClearAndTextureSharing;
  74477. private _depthOfFieldSceneObserver;
  74478. private _buildPipeline;
  74479. private _disposePostProcesses;
  74480. /**
  74481. * Adds a camera to the pipeline
  74482. * @param camera the camera to be added
  74483. */
  74484. addCamera(camera: Camera): void;
  74485. /**
  74486. * Removes a camera from the pipeline
  74487. * @param camera the camera to remove
  74488. */
  74489. removeCamera(camera: Camera): void;
  74490. /**
  74491. * Dispose of the pipeline and stop all post processes
  74492. */
  74493. dispose(): void;
  74494. /**
  74495. * Serialize the rendering pipeline (Used when exporting)
  74496. * @returns the serialized object
  74497. */
  74498. serialize(): any;
  74499. /**
  74500. * Parse the serialized pipeline
  74501. * @param source Source pipeline.
  74502. * @param scene The scene to load the pipeline to.
  74503. * @param rootUrl The URL of the serialized pipeline.
  74504. * @returns An instantiated pipeline from the serialized object.
  74505. */
  74506. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  74507. }
  74508. }
  74509. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  74510. /** @hidden */
  74511. export var lensHighlightsPixelShader: {
  74512. name: string;
  74513. shader: string;
  74514. };
  74515. }
  74516. declare module "babylonjs/Shaders/depthOfField.fragment" {
  74517. /** @hidden */
  74518. export var depthOfFieldPixelShader: {
  74519. name: string;
  74520. shader: string;
  74521. };
  74522. }
  74523. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  74524. import { Camera } from "babylonjs/Cameras/camera";
  74525. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  74526. import { Scene } from "babylonjs/scene";
  74527. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  74528. import "babylonjs/Shaders/chromaticAberration.fragment";
  74529. import "babylonjs/Shaders/lensHighlights.fragment";
  74530. import "babylonjs/Shaders/depthOfField.fragment";
  74531. /**
  74532. * BABYLON.JS Chromatic Aberration GLSL Shader
  74533. * Author: Olivier Guyot
  74534. * Separates very slightly R, G and B colors on the edges of the screen
  74535. * Inspired by Francois Tarlier & Martins Upitis
  74536. */
  74537. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  74538. /**
  74539. * @ignore
  74540. * The chromatic aberration PostProcess id in the pipeline
  74541. */
  74542. LensChromaticAberrationEffect: string;
  74543. /**
  74544. * @ignore
  74545. * The highlights enhancing PostProcess id in the pipeline
  74546. */
  74547. HighlightsEnhancingEffect: string;
  74548. /**
  74549. * @ignore
  74550. * The depth-of-field PostProcess id in the pipeline
  74551. */
  74552. LensDepthOfFieldEffect: string;
  74553. private _scene;
  74554. private _depthTexture;
  74555. private _grainTexture;
  74556. private _chromaticAberrationPostProcess;
  74557. private _highlightsPostProcess;
  74558. private _depthOfFieldPostProcess;
  74559. private _edgeBlur;
  74560. private _grainAmount;
  74561. private _chromaticAberration;
  74562. private _distortion;
  74563. private _highlightsGain;
  74564. private _highlightsThreshold;
  74565. private _dofDistance;
  74566. private _dofAperture;
  74567. private _dofDarken;
  74568. private _dofPentagon;
  74569. private _blurNoise;
  74570. /**
  74571. * @constructor
  74572. *
  74573. * Effect parameters are as follow:
  74574. * {
  74575. * chromatic_aberration: number; // from 0 to x (1 for realism)
  74576. * edge_blur: number; // from 0 to x (1 for realism)
  74577. * distortion: number; // from 0 to x (1 for realism)
  74578. * grain_amount: number; // from 0 to 1
  74579. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  74580. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  74581. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  74582. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  74583. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  74584. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  74585. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  74586. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  74587. * }
  74588. * Note: if an effect parameter is unset, effect is disabled
  74589. *
  74590. * @param name The rendering pipeline name
  74591. * @param parameters - An object containing all parameters (see above)
  74592. * @param scene The scene linked to this pipeline
  74593. * @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)
  74594. * @param cameras The array of cameras that the rendering pipeline will be attached to
  74595. */
  74596. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  74597. /**
  74598. * Get the class name
  74599. * @returns "LensRenderingPipeline"
  74600. */
  74601. getClassName(): string;
  74602. /**
  74603. * Gets associated scene
  74604. */
  74605. get scene(): Scene;
  74606. /**
  74607. * Gets or sets the edge blur
  74608. */
  74609. get edgeBlur(): number;
  74610. set edgeBlur(value: number);
  74611. /**
  74612. * Gets or sets the grain amount
  74613. */
  74614. get grainAmount(): number;
  74615. set grainAmount(value: number);
  74616. /**
  74617. * Gets or sets the chromatic aberration amount
  74618. */
  74619. get chromaticAberration(): number;
  74620. set chromaticAberration(value: number);
  74621. /**
  74622. * Gets or sets the depth of field aperture
  74623. */
  74624. get dofAperture(): number;
  74625. set dofAperture(value: number);
  74626. /**
  74627. * Gets or sets the edge distortion
  74628. */
  74629. get edgeDistortion(): number;
  74630. set edgeDistortion(value: number);
  74631. /**
  74632. * Gets or sets the depth of field distortion
  74633. */
  74634. get dofDistortion(): number;
  74635. set dofDistortion(value: number);
  74636. /**
  74637. * Gets or sets the darken out of focus amount
  74638. */
  74639. get darkenOutOfFocus(): number;
  74640. set darkenOutOfFocus(value: number);
  74641. /**
  74642. * Gets or sets a boolean indicating if blur noise is enabled
  74643. */
  74644. get blurNoise(): boolean;
  74645. set blurNoise(value: boolean);
  74646. /**
  74647. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  74648. */
  74649. get pentagonBokeh(): boolean;
  74650. set pentagonBokeh(value: boolean);
  74651. /**
  74652. * Gets or sets the highlight grain amount
  74653. */
  74654. get highlightsGain(): number;
  74655. set highlightsGain(value: number);
  74656. /**
  74657. * Gets or sets the highlight threshold
  74658. */
  74659. get highlightsThreshold(): number;
  74660. set highlightsThreshold(value: number);
  74661. /**
  74662. * Sets the amount of blur at the edges
  74663. * @param amount blur amount
  74664. */
  74665. setEdgeBlur(amount: number): void;
  74666. /**
  74667. * Sets edge blur to 0
  74668. */
  74669. disableEdgeBlur(): void;
  74670. /**
  74671. * Sets the amout of grain
  74672. * @param amount Amount of grain
  74673. */
  74674. setGrainAmount(amount: number): void;
  74675. /**
  74676. * Set grain amount to 0
  74677. */
  74678. disableGrain(): void;
  74679. /**
  74680. * Sets the chromatic aberration amount
  74681. * @param amount amount of chromatic aberration
  74682. */
  74683. setChromaticAberration(amount: number): void;
  74684. /**
  74685. * Sets chromatic aberration amount to 0
  74686. */
  74687. disableChromaticAberration(): void;
  74688. /**
  74689. * Sets the EdgeDistortion amount
  74690. * @param amount amount of EdgeDistortion
  74691. */
  74692. setEdgeDistortion(amount: number): void;
  74693. /**
  74694. * Sets edge distortion to 0
  74695. */
  74696. disableEdgeDistortion(): void;
  74697. /**
  74698. * Sets the FocusDistance amount
  74699. * @param amount amount of FocusDistance
  74700. */
  74701. setFocusDistance(amount: number): void;
  74702. /**
  74703. * Disables depth of field
  74704. */
  74705. disableDepthOfField(): void;
  74706. /**
  74707. * Sets the Aperture amount
  74708. * @param amount amount of Aperture
  74709. */
  74710. setAperture(amount: number): void;
  74711. /**
  74712. * Sets the DarkenOutOfFocus amount
  74713. * @param amount amount of DarkenOutOfFocus
  74714. */
  74715. setDarkenOutOfFocus(amount: number): void;
  74716. private _pentagonBokehIsEnabled;
  74717. /**
  74718. * Creates a pentagon bokeh effect
  74719. */
  74720. enablePentagonBokeh(): void;
  74721. /**
  74722. * Disables the pentagon bokeh effect
  74723. */
  74724. disablePentagonBokeh(): void;
  74725. /**
  74726. * Enables noise blur
  74727. */
  74728. enableNoiseBlur(): void;
  74729. /**
  74730. * Disables noise blur
  74731. */
  74732. disableNoiseBlur(): void;
  74733. /**
  74734. * Sets the HighlightsGain amount
  74735. * @param amount amount of HighlightsGain
  74736. */
  74737. setHighlightsGain(amount: number): void;
  74738. /**
  74739. * Sets the HighlightsThreshold amount
  74740. * @param amount amount of HighlightsThreshold
  74741. */
  74742. setHighlightsThreshold(amount: number): void;
  74743. /**
  74744. * Disables highlights
  74745. */
  74746. disableHighlights(): void;
  74747. /**
  74748. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  74749. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  74750. */
  74751. dispose(disableDepthRender?: boolean): void;
  74752. private _createChromaticAberrationPostProcess;
  74753. private _createHighlightsPostProcess;
  74754. private _createDepthOfFieldPostProcess;
  74755. private _createGrainTexture;
  74756. }
  74757. }
  74758. declare module "babylonjs/Shaders/ssao2.fragment" {
  74759. /** @hidden */
  74760. export var ssao2PixelShader: {
  74761. name: string;
  74762. shader: string;
  74763. };
  74764. }
  74765. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  74766. /** @hidden */
  74767. export var ssaoCombinePixelShader: {
  74768. name: string;
  74769. shader: string;
  74770. };
  74771. }
  74772. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  74773. import { Camera } from "babylonjs/Cameras/camera";
  74774. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  74775. import { Scene } from "babylonjs/scene";
  74776. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  74777. import "babylonjs/Shaders/ssao2.fragment";
  74778. import "babylonjs/Shaders/ssaoCombine.fragment";
  74779. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  74780. /**
  74781. * Render pipeline to produce ssao effect
  74782. */
  74783. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  74784. /**
  74785. * @ignore
  74786. * The PassPostProcess id in the pipeline that contains the original scene color
  74787. */
  74788. SSAOOriginalSceneColorEffect: string;
  74789. /**
  74790. * @ignore
  74791. * The SSAO PostProcess id in the pipeline
  74792. */
  74793. SSAORenderEffect: string;
  74794. /**
  74795. * @ignore
  74796. * The horizontal blur PostProcess id in the pipeline
  74797. */
  74798. SSAOBlurHRenderEffect: string;
  74799. /**
  74800. * @ignore
  74801. * The vertical blur PostProcess id in the pipeline
  74802. */
  74803. SSAOBlurVRenderEffect: string;
  74804. /**
  74805. * @ignore
  74806. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  74807. */
  74808. SSAOCombineRenderEffect: string;
  74809. /**
  74810. * The output strength of the SSAO post-process. Default value is 1.0.
  74811. */
  74812. totalStrength: number;
  74813. /**
  74814. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  74815. */
  74816. maxZ: number;
  74817. /**
  74818. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  74819. */
  74820. minZAspect: number;
  74821. private _samples;
  74822. /**
  74823. * Number of samples used for the SSAO calculations. Default value is 8
  74824. */
  74825. set samples(n: number);
  74826. get samples(): number;
  74827. private _textureSamples;
  74828. /**
  74829. * Number of samples to use for antialiasing
  74830. */
  74831. set textureSamples(n: number);
  74832. get textureSamples(): number;
  74833. /**
  74834. * Force rendering the geometry through geometry buffer
  74835. */
  74836. private _forceGeometryBuffer;
  74837. /**
  74838. * Ratio object used for SSAO ratio and blur ratio
  74839. */
  74840. private _ratio;
  74841. /**
  74842. * Dynamically generated sphere sampler.
  74843. */
  74844. private _sampleSphere;
  74845. /**
  74846. * Blur filter offsets
  74847. */
  74848. private _samplerOffsets;
  74849. private _expensiveBlur;
  74850. /**
  74851. * If bilateral blur should be used
  74852. */
  74853. set expensiveBlur(b: boolean);
  74854. get expensiveBlur(): boolean;
  74855. /**
  74856. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  74857. */
  74858. radius: number;
  74859. /**
  74860. * The base color of the SSAO post-process
  74861. * The final result is "base + ssao" between [0, 1]
  74862. */
  74863. base: number;
  74864. /**
  74865. * Support test.
  74866. */
  74867. static get IsSupported(): boolean;
  74868. private _scene;
  74869. private _randomTexture;
  74870. private _originalColorPostProcess;
  74871. private _ssaoPostProcess;
  74872. private _blurHPostProcess;
  74873. private _blurVPostProcess;
  74874. private _ssaoCombinePostProcess;
  74875. private _prePassRenderer;
  74876. /**
  74877. * Gets active scene
  74878. */
  74879. get scene(): Scene;
  74880. /**
  74881. * @constructor
  74882. * @param name The rendering pipeline name
  74883. * @param scene The scene linked to this pipeline
  74884. * @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 }
  74885. * @param cameras The array of cameras that the rendering pipeline will be attached to
  74886. * @param forceGeometryBuffer Set to true if you want to use the legacy geometry buffer renderer
  74887. */
  74888. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[], forceGeometryBuffer?: boolean);
  74889. /**
  74890. * Get the class name
  74891. * @returns "SSAO2RenderingPipeline"
  74892. */
  74893. getClassName(): string;
  74894. /**
  74895. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  74896. */
  74897. dispose(disableGeometryBufferRenderer?: boolean): void;
  74898. private _createBlurPostProcess;
  74899. /** @hidden */
  74900. _rebuild(): void;
  74901. private _bits;
  74902. private _radicalInverse_VdC;
  74903. private _hammersley;
  74904. private _hemisphereSample_uniform;
  74905. private _generateHemisphere;
  74906. private _getDefinesForSSAO;
  74907. private _createSSAOPostProcess;
  74908. private _createSSAOCombinePostProcess;
  74909. private _createRandomTexture;
  74910. /**
  74911. * Serialize the rendering pipeline (Used when exporting)
  74912. * @returns the serialized object
  74913. */
  74914. serialize(): any;
  74915. /**
  74916. * Parse the serialized pipeline
  74917. * @param source Source pipeline.
  74918. * @param scene The scene to load the pipeline to.
  74919. * @param rootUrl The URL of the serialized pipeline.
  74920. * @returns An instantiated pipeline from the serialized object.
  74921. */
  74922. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  74923. /**
  74924. * Sets the required values to the prepass renderer.
  74925. * @param prePassRenderer defines the prepass renderer to setup
  74926. * @returns true if the pre pass is needed.
  74927. */
  74928. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  74929. }
  74930. }
  74931. declare module "babylonjs/Shaders/ssao.fragment" {
  74932. /** @hidden */
  74933. export var ssaoPixelShader: {
  74934. name: string;
  74935. shader: string;
  74936. };
  74937. }
  74938. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  74939. import { Camera } from "babylonjs/Cameras/camera";
  74940. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  74941. import { Scene } from "babylonjs/scene";
  74942. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  74943. import "babylonjs/Shaders/ssao.fragment";
  74944. import "babylonjs/Shaders/ssaoCombine.fragment";
  74945. /**
  74946. * Render pipeline to produce ssao effect
  74947. */
  74948. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  74949. /**
  74950. * @ignore
  74951. * The PassPostProcess id in the pipeline that contains the original scene color
  74952. */
  74953. SSAOOriginalSceneColorEffect: string;
  74954. /**
  74955. * @ignore
  74956. * The SSAO PostProcess id in the pipeline
  74957. */
  74958. SSAORenderEffect: string;
  74959. /**
  74960. * @ignore
  74961. * The horizontal blur PostProcess id in the pipeline
  74962. */
  74963. SSAOBlurHRenderEffect: string;
  74964. /**
  74965. * @ignore
  74966. * The vertical blur PostProcess id in the pipeline
  74967. */
  74968. SSAOBlurVRenderEffect: string;
  74969. /**
  74970. * @ignore
  74971. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  74972. */
  74973. SSAOCombineRenderEffect: string;
  74974. /**
  74975. * The output strength of the SSAO post-process. Default value is 1.0.
  74976. */
  74977. totalStrength: number;
  74978. /**
  74979. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  74980. */
  74981. radius: number;
  74982. /**
  74983. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  74984. * Must not be equal to fallOff and superior to fallOff.
  74985. * Default value is 0.0075
  74986. */
  74987. area: number;
  74988. /**
  74989. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  74990. * Must not be equal to area and inferior to area.
  74991. * Default value is 0.000001
  74992. */
  74993. fallOff: number;
  74994. /**
  74995. * The base color of the SSAO post-process
  74996. * The final result is "base + ssao" between [0, 1]
  74997. */
  74998. base: number;
  74999. private _scene;
  75000. private _depthTexture;
  75001. private _randomTexture;
  75002. private _originalColorPostProcess;
  75003. private _ssaoPostProcess;
  75004. private _blurHPostProcess;
  75005. private _blurVPostProcess;
  75006. private _ssaoCombinePostProcess;
  75007. private _firstUpdate;
  75008. /**
  75009. * Gets active scene
  75010. */
  75011. get scene(): Scene;
  75012. /**
  75013. * @constructor
  75014. * @param name - The rendering pipeline name
  75015. * @param scene - The scene linked to this pipeline
  75016. * @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 }
  75017. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  75018. */
  75019. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  75020. /**
  75021. * Get the class name
  75022. * @returns "SSAORenderingPipeline"
  75023. */
  75024. getClassName(): string;
  75025. /**
  75026. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  75027. */
  75028. dispose(disableDepthRender?: boolean): void;
  75029. private _createBlurPostProcess;
  75030. /** @hidden */
  75031. _rebuild(): void;
  75032. private _createSSAOPostProcess;
  75033. private _createSSAOCombinePostProcess;
  75034. private _createRandomTexture;
  75035. }
  75036. }
  75037. declare module "babylonjs/Shaders/screenSpaceReflection.fragment" {
  75038. /** @hidden */
  75039. export var screenSpaceReflectionPixelShader: {
  75040. name: string;
  75041. shader: string;
  75042. };
  75043. }
  75044. declare module "babylonjs/PostProcesses/screenSpaceReflectionPostProcess" {
  75045. import { Nullable } from "babylonjs/types";
  75046. import { Camera } from "babylonjs/Cameras/camera";
  75047. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  75048. import "babylonjs/Shaders/screenSpaceReflection.fragment";
  75049. import { Engine } from "babylonjs/Engines/engine";
  75050. import { Scene } from "babylonjs/scene";
  75051. /**
  75052. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  75053. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  75054. */
  75055. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  75056. /**
  75057. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  75058. */
  75059. threshold: number;
  75060. /**
  75061. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  75062. */
  75063. strength: number;
  75064. /**
  75065. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  75066. */
  75067. reflectionSpecularFalloffExponent: number;
  75068. /**
  75069. * 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]
  75070. */
  75071. step: number;
  75072. /**
  75073. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  75074. */
  75075. roughnessFactor: number;
  75076. private _geometryBufferRenderer;
  75077. private _enableSmoothReflections;
  75078. private _reflectionSamples;
  75079. private _smoothSteps;
  75080. /**
  75081. * Gets a string identifying the name of the class
  75082. * @returns "ScreenSpaceReflectionPostProcess" string
  75083. */
  75084. getClassName(): string;
  75085. /**
  75086. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  75087. * @param name The name of the effect.
  75088. * @param scene The scene containing the objects to calculate reflections.
  75089. * @param options The required width/height ratio to downsize to before computing the render pass.
  75090. * @param camera The camera to apply the render pass to.
  75091. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  75092. * @param engine The engine which the post process will be applied. (default: current engine)
  75093. * @param reusable If the post process can be reused on the same frame. (default: false)
  75094. * @param textureType Type of textures used when performing the post process. (default: 0)
  75095. * @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)
  75096. */
  75097. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  75098. /**
  75099. * Gets wether or not smoothing reflections is enabled.
  75100. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  75101. */
  75102. get enableSmoothReflections(): boolean;
  75103. /**
  75104. * Sets wether or not smoothing reflections is enabled.
  75105. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  75106. */
  75107. set enableSmoothReflections(enabled: boolean);
  75108. /**
  75109. * Gets the number of samples taken while computing reflections. More samples count is high,
  75110. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  75111. */
  75112. get reflectionSamples(): number;
  75113. /**
  75114. * Sets the number of samples taken while computing reflections. More samples count is high,
  75115. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  75116. */
  75117. set reflectionSamples(samples: number);
  75118. /**
  75119. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  75120. * more the post-process will require GPU power and can generate a drop in FPS.
  75121. * Default value (5.0) work pretty well in all cases but can be adjusted.
  75122. */
  75123. get smoothSteps(): number;
  75124. set smoothSteps(steps: number);
  75125. private _updateEffectDefines;
  75126. /** @hidden */
  75127. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceReflectionPostProcess;
  75128. }
  75129. }
  75130. declare module "babylonjs/Shaders/standard.fragment" {
  75131. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  75132. /** @hidden */
  75133. export var standardPixelShader: {
  75134. name: string;
  75135. shader: string;
  75136. };
  75137. }
  75138. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  75139. import { Nullable } from "babylonjs/types";
  75140. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  75141. import { Camera } from "babylonjs/Cameras/camera";
  75142. import { Texture } from "babylonjs/Materials/Textures/texture";
  75143. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  75144. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  75145. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  75146. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  75147. import { IDisposable } from "babylonjs/scene";
  75148. import { SpotLight } from "babylonjs/Lights/spotLight";
  75149. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  75150. import { Scene } from "babylonjs/scene";
  75151. import { ScreenSpaceReflectionPostProcess } from "babylonjs/PostProcesses/screenSpaceReflectionPostProcess";
  75152. import { Animation } from "babylonjs/Animations/animation";
  75153. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  75154. import "babylonjs/Shaders/standard.fragment";
  75155. /**
  75156. * Standard rendering pipeline
  75157. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  75158. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  75159. */
  75160. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  75161. /**
  75162. * Public members
  75163. */
  75164. /**
  75165. * Post-process which contains the original scene color before the pipeline applies all the effects
  75166. */
  75167. originalPostProcess: Nullable<PostProcess>;
  75168. /**
  75169. * Post-process used to down scale an image x4
  75170. */
  75171. downSampleX4PostProcess: Nullable<PostProcess>;
  75172. /**
  75173. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  75174. */
  75175. brightPassPostProcess: Nullable<PostProcess>;
  75176. /**
  75177. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  75178. */
  75179. blurHPostProcesses: PostProcess[];
  75180. /**
  75181. * Post-process array storing all the vertical blur post-processes used by the pipeline
  75182. */
  75183. blurVPostProcesses: PostProcess[];
  75184. /**
  75185. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  75186. */
  75187. textureAdderPostProcess: Nullable<PostProcess>;
  75188. /**
  75189. * Post-process used to create volumetric lighting effect
  75190. */
  75191. volumetricLightPostProcess: Nullable<PostProcess>;
  75192. /**
  75193. * Post-process used to smooth the previous volumetric light post-process on the X axis
  75194. */
  75195. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  75196. /**
  75197. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  75198. */
  75199. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  75200. /**
  75201. * Post-process used to merge the volumetric light effect and the real scene color
  75202. */
  75203. volumetricLightMergePostProces: Nullable<PostProcess>;
  75204. /**
  75205. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  75206. */
  75207. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  75208. /**
  75209. * Base post-process used to calculate the average luminance of the final image for HDR
  75210. */
  75211. luminancePostProcess: Nullable<PostProcess>;
  75212. /**
  75213. * Post-processes used to create down sample post-processes in order to get
  75214. * the average luminance of the final image for HDR
  75215. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  75216. */
  75217. luminanceDownSamplePostProcesses: PostProcess[];
  75218. /**
  75219. * Post-process used to create a HDR effect (light adaptation)
  75220. */
  75221. hdrPostProcess: Nullable<PostProcess>;
  75222. /**
  75223. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  75224. */
  75225. textureAdderFinalPostProcess: Nullable<PostProcess>;
  75226. /**
  75227. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  75228. */
  75229. lensFlareFinalPostProcess: Nullable<PostProcess>;
  75230. /**
  75231. * Post-process used to merge the final HDR post-process and the real scene color
  75232. */
  75233. hdrFinalPostProcess: Nullable<PostProcess>;
  75234. /**
  75235. * Post-process used to create a lens flare effect
  75236. */
  75237. lensFlarePostProcess: Nullable<PostProcess>;
  75238. /**
  75239. * Post-process that merges the result of the lens flare post-process and the real scene color
  75240. */
  75241. lensFlareComposePostProcess: Nullable<PostProcess>;
  75242. /**
  75243. * Post-process used to create a motion blur effect
  75244. */
  75245. motionBlurPostProcess: Nullable<PostProcess>;
  75246. /**
  75247. * Post-process used to create a depth of field effect
  75248. */
  75249. depthOfFieldPostProcess: Nullable<PostProcess>;
  75250. /**
  75251. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  75252. */
  75253. fxaaPostProcess: Nullable<FxaaPostProcess>;
  75254. /**
  75255. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  75256. */
  75257. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  75258. /**
  75259. * Represents the brightness threshold in order to configure the illuminated surfaces
  75260. */
  75261. brightThreshold: number;
  75262. /**
  75263. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  75264. */
  75265. blurWidth: number;
  75266. /**
  75267. * Sets if the blur for highlighted surfaces must be only horizontal
  75268. */
  75269. horizontalBlur: boolean;
  75270. /**
  75271. * Gets the overall exposure used by the pipeline
  75272. */
  75273. get exposure(): number;
  75274. /**
  75275. * Sets the overall exposure used by the pipeline
  75276. */
  75277. set exposure(value: number);
  75278. /**
  75279. * Texture used typically to simulate "dirty" on camera lens
  75280. */
  75281. lensTexture: Nullable<Texture>;
  75282. /**
  75283. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  75284. */
  75285. volumetricLightCoefficient: number;
  75286. /**
  75287. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  75288. */
  75289. volumetricLightPower: number;
  75290. /**
  75291. * Used the set the blur intensity to smooth the volumetric lights
  75292. */
  75293. volumetricLightBlurScale: number;
  75294. /**
  75295. * Light (spot or directional) used to generate the volumetric lights rays
  75296. * The source light must have a shadow generate so the pipeline can get its
  75297. * depth map
  75298. */
  75299. sourceLight: Nullable<SpotLight | DirectionalLight>;
  75300. /**
  75301. * For eye adaptation, represents the minimum luminance the eye can see
  75302. */
  75303. hdrMinimumLuminance: number;
  75304. /**
  75305. * For eye adaptation, represents the decrease luminance speed
  75306. */
  75307. hdrDecreaseRate: number;
  75308. /**
  75309. * For eye adaptation, represents the increase luminance speed
  75310. */
  75311. hdrIncreaseRate: number;
  75312. /**
  75313. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  75314. */
  75315. get hdrAutoExposure(): boolean;
  75316. /**
  75317. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  75318. */
  75319. set hdrAutoExposure(value: boolean);
  75320. /**
  75321. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  75322. */
  75323. lensColorTexture: Nullable<Texture>;
  75324. /**
  75325. * The overall strengh for the lens flare effect
  75326. */
  75327. lensFlareStrength: number;
  75328. /**
  75329. * Dispersion coefficient for lens flare ghosts
  75330. */
  75331. lensFlareGhostDispersal: number;
  75332. /**
  75333. * Main lens flare halo width
  75334. */
  75335. lensFlareHaloWidth: number;
  75336. /**
  75337. * Based on the lens distortion effect, defines how much the lens flare result
  75338. * is distorted
  75339. */
  75340. lensFlareDistortionStrength: number;
  75341. /**
  75342. * Configures the blur intensity used for for lens flare (halo)
  75343. */
  75344. lensFlareBlurWidth: number;
  75345. /**
  75346. * Lens star texture must be used to simulate rays on the flares and is available
  75347. * in the documentation
  75348. */
  75349. lensStarTexture: Nullable<Texture>;
  75350. /**
  75351. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  75352. * flare effect by taking account of the dirt texture
  75353. */
  75354. lensFlareDirtTexture: Nullable<Texture>;
  75355. /**
  75356. * Represents the focal length for the depth of field effect
  75357. */
  75358. depthOfFieldDistance: number;
  75359. /**
  75360. * Represents the blur intensity for the blurred part of the depth of field effect
  75361. */
  75362. depthOfFieldBlurWidth: number;
  75363. /**
  75364. * Gets how much the image is blurred by the movement while using the motion blur post-process
  75365. */
  75366. get motionStrength(): number;
  75367. /**
  75368. * Sets how much the image is blurred by the movement while using the motion blur post-process
  75369. */
  75370. set motionStrength(strength: number);
  75371. /**
  75372. * Gets wether or not the motion blur post-process is object based or screen based.
  75373. */
  75374. get objectBasedMotionBlur(): boolean;
  75375. /**
  75376. * Sets wether or not the motion blur post-process should be object based or screen based
  75377. */
  75378. set objectBasedMotionBlur(value: boolean);
  75379. /**
  75380. * List of animations for the pipeline (IAnimatable implementation)
  75381. */
  75382. animations: Animation[];
  75383. /**
  75384. * Private members
  75385. */
  75386. private _scene;
  75387. private _currentDepthOfFieldSource;
  75388. private _basePostProcess;
  75389. private _fixedExposure;
  75390. private _currentExposure;
  75391. private _hdrAutoExposure;
  75392. private _hdrCurrentLuminance;
  75393. private _motionStrength;
  75394. private _isObjectBasedMotionBlur;
  75395. private _floatTextureType;
  75396. private _camerasToBeAttached;
  75397. private _ratio;
  75398. private _bloomEnabled;
  75399. private _depthOfFieldEnabled;
  75400. private _vlsEnabled;
  75401. private _lensFlareEnabled;
  75402. private _hdrEnabled;
  75403. private _motionBlurEnabled;
  75404. private _fxaaEnabled;
  75405. private _screenSpaceReflectionsEnabled;
  75406. private _motionBlurSamples;
  75407. private _volumetricLightStepsCount;
  75408. private _samples;
  75409. /**
  75410. * @ignore
  75411. * Specifies if the bloom pipeline is enabled
  75412. */
  75413. get BloomEnabled(): boolean;
  75414. set BloomEnabled(enabled: boolean);
  75415. /**
  75416. * @ignore
  75417. * Specifies if the depth of field pipeline is enabed
  75418. */
  75419. get DepthOfFieldEnabled(): boolean;
  75420. set DepthOfFieldEnabled(enabled: boolean);
  75421. /**
  75422. * @ignore
  75423. * Specifies if the lens flare pipeline is enabed
  75424. */
  75425. get LensFlareEnabled(): boolean;
  75426. set LensFlareEnabled(enabled: boolean);
  75427. /**
  75428. * @ignore
  75429. * Specifies if the HDR pipeline is enabled
  75430. */
  75431. get HDREnabled(): boolean;
  75432. set HDREnabled(enabled: boolean);
  75433. /**
  75434. * @ignore
  75435. * Specifies if the volumetric lights scattering effect is enabled
  75436. */
  75437. get VLSEnabled(): boolean;
  75438. set VLSEnabled(enabled: boolean);
  75439. /**
  75440. * @ignore
  75441. * Specifies if the motion blur effect is enabled
  75442. */
  75443. get MotionBlurEnabled(): boolean;
  75444. set MotionBlurEnabled(enabled: boolean);
  75445. /**
  75446. * Specifies if anti-aliasing is enabled
  75447. */
  75448. get fxaaEnabled(): boolean;
  75449. set fxaaEnabled(enabled: boolean);
  75450. /**
  75451. * Specifies if screen space reflections are enabled.
  75452. */
  75453. get screenSpaceReflectionsEnabled(): boolean;
  75454. set screenSpaceReflectionsEnabled(enabled: boolean);
  75455. /**
  75456. * Specifies the number of steps used to calculate the volumetric lights
  75457. * Typically in interval [50, 200]
  75458. */
  75459. get volumetricLightStepsCount(): number;
  75460. set volumetricLightStepsCount(count: number);
  75461. /**
  75462. * Specifies the number of samples used for the motion blur effect
  75463. * Typically in interval [16, 64]
  75464. */
  75465. get motionBlurSamples(): number;
  75466. set motionBlurSamples(samples: number);
  75467. /**
  75468. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  75469. */
  75470. get samples(): number;
  75471. set samples(sampleCount: number);
  75472. /**
  75473. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  75474. * @constructor
  75475. * @param name The rendering pipeline name
  75476. * @param scene The scene linked to this pipeline
  75477. * @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)
  75478. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  75479. * @param cameras The array of cameras that the rendering pipeline will be attached to
  75480. */
  75481. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  75482. private _buildPipeline;
  75483. private _createDownSampleX4PostProcess;
  75484. private _createBrightPassPostProcess;
  75485. private _createBlurPostProcesses;
  75486. private _createTextureAdderPostProcess;
  75487. private _createVolumetricLightPostProcess;
  75488. private _createLuminancePostProcesses;
  75489. private _createHdrPostProcess;
  75490. private _createLensFlarePostProcess;
  75491. private _createDepthOfFieldPostProcess;
  75492. private _createMotionBlurPostProcess;
  75493. private _getDepthTexture;
  75494. private _disposePostProcesses;
  75495. /**
  75496. * Dispose of the pipeline and stop all post processes
  75497. */
  75498. dispose(): void;
  75499. /**
  75500. * Serialize the rendering pipeline (Used when exporting)
  75501. * @returns the serialized object
  75502. */
  75503. serialize(): any;
  75504. /**
  75505. * Parse the serialized pipeline
  75506. * @param source Source pipeline.
  75507. * @param scene The scene to load the pipeline to.
  75508. * @param rootUrl The URL of the serialized pipeline.
  75509. * @returns An instantiated pipeline from the serialized object.
  75510. */
  75511. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  75512. /**
  75513. * Luminance steps
  75514. */
  75515. static LuminanceSteps: number;
  75516. }
  75517. }
  75518. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  75519. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  75520. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  75521. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  75522. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  75523. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  75524. }
  75525. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  75526. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  75527. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  75528. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  75529. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  75530. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  75531. }
  75532. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  75533. /** @hidden */
  75534. export var stereoscopicInterlacePixelShader: {
  75535. name: string;
  75536. shader: string;
  75537. };
  75538. }
  75539. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  75540. import { Camera } from "babylonjs/Cameras/camera";
  75541. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  75542. import { Engine } from "babylonjs/Engines/engine";
  75543. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  75544. /**
  75545. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  75546. */
  75547. export class StereoscopicInterlacePostProcessI extends PostProcess {
  75548. private _stepSize;
  75549. private _passedProcess;
  75550. /**
  75551. * Gets a string identifying the name of the class
  75552. * @returns "StereoscopicInterlacePostProcessI" string
  75553. */
  75554. getClassName(): string;
  75555. /**
  75556. * Initializes a StereoscopicInterlacePostProcessI
  75557. * @param name The name of the effect.
  75558. * @param rigCameras The rig cameras to be appled to the post process
  75559. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  75560. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  75561. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  75562. * @param engine The engine which the post process will be applied. (default: current engine)
  75563. * @param reusable If the post process can be reused on the same frame. (default: false)
  75564. */
  75565. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  75566. }
  75567. /**
  75568. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  75569. */
  75570. export class StereoscopicInterlacePostProcess extends PostProcess {
  75571. private _stepSize;
  75572. private _passedProcess;
  75573. /**
  75574. * Gets a string identifying the name of the class
  75575. * @returns "StereoscopicInterlacePostProcess" string
  75576. */
  75577. getClassName(): string;
  75578. /**
  75579. * Initializes a StereoscopicInterlacePostProcess
  75580. * @param name The name of the effect.
  75581. * @param rigCameras The rig cameras to be appled to the post process
  75582. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  75583. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  75584. * @param engine The engine which the post process will be applied. (default: current engine)
  75585. * @param reusable If the post process can be reused on the same frame. (default: false)
  75586. */
  75587. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  75588. }
  75589. }
  75590. declare module "babylonjs/Shaders/tonemap.fragment" {
  75591. /** @hidden */
  75592. export var tonemapPixelShader: {
  75593. name: string;
  75594. shader: string;
  75595. };
  75596. }
  75597. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  75598. import { Camera } from "babylonjs/Cameras/camera";
  75599. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  75600. import "babylonjs/Shaders/tonemap.fragment";
  75601. import { Engine } from "babylonjs/Engines/engine";
  75602. /** Defines operator used for tonemapping */
  75603. export enum TonemappingOperator {
  75604. /** Hable */
  75605. Hable = 0,
  75606. /** Reinhard */
  75607. Reinhard = 1,
  75608. /** HejiDawson */
  75609. HejiDawson = 2,
  75610. /** Photographic */
  75611. Photographic = 3
  75612. }
  75613. /**
  75614. * Defines a post process to apply tone mapping
  75615. */
  75616. export class TonemapPostProcess extends PostProcess {
  75617. private _operator;
  75618. /** Defines the required exposure adjustement */
  75619. exposureAdjustment: number;
  75620. /**
  75621. * Gets a string identifying the name of the class
  75622. * @returns "TonemapPostProcess" string
  75623. */
  75624. getClassName(): string;
  75625. /**
  75626. * Creates a new TonemapPostProcess
  75627. * @param name defines the name of the postprocess
  75628. * @param _operator defines the operator to use
  75629. * @param exposureAdjustment defines the required exposure adjustement
  75630. * @param camera defines the camera to use (can be null)
  75631. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  75632. * @param engine defines the hosting engine (can be ignore if camera is set)
  75633. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  75634. */
  75635. constructor(name: string, _operator: TonemappingOperator,
  75636. /** Defines the required exposure adjustement */
  75637. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  75638. }
  75639. }
  75640. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  75641. /** @hidden */
  75642. export var volumetricLightScatteringPixelShader: {
  75643. name: string;
  75644. shader: string;
  75645. };
  75646. }
  75647. declare module "babylonjs/Shaders/volumetricLightScatteringPass.vertex" {
  75648. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  75649. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  75650. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  75651. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  75652. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  75653. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  75654. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  75655. /** @hidden */
  75656. export var volumetricLightScatteringPassVertexShader: {
  75657. name: string;
  75658. shader: string;
  75659. };
  75660. }
  75661. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  75662. /** @hidden */
  75663. export var volumetricLightScatteringPassPixelShader: {
  75664. name: string;
  75665. shader: string;
  75666. };
  75667. }
  75668. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  75669. import { Vector3 } from "babylonjs/Maths/math.vector";
  75670. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  75671. import { Mesh } from "babylonjs/Meshes/mesh";
  75672. import { Camera } from "babylonjs/Cameras/camera";
  75673. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  75674. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  75675. import { Scene } from "babylonjs/scene";
  75676. import "babylonjs/Meshes/Builders/planeBuilder";
  75677. import "babylonjs/Shaders/depth.vertex";
  75678. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  75679. import "babylonjs/Shaders/volumetricLightScatteringPass.vertex";
  75680. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  75681. import { Engine } from "babylonjs/Engines/engine";
  75682. /**
  75683. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  75684. */
  75685. export class VolumetricLightScatteringPostProcess extends PostProcess {
  75686. private _volumetricLightScatteringPass;
  75687. private _volumetricLightScatteringRTT;
  75688. private _viewPort;
  75689. private _screenCoordinates;
  75690. private _cachedDefines;
  75691. /**
  75692. * If not undefined, the mesh position is computed from the attached node position
  75693. */
  75694. attachedNode: {
  75695. position: Vector3;
  75696. };
  75697. /**
  75698. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  75699. */
  75700. customMeshPosition: Vector3;
  75701. /**
  75702. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  75703. */
  75704. useCustomMeshPosition: boolean;
  75705. /**
  75706. * If the post-process should inverse the light scattering direction
  75707. */
  75708. invert: boolean;
  75709. /**
  75710. * The internal mesh used by the post-process
  75711. */
  75712. mesh: Mesh;
  75713. /**
  75714. * @hidden
  75715. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  75716. */
  75717. get useDiffuseColor(): boolean;
  75718. set useDiffuseColor(useDiffuseColor: boolean);
  75719. /**
  75720. * Array containing the excluded meshes not rendered in the internal pass
  75721. */
  75722. excludedMeshes: AbstractMesh[];
  75723. /**
  75724. * Controls the overall intensity of the post-process
  75725. */
  75726. exposure: number;
  75727. /**
  75728. * Dissipates each sample's contribution in range [0, 1]
  75729. */
  75730. decay: number;
  75731. /**
  75732. * Controls the overall intensity of each sample
  75733. */
  75734. weight: number;
  75735. /**
  75736. * Controls the density of each sample
  75737. */
  75738. density: number;
  75739. /**
  75740. * @constructor
  75741. * @param name The post-process name
  75742. * @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)
  75743. * @param camera The camera that the post-process will be attached to
  75744. * @param mesh The mesh used to create the light scattering
  75745. * @param samples The post-process quality, default 100
  75746. * @param samplingModeThe post-process filtering mode
  75747. * @param engine The babylon engine
  75748. * @param reusable If the post-process is reusable
  75749. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  75750. */
  75751. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  75752. /**
  75753. * Returns the string "VolumetricLightScatteringPostProcess"
  75754. * @returns "VolumetricLightScatteringPostProcess"
  75755. */
  75756. getClassName(): string;
  75757. private _isReady;
  75758. /**
  75759. * Sets the new light position for light scattering effect
  75760. * @param position The new custom light position
  75761. */
  75762. setCustomMeshPosition(position: Vector3): void;
  75763. /**
  75764. * Returns the light position for light scattering effect
  75765. * @return Vector3 The custom light position
  75766. */
  75767. getCustomMeshPosition(): Vector3;
  75768. /**
  75769. * Disposes the internal assets and detaches the post-process from the camera
  75770. */
  75771. dispose(camera: Camera): void;
  75772. /**
  75773. * Returns the render target texture used by the post-process
  75774. * @return the render target texture used by the post-process
  75775. */
  75776. getPass(): RenderTargetTexture;
  75777. private _meshExcluded;
  75778. private _createPass;
  75779. private _updateMeshScreenCoordinates;
  75780. /**
  75781. * Creates a default mesh for the Volumeric Light Scattering post-process
  75782. * @param name The mesh name
  75783. * @param scene The scene where to create the mesh
  75784. * @return the default mesh
  75785. */
  75786. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  75787. }
  75788. }
  75789. declare module "babylonjs/Shaders/screenSpaceCurvature.fragment" {
  75790. /** @hidden */
  75791. export var screenSpaceCurvaturePixelShader: {
  75792. name: string;
  75793. shader: string;
  75794. };
  75795. }
  75796. declare module "babylonjs/PostProcesses/screenSpaceCurvaturePostProcess" {
  75797. import { Nullable } from "babylonjs/types";
  75798. import { Camera } from "babylonjs/Cameras/camera";
  75799. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  75800. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  75801. import "babylonjs/Shaders/screenSpaceCurvature.fragment";
  75802. import { Engine } from "babylonjs/Engines/engine";
  75803. import { Scene } from "babylonjs/scene";
  75804. /**
  75805. * The Screen Space curvature effect can help highlighting ridge and valley of a model.
  75806. */
  75807. export class ScreenSpaceCurvaturePostProcess extends PostProcess {
  75808. /**
  75809. * Defines how much ridge the curvature effect displays.
  75810. */
  75811. ridge: number;
  75812. /**
  75813. * Defines how much valley the curvature effect displays.
  75814. */
  75815. valley: number;
  75816. private _geometryBufferRenderer;
  75817. /**
  75818. * Gets a string identifying the name of the class
  75819. * @returns "ScreenSpaceCurvaturePostProcess" string
  75820. */
  75821. getClassName(): string;
  75822. /**
  75823. * Creates a new instance ScreenSpaceCurvaturePostProcess
  75824. * @param name The name of the effect.
  75825. * @param scene The scene containing the objects to blur according to their velocity.
  75826. * @param options The required width/height ratio to downsize to before computing the render pass.
  75827. * @param camera The camera to apply the render pass to.
  75828. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  75829. * @param engine The engine which the post process will be applied. (default: current engine)
  75830. * @param reusable If the post process can be reused on the same frame. (default: false)
  75831. * @param textureType Type of textures used when performing the post process. (default: 0)
  75832. * @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)
  75833. */
  75834. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  75835. /**
  75836. * Support test.
  75837. */
  75838. static get IsSupported(): boolean;
  75839. /** @hidden */
  75840. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceCurvaturePostProcess;
  75841. }
  75842. }
  75843. declare module "babylonjs/PostProcesses/index" {
  75844. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  75845. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  75846. export * from "babylonjs/PostProcesses/bloomEffect";
  75847. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  75848. export * from "babylonjs/PostProcesses/blurPostProcess";
  75849. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  75850. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  75851. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  75852. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  75853. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  75854. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  75855. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  75856. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  75857. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  75858. export * from "babylonjs/PostProcesses/filterPostProcess";
  75859. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  75860. export * from "babylonjs/PostProcesses/grainPostProcess";
  75861. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  75862. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  75863. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  75864. export * from "babylonjs/PostProcesses/passPostProcess";
  75865. export * from "babylonjs/PostProcesses/postProcess";
  75866. export * from "babylonjs/PostProcesses/postProcessManager";
  75867. export * from "babylonjs/PostProcesses/refractionPostProcess";
  75868. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  75869. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  75870. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  75871. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  75872. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  75873. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  75874. export * from "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess";
  75875. export * from "babylonjs/PostProcesses/screenSpaceReflectionPostProcess";
  75876. export * from "babylonjs/PostProcesses/screenSpaceCurvaturePostProcess";
  75877. }
  75878. declare module "babylonjs/Probes/index" {
  75879. export * from "babylonjs/Probes/reflectionProbe";
  75880. }
  75881. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  75882. import { Scene } from "babylonjs/scene";
  75883. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  75884. import { SmartArray } from "babylonjs/Misc/smartArray";
  75885. import { ISceneComponent } from "babylonjs/sceneComponent";
  75886. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  75887. import "babylonjs/Meshes/Builders/boxBuilder";
  75888. import "babylonjs/Shaders/color.fragment";
  75889. import "babylonjs/Shaders/color.vertex";
  75890. import { Color3 } from "babylonjs/Maths/math.color";
  75891. import { Observable } from "babylonjs/Misc/observable";
  75892. module "babylonjs/scene" {
  75893. interface Scene {
  75894. /** @hidden (Backing field) */
  75895. _boundingBoxRenderer: BoundingBoxRenderer;
  75896. /** @hidden (Backing field) */
  75897. _forceShowBoundingBoxes: boolean;
  75898. /**
  75899. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  75900. */
  75901. forceShowBoundingBoxes: boolean;
  75902. /**
  75903. * Gets the bounding box renderer associated with the scene
  75904. * @returns a BoundingBoxRenderer
  75905. */
  75906. getBoundingBoxRenderer(): BoundingBoxRenderer;
  75907. }
  75908. }
  75909. module "babylonjs/Meshes/abstractMesh" {
  75910. interface AbstractMesh {
  75911. /** @hidden (Backing field) */
  75912. _showBoundingBox: boolean;
  75913. /**
  75914. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  75915. */
  75916. showBoundingBox: boolean;
  75917. }
  75918. }
  75919. /**
  75920. * Component responsible of rendering the bounding box of the meshes in a scene.
  75921. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  75922. */
  75923. export class BoundingBoxRenderer implements ISceneComponent {
  75924. /**
  75925. * The component name helpfull to identify the component in the list of scene components.
  75926. */
  75927. readonly name: string;
  75928. /**
  75929. * The scene the component belongs to.
  75930. */
  75931. scene: Scene;
  75932. /**
  75933. * Color of the bounding box lines placed in front of an object
  75934. */
  75935. frontColor: Color3;
  75936. /**
  75937. * Color of the bounding box lines placed behind an object
  75938. */
  75939. backColor: Color3;
  75940. /**
  75941. * Defines if the renderer should show the back lines or not
  75942. */
  75943. showBackLines: boolean;
  75944. /**
  75945. * Observable raised before rendering a bounding box
  75946. */
  75947. onBeforeBoxRenderingObservable: Observable<BoundingBox>;
  75948. /**
  75949. * Observable raised after rendering a bounding box
  75950. */
  75951. onAfterBoxRenderingObservable: Observable<BoundingBox>;
  75952. /**
  75953. * @hidden
  75954. */
  75955. renderList: SmartArray<BoundingBox>;
  75956. private _colorShader;
  75957. private _vertexBuffers;
  75958. private _indexBuffer;
  75959. private _fillIndexBuffer;
  75960. private _fillIndexData;
  75961. /**
  75962. * Instantiates a new bounding box renderer in a scene.
  75963. * @param scene the scene the renderer renders in
  75964. */
  75965. constructor(scene: Scene);
  75966. /**
  75967. * Registers the component in a given scene
  75968. */
  75969. register(): void;
  75970. private _evaluateSubMesh;
  75971. private _activeMesh;
  75972. private _prepareRessources;
  75973. private _createIndexBuffer;
  75974. /**
  75975. * Rebuilds the elements related to this component in case of
  75976. * context lost for instance.
  75977. */
  75978. rebuild(): void;
  75979. /**
  75980. * @hidden
  75981. */
  75982. reset(): void;
  75983. /**
  75984. * Render the bounding boxes of a specific rendering group
  75985. * @param renderingGroupId defines the rendering group to render
  75986. */
  75987. render(renderingGroupId: number): void;
  75988. /**
  75989. * In case of occlusion queries, we can render the occlusion bounding box through this method
  75990. * @param mesh Define the mesh to render the occlusion bounding box for
  75991. */
  75992. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  75993. /**
  75994. * Dispose and release the resources attached to this renderer.
  75995. */
  75996. dispose(): void;
  75997. }
  75998. }
  75999. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  76000. import { Nullable } from "babylonjs/types";
  76001. import { Scene } from "babylonjs/scene";
  76002. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  76003. import { Camera } from "babylonjs/Cameras/camera";
  76004. import { ISceneComponent } from "babylonjs/sceneComponent";
  76005. module "babylonjs/scene" {
  76006. interface Scene {
  76007. /** @hidden (Backing field) */
  76008. _depthRenderer: {
  76009. [id: string]: DepthRenderer;
  76010. };
  76011. /**
  76012. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  76013. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  76014. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  76015. * @returns the created depth renderer
  76016. */
  76017. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  76018. /**
  76019. * Disables a depth renderer for a given camera
  76020. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  76021. */
  76022. disableDepthRenderer(camera?: Nullable<Camera>): void;
  76023. }
  76024. }
  76025. /**
  76026. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  76027. * in several rendering techniques.
  76028. */
  76029. export class DepthRendererSceneComponent implements ISceneComponent {
  76030. /**
  76031. * The component name helpfull to identify the component in the list of scene components.
  76032. */
  76033. readonly name: string;
  76034. /**
  76035. * The scene the component belongs to.
  76036. */
  76037. scene: Scene;
  76038. /**
  76039. * Creates a new instance of the component for the given scene
  76040. * @param scene Defines the scene to register the component in
  76041. */
  76042. constructor(scene: Scene);
  76043. /**
  76044. * Registers the component in a given scene
  76045. */
  76046. register(): void;
  76047. /**
  76048. * Rebuilds the elements related to this component in case of
  76049. * context lost for instance.
  76050. */
  76051. rebuild(): void;
  76052. /**
  76053. * Disposes the component and the associated ressources
  76054. */
  76055. dispose(): void;
  76056. private _gatherRenderTargets;
  76057. private _gatherActiveCameraRenderTargets;
  76058. }
  76059. }
  76060. declare module "babylonjs/Rendering/prePassRendererSceneComponent" {
  76061. import { Nullable } from "babylonjs/types";
  76062. import { Scene } from "babylonjs/scene";
  76063. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  76064. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  76065. import { AbstractScene } from "babylonjs/abstractScene";
  76066. module "babylonjs/abstractScene" {
  76067. interface AbstractScene {
  76068. /** @hidden (Backing field) */
  76069. _prePassRenderer: Nullable<PrePassRenderer>;
  76070. /**
  76071. * Gets or Sets the current prepass renderer associated to the scene.
  76072. */
  76073. prePassRenderer: Nullable<PrePassRenderer>;
  76074. /**
  76075. * Enables the prepass and associates it with the scene
  76076. * @returns the PrePassRenderer
  76077. */
  76078. enablePrePassRenderer(): Nullable<PrePassRenderer>;
  76079. /**
  76080. * Disables the prepass associated with the scene
  76081. */
  76082. disablePrePassRenderer(): void;
  76083. }
  76084. }
  76085. /**
  76086. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  76087. * in several rendering techniques.
  76088. */
  76089. export class PrePassRendererSceneComponent implements ISceneSerializableComponent {
  76090. /**
  76091. * The component name helpful to identify the component in the list of scene components.
  76092. */
  76093. readonly name: string;
  76094. /**
  76095. * The scene the component belongs to.
  76096. */
  76097. scene: Scene;
  76098. /**
  76099. * Creates a new instance of the component for the given scene
  76100. * @param scene Defines the scene to register the component in
  76101. */
  76102. constructor(scene: Scene);
  76103. /**
  76104. * Registers the component in a given scene
  76105. */
  76106. register(): void;
  76107. private _beforeCameraDraw;
  76108. private _afterCameraDraw;
  76109. private _beforeClearStage;
  76110. /**
  76111. * Serializes the component data to the specified json object
  76112. * @param serializationObject The object to serialize to
  76113. */
  76114. serialize(serializationObject: any): void;
  76115. /**
  76116. * Adds all the elements from the container to the scene
  76117. * @param container the container holding the elements
  76118. */
  76119. addFromContainer(container: AbstractScene): void;
  76120. /**
  76121. * Removes all the elements in the container from the scene
  76122. * @param container contains the elements to remove
  76123. * @param dispose if the removed element should be disposed (default: false)
  76124. */
  76125. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  76126. /**
  76127. * Rebuilds the elements related to this component in case of
  76128. * context lost for instance.
  76129. */
  76130. rebuild(): void;
  76131. /**
  76132. * Disposes the component and the associated ressources
  76133. */
  76134. dispose(): void;
  76135. }
  76136. }
  76137. declare module "babylonjs/Shaders/outline.fragment" {
  76138. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  76139. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  76140. /** @hidden */
  76141. export var outlinePixelShader: {
  76142. name: string;
  76143. shader: string;
  76144. };
  76145. }
  76146. declare module "babylonjs/Shaders/outline.vertex" {
  76147. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  76148. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  76149. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  76150. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  76151. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  76152. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  76153. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  76154. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  76155. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  76156. /** @hidden */
  76157. export var outlineVertexShader: {
  76158. name: string;
  76159. shader: string;
  76160. };
  76161. }
  76162. declare module "babylonjs/Rendering/outlineRenderer" {
  76163. import { SubMesh } from "babylonjs/Meshes/subMesh";
  76164. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  76165. import { Scene } from "babylonjs/scene";
  76166. import { ISceneComponent } from "babylonjs/sceneComponent";
  76167. import "babylonjs/Shaders/outline.fragment";
  76168. import "babylonjs/Shaders/outline.vertex";
  76169. module "babylonjs/scene" {
  76170. interface Scene {
  76171. /** @hidden */
  76172. _outlineRenderer: OutlineRenderer;
  76173. /**
  76174. * Gets the outline renderer associated with the scene
  76175. * @returns a OutlineRenderer
  76176. */
  76177. getOutlineRenderer(): OutlineRenderer;
  76178. }
  76179. }
  76180. module "babylonjs/Meshes/abstractMesh" {
  76181. interface AbstractMesh {
  76182. /** @hidden (Backing field) */
  76183. _renderOutline: boolean;
  76184. /**
  76185. * Gets or sets a boolean indicating if the outline must be rendered as well
  76186. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  76187. */
  76188. renderOutline: boolean;
  76189. /** @hidden (Backing field) */
  76190. _renderOverlay: boolean;
  76191. /**
  76192. * Gets or sets a boolean indicating if the overlay must be rendered as well
  76193. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  76194. */
  76195. renderOverlay: boolean;
  76196. }
  76197. }
  76198. /**
  76199. * This class is responsible to draw bothe outline/overlay of meshes.
  76200. * It should not be used directly but through the available method on mesh.
  76201. */
  76202. export class OutlineRenderer implements ISceneComponent {
  76203. /**
  76204. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  76205. */
  76206. private static _StencilReference;
  76207. /**
  76208. * The name of the component. Each component must have a unique name.
  76209. */
  76210. name: string;
  76211. /**
  76212. * The scene the component belongs to.
  76213. */
  76214. scene: Scene;
  76215. /**
  76216. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  76217. */
  76218. zOffset: number;
  76219. private _engine;
  76220. private _effect;
  76221. private _cachedDefines;
  76222. private _savedDepthWrite;
  76223. /**
  76224. * Instantiates a new outline renderer. (There could be only one per scene).
  76225. * @param scene Defines the scene it belongs to
  76226. */
  76227. constructor(scene: Scene);
  76228. /**
  76229. * Register the component to one instance of a scene.
  76230. */
  76231. register(): void;
  76232. /**
  76233. * Rebuilds the elements related to this component in case of
  76234. * context lost for instance.
  76235. */
  76236. rebuild(): void;
  76237. /**
  76238. * Disposes the component and the associated ressources.
  76239. */
  76240. dispose(): void;
  76241. /**
  76242. * Renders the outline in the canvas.
  76243. * @param subMesh Defines the sumesh to render
  76244. * @param batch Defines the batch of meshes in case of instances
  76245. * @param useOverlay Defines if the rendering is for the overlay or the outline
  76246. */
  76247. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  76248. /**
  76249. * Returns whether or not the outline renderer is ready for a given submesh.
  76250. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  76251. * @param subMesh Defines the submesh to check readyness for
  76252. * @param useInstances Defines wheter wee are trying to render instances or not
  76253. * @returns true if ready otherwise false
  76254. */
  76255. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  76256. private _beforeRenderingMesh;
  76257. private _afterRenderingMesh;
  76258. }
  76259. }
  76260. declare module "babylonjs/Rendering/index" {
  76261. export * from "babylonjs/Rendering/boundingBoxRenderer";
  76262. export * from "babylonjs/Rendering/depthRenderer";
  76263. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  76264. export * from "babylonjs/Rendering/edgesRenderer";
  76265. export * from "babylonjs/Rendering/geometryBufferRenderer";
  76266. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  76267. export * from "babylonjs/Rendering/prePassRenderer";
  76268. export * from "babylonjs/Rendering/prePassRendererSceneComponent";
  76269. export * from "babylonjs/Rendering/outlineRenderer";
  76270. export * from "babylonjs/Rendering/renderingGroup";
  76271. export * from "babylonjs/Rendering/renderingManager";
  76272. export * from "babylonjs/Rendering/utilityLayerRenderer";
  76273. }
  76274. declare module "babylonjs/Sprites/ISprites" {
  76275. /**
  76276. * Defines the basic options interface of a Sprite Frame Source Size.
  76277. */
  76278. export interface ISpriteJSONSpriteSourceSize {
  76279. /**
  76280. * number of the original width of the Frame
  76281. */
  76282. w: number;
  76283. /**
  76284. * number of the original height of the Frame
  76285. */
  76286. h: number;
  76287. }
  76288. /**
  76289. * Defines the basic options interface of a Sprite Frame Data.
  76290. */
  76291. export interface ISpriteJSONSpriteFrameData {
  76292. /**
  76293. * number of the x offset of the Frame
  76294. */
  76295. x: number;
  76296. /**
  76297. * number of the y offset of the Frame
  76298. */
  76299. y: number;
  76300. /**
  76301. * number of the width of the Frame
  76302. */
  76303. w: number;
  76304. /**
  76305. * number of the height of the Frame
  76306. */
  76307. h: number;
  76308. }
  76309. /**
  76310. * Defines the basic options interface of a JSON Sprite.
  76311. */
  76312. export interface ISpriteJSONSprite {
  76313. /**
  76314. * string name of the Frame
  76315. */
  76316. filename: string;
  76317. /**
  76318. * ISpriteJSONSpriteFrame basic object of the frame data
  76319. */
  76320. frame: ISpriteJSONSpriteFrameData;
  76321. /**
  76322. * boolean to flag is the frame was rotated.
  76323. */
  76324. rotated: boolean;
  76325. /**
  76326. * boolean to flag is the frame was trimmed.
  76327. */
  76328. trimmed: boolean;
  76329. /**
  76330. * ISpriteJSONSpriteFrame basic object of the source data
  76331. */
  76332. spriteSourceSize: ISpriteJSONSpriteFrameData;
  76333. /**
  76334. * ISpriteJSONSpriteFrame basic object of the source data
  76335. */
  76336. sourceSize: ISpriteJSONSpriteSourceSize;
  76337. }
  76338. /**
  76339. * Defines the basic options interface of a JSON atlas.
  76340. */
  76341. export interface ISpriteJSONAtlas {
  76342. /**
  76343. * Array of objects that contain the frame data.
  76344. */
  76345. frames: Array<ISpriteJSONSprite>;
  76346. /**
  76347. * object basic object containing the sprite meta data.
  76348. */
  76349. meta?: object;
  76350. }
  76351. }
  76352. declare module "babylonjs/Shaders/spriteMap.fragment" {
  76353. /** @hidden */
  76354. export var spriteMapPixelShader: {
  76355. name: string;
  76356. shader: string;
  76357. };
  76358. }
  76359. declare module "babylonjs/Shaders/spriteMap.vertex" {
  76360. /** @hidden */
  76361. export var spriteMapVertexShader: {
  76362. name: string;
  76363. shader: string;
  76364. };
  76365. }
  76366. declare module "babylonjs/Sprites/spriteMap" {
  76367. import { IDisposable, Scene } from "babylonjs/scene";
  76368. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  76369. import { Texture } from "babylonjs/Materials/Textures/texture";
  76370. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  76371. import { ISpriteJSONSprite, ISpriteJSONAtlas } from "babylonjs/Sprites/ISprites";
  76372. import "babylonjs/Meshes/Builders/planeBuilder";
  76373. import "babylonjs/Shaders/spriteMap.fragment";
  76374. import "babylonjs/Shaders/spriteMap.vertex";
  76375. /**
  76376. * Defines the basic options interface of a SpriteMap
  76377. */
  76378. export interface ISpriteMapOptions {
  76379. /**
  76380. * Vector2 of the number of cells in the grid.
  76381. */
  76382. stageSize?: Vector2;
  76383. /**
  76384. * Vector2 of the size of the output plane in World Units.
  76385. */
  76386. outputSize?: Vector2;
  76387. /**
  76388. * Vector3 of the position of the output plane in World Units.
  76389. */
  76390. outputPosition?: Vector3;
  76391. /**
  76392. * Vector3 of the rotation of the output plane.
  76393. */
  76394. outputRotation?: Vector3;
  76395. /**
  76396. * number of layers that the system will reserve in resources.
  76397. */
  76398. layerCount?: number;
  76399. /**
  76400. * number of max animation frames a single cell will reserve in resources.
  76401. */
  76402. maxAnimationFrames?: number;
  76403. /**
  76404. * number cell index of the base tile when the system compiles.
  76405. */
  76406. baseTile?: number;
  76407. /**
  76408. * boolean flip the sprite after its been repositioned by the framing data.
  76409. */
  76410. flipU?: boolean;
  76411. /**
  76412. * Vector3 scalar of the global RGB values of the SpriteMap.
  76413. */
  76414. colorMultiply?: Vector3;
  76415. }
  76416. /**
  76417. * Defines the IDisposable interface in order to be cleanable from resources.
  76418. */
  76419. export interface ISpriteMap extends IDisposable {
  76420. /**
  76421. * String name of the SpriteMap.
  76422. */
  76423. name: string;
  76424. /**
  76425. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  76426. */
  76427. atlasJSON: ISpriteJSONAtlas;
  76428. /**
  76429. * Texture of the SpriteMap.
  76430. */
  76431. spriteSheet: Texture;
  76432. /**
  76433. * The parameters to initialize the SpriteMap with.
  76434. */
  76435. options: ISpriteMapOptions;
  76436. }
  76437. /**
  76438. * Class used to manage a grid restricted sprite deployment on an Output plane.
  76439. */
  76440. export class SpriteMap implements ISpriteMap {
  76441. /** The Name of the spriteMap */
  76442. name: string;
  76443. /** The JSON file with the frame and meta data */
  76444. atlasJSON: ISpriteJSONAtlas;
  76445. /** The systems Sprite Sheet Texture */
  76446. spriteSheet: Texture;
  76447. /** Arguments passed with the Constructor */
  76448. options: ISpriteMapOptions;
  76449. /** Public Sprite Storage array, parsed from atlasJSON */
  76450. sprites: Array<ISpriteJSONSprite>;
  76451. /** Returns the Number of Sprites in the System */
  76452. get spriteCount(): number;
  76453. /** Returns the Position of Output Plane*/
  76454. get position(): Vector3;
  76455. /** Returns the Position of Output Plane*/
  76456. set position(v: Vector3);
  76457. /** Returns the Rotation of Output Plane*/
  76458. get rotation(): Vector3;
  76459. /** Returns the Rotation of Output Plane*/
  76460. set rotation(v: Vector3);
  76461. /** Sets the AnimationMap*/
  76462. get animationMap(): RawTexture;
  76463. /** Sets the AnimationMap*/
  76464. set animationMap(v: RawTexture);
  76465. /** Scene that the SpriteMap was created in */
  76466. private _scene;
  76467. /** Texture Buffer of Float32 that holds tile frame data*/
  76468. private _frameMap;
  76469. /** Texture Buffers of Float32 that holds tileMap data*/
  76470. private _tileMaps;
  76471. /** Texture Buffer of Float32 that holds Animation Data*/
  76472. private _animationMap;
  76473. /** Custom ShaderMaterial Central to the System*/
  76474. private _material;
  76475. /** Custom ShaderMaterial Central to the System*/
  76476. private _output;
  76477. /** Systems Time Ticker*/
  76478. private _time;
  76479. /**
  76480. * Creates a new SpriteMap
  76481. * @param name defines the SpriteMaps Name
  76482. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  76483. * @param spriteSheet is the Texture that the Sprites are on.
  76484. * @param options a basic deployment configuration
  76485. * @param scene The Scene that the map is deployed on
  76486. */
  76487. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  76488. /**
  76489. * Returns tileID location
  76490. * @returns Vector2 the cell position ID
  76491. */
  76492. getTileID(): Vector2;
  76493. /**
  76494. * Gets the UV location of the mouse over the SpriteMap.
  76495. * @returns Vector2 the UV position of the mouse interaction
  76496. */
  76497. getMousePosition(): Vector2;
  76498. /**
  76499. * Creates the "frame" texture Buffer
  76500. * -------------------------------------
  76501. * Structure of frames
  76502. * "filename": "Falling-Water-2.png",
  76503. * "frame": {"x":69,"y":103,"w":24,"h":32},
  76504. * "rotated": true,
  76505. * "trimmed": true,
  76506. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  76507. * "sourceSize": {"w":32,"h":32}
  76508. * @returns RawTexture of the frameMap
  76509. */
  76510. private _createFrameBuffer;
  76511. /**
  76512. * Creates the tileMap texture Buffer
  76513. * @param buffer normally and array of numbers, or a false to generate from scratch
  76514. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  76515. * @returns RawTexture of the tileMap
  76516. */
  76517. private _createTileBuffer;
  76518. /**
  76519. * Modifies the data of the tileMaps
  76520. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  76521. * @param pos is the iVector2 Coordinates of the Tile
  76522. * @param tile The SpriteIndex of the new Tile
  76523. */
  76524. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  76525. /**
  76526. * Creates the animationMap texture Buffer
  76527. * @param buffer normally and array of numbers, or a false to generate from scratch
  76528. * @returns RawTexture of the animationMap
  76529. */
  76530. private _createTileAnimationBuffer;
  76531. /**
  76532. * Modifies the data of the animationMap
  76533. * @param cellID is the Index of the Sprite
  76534. * @param _frame is the target Animation frame
  76535. * @param toCell is the Target Index of the next frame of the animation
  76536. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  76537. * @param speed is a global scalar of the time variable on the map.
  76538. */
  76539. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  76540. /**
  76541. * Exports the .tilemaps file
  76542. */
  76543. saveTileMaps(): void;
  76544. /**
  76545. * Imports the .tilemaps file
  76546. * @param url of the .tilemaps file
  76547. */
  76548. loadTileMaps(url: string): void;
  76549. /**
  76550. * Release associated resources
  76551. */
  76552. dispose(): void;
  76553. }
  76554. }
  76555. declare module "babylonjs/Sprites/spritePackedManager" {
  76556. import { SpriteManager } from "babylonjs/Sprites/spriteManager";
  76557. import { Scene } from "babylonjs/scene";
  76558. /**
  76559. * Class used to manage multiple sprites of different sizes on the same spritesheet
  76560. * @see https://doc.babylonjs.com/babylon101/sprites
  76561. */
  76562. export class SpritePackedManager extends SpriteManager {
  76563. /** defines the packed manager's name */
  76564. name: string;
  76565. /**
  76566. * Creates a new sprite manager from a packed sprite sheet
  76567. * @param name defines the manager's name
  76568. * @param imgUrl defines the sprite sheet url
  76569. * @param capacity defines the maximum allowed number of sprites
  76570. * @param scene defines the hosting scene
  76571. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  76572. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  76573. * @param samplingMode defines the smapling mode to use with spritesheet
  76574. * @param fromPacked set to true; do not alter
  76575. */
  76576. constructor(
  76577. /** defines the packed manager's name */
  76578. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  76579. }
  76580. }
  76581. declare module "babylonjs/Sprites/index" {
  76582. export * from "babylonjs/Sprites/sprite";
  76583. export * from "babylonjs/Sprites/ISprites";
  76584. export * from "babylonjs/Sprites/spriteManager";
  76585. export * from "babylonjs/Sprites/spriteMap";
  76586. export * from "babylonjs/Sprites/spritePackedManager";
  76587. export * from "babylonjs/Sprites/spriteSceneComponent";
  76588. }
  76589. declare module "babylonjs/States/index" {
  76590. export * from "babylonjs/States/alphaCullingState";
  76591. export * from "babylonjs/States/depthCullingState";
  76592. export * from "babylonjs/States/stencilState";
  76593. }
  76594. declare module "babylonjs/Misc/assetsManager" {
  76595. import { Scene } from "babylonjs/scene";
  76596. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  76597. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  76598. import { Skeleton } from "babylonjs/Bones/skeleton";
  76599. import { Observable } from "babylonjs/Misc/observable";
  76600. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  76601. import { Texture } from "babylonjs/Materials/Textures/texture";
  76602. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  76603. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  76604. import { EquiRectangularCubeTexture } from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  76605. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  76606. import { AssetContainer } from "babylonjs/assetContainer";
  76607. /**
  76608. * Defines the list of states available for a task inside a AssetsManager
  76609. */
  76610. export enum AssetTaskState {
  76611. /**
  76612. * Initialization
  76613. */
  76614. INIT = 0,
  76615. /**
  76616. * Running
  76617. */
  76618. RUNNING = 1,
  76619. /**
  76620. * Done
  76621. */
  76622. DONE = 2,
  76623. /**
  76624. * Error
  76625. */
  76626. ERROR = 3
  76627. }
  76628. /**
  76629. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  76630. */
  76631. export abstract class AbstractAssetTask {
  76632. /**
  76633. * Task name
  76634. */ name: string;
  76635. /**
  76636. * Callback called when the task is successful
  76637. */
  76638. onSuccess: (task: any) => void;
  76639. /**
  76640. * Callback called when the task is not successful
  76641. */
  76642. onError: (task: any, message?: string, exception?: any) => void;
  76643. /**
  76644. * Creates a new AssetsManager
  76645. * @param name defines the name of the task
  76646. */
  76647. constructor(
  76648. /**
  76649. * Task name
  76650. */ name: string);
  76651. private _isCompleted;
  76652. private _taskState;
  76653. private _errorObject;
  76654. /**
  76655. * Get if the task is completed
  76656. */
  76657. get isCompleted(): boolean;
  76658. /**
  76659. * Gets the current state of the task
  76660. */
  76661. get taskState(): AssetTaskState;
  76662. /**
  76663. * Gets the current error object (if task is in error)
  76664. */
  76665. get errorObject(): {
  76666. message?: string;
  76667. exception?: any;
  76668. };
  76669. /**
  76670. * Internal only
  76671. * @hidden
  76672. */
  76673. _setErrorObject(message?: string, exception?: any): void;
  76674. /**
  76675. * Execute the current task
  76676. * @param scene defines the scene where you want your assets to be loaded
  76677. * @param onSuccess is a callback called when the task is successfully executed
  76678. * @param onError is a callback called if an error occurs
  76679. */
  76680. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  76681. /**
  76682. * Execute the current task
  76683. * @param scene defines the scene where you want your assets to be loaded
  76684. * @param onSuccess is a callback called when the task is successfully executed
  76685. * @param onError is a callback called if an error occurs
  76686. */
  76687. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  76688. /**
  76689. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  76690. * This can be used with failed tasks that have the reason for failure fixed.
  76691. */
  76692. reset(): void;
  76693. private onErrorCallback;
  76694. private onDoneCallback;
  76695. }
  76696. /**
  76697. * Define the interface used by progress events raised during assets loading
  76698. */
  76699. export interface IAssetsProgressEvent {
  76700. /**
  76701. * Defines the number of remaining tasks to process
  76702. */
  76703. remainingCount: number;
  76704. /**
  76705. * Defines the total number of tasks
  76706. */
  76707. totalCount: number;
  76708. /**
  76709. * Defines the task that was just processed
  76710. */
  76711. task: AbstractAssetTask;
  76712. }
  76713. /**
  76714. * Class used to share progress information about assets loading
  76715. */
  76716. export class AssetsProgressEvent implements IAssetsProgressEvent {
  76717. /**
  76718. * Defines the number of remaining tasks to process
  76719. */
  76720. remainingCount: number;
  76721. /**
  76722. * Defines the total number of tasks
  76723. */
  76724. totalCount: number;
  76725. /**
  76726. * Defines the task that was just processed
  76727. */
  76728. task: AbstractAssetTask;
  76729. /**
  76730. * Creates a AssetsProgressEvent
  76731. * @param remainingCount defines the number of remaining tasks to process
  76732. * @param totalCount defines the total number of tasks
  76733. * @param task defines the task that was just processed
  76734. */
  76735. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  76736. }
  76737. /**
  76738. * Define a task used by AssetsManager to load assets into a container
  76739. */
  76740. export class ContainerAssetTask extends AbstractAssetTask {
  76741. /**
  76742. * Defines the name of the task
  76743. */
  76744. name: string;
  76745. /**
  76746. * Defines the list of mesh's names you want to load
  76747. */
  76748. meshesNames: any;
  76749. /**
  76750. * Defines the root url to use as a base to load your meshes and associated resources
  76751. */
  76752. rootUrl: string;
  76753. /**
  76754. * Defines the filename or File of the scene to load from
  76755. */
  76756. sceneFilename: string | File;
  76757. /**
  76758. * Get the loaded asset container
  76759. */
  76760. loadedContainer: AssetContainer;
  76761. /**
  76762. * Gets the list of loaded meshes
  76763. */
  76764. loadedMeshes: Array<AbstractMesh>;
  76765. /**
  76766. * Gets the list of loaded particle systems
  76767. */
  76768. loadedParticleSystems: Array<IParticleSystem>;
  76769. /**
  76770. * Gets the list of loaded skeletons
  76771. */
  76772. loadedSkeletons: Array<Skeleton>;
  76773. /**
  76774. * Gets the list of loaded animation groups
  76775. */
  76776. loadedAnimationGroups: Array<AnimationGroup>;
  76777. /**
  76778. * Callback called when the task is successful
  76779. */
  76780. onSuccess: (task: ContainerAssetTask) => void;
  76781. /**
  76782. * Callback called when the task is successful
  76783. */
  76784. onError: (task: ContainerAssetTask, message?: string, exception?: any) => void;
  76785. /**
  76786. * Creates a new ContainerAssetTask
  76787. * @param name defines the name of the task
  76788. * @param meshesNames defines the list of mesh's names you want to load
  76789. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  76790. * @param sceneFilename defines the filename or File of the scene to load from
  76791. */
  76792. constructor(
  76793. /**
  76794. * Defines the name of the task
  76795. */
  76796. name: string,
  76797. /**
  76798. * Defines the list of mesh's names you want to load
  76799. */
  76800. meshesNames: any,
  76801. /**
  76802. * Defines the root url to use as a base to load your meshes and associated resources
  76803. */
  76804. rootUrl: string,
  76805. /**
  76806. * Defines the filename or File of the scene to load from
  76807. */
  76808. sceneFilename: string | File);
  76809. /**
  76810. * Execute the current task
  76811. * @param scene defines the scene where you want your assets to be loaded
  76812. * @param onSuccess is a callback called when the task is successfully executed
  76813. * @param onError is a callback called if an error occurs
  76814. */
  76815. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  76816. }
  76817. /**
  76818. * Define a task used by AssetsManager to load meshes
  76819. */
  76820. export class MeshAssetTask extends AbstractAssetTask {
  76821. /**
  76822. * Defines the name of the task
  76823. */
  76824. name: string;
  76825. /**
  76826. * Defines the list of mesh's names you want to load
  76827. */
  76828. meshesNames: any;
  76829. /**
  76830. * Defines the root url to use as a base to load your meshes and associated resources
  76831. */
  76832. rootUrl: string;
  76833. /**
  76834. * Defines the filename or File of the scene to load from
  76835. */
  76836. sceneFilename: string | File;
  76837. /**
  76838. * Gets the list of loaded meshes
  76839. */
  76840. loadedMeshes: Array<AbstractMesh>;
  76841. /**
  76842. * Gets the list of loaded particle systems
  76843. */
  76844. loadedParticleSystems: Array<IParticleSystem>;
  76845. /**
  76846. * Gets the list of loaded skeletons
  76847. */
  76848. loadedSkeletons: Array<Skeleton>;
  76849. /**
  76850. * Gets the list of loaded animation groups
  76851. */
  76852. loadedAnimationGroups: Array<AnimationGroup>;
  76853. /**
  76854. * Callback called when the task is successful
  76855. */
  76856. onSuccess: (task: MeshAssetTask) => void;
  76857. /**
  76858. * Callback called when the task is successful
  76859. */
  76860. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  76861. /**
  76862. * Creates a new MeshAssetTask
  76863. * @param name defines the name of the task
  76864. * @param meshesNames defines the list of mesh's names you want to load
  76865. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  76866. * @param sceneFilename defines the filename or File of the scene to load from
  76867. */
  76868. constructor(
  76869. /**
  76870. * Defines the name of the task
  76871. */
  76872. name: string,
  76873. /**
  76874. * Defines the list of mesh's names you want to load
  76875. */
  76876. meshesNames: any,
  76877. /**
  76878. * Defines the root url to use as a base to load your meshes and associated resources
  76879. */
  76880. rootUrl: string,
  76881. /**
  76882. * Defines the filename or File of the scene to load from
  76883. */
  76884. sceneFilename: string | File);
  76885. /**
  76886. * Execute the current task
  76887. * @param scene defines the scene where you want your assets to be loaded
  76888. * @param onSuccess is a callback called when the task is successfully executed
  76889. * @param onError is a callback called if an error occurs
  76890. */
  76891. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  76892. }
  76893. /**
  76894. * Define a task used by AssetsManager to load text content
  76895. */
  76896. export class TextFileAssetTask extends AbstractAssetTask {
  76897. /**
  76898. * Defines the name of the task
  76899. */
  76900. name: string;
  76901. /**
  76902. * Defines the location of the file to load
  76903. */
  76904. url: string;
  76905. /**
  76906. * Gets the loaded text string
  76907. */
  76908. text: string;
  76909. /**
  76910. * Callback called when the task is successful
  76911. */
  76912. onSuccess: (task: TextFileAssetTask) => void;
  76913. /**
  76914. * Callback called when the task is successful
  76915. */
  76916. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  76917. /**
  76918. * Creates a new TextFileAssetTask object
  76919. * @param name defines the name of the task
  76920. * @param url defines the location of the file to load
  76921. */
  76922. constructor(
  76923. /**
  76924. * Defines the name of the task
  76925. */
  76926. name: string,
  76927. /**
  76928. * Defines the location of the file to load
  76929. */
  76930. url: string);
  76931. /**
  76932. * Execute the current task
  76933. * @param scene defines the scene where you want your assets to be loaded
  76934. * @param onSuccess is a callback called when the task is successfully executed
  76935. * @param onError is a callback called if an error occurs
  76936. */
  76937. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  76938. }
  76939. /**
  76940. * Define a task used by AssetsManager to load binary data
  76941. */
  76942. export class BinaryFileAssetTask extends AbstractAssetTask {
  76943. /**
  76944. * Defines the name of the task
  76945. */
  76946. name: string;
  76947. /**
  76948. * Defines the location of the file to load
  76949. */
  76950. url: string;
  76951. /**
  76952. * Gets the lodaded data (as an array buffer)
  76953. */
  76954. data: ArrayBuffer;
  76955. /**
  76956. * Callback called when the task is successful
  76957. */
  76958. onSuccess: (task: BinaryFileAssetTask) => void;
  76959. /**
  76960. * Callback called when the task is successful
  76961. */
  76962. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  76963. /**
  76964. * Creates a new BinaryFileAssetTask object
  76965. * @param name defines the name of the new task
  76966. * @param url defines the location of the file to load
  76967. */
  76968. constructor(
  76969. /**
  76970. * Defines the name of the task
  76971. */
  76972. name: string,
  76973. /**
  76974. * Defines the location of the file to load
  76975. */
  76976. url: string);
  76977. /**
  76978. * Execute the current task
  76979. * @param scene defines the scene where you want your assets to be loaded
  76980. * @param onSuccess is a callback called when the task is successfully executed
  76981. * @param onError is a callback called if an error occurs
  76982. */
  76983. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  76984. }
  76985. /**
  76986. * Define a task used by AssetsManager to load images
  76987. */
  76988. export class ImageAssetTask extends AbstractAssetTask {
  76989. /**
  76990. * Defines the name of the task
  76991. */
  76992. name: string;
  76993. /**
  76994. * Defines the location of the image to load
  76995. */
  76996. url: string;
  76997. /**
  76998. * Gets the loaded images
  76999. */
  77000. image: HTMLImageElement;
  77001. /**
  77002. * Callback called when the task is successful
  77003. */
  77004. onSuccess: (task: ImageAssetTask) => void;
  77005. /**
  77006. * Callback called when the task is successful
  77007. */
  77008. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  77009. /**
  77010. * Creates a new ImageAssetTask
  77011. * @param name defines the name of the task
  77012. * @param url defines the location of the image to load
  77013. */
  77014. constructor(
  77015. /**
  77016. * Defines the name of the task
  77017. */
  77018. name: string,
  77019. /**
  77020. * Defines the location of the image to load
  77021. */
  77022. url: string);
  77023. /**
  77024. * Execute the current task
  77025. * @param scene defines the scene where you want your assets to be loaded
  77026. * @param onSuccess is a callback called when the task is successfully executed
  77027. * @param onError is a callback called if an error occurs
  77028. */
  77029. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77030. }
  77031. /**
  77032. * Defines the interface used by texture loading tasks
  77033. */
  77034. export interface ITextureAssetTask<TEX extends BaseTexture> {
  77035. /**
  77036. * Gets the loaded texture
  77037. */
  77038. texture: TEX;
  77039. }
  77040. /**
  77041. * Define a task used by AssetsManager to load 2D textures
  77042. */
  77043. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  77044. /**
  77045. * Defines the name of the task
  77046. */
  77047. name: string;
  77048. /**
  77049. * Defines the location of the file to load
  77050. */
  77051. url: string;
  77052. /**
  77053. * Defines if mipmap should not be generated (default is false)
  77054. */
  77055. noMipmap?: boolean | undefined;
  77056. /**
  77057. * Defines if texture must be inverted on Y axis (default is true)
  77058. */
  77059. invertY: boolean;
  77060. /**
  77061. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  77062. */
  77063. samplingMode: number;
  77064. /**
  77065. * Gets the loaded texture
  77066. */
  77067. texture: Texture;
  77068. /**
  77069. * Callback called when the task is successful
  77070. */
  77071. onSuccess: (task: TextureAssetTask) => void;
  77072. /**
  77073. * Callback called when the task is successful
  77074. */
  77075. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  77076. /**
  77077. * Creates a new TextureAssetTask object
  77078. * @param name defines the name of the task
  77079. * @param url defines the location of the file to load
  77080. * @param noMipmap defines if mipmap should not be generated (default is false)
  77081. * @param invertY defines if texture must be inverted on Y axis (default is true)
  77082. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  77083. */
  77084. constructor(
  77085. /**
  77086. * Defines the name of the task
  77087. */
  77088. name: string,
  77089. /**
  77090. * Defines the location of the file to load
  77091. */
  77092. url: string,
  77093. /**
  77094. * Defines if mipmap should not be generated (default is false)
  77095. */
  77096. noMipmap?: boolean | undefined,
  77097. /**
  77098. * Defines if texture must be inverted on Y axis (default is true)
  77099. */
  77100. invertY?: boolean,
  77101. /**
  77102. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  77103. */
  77104. samplingMode?: number);
  77105. /**
  77106. * Execute the current task
  77107. * @param scene defines the scene where you want your assets to be loaded
  77108. * @param onSuccess is a callback called when the task is successfully executed
  77109. * @param onError is a callback called if an error occurs
  77110. */
  77111. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77112. }
  77113. /**
  77114. * Define a task used by AssetsManager to load cube textures
  77115. */
  77116. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  77117. /**
  77118. * Defines the name of the task
  77119. */
  77120. name: string;
  77121. /**
  77122. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  77123. */
  77124. url: string;
  77125. /**
  77126. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  77127. */
  77128. extensions?: string[] | undefined;
  77129. /**
  77130. * Defines if mipmaps should not be generated (default is false)
  77131. */
  77132. noMipmap?: boolean | undefined;
  77133. /**
  77134. * Defines the explicit list of files (undefined by default)
  77135. */
  77136. files?: string[] | undefined;
  77137. /**
  77138. * Gets the loaded texture
  77139. */
  77140. texture: CubeTexture;
  77141. /**
  77142. * Callback called when the task is successful
  77143. */
  77144. onSuccess: (task: CubeTextureAssetTask) => void;
  77145. /**
  77146. * Callback called when the task is successful
  77147. */
  77148. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  77149. /**
  77150. * Creates a new CubeTextureAssetTask
  77151. * @param name defines the name of the task
  77152. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  77153. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  77154. * @param noMipmap defines if mipmaps should not be generated (default is false)
  77155. * @param files defines the explicit list of files (undefined by default)
  77156. */
  77157. constructor(
  77158. /**
  77159. * Defines the name of the task
  77160. */
  77161. name: string,
  77162. /**
  77163. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  77164. */
  77165. url: string,
  77166. /**
  77167. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  77168. */
  77169. extensions?: string[] | undefined,
  77170. /**
  77171. * Defines if mipmaps should not be generated (default is false)
  77172. */
  77173. noMipmap?: boolean | undefined,
  77174. /**
  77175. * Defines the explicit list of files (undefined by default)
  77176. */
  77177. files?: string[] | undefined);
  77178. /**
  77179. * Execute the current task
  77180. * @param scene defines the scene where you want your assets to be loaded
  77181. * @param onSuccess is a callback called when the task is successfully executed
  77182. * @param onError is a callback called if an error occurs
  77183. */
  77184. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77185. }
  77186. /**
  77187. * Define a task used by AssetsManager to load HDR cube textures
  77188. */
  77189. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  77190. /**
  77191. * Defines the name of the task
  77192. */
  77193. name: string;
  77194. /**
  77195. * Defines the location of the file to load
  77196. */
  77197. url: string;
  77198. /**
  77199. * Defines the desired size (the more it increases the longer the generation will be)
  77200. */
  77201. size: number;
  77202. /**
  77203. * Defines if mipmaps should not be generated (default is false)
  77204. */
  77205. noMipmap: boolean;
  77206. /**
  77207. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  77208. */
  77209. generateHarmonics: boolean;
  77210. /**
  77211. * 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)
  77212. */
  77213. gammaSpace: boolean;
  77214. /**
  77215. * Internal Use Only
  77216. */
  77217. reserved: boolean;
  77218. /**
  77219. * Gets the loaded texture
  77220. */
  77221. texture: HDRCubeTexture;
  77222. /**
  77223. * Callback called when the task is successful
  77224. */
  77225. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  77226. /**
  77227. * Callback called when the task is successful
  77228. */
  77229. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  77230. /**
  77231. * Creates a new HDRCubeTextureAssetTask object
  77232. * @param name defines the name of the task
  77233. * @param url defines the location of the file to load
  77234. * @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.
  77235. * @param noMipmap defines if mipmaps should not be generated (default is false)
  77236. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  77237. * @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)
  77238. * @param reserved Internal use only
  77239. */
  77240. constructor(
  77241. /**
  77242. * Defines the name of the task
  77243. */
  77244. name: string,
  77245. /**
  77246. * Defines the location of the file to load
  77247. */
  77248. url: string,
  77249. /**
  77250. * Defines the desired size (the more it increases the longer the generation will be)
  77251. */
  77252. size: number,
  77253. /**
  77254. * Defines if mipmaps should not be generated (default is false)
  77255. */
  77256. noMipmap?: boolean,
  77257. /**
  77258. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  77259. */
  77260. generateHarmonics?: boolean,
  77261. /**
  77262. * 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)
  77263. */
  77264. gammaSpace?: boolean,
  77265. /**
  77266. * Internal Use Only
  77267. */
  77268. reserved?: boolean);
  77269. /**
  77270. * Execute the current task
  77271. * @param scene defines the scene where you want your assets to be loaded
  77272. * @param onSuccess is a callback called when the task is successfully executed
  77273. * @param onError is a callback called if an error occurs
  77274. */
  77275. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77276. }
  77277. /**
  77278. * Define a task used by AssetsManager to load Equirectangular cube textures
  77279. */
  77280. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  77281. /**
  77282. * Defines the name of the task
  77283. */
  77284. name: string;
  77285. /**
  77286. * Defines the location of the file to load
  77287. */
  77288. url: string;
  77289. /**
  77290. * Defines the desired size (the more it increases the longer the generation will be)
  77291. */
  77292. size: number;
  77293. /**
  77294. * Defines if mipmaps should not be generated (default is false)
  77295. */
  77296. noMipmap: boolean;
  77297. /**
  77298. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  77299. * but the standard material would require them in Gamma space) (default is true)
  77300. */
  77301. gammaSpace: boolean;
  77302. /**
  77303. * Gets the loaded texture
  77304. */
  77305. texture: EquiRectangularCubeTexture;
  77306. /**
  77307. * Callback called when the task is successful
  77308. */
  77309. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  77310. /**
  77311. * Callback called when the task is successful
  77312. */
  77313. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  77314. /**
  77315. * Creates a new EquiRectangularCubeTextureAssetTask object
  77316. * @param name defines the name of the task
  77317. * @param url defines the location of the file to load
  77318. * @param size defines the desired size (the more it increases the longer the generation will be)
  77319. * If the size is omitted this implies you are using a preprocessed cubemap.
  77320. * @param noMipmap defines if mipmaps should not be generated (default is false)
  77321. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  77322. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  77323. * (default is true)
  77324. */
  77325. constructor(
  77326. /**
  77327. * Defines the name of the task
  77328. */
  77329. name: string,
  77330. /**
  77331. * Defines the location of the file to load
  77332. */
  77333. url: string,
  77334. /**
  77335. * Defines the desired size (the more it increases the longer the generation will be)
  77336. */
  77337. size: number,
  77338. /**
  77339. * Defines if mipmaps should not be generated (default is false)
  77340. */
  77341. noMipmap?: boolean,
  77342. /**
  77343. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  77344. * but the standard material would require them in Gamma space) (default is true)
  77345. */
  77346. gammaSpace?: boolean);
  77347. /**
  77348. * Execute the current task
  77349. * @param scene defines the scene where you want your assets to be loaded
  77350. * @param onSuccess is a callback called when the task is successfully executed
  77351. * @param onError is a callback called if an error occurs
  77352. */
  77353. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77354. }
  77355. /**
  77356. * This class can be used to easily import assets into a scene
  77357. * @see https://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  77358. */
  77359. export class AssetsManager {
  77360. private _scene;
  77361. private _isLoading;
  77362. protected _tasks: AbstractAssetTask[];
  77363. protected _waitingTasksCount: number;
  77364. protected _totalTasksCount: number;
  77365. /**
  77366. * Callback called when all tasks are processed
  77367. */
  77368. onFinish: (tasks: AbstractAssetTask[]) => void;
  77369. /**
  77370. * Callback called when a task is successful
  77371. */
  77372. onTaskSuccess: (task: AbstractAssetTask) => void;
  77373. /**
  77374. * Callback called when a task had an error
  77375. */
  77376. onTaskError: (task: AbstractAssetTask) => void;
  77377. /**
  77378. * Callback called when a task is done (whatever the result is)
  77379. */
  77380. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  77381. /**
  77382. * Observable called when all tasks are processed
  77383. */
  77384. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  77385. /**
  77386. * Observable called when a task had an error
  77387. */
  77388. onTaskErrorObservable: Observable<AbstractAssetTask>;
  77389. /**
  77390. * Observable called when all tasks were executed
  77391. */
  77392. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  77393. /**
  77394. * Observable called when a task is done (whatever the result is)
  77395. */
  77396. onProgressObservable: Observable<IAssetsProgressEvent>;
  77397. /**
  77398. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  77399. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  77400. */
  77401. useDefaultLoadingScreen: boolean;
  77402. /**
  77403. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  77404. * when all assets have been downloaded.
  77405. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  77406. */
  77407. autoHideLoadingUI: boolean;
  77408. /**
  77409. * Creates a new AssetsManager
  77410. * @param scene defines the scene to work on
  77411. */
  77412. constructor(scene: Scene);
  77413. /**
  77414. * Add a ContainerAssetTask to the list of active tasks
  77415. * @param taskName defines the name of the new task
  77416. * @param meshesNames defines the name of meshes to load
  77417. * @param rootUrl defines the root url to use to locate files
  77418. * @param sceneFilename defines the filename of the scene file
  77419. * @returns a new ContainerAssetTask object
  77420. */
  77421. addContainerTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): ContainerAssetTask;
  77422. /**
  77423. * Add a MeshAssetTask to the list of active tasks
  77424. * @param taskName defines the name of the new task
  77425. * @param meshesNames defines the name of meshes to load
  77426. * @param rootUrl defines the root url to use to locate files
  77427. * @param sceneFilename defines the filename of the scene file
  77428. * @returns a new MeshAssetTask object
  77429. */
  77430. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  77431. /**
  77432. * Add a TextFileAssetTask to the list of active tasks
  77433. * @param taskName defines the name of the new task
  77434. * @param url defines the url of the file to load
  77435. * @returns a new TextFileAssetTask object
  77436. */
  77437. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  77438. /**
  77439. * Add a BinaryFileAssetTask to the list of active tasks
  77440. * @param taskName defines the name of the new task
  77441. * @param url defines the url of the file to load
  77442. * @returns a new BinaryFileAssetTask object
  77443. */
  77444. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  77445. /**
  77446. * Add a ImageAssetTask to the list of active tasks
  77447. * @param taskName defines the name of the new task
  77448. * @param url defines the url of the file to load
  77449. * @returns a new ImageAssetTask object
  77450. */
  77451. addImageTask(taskName: string, url: string): ImageAssetTask;
  77452. /**
  77453. * Add a TextureAssetTask to the list of active tasks
  77454. * @param taskName defines the name of the new task
  77455. * @param url defines the url of the file to load
  77456. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  77457. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  77458. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  77459. * @returns a new TextureAssetTask object
  77460. */
  77461. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  77462. /**
  77463. * Add a CubeTextureAssetTask to the list of active tasks
  77464. * @param taskName defines the name of the new task
  77465. * @param url defines the url of the file to load
  77466. * @param extensions defines the extension to use to load the cube map (can be null)
  77467. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  77468. * @param files defines the list of files to load (can be null)
  77469. * @returns a new CubeTextureAssetTask object
  77470. */
  77471. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  77472. /**
  77473. *
  77474. * Add a HDRCubeTextureAssetTask to the list of active tasks
  77475. * @param taskName defines the name of the new task
  77476. * @param url defines the url of the file to load
  77477. * @param size defines the size you want for the cubemap (can be null)
  77478. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  77479. * @param generateHarmonics defines if you want to automatically generate (true by default)
  77480. * @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)
  77481. * @param reserved Internal use only
  77482. * @returns a new HDRCubeTextureAssetTask object
  77483. */
  77484. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  77485. /**
  77486. *
  77487. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  77488. * @param taskName defines the name of the new task
  77489. * @param url defines the url of the file to load
  77490. * @param size defines the size you want for the cubemap (can be null)
  77491. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  77492. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  77493. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  77494. * @returns a new EquiRectangularCubeTextureAssetTask object
  77495. */
  77496. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  77497. /**
  77498. * Remove a task from the assets manager.
  77499. * @param task the task to remove
  77500. */
  77501. removeTask(task: AbstractAssetTask): void;
  77502. private _decreaseWaitingTasksCount;
  77503. private _runTask;
  77504. /**
  77505. * Reset the AssetsManager and remove all tasks
  77506. * @return the current instance of the AssetsManager
  77507. */
  77508. reset(): AssetsManager;
  77509. /**
  77510. * Start the loading process
  77511. * @return the current instance of the AssetsManager
  77512. */
  77513. load(): AssetsManager;
  77514. /**
  77515. * Start the loading process as an async operation
  77516. * @return a promise returning the list of failed tasks
  77517. */
  77518. loadAsync(): Promise<void>;
  77519. }
  77520. }
  77521. declare module "babylonjs/Misc/deferred" {
  77522. /**
  77523. * Wrapper class for promise with external resolve and reject.
  77524. */
  77525. export class Deferred<T> {
  77526. /**
  77527. * The promise associated with this deferred object.
  77528. */
  77529. readonly promise: Promise<T>;
  77530. private _resolve;
  77531. private _reject;
  77532. /**
  77533. * The resolve method of the promise associated with this deferred object.
  77534. */
  77535. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  77536. /**
  77537. * The reject method of the promise associated with this deferred object.
  77538. */
  77539. get reject(): (reason?: any) => void;
  77540. /**
  77541. * Constructor for this deferred object.
  77542. */
  77543. constructor();
  77544. }
  77545. }
  77546. declare module "babylonjs/Misc/meshExploder" {
  77547. import { Mesh } from "babylonjs/Meshes/mesh";
  77548. /**
  77549. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  77550. */
  77551. export class MeshExploder {
  77552. private _centerMesh;
  77553. private _meshes;
  77554. private _meshesOrigins;
  77555. private _toCenterVectors;
  77556. private _scaledDirection;
  77557. private _newPosition;
  77558. private _centerPosition;
  77559. /**
  77560. * Explodes meshes from a center mesh.
  77561. * @param meshes The meshes to explode.
  77562. * @param centerMesh The mesh to be center of explosion.
  77563. */
  77564. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  77565. private _setCenterMesh;
  77566. /**
  77567. * Get class name
  77568. * @returns "MeshExploder"
  77569. */
  77570. getClassName(): string;
  77571. /**
  77572. * "Exploded meshes"
  77573. * @returns Array of meshes with the centerMesh at index 0.
  77574. */
  77575. getMeshes(): Array<Mesh>;
  77576. /**
  77577. * Explodes meshes giving a specific direction
  77578. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  77579. */
  77580. explode(direction?: number): void;
  77581. }
  77582. }
  77583. declare module "babylonjs/Misc/filesInput" {
  77584. import { Engine } from "babylonjs/Engines/engine";
  77585. import { Scene } from "babylonjs/scene";
  77586. import { ISceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  77587. import { Nullable } from "babylonjs/types";
  77588. /**
  77589. * Class used to help managing file picking and drag'n'drop
  77590. */
  77591. export class FilesInput {
  77592. /**
  77593. * List of files ready to be loaded
  77594. */
  77595. static get FilesToLoad(): {
  77596. [key: string]: File;
  77597. };
  77598. /**
  77599. * Callback called when a file is processed
  77600. */
  77601. onProcessFileCallback: (file: File, name: string, extension: string) => boolean;
  77602. private _engine;
  77603. private _currentScene;
  77604. private _sceneLoadedCallback;
  77605. private _progressCallback;
  77606. private _additionalRenderLoopLogicCallback;
  77607. private _textureLoadingCallback;
  77608. private _startingProcessingFilesCallback;
  77609. private _onReloadCallback;
  77610. private _errorCallback;
  77611. private _elementToMonitor;
  77612. private _sceneFileToLoad;
  77613. private _filesToLoad;
  77614. /**
  77615. * Creates a new FilesInput
  77616. * @param engine defines the rendering engine
  77617. * @param scene defines the hosting scene
  77618. * @param sceneLoadedCallback callback called when scene is loaded
  77619. * @param progressCallback callback called to track progress
  77620. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  77621. * @param textureLoadingCallback callback called when a texture is loading
  77622. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  77623. * @param onReloadCallback callback called when a reload is requested
  77624. * @param errorCallback callback call if an error occurs
  77625. */
  77626. 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>);
  77627. private _dragEnterHandler;
  77628. private _dragOverHandler;
  77629. private _dropHandler;
  77630. /**
  77631. * Calls this function to listen to drag'n'drop events on a specific DOM element
  77632. * @param elementToMonitor defines the DOM element to track
  77633. */
  77634. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  77635. /** Gets the current list of files to load */
  77636. get filesToLoad(): File[];
  77637. /**
  77638. * Release all associated resources
  77639. */
  77640. dispose(): void;
  77641. private renderFunction;
  77642. private drag;
  77643. private drop;
  77644. private _traverseFolder;
  77645. private _processFiles;
  77646. /**
  77647. * Load files from a drop event
  77648. * @param event defines the drop event to use as source
  77649. */
  77650. loadFiles(event: any): void;
  77651. private _processReload;
  77652. /**
  77653. * Reload the current scene from the loaded files
  77654. */
  77655. reload(): void;
  77656. }
  77657. }
  77658. declare module "babylonjs/Misc/HighDynamicRange/index" {
  77659. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  77660. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  77661. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  77662. }
  77663. declare module "babylonjs/Misc/sceneOptimizer" {
  77664. import { Scene, IDisposable } from "babylonjs/scene";
  77665. import { Observable } from "babylonjs/Misc/observable";
  77666. /**
  77667. * Defines the root class used to create scene optimization to use with SceneOptimizer
  77668. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  77669. */
  77670. export class SceneOptimization {
  77671. /**
  77672. * Defines the priority of this optimization (0 by default which means first in the list)
  77673. */
  77674. priority: number;
  77675. /**
  77676. * Gets a string describing the action executed by the current optimization
  77677. * @returns description string
  77678. */
  77679. getDescription(): string;
  77680. /**
  77681. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  77682. * @param scene defines the current scene where to apply this optimization
  77683. * @param optimizer defines the current optimizer
  77684. * @returns true if everything that can be done was applied
  77685. */
  77686. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  77687. /**
  77688. * Creates the SceneOptimization object
  77689. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  77690. * @param desc defines the description associated with the optimization
  77691. */
  77692. constructor(
  77693. /**
  77694. * Defines the priority of this optimization (0 by default which means first in the list)
  77695. */
  77696. priority?: number);
  77697. }
  77698. /**
  77699. * Defines an optimization used to reduce the size of render target textures
  77700. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  77701. */
  77702. export class TextureOptimization extends SceneOptimization {
  77703. /**
  77704. * Defines the priority of this optimization (0 by default which means first in the list)
  77705. */
  77706. priority: number;
  77707. /**
  77708. * 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
  77709. */
  77710. maximumSize: number;
  77711. /**
  77712. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  77713. */
  77714. step: number;
  77715. /**
  77716. * Gets a string describing the action executed by the current optimization
  77717. * @returns description string
  77718. */
  77719. getDescription(): string;
  77720. /**
  77721. * Creates the TextureOptimization object
  77722. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  77723. * @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
  77724. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  77725. */
  77726. constructor(
  77727. /**
  77728. * Defines the priority of this optimization (0 by default which means first in the list)
  77729. */
  77730. priority?: number,
  77731. /**
  77732. * 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
  77733. */
  77734. maximumSize?: number,
  77735. /**
  77736. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  77737. */
  77738. step?: number);
  77739. /**
  77740. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  77741. * @param scene defines the current scene where to apply this optimization
  77742. * @param optimizer defines the current optimizer
  77743. * @returns true if everything that can be done was applied
  77744. */
  77745. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  77746. }
  77747. /**
  77748. * Defines an optimization used to increase or decrease the rendering resolution
  77749. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  77750. */
  77751. export class HardwareScalingOptimization extends SceneOptimization {
  77752. /**
  77753. * Defines the priority of this optimization (0 by default which means first in the list)
  77754. */
  77755. priority: number;
  77756. /**
  77757. * Defines the maximum scale to use (2 by default)
  77758. */
  77759. maximumScale: number;
  77760. /**
  77761. * Defines the step to use between two passes (0.5 by default)
  77762. */
  77763. step: number;
  77764. private _currentScale;
  77765. private _directionOffset;
  77766. /**
  77767. * Gets a string describing the action executed by the current optimization
  77768. * @return description string
  77769. */
  77770. getDescription(): string;
  77771. /**
  77772. * Creates the HardwareScalingOptimization object
  77773. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  77774. * @param maximumScale defines the maximum scale to use (2 by default)
  77775. * @param step defines the step to use between two passes (0.5 by default)
  77776. */
  77777. constructor(
  77778. /**
  77779. * Defines the priority of this optimization (0 by default which means first in the list)
  77780. */
  77781. priority?: number,
  77782. /**
  77783. * Defines the maximum scale to use (2 by default)
  77784. */
  77785. maximumScale?: number,
  77786. /**
  77787. * Defines the step to use between two passes (0.5 by default)
  77788. */
  77789. step?: number);
  77790. /**
  77791. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  77792. * @param scene defines the current scene where to apply this optimization
  77793. * @param optimizer defines the current optimizer
  77794. * @returns true if everything that can be done was applied
  77795. */
  77796. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  77797. }
  77798. /**
  77799. * Defines an optimization used to remove shadows
  77800. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  77801. */
  77802. export class ShadowsOptimization extends SceneOptimization {
  77803. /**
  77804. * Gets a string describing the action executed by the current optimization
  77805. * @return description string
  77806. */
  77807. getDescription(): string;
  77808. /**
  77809. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  77810. * @param scene defines the current scene where to apply this optimization
  77811. * @param optimizer defines the current optimizer
  77812. * @returns true if everything that can be done was applied
  77813. */
  77814. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  77815. }
  77816. /**
  77817. * Defines an optimization used to turn post-processes off
  77818. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  77819. */
  77820. export class PostProcessesOptimization extends SceneOptimization {
  77821. /**
  77822. * Gets a string describing the action executed by the current optimization
  77823. * @return description string
  77824. */
  77825. getDescription(): string;
  77826. /**
  77827. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  77828. * @param scene defines the current scene where to apply this optimization
  77829. * @param optimizer defines the current optimizer
  77830. * @returns true if everything that can be done was applied
  77831. */
  77832. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  77833. }
  77834. /**
  77835. * Defines an optimization used to turn lens flares off
  77836. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  77837. */
  77838. export class LensFlaresOptimization extends SceneOptimization {
  77839. /**
  77840. * Gets a string describing the action executed by the current optimization
  77841. * @return description string
  77842. */
  77843. getDescription(): string;
  77844. /**
  77845. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  77846. * @param scene defines the current scene where to apply this optimization
  77847. * @param optimizer defines the current optimizer
  77848. * @returns true if everything that can be done was applied
  77849. */
  77850. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  77851. }
  77852. /**
  77853. * Defines an optimization based on user defined callback.
  77854. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  77855. */
  77856. export class CustomOptimization extends SceneOptimization {
  77857. /**
  77858. * Callback called to apply the custom optimization.
  77859. */
  77860. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  77861. /**
  77862. * Callback called to get custom description
  77863. */
  77864. onGetDescription: () => string;
  77865. /**
  77866. * Gets a string describing the action executed by the current optimization
  77867. * @returns description string
  77868. */
  77869. getDescription(): string;
  77870. /**
  77871. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  77872. * @param scene defines the current scene where to apply this optimization
  77873. * @param optimizer defines the current optimizer
  77874. * @returns true if everything that can be done was applied
  77875. */
  77876. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  77877. }
  77878. /**
  77879. * Defines an optimization used to turn particles off
  77880. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  77881. */
  77882. export class ParticlesOptimization extends SceneOptimization {
  77883. /**
  77884. * Gets a string describing the action executed by the current optimization
  77885. * @return description string
  77886. */
  77887. getDescription(): string;
  77888. /**
  77889. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  77890. * @param scene defines the current scene where to apply this optimization
  77891. * @param optimizer defines the current optimizer
  77892. * @returns true if everything that can be done was applied
  77893. */
  77894. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  77895. }
  77896. /**
  77897. * Defines an optimization used to turn render targets off
  77898. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  77899. */
  77900. export class RenderTargetsOptimization extends SceneOptimization {
  77901. /**
  77902. * Gets a string describing the action executed by the current optimization
  77903. * @return description string
  77904. */
  77905. getDescription(): string;
  77906. /**
  77907. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  77908. * @param scene defines the current scene where to apply this optimization
  77909. * @param optimizer defines the current optimizer
  77910. * @returns true if everything that can be done was applied
  77911. */
  77912. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  77913. }
  77914. /**
  77915. * Defines an optimization used to merge meshes with compatible materials
  77916. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  77917. */
  77918. export class MergeMeshesOptimization extends SceneOptimization {
  77919. private static _UpdateSelectionTree;
  77920. /**
  77921. * Gets or sets a boolean which defines if optimization octree has to be updated
  77922. */
  77923. static get UpdateSelectionTree(): boolean;
  77924. /**
  77925. * Gets or sets a boolean which defines if optimization octree has to be updated
  77926. */
  77927. static set UpdateSelectionTree(value: boolean);
  77928. /**
  77929. * Gets a string describing the action executed by the current optimization
  77930. * @return description string
  77931. */
  77932. getDescription(): string;
  77933. private _canBeMerged;
  77934. /**
  77935. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  77936. * @param scene defines the current scene where to apply this optimization
  77937. * @param optimizer defines the current optimizer
  77938. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  77939. * @returns true if everything that can be done was applied
  77940. */
  77941. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  77942. }
  77943. /**
  77944. * Defines a list of options used by SceneOptimizer
  77945. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  77946. */
  77947. export class SceneOptimizerOptions {
  77948. /**
  77949. * Defines the target frame rate to reach (60 by default)
  77950. */
  77951. targetFrameRate: number;
  77952. /**
  77953. * Defines the interval between two checkes (2000ms by default)
  77954. */
  77955. trackerDuration: number;
  77956. /**
  77957. * Gets the list of optimizations to apply
  77958. */
  77959. optimizations: SceneOptimization[];
  77960. /**
  77961. * Creates a new list of options used by SceneOptimizer
  77962. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  77963. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  77964. */
  77965. constructor(
  77966. /**
  77967. * Defines the target frame rate to reach (60 by default)
  77968. */
  77969. targetFrameRate?: number,
  77970. /**
  77971. * Defines the interval between two checkes (2000ms by default)
  77972. */
  77973. trackerDuration?: number);
  77974. /**
  77975. * Add a new optimization
  77976. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  77977. * @returns the current SceneOptimizerOptions
  77978. */
  77979. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  77980. /**
  77981. * Add a new custom optimization
  77982. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  77983. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  77984. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  77985. * @returns the current SceneOptimizerOptions
  77986. */
  77987. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  77988. /**
  77989. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  77990. * @param targetFrameRate defines the target frame rate (60 by default)
  77991. * @returns a SceneOptimizerOptions object
  77992. */
  77993. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  77994. /**
  77995. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  77996. * @param targetFrameRate defines the target frame rate (60 by default)
  77997. * @returns a SceneOptimizerOptions object
  77998. */
  77999. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  78000. /**
  78001. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  78002. * @param targetFrameRate defines the target frame rate (60 by default)
  78003. * @returns a SceneOptimizerOptions object
  78004. */
  78005. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  78006. }
  78007. /**
  78008. * Class used to run optimizations in order to reach a target frame rate
  78009. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78010. */
  78011. export class SceneOptimizer implements IDisposable {
  78012. private _isRunning;
  78013. private _options;
  78014. private _scene;
  78015. private _currentPriorityLevel;
  78016. private _targetFrameRate;
  78017. private _trackerDuration;
  78018. private _currentFrameRate;
  78019. private _sceneDisposeObserver;
  78020. private _improvementMode;
  78021. /**
  78022. * Defines an observable called when the optimizer reaches the target frame rate
  78023. */
  78024. onSuccessObservable: Observable<SceneOptimizer>;
  78025. /**
  78026. * Defines an observable called when the optimizer enables an optimization
  78027. */
  78028. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  78029. /**
  78030. * Defines an observable called when the optimizer is not able to reach the target frame rate
  78031. */
  78032. onFailureObservable: Observable<SceneOptimizer>;
  78033. /**
  78034. * Gets a boolean indicating if the optimizer is in improvement mode
  78035. */
  78036. get isInImprovementMode(): boolean;
  78037. /**
  78038. * Gets the current priority level (0 at start)
  78039. */
  78040. get currentPriorityLevel(): number;
  78041. /**
  78042. * Gets the current frame rate checked by the SceneOptimizer
  78043. */
  78044. get currentFrameRate(): number;
  78045. /**
  78046. * Gets or sets the current target frame rate (60 by default)
  78047. */
  78048. get targetFrameRate(): number;
  78049. /**
  78050. * Gets or sets the current target frame rate (60 by default)
  78051. */
  78052. set targetFrameRate(value: number);
  78053. /**
  78054. * Gets or sets the current interval between two checks (every 2000ms by default)
  78055. */
  78056. get trackerDuration(): number;
  78057. /**
  78058. * Gets or sets the current interval between two checks (every 2000ms by default)
  78059. */
  78060. set trackerDuration(value: number);
  78061. /**
  78062. * Gets the list of active optimizations
  78063. */
  78064. get optimizations(): SceneOptimization[];
  78065. /**
  78066. * Creates a new SceneOptimizer
  78067. * @param scene defines the scene to work on
  78068. * @param options defines the options to use with the SceneOptimizer
  78069. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  78070. * @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)
  78071. */
  78072. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  78073. /**
  78074. * Stops the current optimizer
  78075. */
  78076. stop(): void;
  78077. /**
  78078. * Reset the optimizer to initial step (current priority level = 0)
  78079. */
  78080. reset(): void;
  78081. /**
  78082. * Start the optimizer. By default it will try to reach a specific framerate
  78083. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  78084. */
  78085. start(): void;
  78086. private _checkCurrentState;
  78087. /**
  78088. * Release all resources
  78089. */
  78090. dispose(): void;
  78091. /**
  78092. * Helper function to create a SceneOptimizer with one single line of code
  78093. * @param scene defines the scene to work on
  78094. * @param options defines the options to use with the SceneOptimizer
  78095. * @param onSuccess defines a callback to call on success
  78096. * @param onFailure defines a callback to call on failure
  78097. * @returns the new SceneOptimizer object
  78098. */
  78099. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  78100. }
  78101. }
  78102. declare module "babylonjs/Misc/sceneSerializer" {
  78103. import { Scene } from "babylonjs/scene";
  78104. /**
  78105. * Class used to serialize a scene into a string
  78106. */
  78107. export class SceneSerializer {
  78108. /**
  78109. * Clear cache used by a previous serialization
  78110. */
  78111. static ClearCache(): void;
  78112. /**
  78113. * Serialize a scene into a JSON compatible object
  78114. * @param scene defines the scene to serialize
  78115. * @returns a JSON compatible object
  78116. */
  78117. static Serialize(scene: Scene): any;
  78118. /**
  78119. * Serialize a mesh into a JSON compatible object
  78120. * @param toSerialize defines the mesh to serialize
  78121. * @param withParents defines if parents must be serialized as well
  78122. * @param withChildren defines if children must be serialized as well
  78123. * @returns a JSON compatible object
  78124. */
  78125. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  78126. }
  78127. }
  78128. declare module "babylonjs/Misc/textureTools" {
  78129. import { Texture } from "babylonjs/Materials/Textures/texture";
  78130. /**
  78131. * Class used to host texture specific utilities
  78132. */
  78133. export class TextureTools {
  78134. /**
  78135. * Uses the GPU to create a copy texture rescaled at a given size
  78136. * @param texture Texture to copy from
  78137. * @param width defines the desired width
  78138. * @param height defines the desired height
  78139. * @param useBilinearMode defines if bilinear mode has to be used
  78140. * @return the generated texture
  78141. */
  78142. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  78143. }
  78144. }
  78145. declare module "babylonjs/Misc/videoRecorder" {
  78146. import { Nullable } from "babylonjs/types";
  78147. import { Engine } from "babylonjs/Engines/engine";
  78148. /**
  78149. * This represents the different options available for the video capture.
  78150. */
  78151. export interface VideoRecorderOptions {
  78152. /** Defines the mime type of the video. */
  78153. mimeType: string;
  78154. /** Defines the FPS the video should be recorded at. */
  78155. fps: number;
  78156. /** Defines the chunk size for the recording data. */
  78157. recordChunckSize: number;
  78158. /** The audio tracks to attach to the recording. */
  78159. audioTracks?: MediaStreamTrack[];
  78160. }
  78161. /**
  78162. * This can help with recording videos from BabylonJS.
  78163. * This is based on the available WebRTC functionalities of the browser.
  78164. *
  78165. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_video
  78166. */
  78167. export class VideoRecorder {
  78168. private static readonly _defaultOptions;
  78169. /**
  78170. * Returns whether or not the VideoRecorder is available in your browser.
  78171. * @param engine Defines the Babylon Engine.
  78172. * @returns true if supported otherwise false.
  78173. */
  78174. static IsSupported(engine: Engine): boolean;
  78175. private readonly _options;
  78176. private _canvas;
  78177. private _mediaRecorder;
  78178. private _recordedChunks;
  78179. private _fileName;
  78180. private _resolve;
  78181. private _reject;
  78182. /**
  78183. * True when a recording is already in progress.
  78184. */
  78185. get isRecording(): boolean;
  78186. /**
  78187. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  78188. * @param engine Defines the BabylonJS Engine you wish to record.
  78189. * @param options Defines options that can be used to customize the capture.
  78190. */
  78191. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  78192. /**
  78193. * Stops the current recording before the default capture timeout passed in the startRecording function.
  78194. */
  78195. stopRecording(): void;
  78196. /**
  78197. * Starts recording the canvas for a max duration specified in parameters.
  78198. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  78199. * If null no automatic download will start and you can rely on the promise to get the data back.
  78200. * @param maxDuration Defines the maximum recording time in seconds.
  78201. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  78202. * @return A promise callback at the end of the recording with the video data in Blob.
  78203. */
  78204. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  78205. /**
  78206. * Releases internal resources used during the recording.
  78207. */
  78208. dispose(): void;
  78209. private _handleDataAvailable;
  78210. private _handleError;
  78211. private _handleStop;
  78212. }
  78213. }
  78214. declare module "babylonjs/Misc/screenshotTools" {
  78215. import { Camera } from "babylonjs/Cameras/camera";
  78216. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  78217. import { Engine } from "babylonjs/Engines/engine";
  78218. /**
  78219. * Class containing a set of static utilities functions for screenshots
  78220. */
  78221. export class ScreenshotTools {
  78222. /**
  78223. * Captures a screenshot of the current rendering
  78224. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  78225. * @param engine defines the rendering engine
  78226. * @param camera defines the source camera
  78227. * @param size This parameter can be set to a single number or to an object with the
  78228. * following (optional) properties: precision, width, height. If a single number is passed,
  78229. * it will be used for both width and height. If an object is passed, the screenshot size
  78230. * will be derived from the parameters. The precision property is a multiplier allowing
  78231. * rendering at a higher or lower resolution
  78232. * @param successCallback defines the callback receives a single parameter which contains the
  78233. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  78234. * src parameter of an <img> to display it
  78235. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  78236. * Check your browser for supported MIME types
  78237. */
  78238. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  78239. /**
  78240. * Captures a screenshot of the current rendering
  78241. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  78242. * @param engine defines the rendering engine
  78243. * @param camera defines the source camera
  78244. * @param size This parameter can be set to a single number or to an object with the
  78245. * following (optional) properties: precision, width, height. If a single number is passed,
  78246. * it will be used for both width and height. If an object is passed, the screenshot size
  78247. * will be derived from the parameters. The precision property is a multiplier allowing
  78248. * rendering at a higher or lower resolution
  78249. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  78250. * Check your browser for supported MIME types
  78251. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  78252. * to the src parameter of an <img> to display it
  78253. */
  78254. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  78255. /**
  78256. * Generates an image screenshot from the specified camera.
  78257. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  78258. * @param engine The engine to use for rendering
  78259. * @param camera The camera to use for rendering
  78260. * @param size This parameter can be set to a single number or to an object with the
  78261. * following (optional) properties: precision, width, height. If a single number is passed,
  78262. * it will be used for both width and height. If an object is passed, the screenshot size
  78263. * will be derived from the parameters. The precision property is a multiplier allowing
  78264. * rendering at a higher or lower resolution
  78265. * @param successCallback The callback receives a single parameter which contains the
  78266. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  78267. * src parameter of an <img> to display it
  78268. * @param mimeType The MIME type of the screenshot image (default: image/png).
  78269. * Check your browser for supported MIME types
  78270. * @param samples Texture samples (default: 1)
  78271. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  78272. * @param fileName A name for for the downloaded file.
  78273. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  78274. * @param enableStencilBuffer Whether the stencil buffer should be enabled or not (default: false)
  78275. */
  78276. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean, enableStencilBuffer?: boolean): void;
  78277. /**
  78278. * Generates an image screenshot from the specified camera.
  78279. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  78280. * @param engine The engine to use for rendering
  78281. * @param camera The camera to use for rendering
  78282. * @param size This parameter can be set to a single number or to an object with the
  78283. * following (optional) properties: precision, width, height. If a single number is passed,
  78284. * it will be used for both width and height. If an object is passed, the screenshot size
  78285. * will be derived from the parameters. The precision property is a multiplier allowing
  78286. * rendering at a higher or lower resolution
  78287. * @param mimeType The MIME type of the screenshot image (default: image/png).
  78288. * Check your browser for supported MIME types
  78289. * @param samples Texture samples (default: 1)
  78290. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  78291. * @param fileName A name for for the downloaded file.
  78292. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  78293. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  78294. * to the src parameter of an <img> to display it
  78295. */
  78296. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  78297. /**
  78298. * Gets height and width for screenshot size
  78299. * @private
  78300. */
  78301. private static _getScreenshotSize;
  78302. }
  78303. }
  78304. declare module "babylonjs/Misc/dataReader" {
  78305. /**
  78306. * Interface for a data buffer
  78307. */
  78308. export interface IDataBuffer {
  78309. /**
  78310. * Reads bytes from the data buffer.
  78311. * @param byteOffset The byte offset to read
  78312. * @param byteLength The byte length to read
  78313. * @returns A promise that resolves when the bytes are read
  78314. */
  78315. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  78316. /**
  78317. * The byte length of the buffer.
  78318. */
  78319. readonly byteLength: number;
  78320. }
  78321. /**
  78322. * Utility class for reading from a data buffer
  78323. */
  78324. export class DataReader {
  78325. /**
  78326. * The data buffer associated with this data reader.
  78327. */
  78328. readonly buffer: IDataBuffer;
  78329. /**
  78330. * The current byte offset from the beginning of the data buffer.
  78331. */
  78332. byteOffset: number;
  78333. private _dataView;
  78334. private _dataByteOffset;
  78335. /**
  78336. * Constructor
  78337. * @param buffer The buffer to read
  78338. */
  78339. constructor(buffer: IDataBuffer);
  78340. /**
  78341. * Loads the given byte length.
  78342. * @param byteLength The byte length to load
  78343. * @returns A promise that resolves when the load is complete
  78344. */
  78345. loadAsync(byteLength: number): Promise<void>;
  78346. /**
  78347. * Read a unsigned 32-bit integer from the currently loaded data range.
  78348. * @returns The 32-bit integer read
  78349. */
  78350. readUint32(): number;
  78351. /**
  78352. * Read a byte array from the currently loaded data range.
  78353. * @param byteLength The byte length to read
  78354. * @returns The byte array read
  78355. */
  78356. readUint8Array(byteLength: number): Uint8Array;
  78357. /**
  78358. * Read a string from the currently loaded data range.
  78359. * @param byteLength The byte length to read
  78360. * @returns The string read
  78361. */
  78362. readString(byteLength: number): string;
  78363. /**
  78364. * Skips the given byte length the currently loaded data range.
  78365. * @param byteLength The byte length to skip
  78366. */
  78367. skipBytes(byteLength: number): void;
  78368. }
  78369. }
  78370. declare module "babylonjs/Misc/dataStorage" {
  78371. /**
  78372. * Class for storing data to local storage if available or in-memory storage otherwise
  78373. */
  78374. export class DataStorage {
  78375. private static _Storage;
  78376. private static _GetStorage;
  78377. /**
  78378. * Reads a string from the data storage
  78379. * @param key The key to read
  78380. * @param defaultValue The value if the key doesn't exist
  78381. * @returns The string value
  78382. */
  78383. static ReadString(key: string, defaultValue: string): string;
  78384. /**
  78385. * Writes a string to the data storage
  78386. * @param key The key to write
  78387. * @param value The value to write
  78388. */
  78389. static WriteString(key: string, value: string): void;
  78390. /**
  78391. * Reads a boolean from the data storage
  78392. * @param key The key to read
  78393. * @param defaultValue The value if the key doesn't exist
  78394. * @returns The boolean value
  78395. */
  78396. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  78397. /**
  78398. * Writes a boolean to the data storage
  78399. * @param key The key to write
  78400. * @param value The value to write
  78401. */
  78402. static WriteBoolean(key: string, value: boolean): void;
  78403. /**
  78404. * Reads a number from the data storage
  78405. * @param key The key to read
  78406. * @param defaultValue The value if the key doesn't exist
  78407. * @returns The number value
  78408. */
  78409. static ReadNumber(key: string, defaultValue: number): number;
  78410. /**
  78411. * Writes a number to the data storage
  78412. * @param key The key to write
  78413. * @param value The value to write
  78414. */
  78415. static WriteNumber(key: string, value: number): void;
  78416. }
  78417. }
  78418. declare module "babylonjs/Misc/sceneRecorder" {
  78419. import { Scene } from "babylonjs/scene";
  78420. /**
  78421. * Class used to record delta files between 2 scene states
  78422. */
  78423. export class SceneRecorder {
  78424. private _trackedScene;
  78425. private _savedJSON;
  78426. /**
  78427. * Track a given scene. This means the current scene state will be considered the original state
  78428. * @param scene defines the scene to track
  78429. */
  78430. track(scene: Scene): void;
  78431. /**
  78432. * Get the delta between current state and original state
  78433. * @returns a string containing the delta
  78434. */
  78435. getDelta(): any;
  78436. private _compareArray;
  78437. private _compareObjects;
  78438. private _compareCollections;
  78439. private static GetShadowGeneratorById;
  78440. /**
  78441. * Apply a given delta to a given scene
  78442. * @param deltaJSON defines the JSON containing the delta
  78443. * @param scene defines the scene to apply the delta to
  78444. */
  78445. static ApplyDelta(deltaJSON: any | string, scene: Scene): void;
  78446. private static _ApplyPropertiesToEntity;
  78447. private static _ApplyDeltaForEntity;
  78448. }
  78449. }
  78450. declare module "babylonjs/Misc/index" {
  78451. export * from "babylonjs/Misc/andOrNotEvaluator";
  78452. export * from "babylonjs/Misc/assetsManager";
  78453. export * from "babylonjs/Misc/basis";
  78454. export * from "babylonjs/Misc/dds";
  78455. export * from "babylonjs/Misc/decorators";
  78456. export * from "babylonjs/Misc/deferred";
  78457. export * from "babylonjs/Misc/environmentTextureTools";
  78458. export * from "babylonjs/Misc/meshExploder";
  78459. export * from "babylonjs/Misc/filesInput";
  78460. export * from "babylonjs/Misc/HighDynamicRange/index";
  78461. export * from "babylonjs/Misc/khronosTextureContainer";
  78462. export * from "babylonjs/Misc/observable";
  78463. export * from "babylonjs/Misc/performanceMonitor";
  78464. export * from "babylonjs/Misc/promise";
  78465. export * from "babylonjs/Misc/sceneOptimizer";
  78466. export * from "babylonjs/Misc/sceneSerializer";
  78467. export * from "babylonjs/Misc/smartArray";
  78468. export * from "babylonjs/Misc/stringDictionary";
  78469. export * from "babylonjs/Misc/tags";
  78470. export * from "babylonjs/Misc/textureTools";
  78471. export * from "babylonjs/Misc/tga";
  78472. export * from "babylonjs/Misc/tools";
  78473. export * from "babylonjs/Misc/videoRecorder";
  78474. export * from "babylonjs/Misc/virtualJoystick";
  78475. export * from "babylonjs/Misc/workerPool";
  78476. export * from "babylonjs/Misc/logger";
  78477. export * from "babylonjs/Misc/typeStore";
  78478. export * from "babylonjs/Misc/filesInputStore";
  78479. export * from "babylonjs/Misc/deepCopier";
  78480. export * from "babylonjs/Misc/pivotTools";
  78481. export * from "babylonjs/Misc/precisionDate";
  78482. export * from "babylonjs/Misc/screenshotTools";
  78483. export * from "babylonjs/Misc/typeStore";
  78484. export * from "babylonjs/Misc/webRequest";
  78485. export * from "babylonjs/Misc/iInspectable";
  78486. export * from "babylonjs/Misc/brdfTextureTools";
  78487. export * from "babylonjs/Misc/rgbdTextureTools";
  78488. export * from "babylonjs/Misc/gradients";
  78489. export * from "babylonjs/Misc/perfCounter";
  78490. export * from "babylonjs/Misc/fileRequest";
  78491. export * from "babylonjs/Misc/customAnimationFrameRequester";
  78492. export * from "babylonjs/Misc/retryStrategy";
  78493. export * from "babylonjs/Misc/interfaces/screenshotSize";
  78494. export * from "babylonjs/Misc/canvasGenerator";
  78495. export * from "babylonjs/Misc/fileTools";
  78496. export * from "babylonjs/Misc/stringTools";
  78497. export * from "babylonjs/Misc/dataReader";
  78498. export * from "babylonjs/Misc/minMaxReducer";
  78499. export * from "babylonjs/Misc/depthReducer";
  78500. export * from "babylonjs/Misc/dataStorage";
  78501. export * from "babylonjs/Misc/sceneRecorder";
  78502. export * from "babylonjs/Misc/khronosTextureContainer2";
  78503. }
  78504. declare module "babylonjs/XR/features/WebXRHitTestLegacy" {
  78505. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  78506. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  78507. import { Observable } from "babylonjs/Misc/observable";
  78508. import { Matrix } from "babylonjs/Maths/math.vector";
  78509. import { TransformNode } from "babylonjs/Meshes/transformNode";
  78510. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  78511. /**
  78512. * An interface for all Hit test features
  78513. */
  78514. export interface IWebXRHitTestFeature<T extends IWebXRLegacyHitResult> extends IWebXRFeature {
  78515. /**
  78516. * Triggered when new babylon (transformed) hit test results are available
  78517. */
  78518. onHitTestResultObservable: Observable<T[]>;
  78519. }
  78520. /**
  78521. * Options used for hit testing
  78522. */
  78523. export interface IWebXRLegacyHitTestOptions {
  78524. /**
  78525. * Only test when user interacted with the scene. Default - hit test every frame
  78526. */
  78527. testOnPointerDownOnly?: boolean;
  78528. /**
  78529. * The node to use to transform the local results to world coordinates
  78530. */
  78531. worldParentNode?: TransformNode;
  78532. }
  78533. /**
  78534. * Interface defining the babylon result of raycasting/hit-test
  78535. */
  78536. export interface IWebXRLegacyHitResult {
  78537. /**
  78538. * Transformation matrix that can be applied to a node that will put it in the hit point location
  78539. */
  78540. transformationMatrix: Matrix;
  78541. /**
  78542. * The native hit test result
  78543. */
  78544. xrHitResult: XRHitResult | XRHitTestResult;
  78545. }
  78546. /**
  78547. * The currently-working hit-test module.
  78548. * Hit test (or Ray-casting) is used to interact with the real world.
  78549. * For further information read here - https://github.com/immersive-web/hit-test
  78550. */
  78551. export class WebXRHitTestLegacy extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRLegacyHitResult> {
  78552. /**
  78553. * options to use when constructing this feature
  78554. */
  78555. readonly options: IWebXRLegacyHitTestOptions;
  78556. private _direction;
  78557. private _mat;
  78558. private _onSelectEnabled;
  78559. private _origin;
  78560. /**
  78561. * The module's name
  78562. */
  78563. static readonly Name: string;
  78564. /**
  78565. * The (Babylon) version of this module.
  78566. * This is an integer representing the implementation version.
  78567. * This number does not correspond to the WebXR specs version
  78568. */
  78569. static readonly Version: number;
  78570. /**
  78571. * Populated with the last native XR Hit Results
  78572. */
  78573. lastNativeXRHitResults: XRHitResult[];
  78574. /**
  78575. * Triggered when new babylon (transformed) hit test results are available
  78576. */
  78577. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  78578. /**
  78579. * Creates a new instance of the (legacy version) hit test feature
  78580. * @param _xrSessionManager an instance of WebXRSessionManager
  78581. * @param options options to use when constructing this feature
  78582. */
  78583. constructor(_xrSessionManager: WebXRSessionManager,
  78584. /**
  78585. * options to use when constructing this feature
  78586. */
  78587. options?: IWebXRLegacyHitTestOptions);
  78588. /**
  78589. * execute a hit test with an XR Ray
  78590. *
  78591. * @param xrSession a native xrSession that will execute this hit test
  78592. * @param xrRay the ray (position and direction) to use for ray-casting
  78593. * @param referenceSpace native XR reference space to use for the hit-test
  78594. * @param filter filter function that will filter the results
  78595. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  78596. */
  78597. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  78598. /**
  78599. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  78600. * @param event the (select) event to use to select with
  78601. * @param referenceSpace the reference space to use for this hit test
  78602. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  78603. */
  78604. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  78605. /**
  78606. * attach this feature
  78607. * Will usually be called by the features manager
  78608. *
  78609. * @returns true if successful.
  78610. */
  78611. attach(): boolean;
  78612. /**
  78613. * detach this feature.
  78614. * Will usually be called by the features manager
  78615. *
  78616. * @returns true if successful.
  78617. */
  78618. detach(): boolean;
  78619. /**
  78620. * Dispose this feature and all of the resources attached
  78621. */
  78622. dispose(): void;
  78623. protected _onXRFrame(frame: XRFrame): void;
  78624. private _onHitTestResults;
  78625. private _onSelect;
  78626. }
  78627. }
  78628. declare module "babylonjs/XR/features/WebXRHitTest" {
  78629. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  78630. import { Observable } from "babylonjs/Misc/observable";
  78631. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  78632. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  78633. import { IWebXRLegacyHitTestOptions, IWebXRLegacyHitResult, IWebXRHitTestFeature } from "babylonjs/XR/features/WebXRHitTestLegacy";
  78634. /**
  78635. * Options used for hit testing (version 2)
  78636. */
  78637. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  78638. /**
  78639. * Do not create a permanent hit test. Will usually be used when only
  78640. * transient inputs are needed.
  78641. */
  78642. disablePermanentHitTest?: boolean;
  78643. /**
  78644. * Enable transient (for example touch-based) hit test inspections
  78645. */
  78646. enableTransientHitTest?: boolean;
  78647. /**
  78648. * Offset ray for the permanent hit test
  78649. */
  78650. offsetRay?: Vector3;
  78651. /**
  78652. * Offset ray for the transient hit test
  78653. */
  78654. transientOffsetRay?: Vector3;
  78655. /**
  78656. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  78657. */
  78658. useReferenceSpace?: boolean;
  78659. /**
  78660. * Override the default entity type(s) of the hit-test result
  78661. */
  78662. entityTypes?: XRHitTestTrackableType[];
  78663. }
  78664. /**
  78665. * Interface defining the babylon result of hit-test
  78666. */
  78667. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  78668. /**
  78669. * The input source that generated this hit test (if transient)
  78670. */
  78671. inputSource?: XRInputSource;
  78672. /**
  78673. * Is this a transient hit test
  78674. */
  78675. isTransient?: boolean;
  78676. /**
  78677. * Position of the hit test result
  78678. */
  78679. position: Vector3;
  78680. /**
  78681. * Rotation of the hit test result
  78682. */
  78683. rotationQuaternion: Quaternion;
  78684. /**
  78685. * The native hit test result
  78686. */
  78687. xrHitResult: XRHitTestResult;
  78688. }
  78689. /**
  78690. * The currently-working hit-test module.
  78691. * Hit test (or Ray-casting) is used to interact with the real world.
  78692. * For further information read here - https://github.com/immersive-web/hit-test
  78693. *
  78694. * Tested on chrome (mobile) 80.
  78695. */
  78696. export class WebXRHitTest extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRHitResult> {
  78697. /**
  78698. * options to use when constructing this feature
  78699. */
  78700. readonly options: IWebXRHitTestOptions;
  78701. private _tmpMat;
  78702. private _tmpPos;
  78703. private _tmpQuat;
  78704. private _transientXrHitTestSource;
  78705. private _xrHitTestSource;
  78706. private initHitTestSource;
  78707. /**
  78708. * The module's name
  78709. */
  78710. static readonly Name: string;
  78711. /**
  78712. * The (Babylon) version of this module.
  78713. * This is an integer representing the implementation version.
  78714. * This number does not correspond to the WebXR specs version
  78715. */
  78716. static readonly Version: number;
  78717. /**
  78718. * When set to true, each hit test will have its own position/rotation objects
  78719. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  78720. * the developers will clone them or copy them as they see fit.
  78721. */
  78722. autoCloneTransformation: boolean;
  78723. /**
  78724. * Triggered when new babylon (transformed) hit test results are available
  78725. * Note - this will be called when results come back from the device. It can be an empty array!!
  78726. */
  78727. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  78728. /**
  78729. * Use this to temporarily pause hit test checks.
  78730. */
  78731. paused: boolean;
  78732. /**
  78733. * Creates a new instance of the hit test feature
  78734. * @param _xrSessionManager an instance of WebXRSessionManager
  78735. * @param options options to use when constructing this feature
  78736. */
  78737. constructor(_xrSessionManager: WebXRSessionManager,
  78738. /**
  78739. * options to use when constructing this feature
  78740. */
  78741. options?: IWebXRHitTestOptions);
  78742. /**
  78743. * attach this feature
  78744. * Will usually be called by the features manager
  78745. *
  78746. * @returns true if successful.
  78747. */
  78748. attach(): boolean;
  78749. /**
  78750. * detach this feature.
  78751. * Will usually be called by the features manager
  78752. *
  78753. * @returns true if successful.
  78754. */
  78755. detach(): boolean;
  78756. /**
  78757. * Dispose this feature and all of the resources attached
  78758. */
  78759. dispose(): void;
  78760. protected _onXRFrame(frame: XRFrame): void;
  78761. private _processWebXRHitTestResult;
  78762. }
  78763. }
  78764. declare module "babylonjs/XR/features/WebXRAnchorSystem" {
  78765. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  78766. import { Observable } from "babylonjs/Misc/observable";
  78767. import { Matrix, Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  78768. import { TransformNode } from "babylonjs/Meshes/transformNode";
  78769. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  78770. import { IWebXRHitResult } from "babylonjs/XR/features/WebXRHitTest";
  78771. /**
  78772. * Configuration options of the anchor system
  78773. */
  78774. export interface IWebXRAnchorSystemOptions {
  78775. /**
  78776. * a node that will be used to convert local to world coordinates
  78777. */
  78778. worldParentNode?: TransformNode;
  78779. /**
  78780. * If set to true a reference of the created anchors will be kept until the next session starts
  78781. * If not defined, anchors will be removed from the array when the feature is detached or the session ended.
  78782. */
  78783. doNotRemoveAnchorsOnSessionEnded?: boolean;
  78784. }
  78785. /**
  78786. * A babylon container for an XR Anchor
  78787. */
  78788. export interface IWebXRAnchor {
  78789. /**
  78790. * A babylon-assigned ID for this anchor
  78791. */
  78792. id: number;
  78793. /**
  78794. * Transformation matrix to apply to an object attached to this anchor
  78795. */
  78796. transformationMatrix: Matrix;
  78797. /**
  78798. * The native anchor object
  78799. */
  78800. xrAnchor: XRAnchor;
  78801. /**
  78802. * if defined, this object will be constantly updated by the anchor's position and rotation
  78803. */
  78804. attachedNode?: TransformNode;
  78805. }
  78806. /**
  78807. * An implementation of the anchor system for WebXR.
  78808. * For further information see https://github.com/immersive-web/anchors/
  78809. */
  78810. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  78811. private _options;
  78812. private _lastFrameDetected;
  78813. private _trackedAnchors;
  78814. private _referenceSpaceForFrameAnchors;
  78815. private _futureAnchors;
  78816. /**
  78817. * The module's name
  78818. */
  78819. static readonly Name: string;
  78820. /**
  78821. * The (Babylon) version of this module.
  78822. * This is an integer representing the implementation version.
  78823. * This number does not correspond to the WebXR specs version
  78824. */
  78825. static readonly Version: number;
  78826. /**
  78827. * Observers registered here will be executed when a new anchor was added to the session
  78828. */
  78829. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  78830. /**
  78831. * Observers registered here will be executed when an anchor was removed from the session
  78832. */
  78833. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  78834. /**
  78835. * Observers registered here will be executed when an existing anchor updates
  78836. * This can execute N times every frame
  78837. */
  78838. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  78839. /**
  78840. * Set the reference space to use for anchor creation, when not using a hit test.
  78841. * Will default to the session's reference space if not defined
  78842. */
  78843. set referenceSpaceForFrameAnchors(referenceSpace: XRReferenceSpace);
  78844. /**
  78845. * constructs a new anchor system
  78846. * @param _xrSessionManager an instance of WebXRSessionManager
  78847. * @param _options configuration object for this feature
  78848. */
  78849. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  78850. private _tmpVector;
  78851. private _tmpQuaternion;
  78852. private _populateTmpTransformation;
  78853. /**
  78854. * Create a new anchor point using a hit test result at a specific point in the scene
  78855. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  78856. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  78857. *
  78858. * @param hitTestResult The hit test result to use for this anchor creation
  78859. * @param position an optional position offset for this anchor
  78860. * @param rotationQuaternion an optional rotation offset for this anchor
  78861. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  78862. */
  78863. addAnchorPointUsingHitTestResultAsync(hitTestResult: IWebXRHitResult, position?: Vector3, rotationQuaternion?: Quaternion): Promise<XRAnchor>;
  78864. /**
  78865. * Add a new anchor at a specific position and rotation
  78866. * This function will add a new anchor per default in the next available frame. Unless forced, the createAnchor function
  78867. * will be called in the next xrFrame loop to make sure that the anchor can be created correctly.
  78868. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  78869. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  78870. *
  78871. * @param position the position in which to add an anchor
  78872. * @param rotationQuaternion an optional rotation for the anchor transformation
  78873. * @param forceCreateInCurrentFrame force the creation of this anchor in the current frame. Must be called inside xrFrame loop!
  78874. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  78875. */
  78876. addAnchorAtPositionAndRotationAsync(position: Vector3, rotationQuaternion?: Quaternion, forceCreateInCurrentFrame?: boolean): Promise<XRAnchor>;
  78877. /**
  78878. * detach this feature.
  78879. * Will usually be called by the features manager
  78880. *
  78881. * @returns true if successful.
  78882. */
  78883. detach(): boolean;
  78884. /**
  78885. * Dispose this feature and all of the resources attached
  78886. */
  78887. dispose(): void;
  78888. protected _onXRFrame(frame: XRFrame): void;
  78889. /**
  78890. * avoiding using Array.find for global support.
  78891. * @param xrAnchor the plane to find in the array
  78892. */
  78893. private _findIndexInAnchorArray;
  78894. private _updateAnchorWithXRFrame;
  78895. private _createAnchorAtTransformation;
  78896. }
  78897. }
  78898. declare module "babylonjs/XR/features/WebXRPlaneDetector" {
  78899. import { TransformNode } from "babylonjs/Meshes/transformNode";
  78900. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  78901. import { Observable } from "babylonjs/Misc/observable";
  78902. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  78903. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  78904. /**
  78905. * Options used in the plane detector module
  78906. */
  78907. export interface IWebXRPlaneDetectorOptions {
  78908. /**
  78909. * The node to use to transform the local results to world coordinates
  78910. */
  78911. worldParentNode?: TransformNode;
  78912. /**
  78913. * If set to true a reference of the created planes will be kept until the next session starts
  78914. * If not defined, planes will be removed from the array when the feature is detached or the session ended.
  78915. */
  78916. doNotRemovePlanesOnSessionEnded?: boolean;
  78917. }
  78918. /**
  78919. * A babylon interface for a WebXR plane.
  78920. * A Plane is actually a polygon, built from N points in space
  78921. *
  78922. * Supported in chrome 79, not supported in canary 81 ATM
  78923. */
  78924. export interface IWebXRPlane {
  78925. /**
  78926. * a babylon-assigned ID for this polygon
  78927. */
  78928. id: number;
  78929. /**
  78930. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  78931. */
  78932. polygonDefinition: Array<Vector3>;
  78933. /**
  78934. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  78935. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  78936. */
  78937. transformationMatrix: Matrix;
  78938. /**
  78939. * the native xr-plane object
  78940. */
  78941. xrPlane: XRPlane;
  78942. }
  78943. /**
  78944. * The plane detector is used to detect planes in the real world when in AR
  78945. * For more information see https://github.com/immersive-web/real-world-geometry/
  78946. */
  78947. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  78948. private _options;
  78949. private _detectedPlanes;
  78950. private _enabled;
  78951. private _lastFrameDetected;
  78952. /**
  78953. * The module's name
  78954. */
  78955. static readonly Name: string;
  78956. /**
  78957. * The (Babylon) version of this module.
  78958. * This is an integer representing the implementation version.
  78959. * This number does not correspond to the WebXR specs version
  78960. */
  78961. static readonly Version: number;
  78962. /**
  78963. * Observers registered here will be executed when a new plane was added to the session
  78964. */
  78965. onPlaneAddedObservable: Observable<IWebXRPlane>;
  78966. /**
  78967. * Observers registered here will be executed when a plane is no longer detected in the session
  78968. */
  78969. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  78970. /**
  78971. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  78972. * This can execute N times every frame
  78973. */
  78974. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  78975. /**
  78976. * construct a new Plane Detector
  78977. * @param _xrSessionManager an instance of xr Session manager
  78978. * @param _options configuration to use when constructing this feature
  78979. */
  78980. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  78981. /**
  78982. * detach this feature.
  78983. * Will usually be called by the features manager
  78984. *
  78985. * @returns true if successful.
  78986. */
  78987. detach(): boolean;
  78988. /**
  78989. * Dispose this feature and all of the resources attached
  78990. */
  78991. dispose(): void;
  78992. protected _onXRFrame(frame: XRFrame): void;
  78993. private _init;
  78994. private _updatePlaneWithXRPlane;
  78995. /**
  78996. * avoiding using Array.find for global support.
  78997. * @param xrPlane the plane to find in the array
  78998. */
  78999. private findIndexInPlaneArray;
  79000. }
  79001. }
  79002. declare module "babylonjs/XR/features/WebXRBackgroundRemover" {
  79003. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  79004. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  79005. import { Observable } from "babylonjs/Misc/observable";
  79006. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  79007. /**
  79008. * Options interface for the background remover plugin
  79009. */
  79010. export interface IWebXRBackgroundRemoverOptions {
  79011. /**
  79012. * Further background meshes to disable when entering AR
  79013. */
  79014. backgroundMeshes?: AbstractMesh[];
  79015. /**
  79016. * flags to configure the removal of the environment helper.
  79017. * If not set, the entire background will be removed. If set, flags should be set as well.
  79018. */
  79019. environmentHelperRemovalFlags?: {
  79020. /**
  79021. * Should the skybox be removed (default false)
  79022. */
  79023. skyBox?: boolean;
  79024. /**
  79025. * Should the ground be removed (default false)
  79026. */
  79027. ground?: boolean;
  79028. };
  79029. /**
  79030. * don't disable the environment helper
  79031. */
  79032. ignoreEnvironmentHelper?: boolean;
  79033. }
  79034. /**
  79035. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  79036. */
  79037. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  79038. /**
  79039. * read-only options to be used in this module
  79040. */
  79041. readonly options: IWebXRBackgroundRemoverOptions;
  79042. /**
  79043. * The module's name
  79044. */
  79045. static readonly Name: string;
  79046. /**
  79047. * The (Babylon) version of this module.
  79048. * This is an integer representing the implementation version.
  79049. * This number does not correspond to the WebXR specs version
  79050. */
  79051. static readonly Version: number;
  79052. /**
  79053. * registered observers will be triggered when the background state changes
  79054. */
  79055. onBackgroundStateChangedObservable: Observable<boolean>;
  79056. /**
  79057. * constructs a new background remover module
  79058. * @param _xrSessionManager the session manager for this module
  79059. * @param options read-only options to be used in this module
  79060. */
  79061. constructor(_xrSessionManager: WebXRSessionManager,
  79062. /**
  79063. * read-only options to be used in this module
  79064. */
  79065. options?: IWebXRBackgroundRemoverOptions);
  79066. /**
  79067. * attach this feature
  79068. * Will usually be called by the features manager
  79069. *
  79070. * @returns true if successful.
  79071. */
  79072. attach(): boolean;
  79073. /**
  79074. * detach this feature.
  79075. * Will usually be called by the features manager
  79076. *
  79077. * @returns true if successful.
  79078. */
  79079. detach(): boolean;
  79080. /**
  79081. * Dispose this feature and all of the resources attached
  79082. */
  79083. dispose(): void;
  79084. protected _onXRFrame(_xrFrame: XRFrame): void;
  79085. private _setBackgroundState;
  79086. }
  79087. }
  79088. declare module "babylonjs/XR/features/WebXRControllerPhysics" {
  79089. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  79090. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  79091. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  79092. import { WebXRInput } from "babylonjs/XR/webXRInput";
  79093. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  79094. import { Nullable } from "babylonjs/types";
  79095. /**
  79096. * Options for the controller physics feature
  79097. */
  79098. export class IWebXRControllerPhysicsOptions {
  79099. /**
  79100. * Should the headset get its own impostor
  79101. */
  79102. enableHeadsetImpostor?: boolean;
  79103. /**
  79104. * Optional parameters for the headset impostor
  79105. */
  79106. headsetImpostorParams?: {
  79107. /**
  79108. * The type of impostor to create. Default is sphere
  79109. */
  79110. impostorType: number;
  79111. /**
  79112. * the size of the impostor. Defaults to 10cm
  79113. */
  79114. impostorSize?: number | {
  79115. width: number;
  79116. height: number;
  79117. depth: number;
  79118. };
  79119. /**
  79120. * Friction definitions
  79121. */
  79122. friction?: number;
  79123. /**
  79124. * Restitution
  79125. */
  79126. restitution?: number;
  79127. };
  79128. /**
  79129. * The physics properties of the future impostors
  79130. */
  79131. physicsProperties?: {
  79132. /**
  79133. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  79134. * Note that this requires a physics engine that supports mesh impostors!
  79135. */
  79136. useControllerMesh?: boolean;
  79137. /**
  79138. * The type of impostor to create. Default is sphere
  79139. */
  79140. impostorType?: number;
  79141. /**
  79142. * the size of the impostor. Defaults to 10cm
  79143. */
  79144. impostorSize?: number | {
  79145. width: number;
  79146. height: number;
  79147. depth: number;
  79148. };
  79149. /**
  79150. * Friction definitions
  79151. */
  79152. friction?: number;
  79153. /**
  79154. * Restitution
  79155. */
  79156. restitution?: number;
  79157. };
  79158. /**
  79159. * the xr input to use with this pointer selection
  79160. */
  79161. xrInput: WebXRInput;
  79162. }
  79163. /**
  79164. * Add physics impostor to your webxr controllers,
  79165. * including naive calculation of their linear and angular velocity
  79166. */
  79167. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  79168. private readonly _options;
  79169. private _attachController;
  79170. private _controllers;
  79171. private _debugMode;
  79172. private _delta;
  79173. private _headsetImpostor?;
  79174. private _headsetMesh?;
  79175. private _lastTimestamp;
  79176. private _tmpQuaternion;
  79177. private _tmpVector;
  79178. /**
  79179. * The module's name
  79180. */
  79181. static readonly Name: string;
  79182. /**
  79183. * The (Babylon) version of this module.
  79184. * This is an integer representing the implementation version.
  79185. * This number does not correspond to the webxr specs version
  79186. */
  79187. static readonly Version: number;
  79188. /**
  79189. * Construct a new Controller Physics Feature
  79190. * @param _xrSessionManager the corresponding xr session manager
  79191. * @param _options options to create this feature with
  79192. */
  79193. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  79194. /**
  79195. * @hidden
  79196. * enable debugging - will show console outputs and the impostor mesh
  79197. */
  79198. _enablePhysicsDebug(): void;
  79199. /**
  79200. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  79201. * @param xrController the controller to add
  79202. */
  79203. addController(xrController: WebXRInputSource): void;
  79204. /**
  79205. * attach this feature
  79206. * Will usually be called by the features manager
  79207. *
  79208. * @returns true if successful.
  79209. */
  79210. attach(): boolean;
  79211. /**
  79212. * detach this feature.
  79213. * Will usually be called by the features manager
  79214. *
  79215. * @returns true if successful.
  79216. */
  79217. detach(): boolean;
  79218. /**
  79219. * Get the headset impostor, if enabled
  79220. * @returns the impostor
  79221. */
  79222. getHeadsetImpostor(): PhysicsImpostor | undefined;
  79223. /**
  79224. * Get the physics impostor of a specific controller.
  79225. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  79226. * @param controller the controller or the controller id of which to get the impostor
  79227. * @returns the impostor or null
  79228. */
  79229. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  79230. /**
  79231. * Update the physics properties provided in the constructor
  79232. * @param newProperties the new properties object
  79233. */
  79234. setPhysicsProperties(newProperties: {
  79235. impostorType?: number;
  79236. impostorSize?: number | {
  79237. width: number;
  79238. height: number;
  79239. depth: number;
  79240. };
  79241. friction?: number;
  79242. restitution?: number;
  79243. }): void;
  79244. protected _onXRFrame(_xrFrame: any): void;
  79245. private _detachController;
  79246. }
  79247. }
  79248. declare module "babylonjs/XR/features/WebXRFeaturePointSystem" {
  79249. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  79250. import { Observable } from "babylonjs/Misc/observable";
  79251. import { Vector3 } from "babylonjs/Maths/math.vector";
  79252. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  79253. /**
  79254. * A babylon interface for a "WebXR" feature point.
  79255. * Represents the position and confidence value of a given feature point.
  79256. */
  79257. export interface IWebXRFeaturePoint {
  79258. /**
  79259. * Represents the position of the feature point in world space.
  79260. */
  79261. position: Vector3;
  79262. /**
  79263. * Represents the confidence value of the feature point in world space. 0 being least confident, and 1 being most confident.
  79264. */
  79265. confidenceValue: number;
  79266. }
  79267. /**
  79268. * The feature point system is used to detect feature points from real world geometry.
  79269. * This feature is currently experimental and only supported on BabylonNative, and should not be used in the browser.
  79270. * The newly introduced API can be seen in webxr.nativeextensions.d.ts and described in FeaturePoints.md.
  79271. */
  79272. export class WebXRFeaturePointSystem extends WebXRAbstractFeature {
  79273. private _enabled;
  79274. private _featurePointCloud;
  79275. /**
  79276. * The module's name
  79277. */
  79278. static readonly Name: string;
  79279. /**
  79280. * The (Babylon) version of this module.
  79281. * This is an integer representing the implementation version.
  79282. * This number does not correspond to the WebXR specs version
  79283. */
  79284. static readonly Version: number;
  79285. /**
  79286. * Observers registered here will be executed whenever new feature points are added (on XRFrame while the session is tracking).
  79287. * Will notify the observers about which feature points have been added.
  79288. */
  79289. readonly onFeaturePointsAddedObservable: Observable<number[]>;
  79290. /**
  79291. * Observers registered here will be executed whenever a feature point has been updated (on XRFrame while the session is tracking).
  79292. * Will notify the observers about which feature points have been updated.
  79293. */
  79294. readonly onFeaturePointsUpdatedObservable: Observable<number[]>;
  79295. /**
  79296. * The current feature point cloud maintained across frames.
  79297. */
  79298. get featurePointCloud(): Array<IWebXRFeaturePoint>;
  79299. /**
  79300. * construct the feature point system
  79301. * @param _xrSessionManager an instance of xr Session manager
  79302. */
  79303. constructor(_xrSessionManager: WebXRSessionManager);
  79304. /**
  79305. * Detach this feature.
  79306. * Will usually be called by the features manager
  79307. *
  79308. * @returns true if successful.
  79309. */
  79310. detach(): boolean;
  79311. /**
  79312. * Dispose this feature and all of the resources attached
  79313. */
  79314. dispose(): void;
  79315. /**
  79316. * On receiving a new XR frame if this feature is attached notify observers new feature point data is available.
  79317. */
  79318. protected _onXRFrame(frame: XRFrame): void;
  79319. /**
  79320. * Initializes the feature. If the feature point feature is not available for this environment do not mark the feature as enabled.
  79321. */
  79322. private _init;
  79323. }
  79324. }
  79325. declare module "babylonjs/XR/features/WebXRHandTracking" {
  79326. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  79327. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  79328. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  79329. import { Mesh } from "babylonjs/Meshes/mesh";
  79330. import { WebXRInput } from "babylonjs/XR/webXRInput";
  79331. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  79332. import { Nullable } from "babylonjs/types";
  79333. import { IDisposable } from "babylonjs/scene";
  79334. import { Observable } from "babylonjs/Misc/observable";
  79335. /**
  79336. * Configuration interface for the hand tracking feature
  79337. */
  79338. export interface IWebXRHandTrackingOptions {
  79339. /**
  79340. * The xrInput that will be used as source for new hands
  79341. */
  79342. xrInput: WebXRInput;
  79343. /**
  79344. * Configuration object for the joint meshes
  79345. */
  79346. jointMeshes?: {
  79347. /**
  79348. * Should the meshes created be invisible (defaults to false)
  79349. */
  79350. invisible?: boolean;
  79351. /**
  79352. * A source mesh to be used to create instances. Defaults to a sphere.
  79353. * This mesh will be the source for all other (25) meshes.
  79354. * It should have the general size of a single unit, as the instances will be scaled according to the provided radius
  79355. */
  79356. sourceMesh?: Mesh;
  79357. /**
  79358. * Should the source mesh stay visible. Defaults to false
  79359. */
  79360. keepOriginalVisible?: boolean;
  79361. /**
  79362. * Scale factor for all instances (defaults to 2)
  79363. */
  79364. scaleFactor?: number;
  79365. /**
  79366. * Should each instance have its own physics impostor
  79367. */
  79368. enablePhysics?: boolean;
  79369. /**
  79370. * If enabled, override default physics properties
  79371. */
  79372. physicsProps?: {
  79373. friction?: number;
  79374. restitution?: number;
  79375. impostorType?: number;
  79376. };
  79377. /**
  79378. * For future use - a single hand-mesh that will be updated according to the XRHand data provided
  79379. */
  79380. handMesh?: AbstractMesh;
  79381. };
  79382. }
  79383. /**
  79384. * Parts of the hands divided to writs and finger names
  79385. */
  79386. export const enum HandPart {
  79387. /**
  79388. * HandPart - Wrist
  79389. */
  79390. WRIST = "wrist",
  79391. /**
  79392. * HandPart - The THumb
  79393. */
  79394. THUMB = "thumb",
  79395. /**
  79396. * HandPart - Index finger
  79397. */
  79398. INDEX = "index",
  79399. /**
  79400. * HandPart - Middle finger
  79401. */
  79402. MIDDLE = "middle",
  79403. /**
  79404. * HandPart - Ring finger
  79405. */
  79406. RING = "ring",
  79407. /**
  79408. * HandPart - Little finger
  79409. */
  79410. LITTLE = "little"
  79411. }
  79412. /**
  79413. * Representing a single hand (with its corresponding native XRHand object)
  79414. */
  79415. export class WebXRHand implements IDisposable {
  79416. /** the controller to which the hand correlates */
  79417. readonly xrController: WebXRInputSource;
  79418. /** the meshes to be used to track the hand joints */
  79419. readonly trackedMeshes: AbstractMesh[];
  79420. /**
  79421. * Hand-parts definition (key is HandPart)
  79422. */
  79423. handPartsDefinition: {
  79424. [key: string]: number[];
  79425. };
  79426. /**
  79427. * Populate the HandPartsDefinition object.
  79428. * This is called as a side effect since certain browsers don't have XRHand defined.
  79429. */
  79430. private generateHandPartsDefinition;
  79431. /**
  79432. * Construct a new hand object
  79433. * @param xrController the controller to which the hand correlates
  79434. * @param trackedMeshes the meshes to be used to track the hand joints
  79435. */
  79436. constructor(
  79437. /** the controller to which the hand correlates */
  79438. xrController: WebXRInputSource,
  79439. /** the meshes to be used to track the hand joints */
  79440. trackedMeshes: AbstractMesh[]);
  79441. /**
  79442. * Update this hand from the latest xr frame
  79443. * @param xrFrame xrFrame to update from
  79444. * @param referenceSpace The current viewer reference space
  79445. * @param scaleFactor optional scale factor for the meshes
  79446. */
  79447. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace, scaleFactor?: number): void;
  79448. /**
  79449. * Get meshes of part of the hand
  79450. * @param part the part of hand to get
  79451. * @returns An array of meshes that correlate to the hand part requested
  79452. */
  79453. getHandPartMeshes(part: HandPart): AbstractMesh[];
  79454. /**
  79455. * Dispose this Hand object
  79456. */
  79457. dispose(): void;
  79458. }
  79459. /**
  79460. * WebXR Hand Joint tracking feature, available for selected browsers and devices
  79461. */
  79462. export class WebXRHandTracking extends WebXRAbstractFeature {
  79463. /**
  79464. * options to use when constructing this feature
  79465. */
  79466. readonly options: IWebXRHandTrackingOptions;
  79467. private static _idCounter;
  79468. /**
  79469. * The module's name
  79470. */
  79471. static readonly Name: string;
  79472. /**
  79473. * The (Babylon) version of this module.
  79474. * This is an integer representing the implementation version.
  79475. * This number does not correspond to the WebXR specs version
  79476. */
  79477. static readonly Version: number;
  79478. /**
  79479. * This observable will notify registered observers when a new hand object was added and initialized
  79480. */
  79481. onHandAddedObservable: Observable<WebXRHand>;
  79482. /**
  79483. * This observable will notify its observers right before the hand object is disposed
  79484. */
  79485. onHandRemovedObservable: Observable<WebXRHand>;
  79486. private _hands;
  79487. /**
  79488. * Creates a new instance of the hit test feature
  79489. * @param _xrSessionManager an instance of WebXRSessionManager
  79490. * @param options options to use when constructing this feature
  79491. */
  79492. constructor(_xrSessionManager: WebXRSessionManager,
  79493. /**
  79494. * options to use when constructing this feature
  79495. */
  79496. options: IWebXRHandTrackingOptions);
  79497. /**
  79498. * Check if the needed objects are defined.
  79499. * This does not mean that the feature is enabled, but that the objects needed are well defined.
  79500. */
  79501. isCompatible(): boolean;
  79502. /**
  79503. * attach this feature
  79504. * Will usually be called by the features manager
  79505. *
  79506. * @returns true if successful.
  79507. */
  79508. attach(): boolean;
  79509. /**
  79510. * detach this feature.
  79511. * Will usually be called by the features manager
  79512. *
  79513. * @returns true if successful.
  79514. */
  79515. detach(): boolean;
  79516. /**
  79517. * Dispose this feature and all of the resources attached
  79518. */
  79519. dispose(): void;
  79520. /**
  79521. * Get the hand object according to the controller id
  79522. * @param controllerId the controller id to which we want to get the hand
  79523. * @returns null if not found or the WebXRHand object if found
  79524. */
  79525. getHandByControllerId(controllerId: string): Nullable<WebXRHand>;
  79526. /**
  79527. * Get a hand object according to the requested handedness
  79528. * @param handedness the handedness to request
  79529. * @returns null if not found or the WebXRHand object if found
  79530. */
  79531. getHandByHandedness(handedness: XRHandedness): Nullable<WebXRHand>;
  79532. protected _onXRFrame(_xrFrame: XRFrame): void;
  79533. private _attachHand;
  79534. private _detachHand;
  79535. }
  79536. }
  79537. declare module "babylonjs/XR/features/index" {
  79538. export * from "babylonjs/XR/features/WebXRHitTestLegacy";
  79539. export * from "babylonjs/XR/features/WebXRAnchorSystem";
  79540. export * from "babylonjs/XR/features/WebXRPlaneDetector";
  79541. export * from "babylonjs/XR/features/WebXRBackgroundRemover";
  79542. export * from "babylonjs/XR/features/WebXRControllerTeleportation";
  79543. export * from "babylonjs/XR/features/WebXRControllerPointerSelection";
  79544. export * from "babylonjs/XR/features/WebXRControllerPhysics";
  79545. export * from "babylonjs/XR/features/WebXRHitTest";
  79546. export * from "babylonjs/XR/features/WebXRFeaturePointSystem";
  79547. export * from "babylonjs/XR/features/WebXRHandTracking";
  79548. }
  79549. declare module "babylonjs/XR/motionController/webXRMicrosoftMixedRealityController" {
  79550. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandedness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  79551. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  79552. import { Scene } from "babylonjs/scene";
  79553. /**
  79554. * The motion controller class for all microsoft mixed reality controllers
  79555. */
  79556. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  79557. protected readonly _mapping: {
  79558. defaultButton: {
  79559. valueNodeName: string;
  79560. unpressedNodeName: string;
  79561. pressedNodeName: string;
  79562. };
  79563. defaultAxis: {
  79564. valueNodeName: string;
  79565. minNodeName: string;
  79566. maxNodeName: string;
  79567. };
  79568. buttons: {
  79569. "xr-standard-trigger": {
  79570. rootNodeName: string;
  79571. componentProperty: string;
  79572. states: string[];
  79573. };
  79574. "xr-standard-squeeze": {
  79575. rootNodeName: string;
  79576. componentProperty: string;
  79577. states: string[];
  79578. };
  79579. "xr-standard-touchpad": {
  79580. rootNodeName: string;
  79581. labelAnchorNodeName: string;
  79582. touchPointNodeName: string;
  79583. };
  79584. "xr-standard-thumbstick": {
  79585. rootNodeName: string;
  79586. componentProperty: string;
  79587. states: string[];
  79588. };
  79589. };
  79590. axes: {
  79591. "xr-standard-touchpad": {
  79592. "x-axis": {
  79593. rootNodeName: string;
  79594. };
  79595. "y-axis": {
  79596. rootNodeName: string;
  79597. };
  79598. };
  79599. "xr-standard-thumbstick": {
  79600. "x-axis": {
  79601. rootNodeName: string;
  79602. };
  79603. "y-axis": {
  79604. rootNodeName: string;
  79605. };
  79606. };
  79607. };
  79608. };
  79609. /**
  79610. * The base url used to load the left and right controller models
  79611. */
  79612. static MODEL_BASE_URL: string;
  79613. /**
  79614. * The name of the left controller model file
  79615. */
  79616. static MODEL_LEFT_FILENAME: string;
  79617. /**
  79618. * The name of the right controller model file
  79619. */
  79620. static MODEL_RIGHT_FILENAME: string;
  79621. profileId: string;
  79622. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  79623. protected _getFilenameAndPath(): {
  79624. filename: string;
  79625. path: string;
  79626. };
  79627. protected _getModelLoadingConstraints(): boolean;
  79628. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  79629. protected _setRootMesh(meshes: AbstractMesh[]): void;
  79630. protected _updateModel(): void;
  79631. }
  79632. }
  79633. declare module "babylonjs/XR/motionController/webXROculusTouchMotionController" {
  79634. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandedness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  79635. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  79636. import { Scene } from "babylonjs/scene";
  79637. /**
  79638. * The motion controller class for oculus touch (quest, rift).
  79639. * This class supports legacy mapping as well the standard xr mapping
  79640. */
  79641. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  79642. private _forceLegacyControllers;
  79643. private _modelRootNode;
  79644. /**
  79645. * The base url used to load the left and right controller models
  79646. */
  79647. static MODEL_BASE_URL: string;
  79648. /**
  79649. * The name of the left controller model file
  79650. */
  79651. static MODEL_LEFT_FILENAME: string;
  79652. /**
  79653. * The name of the right controller model file
  79654. */
  79655. static MODEL_RIGHT_FILENAME: string;
  79656. /**
  79657. * Base Url for the Quest controller model.
  79658. */
  79659. static QUEST_MODEL_BASE_URL: string;
  79660. profileId: string;
  79661. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  79662. protected _getFilenameAndPath(): {
  79663. filename: string;
  79664. path: string;
  79665. };
  79666. protected _getModelLoadingConstraints(): boolean;
  79667. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  79668. protected _setRootMesh(meshes: AbstractMesh[]): void;
  79669. protected _updateModel(): void;
  79670. /**
  79671. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  79672. * between the touch and touch 2.
  79673. */
  79674. private _isQuest;
  79675. }
  79676. }
  79677. declare module "babylonjs/XR/motionController/webXRHTCViveMotionController" {
  79678. import { IMinimalMotionControllerObject, MotionControllerHandedness, WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  79679. import { Scene } from "babylonjs/scene";
  79680. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  79681. /**
  79682. * The motion controller class for the standard HTC-Vive controllers
  79683. */
  79684. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  79685. private _modelRootNode;
  79686. /**
  79687. * The base url used to load the left and right controller models
  79688. */
  79689. static MODEL_BASE_URL: string;
  79690. /**
  79691. * File name for the controller model.
  79692. */
  79693. static MODEL_FILENAME: string;
  79694. profileId: string;
  79695. /**
  79696. * Create a new Vive motion controller object
  79697. * @param scene the scene to use to create this controller
  79698. * @param gamepadObject the corresponding gamepad object
  79699. * @param handedness the handedness of the controller
  79700. */
  79701. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  79702. protected _getFilenameAndPath(): {
  79703. filename: string;
  79704. path: string;
  79705. };
  79706. protected _getModelLoadingConstraints(): boolean;
  79707. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  79708. protected _setRootMesh(meshes: AbstractMesh[]): void;
  79709. protected _updateModel(): void;
  79710. }
  79711. }
  79712. declare module "babylonjs/XR/motionController/index" {
  79713. export * from "babylonjs/XR/motionController/webXRAbstractMotionController";
  79714. export * from "babylonjs/XR/motionController/webXRControllerComponent";
  79715. export * from "babylonjs/XR/motionController/webXRGenericMotionController";
  79716. export * from "babylonjs/XR/motionController/webXRMicrosoftMixedRealityController";
  79717. export * from "babylonjs/XR/motionController/webXRMotionControllerManager";
  79718. export * from "babylonjs/XR/motionController/webXROculusTouchMotionController";
  79719. export * from "babylonjs/XR/motionController/webXRHTCViveMotionController";
  79720. export * from "babylonjs/XR/motionController/webXRProfiledMotionController";
  79721. }
  79722. declare module "babylonjs/XR/index" {
  79723. export * from "babylonjs/XR/webXRCamera";
  79724. export * from "babylonjs/XR/webXREnterExitUI";
  79725. export * from "babylonjs/XR/webXRExperienceHelper";
  79726. export * from "babylonjs/XR/webXRInput";
  79727. export * from "babylonjs/XR/webXRInputSource";
  79728. export * from "babylonjs/XR/webXRManagedOutputCanvas";
  79729. export * from "babylonjs/XR/webXRTypes";
  79730. export * from "babylonjs/XR/webXRSessionManager";
  79731. export * from "babylonjs/XR/webXRDefaultExperience";
  79732. export * from "babylonjs/XR/webXRFeaturesManager";
  79733. export * from "babylonjs/XR/features/index";
  79734. export * from "babylonjs/XR/motionController/index";
  79735. }
  79736. declare module "babylonjs/index" {
  79737. export * from "babylonjs/abstractScene";
  79738. export * from "babylonjs/Actions/index";
  79739. export * from "babylonjs/Animations/index";
  79740. export * from "babylonjs/assetContainer";
  79741. export * from "babylonjs/Audio/index";
  79742. export * from "babylonjs/Behaviors/index";
  79743. export * from "babylonjs/Bones/index";
  79744. export * from "babylonjs/Cameras/index";
  79745. export * from "babylonjs/Collisions/index";
  79746. export * from "babylonjs/Culling/index";
  79747. export * from "babylonjs/Debug/index";
  79748. export * from "babylonjs/DeviceInput/index";
  79749. export * from "babylonjs/Engines/index";
  79750. export * from "babylonjs/Events/index";
  79751. export * from "babylonjs/Gamepads/index";
  79752. export * from "babylonjs/Gizmos/index";
  79753. export * from "babylonjs/Helpers/index";
  79754. export * from "babylonjs/Instrumentation/index";
  79755. export * from "babylonjs/Layers/index";
  79756. export * from "babylonjs/LensFlares/index";
  79757. export * from "babylonjs/Lights/index";
  79758. export * from "babylonjs/Loading/index";
  79759. export * from "babylonjs/Materials/index";
  79760. export * from "babylonjs/Maths/index";
  79761. export * from "babylonjs/Meshes/index";
  79762. export * from "babylonjs/Morph/index";
  79763. export * from "babylonjs/Navigation/index";
  79764. export * from "babylonjs/node";
  79765. export * from "babylonjs/Offline/index";
  79766. export * from "babylonjs/Particles/index";
  79767. export * from "babylonjs/Physics/index";
  79768. export * from "babylonjs/PostProcesses/index";
  79769. export * from "babylonjs/Probes/index";
  79770. export * from "babylonjs/Rendering/index";
  79771. export * from "babylonjs/scene";
  79772. export * from "babylonjs/sceneComponent";
  79773. export * from "babylonjs/Sprites/index";
  79774. export * from "babylonjs/States/index";
  79775. export * from "babylonjs/Misc/index";
  79776. export * from "babylonjs/XR/index";
  79777. export * from "babylonjs/types";
  79778. }
  79779. declare module "babylonjs/Animations/pathCursor" {
  79780. import { Vector3 } from "babylonjs/Maths/math.vector";
  79781. import { Path2 } from "babylonjs/Maths/math.path";
  79782. /**
  79783. * A cursor which tracks a point on a path
  79784. */
  79785. export class PathCursor {
  79786. private path;
  79787. /**
  79788. * Stores path cursor callbacks for when an onchange event is triggered
  79789. */
  79790. private _onchange;
  79791. /**
  79792. * The value of the path cursor
  79793. */
  79794. value: number;
  79795. /**
  79796. * The animation array of the path cursor
  79797. */
  79798. animations: Animation[];
  79799. /**
  79800. * Initializes the path cursor
  79801. * @param path The path to track
  79802. */
  79803. constructor(path: Path2);
  79804. /**
  79805. * Gets the cursor point on the path
  79806. * @returns A point on the path cursor at the cursor location
  79807. */
  79808. getPoint(): Vector3;
  79809. /**
  79810. * Moves the cursor ahead by the step amount
  79811. * @param step The amount to move the cursor forward
  79812. * @returns This path cursor
  79813. */
  79814. moveAhead(step?: number): PathCursor;
  79815. /**
  79816. * Moves the cursor behind by the step amount
  79817. * @param step The amount to move the cursor back
  79818. * @returns This path cursor
  79819. */
  79820. moveBack(step?: number): PathCursor;
  79821. /**
  79822. * Moves the cursor by the step amount
  79823. * If the step amount is greater than one, an exception is thrown
  79824. * @param step The amount to move the cursor
  79825. * @returns This path cursor
  79826. */
  79827. move(step: number): PathCursor;
  79828. /**
  79829. * Ensures that the value is limited between zero and one
  79830. * @returns This path cursor
  79831. */
  79832. private ensureLimits;
  79833. /**
  79834. * Runs onchange callbacks on change (used by the animation engine)
  79835. * @returns This path cursor
  79836. */
  79837. private raiseOnChange;
  79838. /**
  79839. * Executes a function on change
  79840. * @param f A path cursor onchange callback
  79841. * @returns This path cursor
  79842. */
  79843. onchange(f: (cursor: PathCursor) => void): PathCursor;
  79844. }
  79845. }
  79846. declare module "babylonjs/Engines/Processors/Expressions/Operators/index" {
  79847. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator";
  79848. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator";
  79849. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator";
  79850. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator";
  79851. }
  79852. declare module "babylonjs/Engines/Processors/Expressions/index" {
  79853. export * from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  79854. export * from "babylonjs/Engines/Processors/Expressions/Operators/index";
  79855. }
  79856. declare module "babylonjs/Engines/Processors/index" {
  79857. export * from "babylonjs/Engines/Processors/iShaderProcessor";
  79858. export * from "babylonjs/Engines/Processors/Expressions/index";
  79859. export * from "babylonjs/Engines/Processors/shaderCodeConditionNode";
  79860. export * from "babylonjs/Engines/Processors/shaderCodeCursor";
  79861. export * from "babylonjs/Engines/Processors/shaderCodeNode";
  79862. export * from "babylonjs/Engines/Processors/shaderCodeTestNode";
  79863. export * from "babylonjs/Engines/Processors/shaderProcessingOptions";
  79864. export * from "babylonjs/Engines/Processors/shaderProcessor";
  79865. export * from "babylonjs/Engines/Processors/shaderCodeInliner";
  79866. }
  79867. declare module "babylonjs/Legacy/legacy" {
  79868. import * as Babylon from "babylonjs/index";
  79869. export * from "babylonjs/index";
  79870. }
  79871. declare module "babylonjs/Shaders/blur.fragment" {
  79872. /** @hidden */
  79873. export var blurPixelShader: {
  79874. name: string;
  79875. shader: string;
  79876. };
  79877. }
  79878. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  79879. /** @hidden */
  79880. export var pointCloudVertexDeclaration: {
  79881. name: string;
  79882. shader: string;
  79883. };
  79884. }
  79885. declare module "babylonjs" {
  79886. export * from "babylonjs/Legacy/legacy";
  79887. }
  79888. declare module BABYLON {
  79889. /** Alias type for value that can be null */
  79890. export type Nullable<T> = T | null;
  79891. /**
  79892. * Alias type for number that are floats
  79893. * @ignorenaming
  79894. */
  79895. export type float = number;
  79896. /**
  79897. * Alias type for number that are doubles.
  79898. * @ignorenaming
  79899. */
  79900. export type double = number;
  79901. /**
  79902. * Alias type for number that are integer
  79903. * @ignorenaming
  79904. */
  79905. export type int = number;
  79906. /** Alias type for number array or Float32Array */
  79907. export type FloatArray = number[] | Float32Array;
  79908. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  79909. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  79910. /**
  79911. * Alias for types that can be used by a Buffer or VertexBuffer.
  79912. */
  79913. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  79914. /**
  79915. * Alias type for primitive types
  79916. * @ignorenaming
  79917. */
  79918. type Primitive = undefined | null | boolean | string | number | Function;
  79919. /**
  79920. * Type modifier to make all the properties of an object Readonly
  79921. */
  79922. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  79923. /**
  79924. * Type modifier to make all the properties of an object Readonly recursively
  79925. */
  79926. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  79927. /**
  79928. * Type modifier to make object properties readonly.
  79929. */
  79930. export type DeepImmutableObject<T> = {
  79931. readonly [K in keyof T]: DeepImmutable<T[K]>;
  79932. };
  79933. /** @hidden */
  79934. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  79935. }
  79936. }
  79937. declare module BABYLON {
  79938. /**
  79939. * A class serves as a medium between the observable and its observers
  79940. */
  79941. export class EventState {
  79942. /**
  79943. * Create a new EventState
  79944. * @param mask defines the mask associated with this state
  79945. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  79946. * @param target defines the original target of the state
  79947. * @param currentTarget defines the current target of the state
  79948. */
  79949. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  79950. /**
  79951. * Initialize the current event state
  79952. * @param mask defines the mask associated with this state
  79953. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  79954. * @param target defines the original target of the state
  79955. * @param currentTarget defines the current target of the state
  79956. * @returns the current event state
  79957. */
  79958. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  79959. /**
  79960. * An Observer can set this property to true to prevent subsequent observers of being notified
  79961. */
  79962. skipNextObservers: boolean;
  79963. /**
  79964. * Get the mask value that were used to trigger the event corresponding to this EventState object
  79965. */
  79966. mask: number;
  79967. /**
  79968. * The object that originally notified the event
  79969. */
  79970. target?: any;
  79971. /**
  79972. * The current object in the bubbling phase
  79973. */
  79974. currentTarget?: any;
  79975. /**
  79976. * This will be populated with the return value of the last function that was executed.
  79977. * If it is the first function in the callback chain it will be the event data.
  79978. */
  79979. lastReturnValue?: any;
  79980. }
  79981. /**
  79982. * Represent an Observer registered to a given Observable object.
  79983. */
  79984. export class Observer<T> {
  79985. /**
  79986. * Defines the callback to call when the observer is notified
  79987. */
  79988. callback: (eventData: T, eventState: EventState) => void;
  79989. /**
  79990. * Defines the mask of the observer (used to filter notifications)
  79991. */
  79992. mask: number;
  79993. /**
  79994. * Defines the current scope used to restore the JS context
  79995. */
  79996. scope: any;
  79997. /** @hidden */
  79998. _willBeUnregistered: boolean;
  79999. /**
  80000. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  80001. */
  80002. unregisterOnNextCall: boolean;
  80003. /**
  80004. * Creates a new observer
  80005. * @param callback defines the callback to call when the observer is notified
  80006. * @param mask defines the mask of the observer (used to filter notifications)
  80007. * @param scope defines the current scope used to restore the JS context
  80008. */
  80009. constructor(
  80010. /**
  80011. * Defines the callback to call when the observer is notified
  80012. */
  80013. callback: (eventData: T, eventState: EventState) => void,
  80014. /**
  80015. * Defines the mask of the observer (used to filter notifications)
  80016. */
  80017. mask: number,
  80018. /**
  80019. * Defines the current scope used to restore the JS context
  80020. */
  80021. scope?: any);
  80022. }
  80023. /**
  80024. * Represent a list of observers registered to multiple Observables object.
  80025. */
  80026. export class MultiObserver<T> {
  80027. private _observers;
  80028. private _observables;
  80029. /**
  80030. * Release associated resources
  80031. */
  80032. dispose(): void;
  80033. /**
  80034. * Raise a callback when one of the observable will notify
  80035. * @param observables defines a list of observables to watch
  80036. * @param callback defines the callback to call on notification
  80037. * @param mask defines the mask used to filter notifications
  80038. * @param scope defines the current scope used to restore the JS context
  80039. * @returns the new MultiObserver
  80040. */
  80041. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  80042. }
  80043. /**
  80044. * The Observable class is a simple implementation of the Observable pattern.
  80045. *
  80046. * 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.
  80047. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  80048. * 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).
  80049. * 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.
  80050. */
  80051. export class Observable<T> {
  80052. private _observers;
  80053. private _eventState;
  80054. private _onObserverAdded;
  80055. /**
  80056. * Gets the list of observers
  80057. */
  80058. get observers(): Array<Observer<T>>;
  80059. /**
  80060. * Creates a new observable
  80061. * @param onObserverAdded defines a callback to call when a new observer is added
  80062. */
  80063. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  80064. /**
  80065. * Create a new Observer with the specified callback
  80066. * @param callback the callback that will be executed for that Observer
  80067. * @param mask the mask used to filter observers
  80068. * @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.
  80069. * @param scope optional scope for the callback to be called from
  80070. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  80071. * @returns the new observer created for the callback
  80072. */
  80073. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  80074. /**
  80075. * Create a new Observer with the specified callback and unregisters after the next notification
  80076. * @param callback the callback that will be executed for that Observer
  80077. * @returns the new observer created for the callback
  80078. */
  80079. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  80080. /**
  80081. * Remove an Observer from the Observable object
  80082. * @param observer the instance of the Observer to remove
  80083. * @returns false if it doesn't belong to this Observable
  80084. */
  80085. remove(observer: Nullable<Observer<T>>): boolean;
  80086. /**
  80087. * Remove a callback from the Observable object
  80088. * @param callback the callback to remove
  80089. * @param scope optional scope. If used only the callbacks with this scope will be removed
  80090. * @returns false if it doesn't belong to this Observable
  80091. */
  80092. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  80093. private _deferUnregister;
  80094. private _remove;
  80095. /**
  80096. * Moves the observable to the top of the observer list making it get called first when notified
  80097. * @param observer the observer to move
  80098. */
  80099. makeObserverTopPriority(observer: Observer<T>): void;
  80100. /**
  80101. * Moves the observable to the bottom of the observer list making it get called last when notified
  80102. * @param observer the observer to move
  80103. */
  80104. makeObserverBottomPriority(observer: Observer<T>): void;
  80105. /**
  80106. * Notify all Observers by calling their respective callback with the given data
  80107. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  80108. * @param eventData defines the data to send to all observers
  80109. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  80110. * @param target defines the original target of the state
  80111. * @param currentTarget defines the current target of the state
  80112. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  80113. */
  80114. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  80115. /**
  80116. * Calling this will execute each callback, expecting it to be a promise or return a value.
  80117. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  80118. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  80119. * and it is crucial that all callbacks will be executed.
  80120. * The order of the callbacks is kept, callbacks are not executed parallel.
  80121. *
  80122. * @param eventData The data to be sent to each callback
  80123. * @param mask is used to filter observers defaults to -1
  80124. * @param target defines the callback target (see EventState)
  80125. * @param currentTarget defines he current object in the bubbling phase
  80126. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  80127. */
  80128. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  80129. /**
  80130. * Notify a specific observer
  80131. * @param observer defines the observer to notify
  80132. * @param eventData defines the data to be sent to each callback
  80133. * @param mask is used to filter observers defaults to -1
  80134. */
  80135. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  80136. /**
  80137. * Gets a boolean indicating if the observable has at least one observer
  80138. * @returns true is the Observable has at least one Observer registered
  80139. */
  80140. hasObservers(): boolean;
  80141. /**
  80142. * Clear the list of observers
  80143. */
  80144. clear(): void;
  80145. /**
  80146. * Clone the current observable
  80147. * @returns a new observable
  80148. */
  80149. clone(): Observable<T>;
  80150. /**
  80151. * Does this observable handles observer registered with a given mask
  80152. * @param mask defines the mask to be tested
  80153. * @return whether or not one observer registered with the given mask is handeled
  80154. **/
  80155. hasSpecificMask(mask?: number): boolean;
  80156. }
  80157. }
  80158. declare module BABYLON {
  80159. /**
  80160. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  80161. * Babylon.js
  80162. */
  80163. export class DomManagement {
  80164. /**
  80165. * Checks if the window object exists
  80166. * @returns true if the window object exists
  80167. */
  80168. static IsWindowObjectExist(): boolean;
  80169. /**
  80170. * Checks if the navigator object exists
  80171. * @returns true if the navigator object exists
  80172. */
  80173. static IsNavigatorAvailable(): boolean;
  80174. /**
  80175. * Check if the document object exists
  80176. * @returns true if the document object exists
  80177. */
  80178. static IsDocumentAvailable(): boolean;
  80179. /**
  80180. * Extracts text content from a DOM element hierarchy
  80181. * @param element defines the root element
  80182. * @returns a string
  80183. */
  80184. static GetDOMTextContent(element: HTMLElement): string;
  80185. }
  80186. }
  80187. declare module BABYLON {
  80188. /**
  80189. * Logger used througouht the application to allow configuration of
  80190. * the log level required for the messages.
  80191. */
  80192. export class Logger {
  80193. /**
  80194. * No log
  80195. */
  80196. static readonly NoneLogLevel: number;
  80197. /**
  80198. * Only message logs
  80199. */
  80200. static readonly MessageLogLevel: number;
  80201. /**
  80202. * Only warning logs
  80203. */
  80204. static readonly WarningLogLevel: number;
  80205. /**
  80206. * Only error logs
  80207. */
  80208. static readonly ErrorLogLevel: number;
  80209. /**
  80210. * All logs
  80211. */
  80212. static readonly AllLogLevel: number;
  80213. private static _LogCache;
  80214. /**
  80215. * Gets a value indicating the number of loading errors
  80216. * @ignorenaming
  80217. */
  80218. static errorsCount: number;
  80219. /**
  80220. * Callback called when a new log is added
  80221. */
  80222. static OnNewCacheEntry: (entry: string) => void;
  80223. private static _AddLogEntry;
  80224. private static _FormatMessage;
  80225. private static _LogDisabled;
  80226. private static _LogEnabled;
  80227. private static _WarnDisabled;
  80228. private static _WarnEnabled;
  80229. private static _ErrorDisabled;
  80230. private static _ErrorEnabled;
  80231. /**
  80232. * Log a message to the console
  80233. */
  80234. static Log: (message: string) => void;
  80235. /**
  80236. * Write a warning message to the console
  80237. */
  80238. static Warn: (message: string) => void;
  80239. /**
  80240. * Write an error message to the console
  80241. */
  80242. static Error: (message: string) => void;
  80243. /**
  80244. * Gets current log cache (list of logs)
  80245. */
  80246. static get LogCache(): string;
  80247. /**
  80248. * Clears the log cache
  80249. */
  80250. static ClearLogCache(): void;
  80251. /**
  80252. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  80253. */
  80254. static set LogLevels(level: number);
  80255. }
  80256. }
  80257. declare module BABYLON {
  80258. /** @hidden */
  80259. export class _TypeStore {
  80260. /** @hidden */
  80261. static RegisteredTypes: {
  80262. [key: string]: Object;
  80263. };
  80264. /** @hidden */
  80265. static GetClass(fqdn: string): any;
  80266. }
  80267. }
  80268. declare module BABYLON {
  80269. /**
  80270. * Helper to manipulate strings
  80271. */
  80272. export class StringTools {
  80273. /**
  80274. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  80275. * @param str Source string
  80276. * @param suffix Suffix to search for in the source string
  80277. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  80278. */
  80279. static EndsWith(str: string, suffix: string): boolean;
  80280. /**
  80281. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  80282. * @param str Source string
  80283. * @param suffix Suffix to search for in the source string
  80284. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  80285. */
  80286. static StartsWith(str: string, suffix: string): boolean;
  80287. /**
  80288. * Decodes a buffer into a string
  80289. * @param buffer The buffer to decode
  80290. * @returns The decoded string
  80291. */
  80292. static Decode(buffer: Uint8Array | Uint16Array): string;
  80293. /**
  80294. * Encode a buffer to a base64 string
  80295. * @param buffer defines the buffer to encode
  80296. * @returns the encoded string
  80297. */
  80298. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  80299. /**
  80300. * Converts a number to string and pads with preceeding zeroes until it is of specified length.
  80301. * @param num the number to convert and pad
  80302. * @param length the expected length of the string
  80303. * @returns the padded string
  80304. */
  80305. static PadNumber(num: number, length: number): string;
  80306. }
  80307. }
  80308. declare module BABYLON {
  80309. /**
  80310. * Class containing a set of static utilities functions for deep copy.
  80311. */
  80312. export class DeepCopier {
  80313. /**
  80314. * Tries to copy an object by duplicating every property
  80315. * @param source defines the source object
  80316. * @param destination defines the target object
  80317. * @param doNotCopyList defines a list of properties to avoid
  80318. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  80319. */
  80320. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  80321. }
  80322. }
  80323. declare module BABYLON {
  80324. /**
  80325. * Class containing a set of static utilities functions for precision date
  80326. */
  80327. export class PrecisionDate {
  80328. /**
  80329. * Gets either window.performance.now() if supported or Date.now() else
  80330. */
  80331. static get Now(): number;
  80332. }
  80333. }
  80334. declare module BABYLON {
  80335. /** @hidden */
  80336. export class _DevTools {
  80337. static WarnImport(name: string): string;
  80338. }
  80339. }
  80340. declare module BABYLON {
  80341. /**
  80342. * Interface used to define the mechanism to get data from the network
  80343. */
  80344. export interface IWebRequest {
  80345. /**
  80346. * Returns client's response url
  80347. */
  80348. responseURL: string;
  80349. /**
  80350. * Returns client's status
  80351. */
  80352. status: number;
  80353. /**
  80354. * Returns client's status as a text
  80355. */
  80356. statusText: string;
  80357. }
  80358. }
  80359. declare module BABYLON {
  80360. /**
  80361. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  80362. */
  80363. export class WebRequest implements IWebRequest {
  80364. private _xhr;
  80365. /**
  80366. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  80367. * i.e. when loading files, where the server/service expects an Authorization header
  80368. */
  80369. static CustomRequestHeaders: {
  80370. [key: string]: string;
  80371. };
  80372. /**
  80373. * Add callback functions in this array to update all the requests before they get sent to the network
  80374. */
  80375. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  80376. private _injectCustomRequestHeaders;
  80377. /**
  80378. * Gets or sets a function to be called when loading progress changes
  80379. */
  80380. get onprogress(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  80381. set onprogress(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
  80382. /**
  80383. * Returns client's state
  80384. */
  80385. get readyState(): number;
  80386. /**
  80387. * Returns client's status
  80388. */
  80389. get status(): number;
  80390. /**
  80391. * Returns client's status as a text
  80392. */
  80393. get statusText(): string;
  80394. /**
  80395. * Returns client's response
  80396. */
  80397. get response(): any;
  80398. /**
  80399. * Returns client's response url
  80400. */
  80401. get responseURL(): string;
  80402. /**
  80403. * Returns client's response as text
  80404. */
  80405. get responseText(): string;
  80406. /**
  80407. * Gets or sets the expected response type
  80408. */
  80409. get responseType(): XMLHttpRequestResponseType;
  80410. set responseType(value: XMLHttpRequestResponseType);
  80411. /** @hidden */
  80412. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  80413. /** @hidden */
  80414. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  80415. /**
  80416. * Cancels any network activity
  80417. */
  80418. abort(): void;
  80419. /**
  80420. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  80421. * @param body defines an optional request body
  80422. */
  80423. send(body?: Document | BodyInit | null): void;
  80424. /**
  80425. * Sets the request method, request URL
  80426. * @param method defines the method to use (GET, POST, etc..)
  80427. * @param url defines the url to connect with
  80428. */
  80429. open(method: string, url: string): void;
  80430. /**
  80431. * Sets the value of a request header.
  80432. * @param name The name of the header whose value is to be set
  80433. * @param value The value to set as the body of the header
  80434. */
  80435. setRequestHeader(name: string, value: string): void;
  80436. /**
  80437. * Get the string containing the text of a particular header's value.
  80438. * @param name The name of the header
  80439. * @returns The string containing the text of the given header name
  80440. */
  80441. getResponseHeader(name: string): Nullable<string>;
  80442. }
  80443. }
  80444. declare module BABYLON {
  80445. /**
  80446. * File request interface
  80447. */
  80448. export interface IFileRequest {
  80449. /**
  80450. * Raised when the request is complete (success or error).
  80451. */
  80452. onCompleteObservable: Observable<IFileRequest>;
  80453. /**
  80454. * Aborts the request for a file.
  80455. */
  80456. abort: () => void;
  80457. }
  80458. }
  80459. declare module BABYLON {
  80460. /**
  80461. * Define options used to create a render target texture
  80462. */
  80463. export class RenderTargetCreationOptions {
  80464. /**
  80465. * Specifies is mipmaps must be generated
  80466. */
  80467. generateMipMaps?: boolean;
  80468. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  80469. generateDepthBuffer?: boolean;
  80470. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  80471. generateStencilBuffer?: boolean;
  80472. /** Defines texture type (int by default) */
  80473. type?: number;
  80474. /** Defines sampling mode (trilinear by default) */
  80475. samplingMode?: number;
  80476. /** Defines format (RGBA by default) */
  80477. format?: number;
  80478. }
  80479. }
  80480. declare module BABYLON {
  80481. /** Defines the cross module used constants to avoid circular dependncies */
  80482. export class Constants {
  80483. /** Defines that alpha blending is disabled */
  80484. static readonly ALPHA_DISABLE: number;
  80485. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  80486. static readonly ALPHA_ADD: number;
  80487. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  80488. static readonly ALPHA_COMBINE: number;
  80489. /** Defines that alpha blending is DEST - SRC * DEST */
  80490. static readonly ALPHA_SUBTRACT: number;
  80491. /** Defines that alpha blending is SRC * DEST */
  80492. static readonly ALPHA_MULTIPLY: number;
  80493. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  80494. static readonly ALPHA_MAXIMIZED: number;
  80495. /** Defines that alpha blending is SRC + DEST */
  80496. static readonly ALPHA_ONEONE: number;
  80497. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  80498. static readonly ALPHA_PREMULTIPLIED: number;
  80499. /**
  80500. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  80501. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  80502. */
  80503. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  80504. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  80505. static readonly ALPHA_INTERPOLATE: number;
  80506. /**
  80507. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  80508. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  80509. */
  80510. static readonly ALPHA_SCREENMODE: number;
  80511. /**
  80512. * Defines that alpha blending is SRC + DST
  80513. * Alpha will be set to SRC ALPHA + DST ALPHA
  80514. */
  80515. static readonly ALPHA_ONEONE_ONEONE: number;
  80516. /**
  80517. * Defines that alpha blending is SRC * DST ALPHA + DST
  80518. * Alpha will be set to 0
  80519. */
  80520. static readonly ALPHA_ALPHATOCOLOR: number;
  80521. /**
  80522. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  80523. */
  80524. static readonly ALPHA_REVERSEONEMINUS: number;
  80525. /**
  80526. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  80527. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  80528. */
  80529. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  80530. /**
  80531. * Defines that alpha blending is SRC + DST
  80532. * Alpha will be set to SRC ALPHA
  80533. */
  80534. static readonly ALPHA_ONEONE_ONEZERO: number;
  80535. /**
  80536. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  80537. * Alpha will be set to DST ALPHA
  80538. */
  80539. static readonly ALPHA_EXCLUSION: number;
  80540. /** Defines that alpha blending equation a SUM */
  80541. static readonly ALPHA_EQUATION_ADD: number;
  80542. /** Defines that alpha blending equation a SUBSTRACTION */
  80543. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  80544. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  80545. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  80546. /** Defines that alpha blending equation a MAX operation */
  80547. static readonly ALPHA_EQUATION_MAX: number;
  80548. /** Defines that alpha blending equation a MIN operation */
  80549. static readonly ALPHA_EQUATION_MIN: number;
  80550. /**
  80551. * Defines that alpha blending equation a DARKEN operation:
  80552. * It takes the min of the src and sums the alpha channels.
  80553. */
  80554. static readonly ALPHA_EQUATION_DARKEN: number;
  80555. /** Defines that the ressource is not delayed*/
  80556. static readonly DELAYLOADSTATE_NONE: number;
  80557. /** Defines that the ressource was successfully delay loaded */
  80558. static readonly DELAYLOADSTATE_LOADED: number;
  80559. /** Defines that the ressource is currently delay loading */
  80560. static readonly DELAYLOADSTATE_LOADING: number;
  80561. /** Defines that the ressource is delayed and has not started loading */
  80562. static readonly DELAYLOADSTATE_NOTLOADED: number;
  80563. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  80564. static readonly NEVER: number;
  80565. /** 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 */
  80566. static readonly ALWAYS: number;
  80567. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  80568. static readonly LESS: number;
  80569. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  80570. static readonly EQUAL: number;
  80571. /** 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 */
  80572. static readonly LEQUAL: number;
  80573. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  80574. static readonly GREATER: number;
  80575. /** 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 */
  80576. static readonly GEQUAL: number;
  80577. /** 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 */
  80578. static readonly NOTEQUAL: number;
  80579. /** Passed to stencilOperation to specify that stencil value must be kept */
  80580. static readonly KEEP: number;
  80581. /** Passed to stencilOperation to specify that stencil value must be replaced */
  80582. static readonly REPLACE: number;
  80583. /** Passed to stencilOperation to specify that stencil value must be incremented */
  80584. static readonly INCR: number;
  80585. /** Passed to stencilOperation to specify that stencil value must be decremented */
  80586. static readonly DECR: number;
  80587. /** Passed to stencilOperation to specify that stencil value must be inverted */
  80588. static readonly INVERT: number;
  80589. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  80590. static readonly INCR_WRAP: number;
  80591. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  80592. static readonly DECR_WRAP: number;
  80593. /** Texture is not repeating outside of 0..1 UVs */
  80594. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  80595. /** Texture is repeating outside of 0..1 UVs */
  80596. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  80597. /** Texture is repeating and mirrored */
  80598. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  80599. /** ALPHA */
  80600. static readonly TEXTUREFORMAT_ALPHA: number;
  80601. /** LUMINANCE */
  80602. static readonly TEXTUREFORMAT_LUMINANCE: number;
  80603. /** LUMINANCE_ALPHA */
  80604. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  80605. /** RGB */
  80606. static readonly TEXTUREFORMAT_RGB: number;
  80607. /** RGBA */
  80608. static readonly TEXTUREFORMAT_RGBA: number;
  80609. /** RED */
  80610. static readonly TEXTUREFORMAT_RED: number;
  80611. /** RED (2nd reference) */
  80612. static readonly TEXTUREFORMAT_R: number;
  80613. /** RG */
  80614. static readonly TEXTUREFORMAT_RG: number;
  80615. /** RED_INTEGER */
  80616. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  80617. /** RED_INTEGER (2nd reference) */
  80618. static readonly TEXTUREFORMAT_R_INTEGER: number;
  80619. /** RG_INTEGER */
  80620. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  80621. /** RGB_INTEGER */
  80622. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  80623. /** RGBA_INTEGER */
  80624. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  80625. /** UNSIGNED_BYTE */
  80626. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  80627. /** UNSIGNED_BYTE (2nd reference) */
  80628. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  80629. /** FLOAT */
  80630. static readonly TEXTURETYPE_FLOAT: number;
  80631. /** HALF_FLOAT */
  80632. static readonly TEXTURETYPE_HALF_FLOAT: number;
  80633. /** BYTE */
  80634. static readonly TEXTURETYPE_BYTE: number;
  80635. /** SHORT */
  80636. static readonly TEXTURETYPE_SHORT: number;
  80637. /** UNSIGNED_SHORT */
  80638. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  80639. /** INT */
  80640. static readonly TEXTURETYPE_INT: number;
  80641. /** UNSIGNED_INT */
  80642. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  80643. /** UNSIGNED_SHORT_4_4_4_4 */
  80644. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  80645. /** UNSIGNED_SHORT_5_5_5_1 */
  80646. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  80647. /** UNSIGNED_SHORT_5_6_5 */
  80648. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  80649. /** UNSIGNED_INT_2_10_10_10_REV */
  80650. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  80651. /** UNSIGNED_INT_24_8 */
  80652. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  80653. /** UNSIGNED_INT_10F_11F_11F_REV */
  80654. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  80655. /** UNSIGNED_INT_5_9_9_9_REV */
  80656. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  80657. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  80658. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  80659. /** nearest is mag = nearest and min = nearest and no mip */
  80660. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  80661. /** mag = nearest and min = nearest and mip = none */
  80662. static readonly TEXTURE_NEAREST_NEAREST: number;
  80663. /** Bilinear is mag = linear and min = linear and no mip */
  80664. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  80665. /** mag = linear and min = linear and mip = none */
  80666. static readonly TEXTURE_LINEAR_LINEAR: number;
  80667. /** Trilinear is mag = linear and min = linear and mip = linear */
  80668. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  80669. /** Trilinear is mag = linear and min = linear and mip = linear */
  80670. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  80671. /** mag = nearest and min = nearest and mip = nearest */
  80672. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  80673. /** mag = nearest and min = linear and mip = nearest */
  80674. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  80675. /** mag = nearest and min = linear and mip = linear */
  80676. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  80677. /** mag = nearest and min = linear and mip = none */
  80678. static readonly TEXTURE_NEAREST_LINEAR: number;
  80679. /** nearest is mag = nearest and min = nearest and mip = linear */
  80680. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  80681. /** mag = linear and min = nearest and mip = nearest */
  80682. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  80683. /** mag = linear and min = nearest and mip = linear */
  80684. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  80685. /** Bilinear is mag = linear and min = linear and mip = nearest */
  80686. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  80687. /** mag = linear and min = nearest and mip = none */
  80688. static readonly TEXTURE_LINEAR_NEAREST: number;
  80689. /** Explicit coordinates mode */
  80690. static readonly TEXTURE_EXPLICIT_MODE: number;
  80691. /** Spherical coordinates mode */
  80692. static readonly TEXTURE_SPHERICAL_MODE: number;
  80693. /** Planar coordinates mode */
  80694. static readonly TEXTURE_PLANAR_MODE: number;
  80695. /** Cubic coordinates mode */
  80696. static readonly TEXTURE_CUBIC_MODE: number;
  80697. /** Projection coordinates mode */
  80698. static readonly TEXTURE_PROJECTION_MODE: number;
  80699. /** Skybox coordinates mode */
  80700. static readonly TEXTURE_SKYBOX_MODE: number;
  80701. /** Inverse Cubic coordinates mode */
  80702. static readonly TEXTURE_INVCUBIC_MODE: number;
  80703. /** Equirectangular coordinates mode */
  80704. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  80705. /** Equirectangular Fixed coordinates mode */
  80706. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  80707. /** Equirectangular Fixed Mirrored coordinates mode */
  80708. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  80709. /** Offline (baking) quality for texture filtering */
  80710. static readonly TEXTURE_FILTERING_QUALITY_OFFLINE: number;
  80711. /** High quality for texture filtering */
  80712. static readonly TEXTURE_FILTERING_QUALITY_HIGH: number;
  80713. /** Medium quality for texture filtering */
  80714. static readonly TEXTURE_FILTERING_QUALITY_MEDIUM: number;
  80715. /** Low quality for texture filtering */
  80716. static readonly TEXTURE_FILTERING_QUALITY_LOW: number;
  80717. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  80718. static readonly SCALEMODE_FLOOR: number;
  80719. /** Defines that texture rescaling will look for the nearest power of 2 size */
  80720. static readonly SCALEMODE_NEAREST: number;
  80721. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  80722. static readonly SCALEMODE_CEILING: number;
  80723. /**
  80724. * The dirty texture flag value
  80725. */
  80726. static readonly MATERIAL_TextureDirtyFlag: number;
  80727. /**
  80728. * The dirty light flag value
  80729. */
  80730. static readonly MATERIAL_LightDirtyFlag: number;
  80731. /**
  80732. * The dirty fresnel flag value
  80733. */
  80734. static readonly MATERIAL_FresnelDirtyFlag: number;
  80735. /**
  80736. * The dirty attribute flag value
  80737. */
  80738. static readonly MATERIAL_AttributesDirtyFlag: number;
  80739. /**
  80740. * The dirty misc flag value
  80741. */
  80742. static readonly MATERIAL_MiscDirtyFlag: number;
  80743. /**
  80744. * The all dirty flag value
  80745. */
  80746. static readonly MATERIAL_AllDirtyFlag: number;
  80747. /**
  80748. * Returns the triangle fill mode
  80749. */
  80750. static readonly MATERIAL_TriangleFillMode: number;
  80751. /**
  80752. * Returns the wireframe mode
  80753. */
  80754. static readonly MATERIAL_WireFrameFillMode: number;
  80755. /**
  80756. * Returns the point fill mode
  80757. */
  80758. static readonly MATERIAL_PointFillMode: number;
  80759. /**
  80760. * Returns the point list draw mode
  80761. */
  80762. static readonly MATERIAL_PointListDrawMode: number;
  80763. /**
  80764. * Returns the line list draw mode
  80765. */
  80766. static readonly MATERIAL_LineListDrawMode: number;
  80767. /**
  80768. * Returns the line loop draw mode
  80769. */
  80770. static readonly MATERIAL_LineLoopDrawMode: number;
  80771. /**
  80772. * Returns the line strip draw mode
  80773. */
  80774. static readonly MATERIAL_LineStripDrawMode: number;
  80775. /**
  80776. * Returns the triangle strip draw mode
  80777. */
  80778. static readonly MATERIAL_TriangleStripDrawMode: number;
  80779. /**
  80780. * Returns the triangle fan draw mode
  80781. */
  80782. static readonly MATERIAL_TriangleFanDrawMode: number;
  80783. /**
  80784. * Stores the clock-wise side orientation
  80785. */
  80786. static readonly MATERIAL_ClockWiseSideOrientation: number;
  80787. /**
  80788. * Stores the counter clock-wise side orientation
  80789. */
  80790. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  80791. /**
  80792. * Nothing
  80793. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  80794. */
  80795. static readonly ACTION_NothingTrigger: number;
  80796. /**
  80797. * On pick
  80798. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  80799. */
  80800. static readonly ACTION_OnPickTrigger: number;
  80801. /**
  80802. * On left pick
  80803. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  80804. */
  80805. static readonly ACTION_OnLeftPickTrigger: number;
  80806. /**
  80807. * On right pick
  80808. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  80809. */
  80810. static readonly ACTION_OnRightPickTrigger: number;
  80811. /**
  80812. * On center pick
  80813. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  80814. */
  80815. static readonly ACTION_OnCenterPickTrigger: number;
  80816. /**
  80817. * On pick down
  80818. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  80819. */
  80820. static readonly ACTION_OnPickDownTrigger: number;
  80821. /**
  80822. * On double pick
  80823. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  80824. */
  80825. static readonly ACTION_OnDoublePickTrigger: number;
  80826. /**
  80827. * On pick up
  80828. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  80829. */
  80830. static readonly ACTION_OnPickUpTrigger: number;
  80831. /**
  80832. * On pick out.
  80833. * This trigger will only be raised if you also declared a OnPickDown
  80834. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  80835. */
  80836. static readonly ACTION_OnPickOutTrigger: number;
  80837. /**
  80838. * On long press
  80839. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  80840. */
  80841. static readonly ACTION_OnLongPressTrigger: number;
  80842. /**
  80843. * On pointer over
  80844. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  80845. */
  80846. static readonly ACTION_OnPointerOverTrigger: number;
  80847. /**
  80848. * On pointer out
  80849. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  80850. */
  80851. static readonly ACTION_OnPointerOutTrigger: number;
  80852. /**
  80853. * On every frame
  80854. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  80855. */
  80856. static readonly ACTION_OnEveryFrameTrigger: number;
  80857. /**
  80858. * On intersection enter
  80859. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  80860. */
  80861. static readonly ACTION_OnIntersectionEnterTrigger: number;
  80862. /**
  80863. * On intersection exit
  80864. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  80865. */
  80866. static readonly ACTION_OnIntersectionExitTrigger: number;
  80867. /**
  80868. * On key down
  80869. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  80870. */
  80871. static readonly ACTION_OnKeyDownTrigger: number;
  80872. /**
  80873. * On key up
  80874. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  80875. */
  80876. static readonly ACTION_OnKeyUpTrigger: number;
  80877. /**
  80878. * Billboard mode will only apply to Y axis
  80879. */
  80880. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  80881. /**
  80882. * Billboard mode will apply to all axes
  80883. */
  80884. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  80885. /**
  80886. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  80887. */
  80888. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  80889. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  80890. * Test order :
  80891. * Is the bounding sphere outside the frustum ?
  80892. * If not, are the bounding box vertices outside the frustum ?
  80893. * It not, then the cullable object is in the frustum.
  80894. */
  80895. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  80896. /** Culling strategy : Bounding Sphere Only.
  80897. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  80898. * It's also less accurate than the standard because some not visible objects can still be selected.
  80899. * Test : is the bounding sphere outside the frustum ?
  80900. * If not, then the cullable object is in the frustum.
  80901. */
  80902. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  80903. /** Culling strategy : Optimistic Inclusion.
  80904. * This in an inclusion test first, then the standard exclusion test.
  80905. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  80906. * 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.
  80907. * Anyway, it's as accurate as the standard strategy.
  80908. * Test :
  80909. * Is the cullable object bounding sphere center in the frustum ?
  80910. * If not, apply the default culling strategy.
  80911. */
  80912. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  80913. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  80914. * This in an inclusion test first, then the bounding sphere only exclusion test.
  80915. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  80916. * 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.
  80917. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  80918. * Test :
  80919. * Is the cullable object bounding sphere center in the frustum ?
  80920. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  80921. */
  80922. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  80923. /**
  80924. * No logging while loading
  80925. */
  80926. static readonly SCENELOADER_NO_LOGGING: number;
  80927. /**
  80928. * Minimal logging while loading
  80929. */
  80930. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  80931. /**
  80932. * Summary logging while loading
  80933. */
  80934. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  80935. /**
  80936. * Detailled logging while loading
  80937. */
  80938. static readonly SCENELOADER_DETAILED_LOGGING: number;
  80939. /**
  80940. * Prepass texture index for color
  80941. */
  80942. static readonly PREPASS_COLOR_INDEX: number;
  80943. /**
  80944. * Prepass texture index for irradiance
  80945. */
  80946. static readonly PREPASS_IRRADIANCE_INDEX: number;
  80947. /**
  80948. * Prepass texture index for depth + normal
  80949. */
  80950. static readonly PREPASS_DEPTHNORMAL_INDEX: number;
  80951. /**
  80952. * Prepass texture index for albedo
  80953. */
  80954. static readonly PREPASS_ALBEDO_INDEX: number;
  80955. }
  80956. }
  80957. declare module BABYLON {
  80958. /**
  80959. * This represents the required contract to create a new type of texture loader.
  80960. */
  80961. export interface IInternalTextureLoader {
  80962. /**
  80963. * Defines wether the loader supports cascade loading the different faces.
  80964. */
  80965. supportCascades: boolean;
  80966. /**
  80967. * This returns if the loader support the current file information.
  80968. * @param extension defines the file extension of the file being loaded
  80969. * @param mimeType defines the optional mime type of the file being loaded
  80970. * @returns true if the loader can load the specified file
  80971. */
  80972. canLoad(extension: string, mimeType?: string): boolean;
  80973. /**
  80974. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  80975. * @param data contains the texture data
  80976. * @param texture defines the BabylonJS internal texture
  80977. * @param createPolynomials will be true if polynomials have been requested
  80978. * @param onLoad defines the callback to trigger once the texture is ready
  80979. * @param onError defines the callback to trigger in case of error
  80980. */
  80981. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  80982. /**
  80983. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  80984. * @param data contains the texture data
  80985. * @param texture defines the BabylonJS internal texture
  80986. * @param callback defines the method to call once ready to upload
  80987. */
  80988. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  80989. }
  80990. }
  80991. declare module BABYLON {
  80992. /**
  80993. * Class used to store and describe the pipeline context associated with an effect
  80994. */
  80995. export interface IPipelineContext {
  80996. /**
  80997. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  80998. */
  80999. isAsync: boolean;
  81000. /**
  81001. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  81002. */
  81003. isReady: boolean;
  81004. /** @hidden */
  81005. _getVertexShaderCode(): string | null;
  81006. /** @hidden */
  81007. _getFragmentShaderCode(): string | null;
  81008. /** @hidden */
  81009. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  81010. }
  81011. }
  81012. declare module BABYLON {
  81013. /**
  81014. * Class used to store gfx data (like WebGLBuffer)
  81015. */
  81016. export class DataBuffer {
  81017. /**
  81018. * Gets or sets the number of objects referencing this buffer
  81019. */
  81020. references: number;
  81021. /** Gets or sets the size of the underlying buffer */
  81022. capacity: number;
  81023. /**
  81024. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  81025. */
  81026. is32Bits: boolean;
  81027. /**
  81028. * Gets the underlying buffer
  81029. */
  81030. get underlyingResource(): any;
  81031. }
  81032. }
  81033. declare module BABYLON {
  81034. /** @hidden */
  81035. export interface IShaderProcessor {
  81036. attributeProcessor?: (attribute: string) => string;
  81037. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  81038. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  81039. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  81040. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  81041. lineProcessor?: (line: string, isFragment: boolean) => string;
  81042. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  81043. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  81044. }
  81045. }
  81046. declare module BABYLON {
  81047. /** @hidden */
  81048. export interface ProcessingOptions {
  81049. defines: string[];
  81050. indexParameters: any;
  81051. isFragment: boolean;
  81052. shouldUseHighPrecisionShader: boolean;
  81053. supportsUniformBuffers: boolean;
  81054. shadersRepository: string;
  81055. includesShadersStore: {
  81056. [key: string]: string;
  81057. };
  81058. processor?: IShaderProcessor;
  81059. version: string;
  81060. platformName: string;
  81061. lookForClosingBracketForUniformBuffer?: boolean;
  81062. }
  81063. }
  81064. declare module BABYLON {
  81065. /** @hidden */
  81066. export class ShaderCodeNode {
  81067. line: string;
  81068. children: ShaderCodeNode[];
  81069. additionalDefineKey?: string;
  81070. additionalDefineValue?: string;
  81071. isValid(preprocessors: {
  81072. [key: string]: string;
  81073. }): boolean;
  81074. process(preprocessors: {
  81075. [key: string]: string;
  81076. }, options: ProcessingOptions): string;
  81077. }
  81078. }
  81079. declare module BABYLON {
  81080. /** @hidden */
  81081. export class ShaderCodeCursor {
  81082. private _lines;
  81083. lineIndex: number;
  81084. get currentLine(): string;
  81085. get canRead(): boolean;
  81086. set lines(value: string[]);
  81087. }
  81088. }
  81089. declare module BABYLON {
  81090. /** @hidden */
  81091. export class ShaderCodeConditionNode extends ShaderCodeNode {
  81092. process(preprocessors: {
  81093. [key: string]: string;
  81094. }, options: ProcessingOptions): string;
  81095. }
  81096. }
  81097. declare module BABYLON {
  81098. /** @hidden */
  81099. export class ShaderDefineExpression {
  81100. isTrue(preprocessors: {
  81101. [key: string]: string;
  81102. }): boolean;
  81103. private static _OperatorPriority;
  81104. private static _Stack;
  81105. static postfixToInfix(postfix: string[]): string;
  81106. static infixToPostfix(infix: string): string[];
  81107. }
  81108. }
  81109. declare module BABYLON {
  81110. /** @hidden */
  81111. export class ShaderCodeTestNode extends ShaderCodeNode {
  81112. testExpression: ShaderDefineExpression;
  81113. isValid(preprocessors: {
  81114. [key: string]: string;
  81115. }): boolean;
  81116. }
  81117. }
  81118. declare module BABYLON {
  81119. /** @hidden */
  81120. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  81121. define: string;
  81122. not: boolean;
  81123. constructor(define: string, not?: boolean);
  81124. isTrue(preprocessors: {
  81125. [key: string]: string;
  81126. }): boolean;
  81127. }
  81128. }
  81129. declare module BABYLON {
  81130. /** @hidden */
  81131. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  81132. leftOperand: ShaderDefineExpression;
  81133. rightOperand: ShaderDefineExpression;
  81134. isTrue(preprocessors: {
  81135. [key: string]: string;
  81136. }): boolean;
  81137. }
  81138. }
  81139. declare module BABYLON {
  81140. /** @hidden */
  81141. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  81142. leftOperand: ShaderDefineExpression;
  81143. rightOperand: ShaderDefineExpression;
  81144. isTrue(preprocessors: {
  81145. [key: string]: string;
  81146. }): boolean;
  81147. }
  81148. }
  81149. declare module BABYLON {
  81150. /** @hidden */
  81151. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  81152. define: string;
  81153. operand: string;
  81154. testValue: string;
  81155. constructor(define: string, operand: string, testValue: string);
  81156. isTrue(preprocessors: {
  81157. [key: string]: string;
  81158. }): boolean;
  81159. }
  81160. }
  81161. declare module BABYLON {
  81162. /**
  81163. * Class used to enable access to offline support
  81164. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  81165. */
  81166. export interface IOfflineProvider {
  81167. /**
  81168. * Gets a boolean indicating if scene must be saved in the database
  81169. */
  81170. enableSceneOffline: boolean;
  81171. /**
  81172. * Gets a boolean indicating if textures must be saved in the database
  81173. */
  81174. enableTexturesOffline: boolean;
  81175. /**
  81176. * Open the offline support and make it available
  81177. * @param successCallback defines the callback to call on success
  81178. * @param errorCallback defines the callback to call on error
  81179. */
  81180. open(successCallback: () => void, errorCallback: () => void): void;
  81181. /**
  81182. * Loads an image from the offline support
  81183. * @param url defines the url to load from
  81184. * @param image defines the target DOM image
  81185. */
  81186. loadImage(url: string, image: HTMLImageElement): void;
  81187. /**
  81188. * Loads a file from offline support
  81189. * @param url defines the URL to load from
  81190. * @param sceneLoaded defines a callback to call on success
  81191. * @param progressCallBack defines a callback to call when progress changed
  81192. * @param errorCallback defines a callback to call on error
  81193. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  81194. */
  81195. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  81196. }
  81197. }
  81198. declare module BABYLON {
  81199. /**
  81200. * Class used to help managing file picking and drag'n'drop
  81201. * File Storage
  81202. */
  81203. export class FilesInputStore {
  81204. /**
  81205. * List of files ready to be loaded
  81206. */
  81207. static FilesToLoad: {
  81208. [key: string]: File;
  81209. };
  81210. }
  81211. }
  81212. declare module BABYLON {
  81213. /**
  81214. * Class used to define a retry strategy when error happens while loading assets
  81215. */
  81216. export class RetryStrategy {
  81217. /**
  81218. * Function used to defines an exponential back off strategy
  81219. * @param maxRetries defines the maximum number of retries (3 by default)
  81220. * @param baseInterval defines the interval between retries
  81221. * @returns the strategy function to use
  81222. */
  81223. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  81224. }
  81225. }
  81226. declare module BABYLON {
  81227. /**
  81228. * @ignore
  81229. * Application error to support additional information when loading a file
  81230. */
  81231. export abstract class BaseError extends Error {
  81232. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  81233. }
  81234. }
  81235. declare module BABYLON {
  81236. /** @ignore */
  81237. export class LoadFileError extends BaseError {
  81238. request?: WebRequest;
  81239. file?: File;
  81240. /**
  81241. * Creates a new LoadFileError
  81242. * @param message defines the message of the error
  81243. * @param request defines the optional web request
  81244. * @param file defines the optional file
  81245. */
  81246. constructor(message: string, object?: WebRequest | File);
  81247. }
  81248. /** @ignore */
  81249. export class RequestFileError extends BaseError {
  81250. request: WebRequest;
  81251. /**
  81252. * Creates a new LoadFileError
  81253. * @param message defines the message of the error
  81254. * @param request defines the optional web request
  81255. */
  81256. constructor(message: string, request: WebRequest);
  81257. }
  81258. /** @ignore */
  81259. export class ReadFileError extends BaseError {
  81260. file: File;
  81261. /**
  81262. * Creates a new ReadFileError
  81263. * @param message defines the message of the error
  81264. * @param file defines the optional file
  81265. */
  81266. constructor(message: string, file: File);
  81267. }
  81268. /**
  81269. * @hidden
  81270. */
  81271. export class FileTools {
  81272. /**
  81273. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  81274. */
  81275. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  81276. /**
  81277. * Gets or sets the base URL to use to load assets
  81278. */
  81279. static BaseUrl: string;
  81280. /**
  81281. * Default behaviour for cors in the application.
  81282. * It can be a string if the expected behavior is identical in the entire app.
  81283. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  81284. */
  81285. static CorsBehavior: string | ((url: string | string[]) => string);
  81286. /**
  81287. * Gets or sets a function used to pre-process url before using them to load assets
  81288. */
  81289. static PreprocessUrl: (url: string) => string;
  81290. /**
  81291. * Removes unwanted characters from an url
  81292. * @param url defines the url to clean
  81293. * @returns the cleaned url
  81294. */
  81295. private static _CleanUrl;
  81296. /**
  81297. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  81298. * @param url define the url we are trying
  81299. * @param element define the dom element where to configure the cors policy
  81300. */
  81301. static SetCorsBehavior(url: string | string[], element: {
  81302. crossOrigin: string | null;
  81303. }): void;
  81304. /**
  81305. * Loads an image as an HTMLImageElement.
  81306. * @param input url string, ArrayBuffer, or Blob to load
  81307. * @param onLoad callback called when the image successfully loads
  81308. * @param onError callback called when the image fails to load
  81309. * @param offlineProvider offline provider for caching
  81310. * @param mimeType optional mime type
  81311. * @returns the HTMLImageElement of the loaded image
  81312. */
  81313. 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>;
  81314. /**
  81315. * Reads a file from a File object
  81316. * @param file defines the file to load
  81317. * @param onSuccess defines the callback to call when data is loaded
  81318. * @param onProgress defines the callback to call during loading process
  81319. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  81320. * @param onError defines the callback to call when an error occurs
  81321. * @returns a file request object
  81322. */
  81323. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  81324. /**
  81325. * Loads a file from a url
  81326. * @param url url to load
  81327. * @param onSuccess callback called when the file successfully loads
  81328. * @param onProgress callback called while file is loading (if the server supports this mode)
  81329. * @param offlineProvider defines the offline provider for caching
  81330. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  81331. * @param onError callback called when the file fails to load
  81332. * @returns a file request object
  81333. */
  81334. 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;
  81335. /**
  81336. * Loads a file
  81337. * @param url url to load
  81338. * @param onSuccess callback called when the file successfully loads
  81339. * @param onProgress callback called while file is loading (if the server supports this mode)
  81340. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  81341. * @param onError callback called when the file fails to load
  81342. * @param onOpened callback called when the web request is opened
  81343. * @returns a file request object
  81344. */
  81345. 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;
  81346. /**
  81347. * Checks if the loaded document was accessed via `file:`-Protocol.
  81348. * @returns boolean
  81349. */
  81350. static IsFileURL(): boolean;
  81351. }
  81352. }
  81353. declare module BABYLON {
  81354. /** @hidden */
  81355. export class ShaderProcessor {
  81356. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  81357. private static _ProcessPrecision;
  81358. private static _ExtractOperation;
  81359. private static _BuildSubExpression;
  81360. private static _BuildExpression;
  81361. private static _MoveCursorWithinIf;
  81362. private static _MoveCursor;
  81363. private static _EvaluatePreProcessors;
  81364. private static _PreparePreProcessors;
  81365. private static _ProcessShaderConversion;
  81366. private static _ProcessIncludes;
  81367. /**
  81368. * Loads a file from a url
  81369. * @param url url to load
  81370. * @param onSuccess callback called when the file successfully loads
  81371. * @param onProgress callback called while file is loading (if the server supports this mode)
  81372. * @param offlineProvider defines the offline provider for caching
  81373. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  81374. * @param onError callback called when the file fails to load
  81375. * @returns a file request object
  81376. * @hidden
  81377. */
  81378. 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;
  81379. }
  81380. }
  81381. declare module BABYLON {
  81382. /**
  81383. * @hidden
  81384. */
  81385. export interface IColor4Like {
  81386. r: float;
  81387. g: float;
  81388. b: float;
  81389. a: float;
  81390. }
  81391. /**
  81392. * @hidden
  81393. */
  81394. export interface IColor3Like {
  81395. r: float;
  81396. g: float;
  81397. b: float;
  81398. }
  81399. /**
  81400. * @hidden
  81401. */
  81402. export interface IVector4Like {
  81403. x: float;
  81404. y: float;
  81405. z: float;
  81406. w: float;
  81407. }
  81408. /**
  81409. * @hidden
  81410. */
  81411. export interface IVector3Like {
  81412. x: float;
  81413. y: float;
  81414. z: float;
  81415. }
  81416. /**
  81417. * @hidden
  81418. */
  81419. export interface IVector2Like {
  81420. x: float;
  81421. y: float;
  81422. }
  81423. /**
  81424. * @hidden
  81425. */
  81426. export interface IMatrixLike {
  81427. toArray(): DeepImmutable<Float32Array | Array<number>>;
  81428. updateFlag: int;
  81429. }
  81430. /**
  81431. * @hidden
  81432. */
  81433. export interface IViewportLike {
  81434. x: float;
  81435. y: float;
  81436. width: float;
  81437. height: float;
  81438. }
  81439. /**
  81440. * @hidden
  81441. */
  81442. export interface IPlaneLike {
  81443. normal: IVector3Like;
  81444. d: float;
  81445. normalize(): void;
  81446. }
  81447. }
  81448. declare module BABYLON {
  81449. /**
  81450. * Interface used to define common properties for effect fallbacks
  81451. */
  81452. export interface IEffectFallbacks {
  81453. /**
  81454. * Removes the defines that should be removed when falling back.
  81455. * @param currentDefines defines the current define statements for the shader.
  81456. * @param effect defines the current effect we try to compile
  81457. * @returns The resulting defines with defines of the current rank removed.
  81458. */
  81459. reduce(currentDefines: string, effect: Effect): string;
  81460. /**
  81461. * Removes the fallback from the bound mesh.
  81462. */
  81463. unBindMesh(): void;
  81464. /**
  81465. * Checks to see if more fallbacks are still availible.
  81466. */
  81467. hasMoreFallbacks: boolean;
  81468. }
  81469. }
  81470. declare module BABYLON {
  81471. /**
  81472. * Class used to evalaute queries containing `and` and `or` operators
  81473. */
  81474. export class AndOrNotEvaluator {
  81475. /**
  81476. * Evaluate a query
  81477. * @param query defines the query to evaluate
  81478. * @param evaluateCallback defines the callback used to filter result
  81479. * @returns true if the query matches
  81480. */
  81481. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  81482. private static _HandleParenthesisContent;
  81483. private static _SimplifyNegation;
  81484. }
  81485. }
  81486. declare module BABYLON {
  81487. /**
  81488. * Class used to store custom tags
  81489. */
  81490. export class Tags {
  81491. /**
  81492. * Adds support for tags on the given object
  81493. * @param obj defines the object to use
  81494. */
  81495. static EnableFor(obj: any): void;
  81496. /**
  81497. * Removes tags support
  81498. * @param obj defines the object to use
  81499. */
  81500. static DisableFor(obj: any): void;
  81501. /**
  81502. * Gets a boolean indicating if the given object has tags
  81503. * @param obj defines the object to use
  81504. * @returns a boolean
  81505. */
  81506. static HasTags(obj: any): boolean;
  81507. /**
  81508. * Gets the tags available on a given object
  81509. * @param obj defines the object to use
  81510. * @param asString defines if the tags must be returned as a string instead of an array of strings
  81511. * @returns the tags
  81512. */
  81513. static GetTags(obj: any, asString?: boolean): any;
  81514. /**
  81515. * Adds tags to an object
  81516. * @param obj defines the object to use
  81517. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  81518. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  81519. */
  81520. static AddTagsTo(obj: any, tagsString: string): void;
  81521. /**
  81522. * @hidden
  81523. */
  81524. static _AddTagTo(obj: any, tag: string): void;
  81525. /**
  81526. * Removes specific tags from a specific object
  81527. * @param obj defines the object to use
  81528. * @param tagsString defines the tags to remove
  81529. */
  81530. static RemoveTagsFrom(obj: any, tagsString: string): void;
  81531. /**
  81532. * @hidden
  81533. */
  81534. static _RemoveTagFrom(obj: any, tag: string): void;
  81535. /**
  81536. * Defines if tags hosted on an object match a given query
  81537. * @param obj defines the object to use
  81538. * @param tagsQuery defines the tag query
  81539. * @returns a boolean
  81540. */
  81541. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  81542. }
  81543. }
  81544. declare module BABYLON {
  81545. /**
  81546. * Scalar computation library
  81547. */
  81548. export class Scalar {
  81549. /**
  81550. * Two pi constants convenient for computation.
  81551. */
  81552. static TwoPi: number;
  81553. /**
  81554. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  81555. * @param a number
  81556. * @param b number
  81557. * @param epsilon (default = 1.401298E-45)
  81558. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  81559. */
  81560. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  81561. /**
  81562. * Returns a string : the upper case translation of the number i to hexadecimal.
  81563. * @param i number
  81564. * @returns the upper case translation of the number i to hexadecimal.
  81565. */
  81566. static ToHex(i: number): string;
  81567. /**
  81568. * Returns -1 if value is negative and +1 is value is positive.
  81569. * @param value the value
  81570. * @returns the value itself if it's equal to zero.
  81571. */
  81572. static Sign(value: number): number;
  81573. /**
  81574. * Returns the value itself if it's between min and max.
  81575. * Returns min if the value is lower than min.
  81576. * Returns max if the value is greater than max.
  81577. * @param value the value to clmap
  81578. * @param min the min value to clamp to (default: 0)
  81579. * @param max the max value to clamp to (default: 1)
  81580. * @returns the clamped value
  81581. */
  81582. static Clamp(value: number, min?: number, max?: number): number;
  81583. /**
  81584. * the log2 of value.
  81585. * @param value the value to compute log2 of
  81586. * @returns the log2 of value.
  81587. */
  81588. static Log2(value: number): number;
  81589. /**
  81590. * Loops the value, so that it is never larger than length and never smaller than 0.
  81591. *
  81592. * This is similar to the modulo operator but it works with floating point numbers.
  81593. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  81594. * With t = 5 and length = 2.5, the result would be 0.0.
  81595. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  81596. * @param value the value
  81597. * @param length the length
  81598. * @returns the looped value
  81599. */
  81600. static Repeat(value: number, length: number): number;
  81601. /**
  81602. * Normalize the value between 0.0 and 1.0 using min and max values
  81603. * @param value value to normalize
  81604. * @param min max to normalize between
  81605. * @param max min to normalize between
  81606. * @returns the normalized value
  81607. */
  81608. static Normalize(value: number, min: number, max: number): number;
  81609. /**
  81610. * Denormalize the value from 0.0 and 1.0 using min and max values
  81611. * @param normalized value to denormalize
  81612. * @param min max to denormalize between
  81613. * @param max min to denormalize between
  81614. * @returns the denormalized value
  81615. */
  81616. static Denormalize(normalized: number, min: number, max: number): number;
  81617. /**
  81618. * Calculates the shortest difference between two given angles given in degrees.
  81619. * @param current current angle in degrees
  81620. * @param target target angle in degrees
  81621. * @returns the delta
  81622. */
  81623. static DeltaAngle(current: number, target: number): number;
  81624. /**
  81625. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  81626. * @param tx value
  81627. * @param length length
  81628. * @returns The returned value will move back and forth between 0 and length
  81629. */
  81630. static PingPong(tx: number, length: number): number;
  81631. /**
  81632. * Interpolates between min and max with smoothing at the limits.
  81633. *
  81634. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  81635. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  81636. * @param from from
  81637. * @param to to
  81638. * @param tx value
  81639. * @returns the smooth stepped value
  81640. */
  81641. static SmoothStep(from: number, to: number, tx: number): number;
  81642. /**
  81643. * Moves a value current towards target.
  81644. *
  81645. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  81646. * Negative values of maxDelta pushes the value away from target.
  81647. * @param current current value
  81648. * @param target target value
  81649. * @param maxDelta max distance to move
  81650. * @returns resulting value
  81651. */
  81652. static MoveTowards(current: number, target: number, maxDelta: number): number;
  81653. /**
  81654. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  81655. *
  81656. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  81657. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  81658. * @param current current value
  81659. * @param target target value
  81660. * @param maxDelta max distance to move
  81661. * @returns resulting angle
  81662. */
  81663. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  81664. /**
  81665. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  81666. * @param start start value
  81667. * @param end target value
  81668. * @param amount amount to lerp between
  81669. * @returns the lerped value
  81670. */
  81671. static Lerp(start: number, end: number, amount: number): number;
  81672. /**
  81673. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  81674. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  81675. * @param start start value
  81676. * @param end target value
  81677. * @param amount amount to lerp between
  81678. * @returns the lerped value
  81679. */
  81680. static LerpAngle(start: number, end: number, amount: number): number;
  81681. /**
  81682. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  81683. * @param a start value
  81684. * @param b target value
  81685. * @param value value between a and b
  81686. * @returns the inverseLerp value
  81687. */
  81688. static InverseLerp(a: number, b: number, value: number): number;
  81689. /**
  81690. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  81691. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  81692. * @param value1 spline value
  81693. * @param tangent1 spline value
  81694. * @param value2 spline value
  81695. * @param tangent2 spline value
  81696. * @param amount input value
  81697. * @returns hermite result
  81698. */
  81699. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  81700. /**
  81701. * Returns a random float number between and min and max values
  81702. * @param min min value of random
  81703. * @param max max value of random
  81704. * @returns random value
  81705. */
  81706. static RandomRange(min: number, max: number): number;
  81707. /**
  81708. * This function returns percentage of a number in a given range.
  81709. *
  81710. * RangeToPercent(40,20,60) will return 0.5 (50%)
  81711. * RangeToPercent(34,0,100) will return 0.34 (34%)
  81712. * @param number to convert to percentage
  81713. * @param min min range
  81714. * @param max max range
  81715. * @returns the percentage
  81716. */
  81717. static RangeToPercent(number: number, min: number, max: number): number;
  81718. /**
  81719. * This function returns number that corresponds to the percentage in a given range.
  81720. *
  81721. * PercentToRange(0.34,0,100) will return 34.
  81722. * @param percent to convert to number
  81723. * @param min min range
  81724. * @param max max range
  81725. * @returns the number
  81726. */
  81727. static PercentToRange(percent: number, min: number, max: number): number;
  81728. /**
  81729. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  81730. * @param angle The angle to normalize in radian.
  81731. * @return The converted angle.
  81732. */
  81733. static NormalizeRadians(angle: number): number;
  81734. }
  81735. }
  81736. declare module BABYLON {
  81737. /**
  81738. * Constant used to convert a value to gamma space
  81739. * @ignorenaming
  81740. */
  81741. export const ToGammaSpace: number;
  81742. /**
  81743. * Constant used to convert a value to linear space
  81744. * @ignorenaming
  81745. */
  81746. export const ToLinearSpace = 2.2;
  81747. /**
  81748. * Constant used to define the minimal number value in Babylon.js
  81749. * @ignorenaming
  81750. */
  81751. let Epsilon: number;
  81752. }
  81753. declare module BABYLON {
  81754. /**
  81755. * Class used to represent a viewport on screen
  81756. */
  81757. export class Viewport {
  81758. /** viewport left coordinate */
  81759. x: number;
  81760. /** viewport top coordinate */
  81761. y: number;
  81762. /**viewport width */
  81763. width: number;
  81764. /** viewport height */
  81765. height: number;
  81766. /**
  81767. * Creates a Viewport object located at (x, y) and sized (width, height)
  81768. * @param x defines viewport left coordinate
  81769. * @param y defines viewport top coordinate
  81770. * @param width defines the viewport width
  81771. * @param height defines the viewport height
  81772. */
  81773. constructor(
  81774. /** viewport left coordinate */
  81775. x: number,
  81776. /** viewport top coordinate */
  81777. y: number,
  81778. /**viewport width */
  81779. width: number,
  81780. /** viewport height */
  81781. height: number);
  81782. /**
  81783. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  81784. * @param renderWidth defines the rendering width
  81785. * @param renderHeight defines the rendering height
  81786. * @returns a new Viewport
  81787. */
  81788. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  81789. /**
  81790. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  81791. * @param renderWidth defines the rendering width
  81792. * @param renderHeight defines the rendering height
  81793. * @param ref defines the target viewport
  81794. * @returns the current viewport
  81795. */
  81796. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  81797. /**
  81798. * Returns a new Viewport copied from the current one
  81799. * @returns a new Viewport
  81800. */
  81801. clone(): Viewport;
  81802. }
  81803. }
  81804. declare module BABYLON {
  81805. /**
  81806. * Class containing a set of static utilities functions for arrays.
  81807. */
  81808. export class ArrayTools {
  81809. /**
  81810. * Returns an array of the given size filled with element built from the given constructor and the paramters
  81811. * @param size the number of element to construct and put in the array
  81812. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  81813. * @returns a new array filled with new objects
  81814. */
  81815. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  81816. }
  81817. }
  81818. declare module BABYLON {
  81819. /**
  81820. * Represents a plane by the equation ax + by + cz + d = 0
  81821. */
  81822. export class Plane {
  81823. private static _TmpMatrix;
  81824. /**
  81825. * Normal of the plane (a,b,c)
  81826. */
  81827. normal: Vector3;
  81828. /**
  81829. * d component of the plane
  81830. */
  81831. d: number;
  81832. /**
  81833. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  81834. * @param a a component of the plane
  81835. * @param b b component of the plane
  81836. * @param c c component of the plane
  81837. * @param d d component of the plane
  81838. */
  81839. constructor(a: number, b: number, c: number, d: number);
  81840. /**
  81841. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  81842. */
  81843. asArray(): number[];
  81844. /**
  81845. * @returns a new plane copied from the current Plane.
  81846. */
  81847. clone(): Plane;
  81848. /**
  81849. * @returns the string "Plane".
  81850. */
  81851. getClassName(): string;
  81852. /**
  81853. * @returns the Plane hash code.
  81854. */
  81855. getHashCode(): number;
  81856. /**
  81857. * Normalize the current Plane in place.
  81858. * @returns the updated Plane.
  81859. */
  81860. normalize(): Plane;
  81861. /**
  81862. * Applies a transformation the plane and returns the result
  81863. * @param transformation the transformation matrix to be applied to the plane
  81864. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  81865. */
  81866. transform(transformation: DeepImmutable<Matrix>): Plane;
  81867. /**
  81868. * Compute the dot product between the point and the plane normal
  81869. * @param point point to calculate the dot product with
  81870. * @returns the dot product (float) of the point coordinates and the plane normal.
  81871. */
  81872. dotCoordinate(point: DeepImmutable<Vector3>): number;
  81873. /**
  81874. * Updates the current Plane from the plane defined by the three given points.
  81875. * @param point1 one of the points used to contruct the plane
  81876. * @param point2 one of the points used to contruct the plane
  81877. * @param point3 one of the points used to contruct the plane
  81878. * @returns the updated Plane.
  81879. */
  81880. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  81881. /**
  81882. * Checks if the plane is facing a given direction
  81883. * @param direction the direction to check if the plane is facing
  81884. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  81885. * @returns True is the vector "direction" is the same side than the plane normal.
  81886. */
  81887. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  81888. /**
  81889. * Calculates the distance to a point
  81890. * @param point point to calculate distance to
  81891. * @returns the signed distance (float) from the given point to the Plane.
  81892. */
  81893. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  81894. /**
  81895. * Creates a plane from an array
  81896. * @param array the array to create a plane from
  81897. * @returns a new Plane from the given array.
  81898. */
  81899. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  81900. /**
  81901. * Creates a plane from three points
  81902. * @param point1 point used to create the plane
  81903. * @param point2 point used to create the plane
  81904. * @param point3 point used to create the plane
  81905. * @returns a new Plane defined by the three given points.
  81906. */
  81907. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  81908. /**
  81909. * Creates a plane from an origin point and a normal
  81910. * @param origin origin of the plane to be constructed
  81911. * @param normal normal of the plane to be constructed
  81912. * @returns a new Plane the normal vector to this plane at the given origin point.
  81913. * Note : the vector "normal" is updated because normalized.
  81914. */
  81915. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: Vector3): Plane;
  81916. /**
  81917. * Calculates the distance from a plane and a point
  81918. * @param origin origin of the plane to be constructed
  81919. * @param normal normal of the plane to be constructed
  81920. * @param point point to calculate distance to
  81921. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  81922. */
  81923. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  81924. }
  81925. }
  81926. declare module BABYLON {
  81927. /** @hidden */
  81928. export class PerformanceConfigurator {
  81929. /** @hidden */
  81930. static MatrixUse64Bits: boolean;
  81931. /** @hidden */
  81932. static MatrixTrackPrecisionChange: boolean;
  81933. /** @hidden */
  81934. static MatrixCurrentType: any;
  81935. /** @hidden */
  81936. static MatrixTrackedMatrices: Array<any> | null;
  81937. /** @hidden */
  81938. static SetMatrixPrecision(use64bits: boolean): void;
  81939. }
  81940. }
  81941. declare module BABYLON {
  81942. /**
  81943. * Class representing a vector containing 2 coordinates
  81944. */
  81945. export class Vector2 {
  81946. /** defines the first coordinate */
  81947. x: number;
  81948. /** defines the second coordinate */
  81949. y: number;
  81950. /**
  81951. * Creates a new Vector2 from the given x and y coordinates
  81952. * @param x defines the first coordinate
  81953. * @param y defines the second coordinate
  81954. */
  81955. constructor(
  81956. /** defines the first coordinate */
  81957. x?: number,
  81958. /** defines the second coordinate */
  81959. y?: number);
  81960. /**
  81961. * Gets a string with the Vector2 coordinates
  81962. * @returns a string with the Vector2 coordinates
  81963. */
  81964. toString(): string;
  81965. /**
  81966. * Gets class name
  81967. * @returns the string "Vector2"
  81968. */
  81969. getClassName(): string;
  81970. /**
  81971. * Gets current vector hash code
  81972. * @returns the Vector2 hash code as a number
  81973. */
  81974. getHashCode(): number;
  81975. /**
  81976. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  81977. * @param array defines the source array
  81978. * @param index defines the offset in source array
  81979. * @returns the current Vector2
  81980. */
  81981. toArray(array: FloatArray, index?: number): Vector2;
  81982. /**
  81983. * Update the current vector from an array
  81984. * @param array defines the destination array
  81985. * @param index defines the offset in the destination array
  81986. * @returns the current Vector3
  81987. */
  81988. fromArray(array: FloatArray, index?: number): Vector2;
  81989. /**
  81990. * Copy the current vector to an array
  81991. * @returns a new array with 2 elements: the Vector2 coordinates.
  81992. */
  81993. asArray(): number[];
  81994. /**
  81995. * Sets the Vector2 coordinates with the given Vector2 coordinates
  81996. * @param source defines the source Vector2
  81997. * @returns the current updated Vector2
  81998. */
  81999. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  82000. /**
  82001. * Sets the Vector2 coordinates with the given floats
  82002. * @param x defines the first coordinate
  82003. * @param y defines the second coordinate
  82004. * @returns the current updated Vector2
  82005. */
  82006. copyFromFloats(x: number, y: number): Vector2;
  82007. /**
  82008. * Sets the Vector2 coordinates with the given floats
  82009. * @param x defines the first coordinate
  82010. * @param y defines the second coordinate
  82011. * @returns the current updated Vector2
  82012. */
  82013. set(x: number, y: number): Vector2;
  82014. /**
  82015. * Add another vector with the current one
  82016. * @param otherVector defines the other vector
  82017. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  82018. */
  82019. add(otherVector: DeepImmutable<Vector2>): Vector2;
  82020. /**
  82021. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  82022. * @param otherVector defines the other vector
  82023. * @param result defines the target vector
  82024. * @returns the unmodified current Vector2
  82025. */
  82026. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  82027. /**
  82028. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  82029. * @param otherVector defines the other vector
  82030. * @returns the current updated Vector2
  82031. */
  82032. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  82033. /**
  82034. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  82035. * @param otherVector defines the other vector
  82036. * @returns a new Vector2
  82037. */
  82038. addVector3(otherVector: Vector3): Vector2;
  82039. /**
  82040. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  82041. * @param otherVector defines the other vector
  82042. * @returns a new Vector2
  82043. */
  82044. subtract(otherVector: Vector2): Vector2;
  82045. /**
  82046. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  82047. * @param otherVector defines the other vector
  82048. * @param result defines the target vector
  82049. * @returns the unmodified current Vector2
  82050. */
  82051. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  82052. /**
  82053. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  82054. * @param otherVector defines the other vector
  82055. * @returns the current updated Vector2
  82056. */
  82057. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  82058. /**
  82059. * Multiplies in place the current Vector2 coordinates by the given ones
  82060. * @param otherVector defines the other vector
  82061. * @returns the current updated Vector2
  82062. */
  82063. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  82064. /**
  82065. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  82066. * @param otherVector defines the other vector
  82067. * @returns a new Vector2
  82068. */
  82069. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  82070. /**
  82071. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  82072. * @param otherVector defines the other vector
  82073. * @param result defines the target vector
  82074. * @returns the unmodified current Vector2
  82075. */
  82076. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  82077. /**
  82078. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  82079. * @param x defines the first coordinate
  82080. * @param y defines the second coordinate
  82081. * @returns a new Vector2
  82082. */
  82083. multiplyByFloats(x: number, y: number): Vector2;
  82084. /**
  82085. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  82086. * @param otherVector defines the other vector
  82087. * @returns a new Vector2
  82088. */
  82089. divide(otherVector: Vector2): Vector2;
  82090. /**
  82091. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  82092. * @param otherVector defines the other vector
  82093. * @param result defines the target vector
  82094. * @returns the unmodified current Vector2
  82095. */
  82096. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  82097. /**
  82098. * Divides the current Vector2 coordinates by the given ones
  82099. * @param otherVector defines the other vector
  82100. * @returns the current updated Vector2
  82101. */
  82102. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  82103. /**
  82104. * Gets a new Vector2 with current Vector2 negated coordinates
  82105. * @returns a new Vector2
  82106. */
  82107. negate(): Vector2;
  82108. /**
  82109. * Negate this vector in place
  82110. * @returns this
  82111. */
  82112. negateInPlace(): Vector2;
  82113. /**
  82114. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  82115. * @param result defines the Vector3 object where to store the result
  82116. * @returns the current Vector2
  82117. */
  82118. negateToRef(result: Vector2): Vector2;
  82119. /**
  82120. * Multiply the Vector2 coordinates by scale
  82121. * @param scale defines the scaling factor
  82122. * @returns the current updated Vector2
  82123. */
  82124. scaleInPlace(scale: number): Vector2;
  82125. /**
  82126. * Returns a new Vector2 scaled by "scale" from the current Vector2
  82127. * @param scale defines the scaling factor
  82128. * @returns a new Vector2
  82129. */
  82130. scale(scale: number): Vector2;
  82131. /**
  82132. * Scale the current Vector2 values by a factor to a given Vector2
  82133. * @param scale defines the scale factor
  82134. * @param result defines the Vector2 object where to store the result
  82135. * @returns the unmodified current Vector2
  82136. */
  82137. scaleToRef(scale: number, result: Vector2): Vector2;
  82138. /**
  82139. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  82140. * @param scale defines the scale factor
  82141. * @param result defines the Vector2 object where to store the result
  82142. * @returns the unmodified current Vector2
  82143. */
  82144. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  82145. /**
  82146. * Gets a boolean if two vectors are equals
  82147. * @param otherVector defines the other vector
  82148. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  82149. */
  82150. equals(otherVector: DeepImmutable<Vector2>): boolean;
  82151. /**
  82152. * Gets a boolean if two vectors are equals (using an epsilon value)
  82153. * @param otherVector defines the other vector
  82154. * @param epsilon defines the minimal distance to consider equality
  82155. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  82156. */
  82157. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  82158. /**
  82159. * Gets a new Vector2 from current Vector2 floored values
  82160. * @returns a new Vector2
  82161. */
  82162. floor(): Vector2;
  82163. /**
  82164. * Gets a new Vector2 from current Vector2 floored values
  82165. * @returns a new Vector2
  82166. */
  82167. fract(): Vector2;
  82168. /**
  82169. * Gets the length of the vector
  82170. * @returns the vector length (float)
  82171. */
  82172. length(): number;
  82173. /**
  82174. * Gets the vector squared length
  82175. * @returns the vector squared length (float)
  82176. */
  82177. lengthSquared(): number;
  82178. /**
  82179. * Normalize the vector
  82180. * @returns the current updated Vector2
  82181. */
  82182. normalize(): Vector2;
  82183. /**
  82184. * Gets a new Vector2 copied from the Vector2
  82185. * @returns a new Vector2
  82186. */
  82187. clone(): Vector2;
  82188. /**
  82189. * Gets a new Vector2(0, 0)
  82190. * @returns a new Vector2
  82191. */
  82192. static Zero(): Vector2;
  82193. /**
  82194. * Gets a new Vector2(1, 1)
  82195. * @returns a new Vector2
  82196. */
  82197. static One(): Vector2;
  82198. /**
  82199. * Gets a new Vector2 set from the given index element of the given array
  82200. * @param array defines the data source
  82201. * @param offset defines the offset in the data source
  82202. * @returns a new Vector2
  82203. */
  82204. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  82205. /**
  82206. * Sets "result" from the given index element of the given array
  82207. * @param array defines the data source
  82208. * @param offset defines the offset in the data source
  82209. * @param result defines the target vector
  82210. */
  82211. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  82212. /**
  82213. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  82214. * @param value1 defines 1st point of control
  82215. * @param value2 defines 2nd point of control
  82216. * @param value3 defines 3rd point of control
  82217. * @param value4 defines 4th point of control
  82218. * @param amount defines the interpolation factor
  82219. * @returns a new Vector2
  82220. */
  82221. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  82222. /**
  82223. * 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".
  82224. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  82225. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  82226. * @param value defines the value to clamp
  82227. * @param min defines the lower limit
  82228. * @param max defines the upper limit
  82229. * @returns a new Vector2
  82230. */
  82231. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  82232. /**
  82233. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  82234. * @param value1 defines the 1st control point
  82235. * @param tangent1 defines the outgoing tangent
  82236. * @param value2 defines the 2nd control point
  82237. * @param tangent2 defines the incoming tangent
  82238. * @param amount defines the interpolation factor
  82239. * @returns a new Vector2
  82240. */
  82241. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  82242. /**
  82243. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  82244. * @param start defines the start vector
  82245. * @param end defines the end vector
  82246. * @param amount defines the interpolation factor
  82247. * @returns a new Vector2
  82248. */
  82249. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  82250. /**
  82251. * Gets the dot product of the vector "left" and the vector "right"
  82252. * @param left defines first vector
  82253. * @param right defines second vector
  82254. * @returns the dot product (float)
  82255. */
  82256. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  82257. /**
  82258. * Returns a new Vector2 equal to the normalized given vector
  82259. * @param vector defines the vector to normalize
  82260. * @returns a new Vector2
  82261. */
  82262. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  82263. /**
  82264. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  82265. * @param left defines 1st vector
  82266. * @param right defines 2nd vector
  82267. * @returns a new Vector2
  82268. */
  82269. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  82270. /**
  82271. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  82272. * @param left defines 1st vector
  82273. * @param right defines 2nd vector
  82274. * @returns a new Vector2
  82275. */
  82276. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  82277. /**
  82278. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  82279. * @param vector defines the vector to transform
  82280. * @param transformation defines the matrix to apply
  82281. * @returns a new Vector2
  82282. */
  82283. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  82284. /**
  82285. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  82286. * @param vector defines the vector to transform
  82287. * @param transformation defines the matrix to apply
  82288. * @param result defines the target vector
  82289. */
  82290. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  82291. /**
  82292. * Determines if a given vector is included in a triangle
  82293. * @param p defines the vector to test
  82294. * @param p0 defines 1st triangle point
  82295. * @param p1 defines 2nd triangle point
  82296. * @param p2 defines 3rd triangle point
  82297. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  82298. */
  82299. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  82300. /**
  82301. * Gets the distance between the vectors "value1" and "value2"
  82302. * @param value1 defines first vector
  82303. * @param value2 defines second vector
  82304. * @returns the distance between vectors
  82305. */
  82306. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  82307. /**
  82308. * Returns the squared distance between the vectors "value1" and "value2"
  82309. * @param value1 defines first vector
  82310. * @param value2 defines second vector
  82311. * @returns the squared distance between vectors
  82312. */
  82313. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  82314. /**
  82315. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  82316. * @param value1 defines first vector
  82317. * @param value2 defines second vector
  82318. * @returns a new Vector2
  82319. */
  82320. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  82321. /**
  82322. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  82323. * @param p defines the middle point
  82324. * @param segA defines one point of the segment
  82325. * @param segB defines the other point of the segment
  82326. * @returns the shortest distance
  82327. */
  82328. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  82329. }
  82330. /**
  82331. * Class used to store (x,y,z) vector representation
  82332. * A Vector3 is the main object used in 3D geometry
  82333. * It can represent etiher the coordinates of a point the space, either a direction
  82334. * Reminder: js uses a left handed forward facing system
  82335. */
  82336. export class Vector3 {
  82337. private static _UpReadOnly;
  82338. private static _ZeroReadOnly;
  82339. /** @hidden */
  82340. _x: number;
  82341. /** @hidden */
  82342. _y: number;
  82343. /** @hidden */
  82344. _z: number;
  82345. /** @hidden */
  82346. _isDirty: boolean;
  82347. /** Gets or sets the x coordinate */
  82348. get x(): number;
  82349. set x(value: number);
  82350. /** Gets or sets the y coordinate */
  82351. get y(): number;
  82352. set y(value: number);
  82353. /** Gets or sets the z coordinate */
  82354. get z(): number;
  82355. set z(value: number);
  82356. /**
  82357. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  82358. * @param x defines the first coordinates (on X axis)
  82359. * @param y defines the second coordinates (on Y axis)
  82360. * @param z defines the third coordinates (on Z axis)
  82361. */
  82362. constructor(x?: number, y?: number, z?: number);
  82363. /**
  82364. * Creates a string representation of the Vector3
  82365. * @returns a string with the Vector3 coordinates.
  82366. */
  82367. toString(): string;
  82368. /**
  82369. * Gets the class name
  82370. * @returns the string "Vector3"
  82371. */
  82372. getClassName(): string;
  82373. /**
  82374. * Creates the Vector3 hash code
  82375. * @returns a number which tends to be unique between Vector3 instances
  82376. */
  82377. getHashCode(): number;
  82378. /**
  82379. * Creates an array containing three elements : the coordinates of the Vector3
  82380. * @returns a new array of numbers
  82381. */
  82382. asArray(): number[];
  82383. /**
  82384. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  82385. * @param array defines the destination array
  82386. * @param index defines the offset in the destination array
  82387. * @returns the current Vector3
  82388. */
  82389. toArray(array: FloatArray, index?: number): Vector3;
  82390. /**
  82391. * Update the current vector from an array
  82392. * @param array defines the destination array
  82393. * @param index defines the offset in the destination array
  82394. * @returns the current Vector3
  82395. */
  82396. fromArray(array: FloatArray, index?: number): Vector3;
  82397. /**
  82398. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  82399. * @returns a new Quaternion object, computed from the Vector3 coordinates
  82400. */
  82401. toQuaternion(): Quaternion;
  82402. /**
  82403. * Adds the given vector to the current Vector3
  82404. * @param otherVector defines the second operand
  82405. * @returns the current updated Vector3
  82406. */
  82407. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  82408. /**
  82409. * Adds the given coordinates to the current Vector3
  82410. * @param x defines the x coordinate of the operand
  82411. * @param y defines the y coordinate of the operand
  82412. * @param z defines the z coordinate of the operand
  82413. * @returns the current updated Vector3
  82414. */
  82415. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  82416. /**
  82417. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  82418. * @param otherVector defines the second operand
  82419. * @returns the resulting Vector3
  82420. */
  82421. add(otherVector: DeepImmutable<Vector3>): Vector3;
  82422. /**
  82423. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  82424. * @param otherVector defines the second operand
  82425. * @param result defines the Vector3 object where to store the result
  82426. * @returns the current Vector3
  82427. */
  82428. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  82429. /**
  82430. * Subtract the given vector from the current Vector3
  82431. * @param otherVector defines the second operand
  82432. * @returns the current updated Vector3
  82433. */
  82434. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  82435. /**
  82436. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  82437. * @param otherVector defines the second operand
  82438. * @returns the resulting Vector3
  82439. */
  82440. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  82441. /**
  82442. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  82443. * @param otherVector defines the second operand
  82444. * @param result defines the Vector3 object where to store the result
  82445. * @returns the current Vector3
  82446. */
  82447. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  82448. /**
  82449. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  82450. * @param x defines the x coordinate of the operand
  82451. * @param y defines the y coordinate of the operand
  82452. * @param z defines the z coordinate of the operand
  82453. * @returns the resulting Vector3
  82454. */
  82455. subtractFromFloats(x: number, y: number, z: number): Vector3;
  82456. /**
  82457. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  82458. * @param x defines the x coordinate of the operand
  82459. * @param y defines the y coordinate of the operand
  82460. * @param z defines the z coordinate of the operand
  82461. * @param result defines the Vector3 object where to store the result
  82462. * @returns the current Vector3
  82463. */
  82464. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  82465. /**
  82466. * Gets a new Vector3 set with the current Vector3 negated coordinates
  82467. * @returns a new Vector3
  82468. */
  82469. negate(): Vector3;
  82470. /**
  82471. * Negate this vector in place
  82472. * @returns this
  82473. */
  82474. negateInPlace(): Vector3;
  82475. /**
  82476. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  82477. * @param result defines the Vector3 object where to store the result
  82478. * @returns the current Vector3
  82479. */
  82480. negateToRef(result: Vector3): Vector3;
  82481. /**
  82482. * Multiplies the Vector3 coordinates by the float "scale"
  82483. * @param scale defines the multiplier factor
  82484. * @returns the current updated Vector3
  82485. */
  82486. scaleInPlace(scale: number): Vector3;
  82487. /**
  82488. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  82489. * @param scale defines the multiplier factor
  82490. * @returns a new Vector3
  82491. */
  82492. scale(scale: number): Vector3;
  82493. /**
  82494. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  82495. * @param scale defines the multiplier factor
  82496. * @param result defines the Vector3 object where to store the result
  82497. * @returns the current Vector3
  82498. */
  82499. scaleToRef(scale: number, result: Vector3): Vector3;
  82500. /**
  82501. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  82502. * @param scale defines the scale factor
  82503. * @param result defines the Vector3 object where to store the result
  82504. * @returns the unmodified current Vector3
  82505. */
  82506. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  82507. /**
  82508. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  82509. * @param origin defines the origin of the projection ray
  82510. * @param plane defines the plane to project to
  82511. * @returns the projected vector3
  82512. */
  82513. projectOnPlane(plane: Plane, origin: Vector3): Vector3;
  82514. /**
  82515. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  82516. * @param origin defines the origin of the projection ray
  82517. * @param plane defines the plane to project to
  82518. * @param result defines the Vector3 where to store the result
  82519. */
  82520. projectOnPlaneToRef(plane: Plane, origin: Vector3, result: Vector3): void;
  82521. /**
  82522. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  82523. * @param otherVector defines the second operand
  82524. * @returns true if both vectors are equals
  82525. */
  82526. equals(otherVector: DeepImmutable<Vector3>): boolean;
  82527. /**
  82528. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  82529. * @param otherVector defines the second operand
  82530. * @param epsilon defines the minimal distance to define values as equals
  82531. * @returns true if both vectors are distant less than epsilon
  82532. */
  82533. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  82534. /**
  82535. * Returns true if the current Vector3 coordinates equals the given floats
  82536. * @param x defines the x coordinate of the operand
  82537. * @param y defines the y coordinate of the operand
  82538. * @param z defines the z coordinate of the operand
  82539. * @returns true if both vectors are equals
  82540. */
  82541. equalsToFloats(x: number, y: number, z: number): boolean;
  82542. /**
  82543. * Multiplies the current Vector3 coordinates by the given ones
  82544. * @param otherVector defines the second operand
  82545. * @returns the current updated Vector3
  82546. */
  82547. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  82548. /**
  82549. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  82550. * @param otherVector defines the second operand
  82551. * @returns the new Vector3
  82552. */
  82553. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  82554. /**
  82555. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  82556. * @param otherVector defines the second operand
  82557. * @param result defines the Vector3 object where to store the result
  82558. * @returns the current Vector3
  82559. */
  82560. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  82561. /**
  82562. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  82563. * @param x defines the x coordinate of the operand
  82564. * @param y defines the y coordinate of the operand
  82565. * @param z defines the z coordinate of the operand
  82566. * @returns the new Vector3
  82567. */
  82568. multiplyByFloats(x: number, y: number, z: number): Vector3;
  82569. /**
  82570. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  82571. * @param otherVector defines the second operand
  82572. * @returns the new Vector3
  82573. */
  82574. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  82575. /**
  82576. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  82577. * @param otherVector defines the second operand
  82578. * @param result defines the Vector3 object where to store the result
  82579. * @returns the current Vector3
  82580. */
  82581. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  82582. /**
  82583. * Divides the current Vector3 coordinates by the given ones.
  82584. * @param otherVector defines the second operand
  82585. * @returns the current updated Vector3
  82586. */
  82587. divideInPlace(otherVector: Vector3): Vector3;
  82588. /**
  82589. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  82590. * @param other defines the second operand
  82591. * @returns the current updated Vector3
  82592. */
  82593. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  82594. /**
  82595. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  82596. * @param other defines the second operand
  82597. * @returns the current updated Vector3
  82598. */
  82599. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  82600. /**
  82601. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  82602. * @param x defines the x coordinate of the operand
  82603. * @param y defines the y coordinate of the operand
  82604. * @param z defines the z coordinate of the operand
  82605. * @returns the current updated Vector3
  82606. */
  82607. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  82608. /**
  82609. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  82610. * @param x defines the x coordinate of the operand
  82611. * @param y defines the y coordinate of the operand
  82612. * @param z defines the z coordinate of the operand
  82613. * @returns the current updated Vector3
  82614. */
  82615. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  82616. /**
  82617. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  82618. * Check if is non uniform within a certain amount of decimal places to account for this
  82619. * @param epsilon the amount the values can differ
  82620. * @returns if the the vector is non uniform to a certain number of decimal places
  82621. */
  82622. isNonUniformWithinEpsilon(epsilon: number): boolean;
  82623. /**
  82624. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  82625. */
  82626. get isNonUniform(): boolean;
  82627. /**
  82628. * Gets a new Vector3 from current Vector3 floored values
  82629. * @returns a new Vector3
  82630. */
  82631. floor(): Vector3;
  82632. /**
  82633. * Gets a new Vector3 from current Vector3 floored values
  82634. * @returns a new Vector3
  82635. */
  82636. fract(): Vector3;
  82637. /**
  82638. * Gets the length of the Vector3
  82639. * @returns the length of the Vector3
  82640. */
  82641. length(): number;
  82642. /**
  82643. * Gets the squared length of the Vector3
  82644. * @returns squared length of the Vector3
  82645. */
  82646. lengthSquared(): number;
  82647. /**
  82648. * Normalize the current Vector3.
  82649. * Please note that this is an in place operation.
  82650. * @returns the current updated Vector3
  82651. */
  82652. normalize(): Vector3;
  82653. /**
  82654. * Reorders the x y z properties of the vector in place
  82655. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  82656. * @returns the current updated vector
  82657. */
  82658. reorderInPlace(order: string): this;
  82659. /**
  82660. * Rotates the vector around 0,0,0 by a quaternion
  82661. * @param quaternion the rotation quaternion
  82662. * @param result vector to store the result
  82663. * @returns the resulting vector
  82664. */
  82665. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  82666. /**
  82667. * Rotates a vector around a given point
  82668. * @param quaternion the rotation quaternion
  82669. * @param point the point to rotate around
  82670. * @param result vector to store the result
  82671. * @returns the resulting vector
  82672. */
  82673. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  82674. /**
  82675. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  82676. * The cross product is then orthogonal to both current and "other"
  82677. * @param other defines the right operand
  82678. * @returns the cross product
  82679. */
  82680. cross(other: Vector3): Vector3;
  82681. /**
  82682. * Normalize the current Vector3 with the given input length.
  82683. * Please note that this is an in place operation.
  82684. * @param len the length of the vector
  82685. * @returns the current updated Vector3
  82686. */
  82687. normalizeFromLength(len: number): Vector3;
  82688. /**
  82689. * Normalize the current Vector3 to a new vector
  82690. * @returns the new Vector3
  82691. */
  82692. normalizeToNew(): Vector3;
  82693. /**
  82694. * Normalize the current Vector3 to the reference
  82695. * @param reference define the Vector3 to update
  82696. * @returns the updated Vector3
  82697. */
  82698. normalizeToRef(reference: Vector3): Vector3;
  82699. /**
  82700. * Creates a new Vector3 copied from the current Vector3
  82701. * @returns the new Vector3
  82702. */
  82703. clone(): Vector3;
  82704. /**
  82705. * Copies the given vector coordinates to the current Vector3 ones
  82706. * @param source defines the source Vector3
  82707. * @returns the current updated Vector3
  82708. */
  82709. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  82710. /**
  82711. * Copies the given floats to the current Vector3 coordinates
  82712. * @param x defines the x coordinate of the operand
  82713. * @param y defines the y coordinate of the operand
  82714. * @param z defines the z coordinate of the operand
  82715. * @returns the current updated Vector3
  82716. */
  82717. copyFromFloats(x: number, y: number, z: number): Vector3;
  82718. /**
  82719. * Copies the given floats to the current Vector3 coordinates
  82720. * @param x defines the x coordinate of the operand
  82721. * @param y defines the y coordinate of the operand
  82722. * @param z defines the z coordinate of the operand
  82723. * @returns the current updated Vector3
  82724. */
  82725. set(x: number, y: number, z: number): Vector3;
  82726. /**
  82727. * Copies the given float to the current Vector3 coordinates
  82728. * @param v defines the x, y and z coordinates of the operand
  82729. * @returns the current updated Vector3
  82730. */
  82731. setAll(v: number): Vector3;
  82732. /**
  82733. * Get the clip factor between two vectors
  82734. * @param vector0 defines the first operand
  82735. * @param vector1 defines the second operand
  82736. * @param axis defines the axis to use
  82737. * @param size defines the size along the axis
  82738. * @returns the clip factor
  82739. */
  82740. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  82741. /**
  82742. * Get angle between two vectors
  82743. * @param vector0 angle between vector0 and vector1
  82744. * @param vector1 angle between vector0 and vector1
  82745. * @param normal direction of the normal
  82746. * @return the angle between vector0 and vector1
  82747. */
  82748. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  82749. /**
  82750. * Returns a new Vector3 set from the index "offset" of the given array
  82751. * @param array defines the source array
  82752. * @param offset defines the offset in the source array
  82753. * @returns the new Vector3
  82754. */
  82755. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  82756. /**
  82757. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  82758. * @param array defines the source array
  82759. * @param offset defines the offset in the source array
  82760. * @returns the new Vector3
  82761. * @deprecated Please use FromArray instead.
  82762. */
  82763. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  82764. /**
  82765. * Sets the given vector "result" with the element values from the index "offset" of the given array
  82766. * @param array defines the source array
  82767. * @param offset defines the offset in the source array
  82768. * @param result defines the Vector3 where to store the result
  82769. */
  82770. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  82771. /**
  82772. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  82773. * @param array defines the source array
  82774. * @param offset defines the offset in the source array
  82775. * @param result defines the Vector3 where to store the result
  82776. * @deprecated Please use FromArrayToRef instead.
  82777. */
  82778. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  82779. /**
  82780. * Sets the given vector "result" with the given floats.
  82781. * @param x defines the x coordinate of the source
  82782. * @param y defines the y coordinate of the source
  82783. * @param z defines the z coordinate of the source
  82784. * @param result defines the Vector3 where to store the result
  82785. */
  82786. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  82787. /**
  82788. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  82789. * @returns a new empty Vector3
  82790. */
  82791. static Zero(): Vector3;
  82792. /**
  82793. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  82794. * @returns a new unit Vector3
  82795. */
  82796. static One(): Vector3;
  82797. /**
  82798. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  82799. * @returns a new up Vector3
  82800. */
  82801. static Up(): Vector3;
  82802. /**
  82803. * Gets a up Vector3 that must not be updated
  82804. */
  82805. static get UpReadOnly(): DeepImmutable<Vector3>;
  82806. /**
  82807. * Gets a zero Vector3 that must not be updated
  82808. */
  82809. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  82810. /**
  82811. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  82812. * @returns a new down Vector3
  82813. */
  82814. static Down(): Vector3;
  82815. /**
  82816. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  82817. * @param rightHandedSystem is the scene right-handed (negative z)
  82818. * @returns a new forward Vector3
  82819. */
  82820. static Forward(rightHandedSystem?: boolean): Vector3;
  82821. /**
  82822. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  82823. * @param rightHandedSystem is the scene right-handed (negative-z)
  82824. * @returns a new forward Vector3
  82825. */
  82826. static Backward(rightHandedSystem?: boolean): Vector3;
  82827. /**
  82828. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  82829. * @returns a new right Vector3
  82830. */
  82831. static Right(): Vector3;
  82832. /**
  82833. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  82834. * @returns a new left Vector3
  82835. */
  82836. static Left(): Vector3;
  82837. /**
  82838. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  82839. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  82840. * @param vector defines the Vector3 to transform
  82841. * @param transformation defines the transformation matrix
  82842. * @returns the transformed Vector3
  82843. */
  82844. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  82845. /**
  82846. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  82847. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  82848. * @param vector defines the Vector3 to transform
  82849. * @param transformation defines the transformation matrix
  82850. * @param result defines the Vector3 where to store the result
  82851. */
  82852. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  82853. /**
  82854. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  82855. * This method computes tranformed coordinates only, not transformed direction vectors
  82856. * @param x define the x coordinate of the source vector
  82857. * @param y define the y coordinate of the source vector
  82858. * @param z define the z coordinate of the source vector
  82859. * @param transformation defines the transformation matrix
  82860. * @param result defines the Vector3 where to store the result
  82861. */
  82862. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  82863. /**
  82864. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  82865. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  82866. * @param vector defines the Vector3 to transform
  82867. * @param transformation defines the transformation matrix
  82868. * @returns the new Vector3
  82869. */
  82870. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  82871. /**
  82872. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  82873. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  82874. * @param vector defines the Vector3 to transform
  82875. * @param transformation defines the transformation matrix
  82876. * @param result defines the Vector3 where to store the result
  82877. */
  82878. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  82879. /**
  82880. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  82881. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  82882. * @param x define the x coordinate of the source vector
  82883. * @param y define the y coordinate of the source vector
  82884. * @param z define the z coordinate of the source vector
  82885. * @param transformation defines the transformation matrix
  82886. * @param result defines the Vector3 where to store the result
  82887. */
  82888. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  82889. /**
  82890. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  82891. * @param value1 defines the first control point
  82892. * @param value2 defines the second control point
  82893. * @param value3 defines the third control point
  82894. * @param value4 defines the fourth control point
  82895. * @param amount defines the amount on the spline to use
  82896. * @returns the new Vector3
  82897. */
  82898. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  82899. /**
  82900. * 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"
  82901. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  82902. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  82903. * @param value defines the current value
  82904. * @param min defines the lower range value
  82905. * @param max defines the upper range value
  82906. * @returns the new Vector3
  82907. */
  82908. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  82909. /**
  82910. * 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"
  82911. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  82912. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  82913. * @param value defines the current value
  82914. * @param min defines the lower range value
  82915. * @param max defines the upper range value
  82916. * @param result defines the Vector3 where to store the result
  82917. */
  82918. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  82919. /**
  82920. * Checks if a given vector is inside a specific range
  82921. * @param v defines the vector to test
  82922. * @param min defines the minimum range
  82923. * @param max defines the maximum range
  82924. */
  82925. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  82926. /**
  82927. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  82928. * @param value1 defines the first control point
  82929. * @param tangent1 defines the first tangent vector
  82930. * @param value2 defines the second control point
  82931. * @param tangent2 defines the second tangent vector
  82932. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  82933. * @returns the new Vector3
  82934. */
  82935. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  82936. /**
  82937. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  82938. * @param start defines the start value
  82939. * @param end defines the end value
  82940. * @param amount max defines amount between both (between 0 and 1)
  82941. * @returns the new Vector3
  82942. */
  82943. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  82944. /**
  82945. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  82946. * @param start defines the start value
  82947. * @param end defines the end value
  82948. * @param amount max defines amount between both (between 0 and 1)
  82949. * @param result defines the Vector3 where to store the result
  82950. */
  82951. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  82952. /**
  82953. * Returns the dot product (float) between the vectors "left" and "right"
  82954. * @param left defines the left operand
  82955. * @param right defines the right operand
  82956. * @returns the dot product
  82957. */
  82958. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  82959. /**
  82960. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  82961. * The cross product is then orthogonal to both "left" and "right"
  82962. * @param left defines the left operand
  82963. * @param right defines the right operand
  82964. * @returns the cross product
  82965. */
  82966. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  82967. /**
  82968. * Sets the given vector "result" with the cross product of "left" and "right"
  82969. * The cross product is then orthogonal to both "left" and "right"
  82970. * @param left defines the left operand
  82971. * @param right defines the right operand
  82972. * @param result defines the Vector3 where to store the result
  82973. */
  82974. static CrossToRef(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>, result: Vector3): void;
  82975. /**
  82976. * Returns a new Vector3 as the normalization of the given vector
  82977. * @param vector defines the Vector3 to normalize
  82978. * @returns the new Vector3
  82979. */
  82980. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  82981. /**
  82982. * Sets the given vector "result" with the normalization of the given first vector
  82983. * @param vector defines the Vector3 to normalize
  82984. * @param result defines the Vector3 where to store the result
  82985. */
  82986. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  82987. /**
  82988. * Project a Vector3 onto screen space
  82989. * @param vector defines the Vector3 to project
  82990. * @param world defines the world matrix to use
  82991. * @param transform defines the transform (view x projection) matrix to use
  82992. * @param viewport defines the screen viewport to use
  82993. * @returns the new Vector3
  82994. */
  82995. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  82996. /** @hidden */
  82997. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  82998. /**
  82999. * Unproject from screen space to object space
  83000. * @param source defines the screen space Vector3 to use
  83001. * @param viewportWidth defines the current width of the viewport
  83002. * @param viewportHeight defines the current height of the viewport
  83003. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  83004. * @param transform defines the transform (view x projection) matrix to use
  83005. * @returns the new Vector3
  83006. */
  83007. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  83008. /**
  83009. * Unproject from screen space to object space
  83010. * @param source defines the screen space Vector3 to use
  83011. * @param viewportWidth defines the current width of the viewport
  83012. * @param viewportHeight defines the current height of the viewport
  83013. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  83014. * @param view defines the view matrix to use
  83015. * @param projection defines the projection matrix to use
  83016. * @returns the new Vector3
  83017. */
  83018. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  83019. /**
  83020. * Unproject from screen space to object space
  83021. * @param source defines the screen space Vector3 to use
  83022. * @param viewportWidth defines the current width of the viewport
  83023. * @param viewportHeight defines the current height of the viewport
  83024. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  83025. * @param view defines the view matrix to use
  83026. * @param projection defines the projection matrix to use
  83027. * @param result defines the Vector3 where to store the result
  83028. */
  83029. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  83030. /**
  83031. * Unproject from screen space to object space
  83032. * @param sourceX defines the screen space x coordinate to use
  83033. * @param sourceY defines the screen space y coordinate to use
  83034. * @param sourceZ defines the screen space z coordinate to use
  83035. * @param viewportWidth defines the current width of the viewport
  83036. * @param viewportHeight defines the current height of the viewport
  83037. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  83038. * @param view defines the view matrix to use
  83039. * @param projection defines the projection matrix to use
  83040. * @param result defines the Vector3 where to store the result
  83041. */
  83042. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  83043. /**
  83044. * Gets the minimal coordinate values between two Vector3
  83045. * @param left defines the first operand
  83046. * @param right defines the second operand
  83047. * @returns the new Vector3
  83048. */
  83049. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  83050. /**
  83051. * Gets the maximal coordinate values between two Vector3
  83052. * @param left defines the first operand
  83053. * @param right defines the second operand
  83054. * @returns the new Vector3
  83055. */
  83056. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  83057. /**
  83058. * Returns the distance between the vectors "value1" and "value2"
  83059. * @param value1 defines the first operand
  83060. * @param value2 defines the second operand
  83061. * @returns the distance
  83062. */
  83063. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  83064. /**
  83065. * Returns the squared distance between the vectors "value1" and "value2"
  83066. * @param value1 defines the first operand
  83067. * @param value2 defines the second operand
  83068. * @returns the squared distance
  83069. */
  83070. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  83071. /**
  83072. * Returns a new Vector3 located at the center between "value1" and "value2"
  83073. * @param value1 defines the first operand
  83074. * @param value2 defines the second operand
  83075. * @returns the new Vector3
  83076. */
  83077. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  83078. /**
  83079. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  83080. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  83081. * to something in order to rotate it from its local system to the given target system
  83082. * Note: axis1, axis2 and axis3 are normalized during this operation
  83083. * @param axis1 defines the first axis
  83084. * @param axis2 defines the second axis
  83085. * @param axis3 defines the third axis
  83086. * @returns a new Vector3
  83087. */
  83088. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  83089. /**
  83090. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  83091. * @param axis1 defines the first axis
  83092. * @param axis2 defines the second axis
  83093. * @param axis3 defines the third axis
  83094. * @param ref defines the Vector3 where to store the result
  83095. */
  83096. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  83097. }
  83098. /**
  83099. * Vector4 class created for EulerAngle class conversion to Quaternion
  83100. */
  83101. export class Vector4 {
  83102. /** x value of the vector */
  83103. x: number;
  83104. /** y value of the vector */
  83105. y: number;
  83106. /** z value of the vector */
  83107. z: number;
  83108. /** w value of the vector */
  83109. w: number;
  83110. /**
  83111. * Creates a Vector4 object from the given floats.
  83112. * @param x x value of the vector
  83113. * @param y y value of the vector
  83114. * @param z z value of the vector
  83115. * @param w w value of the vector
  83116. */
  83117. constructor(
  83118. /** x value of the vector */
  83119. x: number,
  83120. /** y value of the vector */
  83121. y: number,
  83122. /** z value of the vector */
  83123. z: number,
  83124. /** w value of the vector */
  83125. w: number);
  83126. /**
  83127. * Returns the string with the Vector4 coordinates.
  83128. * @returns a string containing all the vector values
  83129. */
  83130. toString(): string;
  83131. /**
  83132. * Returns the string "Vector4".
  83133. * @returns "Vector4"
  83134. */
  83135. getClassName(): string;
  83136. /**
  83137. * Returns the Vector4 hash code.
  83138. * @returns a unique hash code
  83139. */
  83140. getHashCode(): number;
  83141. /**
  83142. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  83143. * @returns the resulting array
  83144. */
  83145. asArray(): number[];
  83146. /**
  83147. * Populates the given array from the given index with the Vector4 coordinates.
  83148. * @param array array to populate
  83149. * @param index index of the array to start at (default: 0)
  83150. * @returns the Vector4.
  83151. */
  83152. toArray(array: FloatArray, index?: number): Vector4;
  83153. /**
  83154. * Update the current vector from an array
  83155. * @param array defines the destination array
  83156. * @param index defines the offset in the destination array
  83157. * @returns the current Vector3
  83158. */
  83159. fromArray(array: FloatArray, index?: number): Vector4;
  83160. /**
  83161. * Adds the given vector to the current Vector4.
  83162. * @param otherVector the vector to add
  83163. * @returns the updated Vector4.
  83164. */
  83165. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  83166. /**
  83167. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  83168. * @param otherVector the vector to add
  83169. * @returns the resulting vector
  83170. */
  83171. add(otherVector: DeepImmutable<Vector4>): Vector4;
  83172. /**
  83173. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  83174. * @param otherVector the vector to add
  83175. * @param result the vector to store the result
  83176. * @returns the current Vector4.
  83177. */
  83178. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  83179. /**
  83180. * Subtract in place the given vector from the current Vector4.
  83181. * @param otherVector the vector to subtract
  83182. * @returns the updated Vector4.
  83183. */
  83184. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  83185. /**
  83186. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  83187. * @param otherVector the vector to add
  83188. * @returns the new vector with the result
  83189. */
  83190. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  83191. /**
  83192. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  83193. * @param otherVector the vector to subtract
  83194. * @param result the vector to store the result
  83195. * @returns the current Vector4.
  83196. */
  83197. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  83198. /**
  83199. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  83200. */
  83201. /**
  83202. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  83203. * @param x value to subtract
  83204. * @param y value to subtract
  83205. * @param z value to subtract
  83206. * @param w value to subtract
  83207. * @returns new vector containing the result
  83208. */
  83209. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  83210. /**
  83211. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  83212. * @param x value to subtract
  83213. * @param y value to subtract
  83214. * @param z value to subtract
  83215. * @param w value to subtract
  83216. * @param result the vector to store the result in
  83217. * @returns the current Vector4.
  83218. */
  83219. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  83220. /**
  83221. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  83222. * @returns a new vector with the negated values
  83223. */
  83224. negate(): Vector4;
  83225. /**
  83226. * Negate this vector in place
  83227. * @returns this
  83228. */
  83229. negateInPlace(): Vector4;
  83230. /**
  83231. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  83232. * @param result defines the Vector3 object where to store the result
  83233. * @returns the current Vector4
  83234. */
  83235. negateToRef(result: Vector4): Vector4;
  83236. /**
  83237. * Multiplies the current Vector4 coordinates by scale (float).
  83238. * @param scale the number to scale with
  83239. * @returns the updated Vector4.
  83240. */
  83241. scaleInPlace(scale: number): Vector4;
  83242. /**
  83243. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  83244. * @param scale the number to scale with
  83245. * @returns a new vector with the result
  83246. */
  83247. scale(scale: number): Vector4;
  83248. /**
  83249. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  83250. * @param scale the number to scale with
  83251. * @param result a vector to store the result in
  83252. * @returns the current Vector4.
  83253. */
  83254. scaleToRef(scale: number, result: Vector4): Vector4;
  83255. /**
  83256. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  83257. * @param scale defines the scale factor
  83258. * @param result defines the Vector4 object where to store the result
  83259. * @returns the unmodified current Vector4
  83260. */
  83261. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  83262. /**
  83263. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  83264. * @param otherVector the vector to compare against
  83265. * @returns true if they are equal
  83266. */
  83267. equals(otherVector: DeepImmutable<Vector4>): boolean;
  83268. /**
  83269. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  83270. * @param otherVector vector to compare against
  83271. * @param epsilon (Default: very small number)
  83272. * @returns true if they are equal
  83273. */
  83274. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  83275. /**
  83276. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  83277. * @param x x value to compare against
  83278. * @param y y value to compare against
  83279. * @param z z value to compare against
  83280. * @param w w value to compare against
  83281. * @returns true if equal
  83282. */
  83283. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  83284. /**
  83285. * Multiplies in place the current Vector4 by the given one.
  83286. * @param otherVector vector to multiple with
  83287. * @returns the updated Vector4.
  83288. */
  83289. multiplyInPlace(otherVector: Vector4): Vector4;
  83290. /**
  83291. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  83292. * @param otherVector vector to multiple with
  83293. * @returns resulting new vector
  83294. */
  83295. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  83296. /**
  83297. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  83298. * @param otherVector vector to multiple with
  83299. * @param result vector to store the result
  83300. * @returns the current Vector4.
  83301. */
  83302. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  83303. /**
  83304. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  83305. * @param x x value multiply with
  83306. * @param y y value multiply with
  83307. * @param z z value multiply with
  83308. * @param w w value multiply with
  83309. * @returns resulting new vector
  83310. */
  83311. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  83312. /**
  83313. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  83314. * @param otherVector vector to devide with
  83315. * @returns resulting new vector
  83316. */
  83317. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  83318. /**
  83319. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  83320. * @param otherVector vector to devide with
  83321. * @param result vector to store the result
  83322. * @returns the current Vector4.
  83323. */
  83324. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  83325. /**
  83326. * Divides the current Vector3 coordinates by the given ones.
  83327. * @param otherVector vector to devide with
  83328. * @returns the updated Vector3.
  83329. */
  83330. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  83331. /**
  83332. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  83333. * @param other defines the second operand
  83334. * @returns the current updated Vector4
  83335. */
  83336. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  83337. /**
  83338. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  83339. * @param other defines the second operand
  83340. * @returns the current updated Vector4
  83341. */
  83342. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  83343. /**
  83344. * Gets a new Vector4 from current Vector4 floored values
  83345. * @returns a new Vector4
  83346. */
  83347. floor(): Vector4;
  83348. /**
  83349. * Gets a new Vector4 from current Vector3 floored values
  83350. * @returns a new Vector4
  83351. */
  83352. fract(): Vector4;
  83353. /**
  83354. * Returns the Vector4 length (float).
  83355. * @returns the length
  83356. */
  83357. length(): number;
  83358. /**
  83359. * Returns the Vector4 squared length (float).
  83360. * @returns the length squared
  83361. */
  83362. lengthSquared(): number;
  83363. /**
  83364. * Normalizes in place the Vector4.
  83365. * @returns the updated Vector4.
  83366. */
  83367. normalize(): Vector4;
  83368. /**
  83369. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  83370. * @returns this converted to a new vector3
  83371. */
  83372. toVector3(): Vector3;
  83373. /**
  83374. * Returns a new Vector4 copied from the current one.
  83375. * @returns the new cloned vector
  83376. */
  83377. clone(): Vector4;
  83378. /**
  83379. * Updates the current Vector4 with the given one coordinates.
  83380. * @param source the source vector to copy from
  83381. * @returns the updated Vector4.
  83382. */
  83383. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  83384. /**
  83385. * Updates the current Vector4 coordinates with the given floats.
  83386. * @param x float to copy from
  83387. * @param y float to copy from
  83388. * @param z float to copy from
  83389. * @param w float to copy from
  83390. * @returns the updated Vector4.
  83391. */
  83392. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  83393. /**
  83394. * Updates the current Vector4 coordinates with the given floats.
  83395. * @param x float to set from
  83396. * @param y float to set from
  83397. * @param z float to set from
  83398. * @param w float to set from
  83399. * @returns the updated Vector4.
  83400. */
  83401. set(x: number, y: number, z: number, w: number): Vector4;
  83402. /**
  83403. * Copies the given float to the current Vector3 coordinates
  83404. * @param v defines the x, y, z and w coordinates of the operand
  83405. * @returns the current updated Vector3
  83406. */
  83407. setAll(v: number): Vector4;
  83408. /**
  83409. * Returns a new Vector4 set from the starting index of the given array.
  83410. * @param array the array to pull values from
  83411. * @param offset the offset into the array to start at
  83412. * @returns the new vector
  83413. */
  83414. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  83415. /**
  83416. * Updates the given vector "result" from the starting index of the given array.
  83417. * @param array the array to pull values from
  83418. * @param offset the offset into the array to start at
  83419. * @param result the vector to store the result in
  83420. */
  83421. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  83422. /**
  83423. * Updates the given vector "result" from the starting index of the given Float32Array.
  83424. * @param array the array to pull values from
  83425. * @param offset the offset into the array to start at
  83426. * @param result the vector to store the result in
  83427. */
  83428. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  83429. /**
  83430. * Updates the given vector "result" coordinates from the given floats.
  83431. * @param x float to set from
  83432. * @param y float to set from
  83433. * @param z float to set from
  83434. * @param w float to set from
  83435. * @param result the vector to the floats in
  83436. */
  83437. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  83438. /**
  83439. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  83440. * @returns the new vector
  83441. */
  83442. static Zero(): Vector4;
  83443. /**
  83444. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  83445. * @returns the new vector
  83446. */
  83447. static One(): Vector4;
  83448. /**
  83449. * Returns a new normalized Vector4 from the given one.
  83450. * @param vector the vector to normalize
  83451. * @returns the vector
  83452. */
  83453. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  83454. /**
  83455. * Updates the given vector "result" from the normalization of the given one.
  83456. * @param vector the vector to normalize
  83457. * @param result the vector to store the result in
  83458. */
  83459. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  83460. /**
  83461. * Returns a vector with the minimum values from the left and right vectors
  83462. * @param left left vector to minimize
  83463. * @param right right vector to minimize
  83464. * @returns a new vector with the minimum of the left and right vector values
  83465. */
  83466. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  83467. /**
  83468. * Returns a vector with the maximum values from the left and right vectors
  83469. * @param left left vector to maximize
  83470. * @param right right vector to maximize
  83471. * @returns a new vector with the maximum of the left and right vector values
  83472. */
  83473. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  83474. /**
  83475. * Returns the distance (float) between the vectors "value1" and "value2".
  83476. * @param value1 value to calulate the distance between
  83477. * @param value2 value to calulate the distance between
  83478. * @return the distance between the two vectors
  83479. */
  83480. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  83481. /**
  83482. * Returns the squared distance (float) between the vectors "value1" and "value2".
  83483. * @param value1 value to calulate the distance between
  83484. * @param value2 value to calulate the distance between
  83485. * @return the distance between the two vectors squared
  83486. */
  83487. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  83488. /**
  83489. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  83490. * @param value1 value to calulate the center between
  83491. * @param value2 value to calulate the center between
  83492. * @return the center between the two vectors
  83493. */
  83494. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  83495. /**
  83496. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  83497. * This methods computes transformed normalized direction vectors only.
  83498. * @param vector the vector to transform
  83499. * @param transformation the transformation matrix to apply
  83500. * @returns the new vector
  83501. */
  83502. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  83503. /**
  83504. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  83505. * This methods computes transformed normalized direction vectors only.
  83506. * @param vector the vector to transform
  83507. * @param transformation the transformation matrix to apply
  83508. * @param result the vector to store the result in
  83509. */
  83510. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  83511. /**
  83512. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  83513. * This methods computes transformed normalized direction vectors only.
  83514. * @param x value to transform
  83515. * @param y value to transform
  83516. * @param z value to transform
  83517. * @param w value to transform
  83518. * @param transformation the transformation matrix to apply
  83519. * @param result the vector to store the results in
  83520. */
  83521. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  83522. /**
  83523. * Creates a new Vector4 from a Vector3
  83524. * @param source defines the source data
  83525. * @param w defines the 4th component (default is 0)
  83526. * @returns a new Vector4
  83527. */
  83528. static FromVector3(source: Vector3, w?: number): Vector4;
  83529. }
  83530. /**
  83531. * Class used to store quaternion data
  83532. * @see https://en.wikipedia.org/wiki/Quaternion
  83533. * @see https://doc.babylonjs.com/features/position,_rotation,_scaling
  83534. */
  83535. export class Quaternion {
  83536. /** @hidden */
  83537. _x: number;
  83538. /** @hidden */
  83539. _y: number;
  83540. /** @hidden */
  83541. _z: number;
  83542. /** @hidden */
  83543. _w: number;
  83544. /** @hidden */
  83545. _isDirty: boolean;
  83546. /** Gets or sets the x coordinate */
  83547. get x(): number;
  83548. set x(value: number);
  83549. /** Gets or sets the y coordinate */
  83550. get y(): number;
  83551. set y(value: number);
  83552. /** Gets or sets the z coordinate */
  83553. get z(): number;
  83554. set z(value: number);
  83555. /** Gets or sets the w coordinate */
  83556. get w(): number;
  83557. set w(value: number);
  83558. /**
  83559. * Creates a new Quaternion from the given floats
  83560. * @param x defines the first component (0 by default)
  83561. * @param y defines the second component (0 by default)
  83562. * @param z defines the third component (0 by default)
  83563. * @param w defines the fourth component (1.0 by default)
  83564. */
  83565. constructor(x?: number, y?: number, z?: number, w?: number);
  83566. /**
  83567. * Gets a string representation for the current quaternion
  83568. * @returns a string with the Quaternion coordinates
  83569. */
  83570. toString(): string;
  83571. /**
  83572. * Gets the class name of the quaternion
  83573. * @returns the string "Quaternion"
  83574. */
  83575. getClassName(): string;
  83576. /**
  83577. * Gets a hash code for this quaternion
  83578. * @returns the quaternion hash code
  83579. */
  83580. getHashCode(): number;
  83581. /**
  83582. * Copy the quaternion to an array
  83583. * @returns a new array populated with 4 elements from the quaternion coordinates
  83584. */
  83585. asArray(): number[];
  83586. /**
  83587. * Check if two quaternions are equals
  83588. * @param otherQuaternion defines the second operand
  83589. * @return true if the current quaternion and the given one coordinates are strictly equals
  83590. */
  83591. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  83592. /**
  83593. * Gets a boolean if two quaternions are equals (using an epsilon value)
  83594. * @param otherQuaternion defines the other quaternion
  83595. * @param epsilon defines the minimal distance to consider equality
  83596. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  83597. */
  83598. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  83599. /**
  83600. * Clone the current quaternion
  83601. * @returns a new quaternion copied from the current one
  83602. */
  83603. clone(): Quaternion;
  83604. /**
  83605. * Copy a quaternion to the current one
  83606. * @param other defines the other quaternion
  83607. * @returns the updated current quaternion
  83608. */
  83609. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  83610. /**
  83611. * Updates the current quaternion with the given float coordinates
  83612. * @param x defines the x coordinate
  83613. * @param y defines the y coordinate
  83614. * @param z defines the z coordinate
  83615. * @param w defines the w coordinate
  83616. * @returns the updated current quaternion
  83617. */
  83618. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  83619. /**
  83620. * Updates the current quaternion from the given float coordinates
  83621. * @param x defines the x coordinate
  83622. * @param y defines the y coordinate
  83623. * @param z defines the z coordinate
  83624. * @param w defines the w coordinate
  83625. * @returns the updated current quaternion
  83626. */
  83627. set(x: number, y: number, z: number, w: number): Quaternion;
  83628. /**
  83629. * Adds two quaternions
  83630. * @param other defines the second operand
  83631. * @returns a new quaternion as the addition result of the given one and the current quaternion
  83632. */
  83633. add(other: DeepImmutable<Quaternion>): Quaternion;
  83634. /**
  83635. * Add a quaternion to the current one
  83636. * @param other defines the quaternion to add
  83637. * @returns the current quaternion
  83638. */
  83639. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  83640. /**
  83641. * Subtract two quaternions
  83642. * @param other defines the second operand
  83643. * @returns a new quaternion as the subtraction result of the given one from the current one
  83644. */
  83645. subtract(other: Quaternion): Quaternion;
  83646. /**
  83647. * Multiplies the current quaternion by a scale factor
  83648. * @param value defines the scale factor
  83649. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  83650. */
  83651. scale(value: number): Quaternion;
  83652. /**
  83653. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  83654. * @param scale defines the scale factor
  83655. * @param result defines the Quaternion object where to store the result
  83656. * @returns the unmodified current quaternion
  83657. */
  83658. scaleToRef(scale: number, result: Quaternion): Quaternion;
  83659. /**
  83660. * Multiplies in place the current quaternion by a scale factor
  83661. * @param value defines the scale factor
  83662. * @returns the current modified quaternion
  83663. */
  83664. scaleInPlace(value: number): Quaternion;
  83665. /**
  83666. * Scale the current quaternion values by a factor and add the result to a given quaternion
  83667. * @param scale defines the scale factor
  83668. * @param result defines the Quaternion object where to store the result
  83669. * @returns the unmodified current quaternion
  83670. */
  83671. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  83672. /**
  83673. * Multiplies two quaternions
  83674. * @param q1 defines the second operand
  83675. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  83676. */
  83677. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  83678. /**
  83679. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  83680. * @param q1 defines the second operand
  83681. * @param result defines the target quaternion
  83682. * @returns the current quaternion
  83683. */
  83684. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  83685. /**
  83686. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  83687. * @param q1 defines the second operand
  83688. * @returns the currentupdated quaternion
  83689. */
  83690. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  83691. /**
  83692. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  83693. * @param ref defines the target quaternion
  83694. * @returns the current quaternion
  83695. */
  83696. conjugateToRef(ref: Quaternion): Quaternion;
  83697. /**
  83698. * Conjugates in place (1-q) the current quaternion
  83699. * @returns the current updated quaternion
  83700. */
  83701. conjugateInPlace(): Quaternion;
  83702. /**
  83703. * Conjugates in place (1-q) the current quaternion
  83704. * @returns a new quaternion
  83705. */
  83706. conjugate(): Quaternion;
  83707. /**
  83708. * Gets length of current quaternion
  83709. * @returns the quaternion length (float)
  83710. */
  83711. length(): number;
  83712. /**
  83713. * Normalize in place the current quaternion
  83714. * @returns the current updated quaternion
  83715. */
  83716. normalize(): Quaternion;
  83717. /**
  83718. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  83719. * @param order is a reserved parameter and is ignore for now
  83720. * @returns a new Vector3 containing the Euler angles
  83721. */
  83722. toEulerAngles(order?: string): Vector3;
  83723. /**
  83724. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  83725. * @param result defines the vector which will be filled with the Euler angles
  83726. * @param order is a reserved parameter and is ignore for now
  83727. * @returns the current unchanged quaternion
  83728. */
  83729. toEulerAnglesToRef(result: Vector3): Quaternion;
  83730. /**
  83731. * Updates the given rotation matrix with the current quaternion values
  83732. * @param result defines the target matrix
  83733. * @returns the current unchanged quaternion
  83734. */
  83735. toRotationMatrix(result: Matrix): Quaternion;
  83736. /**
  83737. * Updates the current quaternion from the given rotation matrix values
  83738. * @param matrix defines the source matrix
  83739. * @returns the current updated quaternion
  83740. */
  83741. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  83742. /**
  83743. * Creates a new quaternion from a rotation matrix
  83744. * @param matrix defines the source matrix
  83745. * @returns a new quaternion created from the given rotation matrix values
  83746. */
  83747. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  83748. /**
  83749. * Updates the given quaternion with the given rotation matrix values
  83750. * @param matrix defines the source matrix
  83751. * @param result defines the target quaternion
  83752. */
  83753. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  83754. /**
  83755. * Returns the dot product (float) between the quaternions "left" and "right"
  83756. * @param left defines the left operand
  83757. * @param right defines the right operand
  83758. * @returns the dot product
  83759. */
  83760. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  83761. /**
  83762. * Checks if the two quaternions are close to each other
  83763. * @param quat0 defines the first quaternion to check
  83764. * @param quat1 defines the second quaternion to check
  83765. * @returns true if the two quaternions are close to each other
  83766. */
  83767. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  83768. /**
  83769. * Creates an empty quaternion
  83770. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  83771. */
  83772. static Zero(): Quaternion;
  83773. /**
  83774. * Inverse a given quaternion
  83775. * @param q defines the source quaternion
  83776. * @returns a new quaternion as the inverted current quaternion
  83777. */
  83778. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  83779. /**
  83780. * Inverse a given quaternion
  83781. * @param q defines the source quaternion
  83782. * @param result the quaternion the result will be stored in
  83783. * @returns the result quaternion
  83784. */
  83785. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  83786. /**
  83787. * Creates an identity quaternion
  83788. * @returns the identity quaternion
  83789. */
  83790. static Identity(): Quaternion;
  83791. /**
  83792. * Gets a boolean indicating if the given quaternion is identity
  83793. * @param quaternion defines the quaternion to check
  83794. * @returns true if the quaternion is identity
  83795. */
  83796. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  83797. /**
  83798. * Creates a quaternion from a rotation around an axis
  83799. * @param axis defines the axis to use
  83800. * @param angle defines the angle to use
  83801. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  83802. */
  83803. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  83804. /**
  83805. * Creates a rotation around an axis and stores it into the given quaternion
  83806. * @param axis defines the axis to use
  83807. * @param angle defines the angle to use
  83808. * @param result defines the target quaternion
  83809. * @returns the target quaternion
  83810. */
  83811. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  83812. /**
  83813. * Creates a new quaternion from data stored into an array
  83814. * @param array defines the data source
  83815. * @param offset defines the offset in the source array where the data starts
  83816. * @returns a new quaternion
  83817. */
  83818. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  83819. /**
  83820. * Updates the given quaternion "result" from the starting index of the given array.
  83821. * @param array the array to pull values from
  83822. * @param offset the offset into the array to start at
  83823. * @param result the quaternion to store the result in
  83824. */
  83825. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Quaternion): void;
  83826. /**
  83827. * Create a quaternion from Euler rotation angles
  83828. * @param x Pitch
  83829. * @param y Yaw
  83830. * @param z Roll
  83831. * @returns the new Quaternion
  83832. */
  83833. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  83834. /**
  83835. * Updates a quaternion from Euler rotation angles
  83836. * @param x Pitch
  83837. * @param y Yaw
  83838. * @param z Roll
  83839. * @param result the quaternion to store the result
  83840. * @returns the updated quaternion
  83841. */
  83842. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  83843. /**
  83844. * Create a quaternion from Euler rotation vector
  83845. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  83846. * @returns the new Quaternion
  83847. */
  83848. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  83849. /**
  83850. * Updates a quaternion from Euler rotation vector
  83851. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  83852. * @param result the quaternion to store the result
  83853. * @returns the updated quaternion
  83854. */
  83855. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  83856. /**
  83857. * Creates a new quaternion from the given Euler float angles (y, x, z)
  83858. * @param yaw defines the rotation around Y axis
  83859. * @param pitch defines the rotation around X axis
  83860. * @param roll defines the rotation around Z axis
  83861. * @returns the new quaternion
  83862. */
  83863. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  83864. /**
  83865. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  83866. * @param yaw defines the rotation around Y axis
  83867. * @param pitch defines the rotation around X axis
  83868. * @param roll defines the rotation around Z axis
  83869. * @param result defines the target quaternion
  83870. */
  83871. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  83872. /**
  83873. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  83874. * @param alpha defines the rotation around first axis
  83875. * @param beta defines the rotation around second axis
  83876. * @param gamma defines the rotation around third axis
  83877. * @returns the new quaternion
  83878. */
  83879. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  83880. /**
  83881. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  83882. * @param alpha defines the rotation around first axis
  83883. * @param beta defines the rotation around second axis
  83884. * @param gamma defines the rotation around third axis
  83885. * @param result defines the target quaternion
  83886. */
  83887. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  83888. /**
  83889. * 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)
  83890. * @param axis1 defines the first axis
  83891. * @param axis2 defines the second axis
  83892. * @param axis3 defines the third axis
  83893. * @returns the new quaternion
  83894. */
  83895. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  83896. /**
  83897. * 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
  83898. * @param axis1 defines the first axis
  83899. * @param axis2 defines the second axis
  83900. * @param axis3 defines the third axis
  83901. * @param ref defines the target quaternion
  83902. */
  83903. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  83904. /**
  83905. * Interpolates between two quaternions
  83906. * @param left defines first quaternion
  83907. * @param right defines second quaternion
  83908. * @param amount defines the gradient to use
  83909. * @returns the new interpolated quaternion
  83910. */
  83911. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  83912. /**
  83913. * Interpolates between two quaternions and stores it into a target quaternion
  83914. * @param left defines first quaternion
  83915. * @param right defines second quaternion
  83916. * @param amount defines the gradient to use
  83917. * @param result defines the target quaternion
  83918. */
  83919. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  83920. /**
  83921. * Interpolate between two quaternions using Hermite interpolation
  83922. * @param value1 defines first quaternion
  83923. * @param tangent1 defines the incoming tangent
  83924. * @param value2 defines second quaternion
  83925. * @param tangent2 defines the outgoing tangent
  83926. * @param amount defines the target quaternion
  83927. * @returns the new interpolated quaternion
  83928. */
  83929. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  83930. }
  83931. /**
  83932. * Class used to store matrix data (4x4)
  83933. */
  83934. export class Matrix {
  83935. /**
  83936. * Gets the precision of matrix computations
  83937. */
  83938. static get Use64Bits(): boolean;
  83939. private static _updateFlagSeed;
  83940. private static _identityReadOnly;
  83941. private _isIdentity;
  83942. private _isIdentityDirty;
  83943. private _isIdentity3x2;
  83944. private _isIdentity3x2Dirty;
  83945. /**
  83946. * Gets the update flag of the matrix which is an unique number for the matrix.
  83947. * It will be incremented every time the matrix data change.
  83948. * You can use it to speed the comparison between two versions of the same matrix.
  83949. */
  83950. updateFlag: number;
  83951. private readonly _m;
  83952. /**
  83953. * Gets the internal data of the matrix
  83954. */
  83955. get m(): DeepImmutable<Float32Array | Array<number>>;
  83956. /** @hidden */
  83957. _markAsUpdated(): void;
  83958. /** @hidden */
  83959. private _updateIdentityStatus;
  83960. /**
  83961. * Creates an empty matrix (filled with zeros)
  83962. */
  83963. constructor();
  83964. /**
  83965. * Check if the current matrix is identity
  83966. * @returns true is the matrix is the identity matrix
  83967. */
  83968. isIdentity(): boolean;
  83969. /**
  83970. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  83971. * @returns true is the matrix is the identity matrix
  83972. */
  83973. isIdentityAs3x2(): boolean;
  83974. /**
  83975. * Gets the determinant of the matrix
  83976. * @returns the matrix determinant
  83977. */
  83978. determinant(): number;
  83979. /**
  83980. * Returns the matrix as a Float32Array or Array<number>
  83981. * @returns the matrix underlying array
  83982. */
  83983. toArray(): DeepImmutable<Float32Array | Array<number>>;
  83984. /**
  83985. * Returns the matrix as a Float32Array or Array<number>
  83986. * @returns the matrix underlying array.
  83987. */
  83988. asArray(): DeepImmutable<Float32Array | Array<number>>;
  83989. /**
  83990. * Inverts the current matrix in place
  83991. * @returns the current inverted matrix
  83992. */
  83993. invert(): Matrix;
  83994. /**
  83995. * Sets all the matrix elements to zero
  83996. * @returns the current matrix
  83997. */
  83998. reset(): Matrix;
  83999. /**
  84000. * Adds the current matrix with a second one
  84001. * @param other defines the matrix to add
  84002. * @returns a new matrix as the addition of the current matrix and the given one
  84003. */
  84004. add(other: DeepImmutable<Matrix>): Matrix;
  84005. /**
  84006. * Sets the given matrix "result" to the addition of the current matrix and the given one
  84007. * @param other defines the matrix to add
  84008. * @param result defines the target matrix
  84009. * @returns the current matrix
  84010. */
  84011. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  84012. /**
  84013. * Adds in place the given matrix to the current matrix
  84014. * @param other defines the second operand
  84015. * @returns the current updated matrix
  84016. */
  84017. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  84018. /**
  84019. * Sets the given matrix to the current inverted Matrix
  84020. * @param other defines the target matrix
  84021. * @returns the unmodified current matrix
  84022. */
  84023. invertToRef(other: Matrix): Matrix;
  84024. /**
  84025. * add a value at the specified position in the current Matrix
  84026. * @param index the index of the value within the matrix. between 0 and 15.
  84027. * @param value the value to be added
  84028. * @returns the current updated matrix
  84029. */
  84030. addAtIndex(index: number, value: number): Matrix;
  84031. /**
  84032. * mutiply the specified position in the current Matrix by a value
  84033. * @param index the index of the value within the matrix. between 0 and 15.
  84034. * @param value the value to be added
  84035. * @returns the current updated matrix
  84036. */
  84037. multiplyAtIndex(index: number, value: number): Matrix;
  84038. /**
  84039. * Inserts the translation vector (using 3 floats) in the current matrix
  84040. * @param x defines the 1st component of the translation
  84041. * @param y defines the 2nd component of the translation
  84042. * @param z defines the 3rd component of the translation
  84043. * @returns the current updated matrix
  84044. */
  84045. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  84046. /**
  84047. * Adds the translation vector (using 3 floats) in the current matrix
  84048. * @param x defines the 1st component of the translation
  84049. * @param y defines the 2nd component of the translation
  84050. * @param z defines the 3rd component of the translation
  84051. * @returns the current updated matrix
  84052. */
  84053. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  84054. /**
  84055. * Inserts the translation vector in the current matrix
  84056. * @param vector3 defines the translation to insert
  84057. * @returns the current updated matrix
  84058. */
  84059. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  84060. /**
  84061. * Gets the translation value of the current matrix
  84062. * @returns a new Vector3 as the extracted translation from the matrix
  84063. */
  84064. getTranslation(): Vector3;
  84065. /**
  84066. * Fill a Vector3 with the extracted translation from the matrix
  84067. * @param result defines the Vector3 where to store the translation
  84068. * @returns the current matrix
  84069. */
  84070. getTranslationToRef(result: Vector3): Matrix;
  84071. /**
  84072. * Remove rotation and scaling part from the matrix
  84073. * @returns the updated matrix
  84074. */
  84075. removeRotationAndScaling(): Matrix;
  84076. /**
  84077. * Multiply two matrices
  84078. * @param other defines the second operand
  84079. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  84080. */
  84081. multiply(other: DeepImmutable<Matrix>): Matrix;
  84082. /**
  84083. * Copy the current matrix from the given one
  84084. * @param other defines the source matrix
  84085. * @returns the current updated matrix
  84086. */
  84087. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  84088. /**
  84089. * Populates the given array from the starting index with the current matrix values
  84090. * @param array defines the target array
  84091. * @param offset defines the offset in the target array where to start storing values
  84092. * @returns the current matrix
  84093. */
  84094. copyToArray(array: Float32Array | Array<number>, offset?: number): Matrix;
  84095. /**
  84096. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  84097. * @param other defines the second operand
  84098. * @param result defines the matrix where to store the multiplication
  84099. * @returns the current matrix
  84100. */
  84101. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  84102. /**
  84103. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  84104. * @param other defines the second operand
  84105. * @param result defines the array where to store the multiplication
  84106. * @param offset defines the offset in the target array where to start storing values
  84107. * @returns the current matrix
  84108. */
  84109. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array | Array<number>, offset: number): Matrix;
  84110. /**
  84111. * Check equality between this matrix and a second one
  84112. * @param value defines the second matrix to compare
  84113. * @returns true is the current matrix and the given one values are strictly equal
  84114. */
  84115. equals(value: DeepImmutable<Matrix>): boolean;
  84116. /**
  84117. * Clone the current matrix
  84118. * @returns a new matrix from the current matrix
  84119. */
  84120. clone(): Matrix;
  84121. /**
  84122. * Returns the name of the current matrix class
  84123. * @returns the string "Matrix"
  84124. */
  84125. getClassName(): string;
  84126. /**
  84127. * Gets the hash code of the current matrix
  84128. * @returns the hash code
  84129. */
  84130. getHashCode(): number;
  84131. /**
  84132. * Decomposes the current Matrix into a translation, rotation and scaling components
  84133. * @param scale defines the scale vector3 given as a reference to update
  84134. * @param rotation defines the rotation quaternion given as a reference to update
  84135. * @param translation defines the translation vector3 given as a reference to update
  84136. * @returns true if operation was successful
  84137. */
  84138. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  84139. /**
  84140. * Gets specific row of the matrix
  84141. * @param index defines the number of the row to get
  84142. * @returns the index-th row of the current matrix as a new Vector4
  84143. */
  84144. getRow(index: number): Nullable<Vector4>;
  84145. /**
  84146. * Sets the index-th row of the current matrix to the vector4 values
  84147. * @param index defines the number of the row to set
  84148. * @param row defines the target vector4
  84149. * @returns the updated current matrix
  84150. */
  84151. setRow(index: number, row: Vector4): Matrix;
  84152. /**
  84153. * Compute the transpose of the matrix
  84154. * @returns the new transposed matrix
  84155. */
  84156. transpose(): Matrix;
  84157. /**
  84158. * Compute the transpose of the matrix and store it in a given matrix
  84159. * @param result defines the target matrix
  84160. * @returns the current matrix
  84161. */
  84162. transposeToRef(result: Matrix): Matrix;
  84163. /**
  84164. * Sets the index-th row of the current matrix with the given 4 x float values
  84165. * @param index defines the row index
  84166. * @param x defines the x component to set
  84167. * @param y defines the y component to set
  84168. * @param z defines the z component to set
  84169. * @param w defines the w component to set
  84170. * @returns the updated current matrix
  84171. */
  84172. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  84173. /**
  84174. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  84175. * @param scale defines the scale factor
  84176. * @returns a new matrix
  84177. */
  84178. scale(scale: number): Matrix;
  84179. /**
  84180. * Scale the current matrix values by a factor to a given result matrix
  84181. * @param scale defines the scale factor
  84182. * @param result defines the matrix to store the result
  84183. * @returns the current matrix
  84184. */
  84185. scaleToRef(scale: number, result: Matrix): Matrix;
  84186. /**
  84187. * Scale the current matrix values by a factor and add the result to a given matrix
  84188. * @param scale defines the scale factor
  84189. * @param result defines the Matrix to store the result
  84190. * @returns the current matrix
  84191. */
  84192. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  84193. /**
  84194. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  84195. * @param ref matrix to store the result
  84196. */
  84197. toNormalMatrix(ref: Matrix): void;
  84198. /**
  84199. * Gets only rotation part of the current matrix
  84200. * @returns a new matrix sets to the extracted rotation matrix from the current one
  84201. */
  84202. getRotationMatrix(): Matrix;
  84203. /**
  84204. * Extracts the rotation matrix from the current one and sets it as the given "result"
  84205. * @param result defines the target matrix to store data to
  84206. * @returns the current matrix
  84207. */
  84208. getRotationMatrixToRef(result: Matrix): Matrix;
  84209. /**
  84210. * Toggles model matrix from being right handed to left handed in place and vice versa
  84211. */
  84212. toggleModelMatrixHandInPlace(): void;
  84213. /**
  84214. * Toggles projection matrix from being right handed to left handed in place and vice versa
  84215. */
  84216. toggleProjectionMatrixHandInPlace(): void;
  84217. /**
  84218. * Creates a matrix from an array
  84219. * @param array defines the source array
  84220. * @param offset defines an offset in the source array
  84221. * @returns a new Matrix set from the starting index of the given array
  84222. */
  84223. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  84224. /**
  84225. * Copy the content of an array into a given matrix
  84226. * @param array defines the source array
  84227. * @param offset defines an offset in the source array
  84228. * @param result defines the target matrix
  84229. */
  84230. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  84231. /**
  84232. * Stores an array into a matrix after having multiplied each component by a given factor
  84233. * @param array defines the source array
  84234. * @param offset defines the offset in the source array
  84235. * @param scale defines the scaling factor
  84236. * @param result defines the target matrix
  84237. */
  84238. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array | Array<number>>, offset: number, scale: number, result: Matrix): void;
  84239. /**
  84240. * Gets an identity matrix that must not be updated
  84241. */
  84242. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  84243. /**
  84244. * Stores a list of values (16) inside a given matrix
  84245. * @param initialM11 defines 1st value of 1st row
  84246. * @param initialM12 defines 2nd value of 1st row
  84247. * @param initialM13 defines 3rd value of 1st row
  84248. * @param initialM14 defines 4th value of 1st row
  84249. * @param initialM21 defines 1st value of 2nd row
  84250. * @param initialM22 defines 2nd value of 2nd row
  84251. * @param initialM23 defines 3rd value of 2nd row
  84252. * @param initialM24 defines 4th value of 2nd row
  84253. * @param initialM31 defines 1st value of 3rd row
  84254. * @param initialM32 defines 2nd value of 3rd row
  84255. * @param initialM33 defines 3rd value of 3rd row
  84256. * @param initialM34 defines 4th value of 3rd row
  84257. * @param initialM41 defines 1st value of 4th row
  84258. * @param initialM42 defines 2nd value of 4th row
  84259. * @param initialM43 defines 3rd value of 4th row
  84260. * @param initialM44 defines 4th value of 4th row
  84261. * @param result defines the target matrix
  84262. */
  84263. 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;
  84264. /**
  84265. * Creates new matrix from a list of values (16)
  84266. * @param initialM11 defines 1st value of 1st row
  84267. * @param initialM12 defines 2nd value of 1st row
  84268. * @param initialM13 defines 3rd value of 1st row
  84269. * @param initialM14 defines 4th value of 1st row
  84270. * @param initialM21 defines 1st value of 2nd row
  84271. * @param initialM22 defines 2nd value of 2nd row
  84272. * @param initialM23 defines 3rd value of 2nd row
  84273. * @param initialM24 defines 4th value of 2nd row
  84274. * @param initialM31 defines 1st value of 3rd row
  84275. * @param initialM32 defines 2nd value of 3rd row
  84276. * @param initialM33 defines 3rd value of 3rd row
  84277. * @param initialM34 defines 4th value of 3rd row
  84278. * @param initialM41 defines 1st value of 4th row
  84279. * @param initialM42 defines 2nd value of 4th row
  84280. * @param initialM43 defines 3rd value of 4th row
  84281. * @param initialM44 defines 4th value of 4th row
  84282. * @returns the new matrix
  84283. */
  84284. 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;
  84285. /**
  84286. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  84287. * @param scale defines the scale vector3
  84288. * @param rotation defines the rotation quaternion
  84289. * @param translation defines the translation vector3
  84290. * @returns a new matrix
  84291. */
  84292. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  84293. /**
  84294. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  84295. * @param scale defines the scale vector3
  84296. * @param rotation defines the rotation quaternion
  84297. * @param translation defines the translation vector3
  84298. * @param result defines the target matrix
  84299. */
  84300. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  84301. /**
  84302. * Creates a new identity matrix
  84303. * @returns a new identity matrix
  84304. */
  84305. static Identity(): Matrix;
  84306. /**
  84307. * Creates a new identity matrix and stores the result in a given matrix
  84308. * @param result defines the target matrix
  84309. */
  84310. static IdentityToRef(result: Matrix): void;
  84311. /**
  84312. * Creates a new zero matrix
  84313. * @returns a new zero matrix
  84314. */
  84315. static Zero(): Matrix;
  84316. /**
  84317. * Creates a new rotation matrix for "angle" radians around the X axis
  84318. * @param angle defines the angle (in radians) to use
  84319. * @return the new matrix
  84320. */
  84321. static RotationX(angle: number): Matrix;
  84322. /**
  84323. * Creates a new matrix as the invert of a given matrix
  84324. * @param source defines the source matrix
  84325. * @returns the new matrix
  84326. */
  84327. static Invert(source: DeepImmutable<Matrix>): Matrix;
  84328. /**
  84329. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  84330. * @param angle defines the angle (in radians) to use
  84331. * @param result defines the target matrix
  84332. */
  84333. static RotationXToRef(angle: number, result: Matrix): void;
  84334. /**
  84335. * Creates a new rotation matrix for "angle" radians around the Y axis
  84336. * @param angle defines the angle (in radians) to use
  84337. * @return the new matrix
  84338. */
  84339. static RotationY(angle: number): Matrix;
  84340. /**
  84341. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  84342. * @param angle defines the angle (in radians) to use
  84343. * @param result defines the target matrix
  84344. */
  84345. static RotationYToRef(angle: number, result: Matrix): void;
  84346. /**
  84347. * Creates a new rotation matrix for "angle" radians around the Z axis
  84348. * @param angle defines the angle (in radians) to use
  84349. * @return the new matrix
  84350. */
  84351. static RotationZ(angle: number): Matrix;
  84352. /**
  84353. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  84354. * @param angle defines the angle (in radians) to use
  84355. * @param result defines the target matrix
  84356. */
  84357. static RotationZToRef(angle: number, result: Matrix): void;
  84358. /**
  84359. * Creates a new rotation matrix for "angle" radians around the given axis
  84360. * @param axis defines the axis to use
  84361. * @param angle defines the angle (in radians) to use
  84362. * @return the new matrix
  84363. */
  84364. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  84365. /**
  84366. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  84367. * @param axis defines the axis to use
  84368. * @param angle defines the angle (in radians) to use
  84369. * @param result defines the target matrix
  84370. */
  84371. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  84372. /**
  84373. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  84374. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  84375. * @param from defines the vector to align
  84376. * @param to defines the vector to align to
  84377. * @param result defines the target matrix
  84378. */
  84379. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  84380. /**
  84381. * Creates a rotation matrix
  84382. * @param yaw defines the yaw angle in radians (Y axis)
  84383. * @param pitch defines the pitch angle in radians (X axis)
  84384. * @param roll defines the roll angle in radians (Z axis)
  84385. * @returns the new rotation matrix
  84386. */
  84387. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  84388. /**
  84389. * Creates a rotation matrix and stores it in a given matrix
  84390. * @param yaw defines the yaw angle in radians (Y axis)
  84391. * @param pitch defines the pitch angle in radians (X axis)
  84392. * @param roll defines the roll angle in radians (Z axis)
  84393. * @param result defines the target matrix
  84394. */
  84395. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  84396. /**
  84397. * Creates a scaling matrix
  84398. * @param x defines the scale factor on X axis
  84399. * @param y defines the scale factor on Y axis
  84400. * @param z defines the scale factor on Z axis
  84401. * @returns the new matrix
  84402. */
  84403. static Scaling(x: number, y: number, z: number): Matrix;
  84404. /**
  84405. * Creates a scaling matrix and stores it in a given matrix
  84406. * @param x defines the scale factor on X axis
  84407. * @param y defines the scale factor on Y axis
  84408. * @param z defines the scale factor on Z axis
  84409. * @param result defines the target matrix
  84410. */
  84411. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  84412. /**
  84413. * Creates a translation matrix
  84414. * @param x defines the translation on X axis
  84415. * @param y defines the translation on Y axis
  84416. * @param z defines the translationon Z axis
  84417. * @returns the new matrix
  84418. */
  84419. static Translation(x: number, y: number, z: number): Matrix;
  84420. /**
  84421. * Creates a translation matrix and stores it in a given matrix
  84422. * @param x defines the translation on X axis
  84423. * @param y defines the translation on Y axis
  84424. * @param z defines the translationon Z axis
  84425. * @param result defines the target matrix
  84426. */
  84427. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  84428. /**
  84429. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  84430. * @param startValue defines the start value
  84431. * @param endValue defines the end value
  84432. * @param gradient defines the gradient factor
  84433. * @returns the new matrix
  84434. */
  84435. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  84436. /**
  84437. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  84438. * @param startValue defines the start value
  84439. * @param endValue defines the end value
  84440. * @param gradient defines the gradient factor
  84441. * @param result defines the Matrix object where to store data
  84442. */
  84443. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  84444. /**
  84445. * Builds a new matrix whose values are computed by:
  84446. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  84447. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  84448. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  84449. * @param startValue defines the first matrix
  84450. * @param endValue defines the second matrix
  84451. * @param gradient defines the gradient between the two matrices
  84452. * @returns the new matrix
  84453. */
  84454. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  84455. /**
  84456. * Update a matrix to values which are computed by:
  84457. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  84458. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  84459. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  84460. * @param startValue defines the first matrix
  84461. * @param endValue defines the second matrix
  84462. * @param gradient defines the gradient between the two matrices
  84463. * @param result defines the target matrix
  84464. */
  84465. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  84466. /**
  84467. * 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"
  84468. * This function works in left handed mode
  84469. * @param eye defines the final position of the entity
  84470. * @param target defines where the entity should look at
  84471. * @param up defines the up vector for the entity
  84472. * @returns the new matrix
  84473. */
  84474. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  84475. /**
  84476. * 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".
  84477. * This function works in left handed mode
  84478. * @param eye defines the final position of the entity
  84479. * @param target defines where the entity should look at
  84480. * @param up defines the up vector for the entity
  84481. * @param result defines the target matrix
  84482. */
  84483. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  84484. /**
  84485. * 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"
  84486. * This function works in right handed mode
  84487. * @param eye defines the final position of the entity
  84488. * @param target defines where the entity should look at
  84489. * @param up defines the up vector for the entity
  84490. * @returns the new matrix
  84491. */
  84492. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  84493. /**
  84494. * 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".
  84495. * This function works in right handed mode
  84496. * @param eye defines the final position of the entity
  84497. * @param target defines where the entity should look at
  84498. * @param up defines the up vector for the entity
  84499. * @param result defines the target matrix
  84500. */
  84501. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  84502. /**
  84503. * Create a left-handed orthographic projection matrix
  84504. * @param width defines the viewport width
  84505. * @param height defines the viewport height
  84506. * @param znear defines the near clip plane
  84507. * @param zfar defines the far clip plane
  84508. * @returns a new matrix as a left-handed orthographic projection matrix
  84509. */
  84510. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  84511. /**
  84512. * Store a left-handed orthographic projection to a given matrix
  84513. * @param width defines the viewport width
  84514. * @param height defines the viewport height
  84515. * @param znear defines the near clip plane
  84516. * @param zfar defines the far clip plane
  84517. * @param result defines the target matrix
  84518. */
  84519. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  84520. /**
  84521. * Create a left-handed orthographic projection matrix
  84522. * @param left defines the viewport left coordinate
  84523. * @param right defines the viewport right coordinate
  84524. * @param bottom defines the viewport bottom coordinate
  84525. * @param top defines the viewport top coordinate
  84526. * @param znear defines the near clip plane
  84527. * @param zfar defines the far clip plane
  84528. * @returns a new matrix as a left-handed orthographic projection matrix
  84529. */
  84530. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  84531. /**
  84532. * Stores a left-handed orthographic projection into a given matrix
  84533. * @param left defines the viewport left coordinate
  84534. * @param right defines the viewport right coordinate
  84535. * @param bottom defines the viewport bottom coordinate
  84536. * @param top defines the viewport top coordinate
  84537. * @param znear defines the near clip plane
  84538. * @param zfar defines the far clip plane
  84539. * @param result defines the target matrix
  84540. */
  84541. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  84542. /**
  84543. * Creates a right-handed orthographic projection matrix
  84544. * @param left defines the viewport left coordinate
  84545. * @param right defines the viewport right coordinate
  84546. * @param bottom defines the viewport bottom coordinate
  84547. * @param top defines the viewport top coordinate
  84548. * @param znear defines the near clip plane
  84549. * @param zfar defines the far clip plane
  84550. * @returns a new matrix as a right-handed orthographic projection matrix
  84551. */
  84552. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  84553. /**
  84554. * Stores a right-handed orthographic projection into a given matrix
  84555. * @param left defines the viewport left coordinate
  84556. * @param right defines the viewport right coordinate
  84557. * @param bottom defines the viewport bottom coordinate
  84558. * @param top defines the viewport top coordinate
  84559. * @param znear defines the near clip plane
  84560. * @param zfar defines the far clip plane
  84561. * @param result defines the target matrix
  84562. */
  84563. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  84564. /**
  84565. * Creates a left-handed perspective projection matrix
  84566. * @param width defines the viewport width
  84567. * @param height defines the viewport height
  84568. * @param znear defines the near clip plane
  84569. * @param zfar defines the far clip plane
  84570. * @returns a new matrix as a left-handed perspective projection matrix
  84571. */
  84572. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  84573. /**
  84574. * Creates a left-handed perspective projection matrix
  84575. * @param fov defines the horizontal field of view
  84576. * @param aspect defines the aspect ratio
  84577. * @param znear defines the near clip plane
  84578. * @param zfar defines the far clip plane
  84579. * @returns a new matrix as a left-handed perspective projection matrix
  84580. */
  84581. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  84582. /**
  84583. * Stores a left-handed perspective projection into a given matrix
  84584. * @param fov defines the horizontal field of view
  84585. * @param aspect defines the aspect ratio
  84586. * @param znear defines the near clip plane
  84587. * @param zfar defines the far clip plane
  84588. * @param result defines the target matrix
  84589. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  84590. */
  84591. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  84592. /**
  84593. * Stores a left-handed perspective projection into a given matrix with depth reversed
  84594. * @param fov defines the horizontal field of view
  84595. * @param aspect defines the aspect ratio
  84596. * @param znear defines the near clip plane
  84597. * @param zfar not used as infinity is used as far clip
  84598. * @param result defines the target matrix
  84599. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  84600. */
  84601. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  84602. /**
  84603. * Creates a right-handed perspective projection matrix
  84604. * @param fov defines the horizontal field of view
  84605. * @param aspect defines the aspect ratio
  84606. * @param znear defines the near clip plane
  84607. * @param zfar defines the far clip plane
  84608. * @returns a new matrix as a right-handed perspective projection matrix
  84609. */
  84610. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  84611. /**
  84612. * Stores a right-handed perspective projection into a given matrix
  84613. * @param fov defines the horizontal field of view
  84614. * @param aspect defines the aspect ratio
  84615. * @param znear defines the near clip plane
  84616. * @param zfar defines the far clip plane
  84617. * @param result defines the target matrix
  84618. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  84619. */
  84620. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  84621. /**
  84622. * Stores a right-handed perspective projection into a given matrix
  84623. * @param fov defines the horizontal field of view
  84624. * @param aspect defines the aspect ratio
  84625. * @param znear defines the near clip plane
  84626. * @param zfar not used as infinity is used as far clip
  84627. * @param result defines the target matrix
  84628. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  84629. */
  84630. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  84631. /**
  84632. * Stores a perspective projection for WebVR info a given matrix
  84633. * @param fov defines the field of view
  84634. * @param znear defines the near clip plane
  84635. * @param zfar defines the far clip plane
  84636. * @param result defines the target matrix
  84637. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  84638. */
  84639. static PerspectiveFovWebVRToRef(fov: {
  84640. upDegrees: number;
  84641. downDegrees: number;
  84642. leftDegrees: number;
  84643. rightDegrees: number;
  84644. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  84645. /**
  84646. * Computes a complete transformation matrix
  84647. * @param viewport defines the viewport to use
  84648. * @param world defines the world matrix
  84649. * @param view defines the view matrix
  84650. * @param projection defines the projection matrix
  84651. * @param zmin defines the near clip plane
  84652. * @param zmax defines the far clip plane
  84653. * @returns the transformation matrix
  84654. */
  84655. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  84656. /**
  84657. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  84658. * @param matrix defines the matrix to use
  84659. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  84660. */
  84661. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  84662. /**
  84663. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  84664. * @param matrix defines the matrix to use
  84665. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  84666. */
  84667. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  84668. /**
  84669. * Compute the transpose of a given matrix
  84670. * @param matrix defines the matrix to transpose
  84671. * @returns the new matrix
  84672. */
  84673. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  84674. /**
  84675. * Compute the transpose of a matrix and store it in a target matrix
  84676. * @param matrix defines the matrix to transpose
  84677. * @param result defines the target matrix
  84678. */
  84679. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  84680. /**
  84681. * Computes a reflection matrix from a plane
  84682. * @param plane defines the reflection plane
  84683. * @returns a new matrix
  84684. */
  84685. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  84686. /**
  84687. * Computes a reflection matrix from a plane
  84688. * @param plane defines the reflection plane
  84689. * @param result defines the target matrix
  84690. */
  84691. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  84692. /**
  84693. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  84694. * @param xaxis defines the value of the 1st axis
  84695. * @param yaxis defines the value of the 2nd axis
  84696. * @param zaxis defines the value of the 3rd axis
  84697. * @param result defines the target matrix
  84698. */
  84699. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  84700. /**
  84701. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  84702. * @param quat defines the quaternion to use
  84703. * @param result defines the target matrix
  84704. */
  84705. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  84706. }
  84707. /**
  84708. * @hidden
  84709. */
  84710. export class TmpVectors {
  84711. static Vector2: Vector2[];
  84712. static Vector3: Vector3[];
  84713. static Vector4: Vector4[];
  84714. static Quaternion: Quaternion[];
  84715. static Matrix: Matrix[];
  84716. }
  84717. }
  84718. declare module BABYLON {
  84719. /**
  84720. * Defines potential orientation for back face culling
  84721. */
  84722. export enum Orientation {
  84723. /**
  84724. * Clockwise
  84725. */
  84726. CW = 0,
  84727. /** Counter clockwise */
  84728. CCW = 1
  84729. }
  84730. /** Class used to represent a Bezier curve */
  84731. export class BezierCurve {
  84732. /**
  84733. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  84734. * @param t defines the time
  84735. * @param x1 defines the left coordinate on X axis
  84736. * @param y1 defines the left coordinate on Y axis
  84737. * @param x2 defines the right coordinate on X axis
  84738. * @param y2 defines the right coordinate on Y axis
  84739. * @returns the interpolated value
  84740. */
  84741. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  84742. }
  84743. /**
  84744. * Defines angle representation
  84745. */
  84746. export class Angle {
  84747. private _radians;
  84748. /**
  84749. * Creates an Angle object of "radians" radians (float).
  84750. * @param radians the angle in radians
  84751. */
  84752. constructor(radians: number);
  84753. /**
  84754. * Get value in degrees
  84755. * @returns the Angle value in degrees (float)
  84756. */
  84757. degrees(): number;
  84758. /**
  84759. * Get value in radians
  84760. * @returns the Angle value in radians (float)
  84761. */
  84762. radians(): number;
  84763. /**
  84764. * Gets a new Angle object valued with the gradient angle, in radians, of the line joining two points
  84765. * @param a defines first point as the origin
  84766. * @param b defines point
  84767. * @returns a new Angle
  84768. */
  84769. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  84770. /**
  84771. * Gets a new Angle object from the given float in radians
  84772. * @param radians defines the angle value in radians
  84773. * @returns a new Angle
  84774. */
  84775. static FromRadians(radians: number): Angle;
  84776. /**
  84777. * Gets a new Angle object from the given float in degrees
  84778. * @param degrees defines the angle value in degrees
  84779. * @returns a new Angle
  84780. */
  84781. static FromDegrees(degrees: number): Angle;
  84782. }
  84783. /**
  84784. * This represents an arc in a 2d space.
  84785. */
  84786. export class Arc2 {
  84787. /** Defines the start point of the arc */
  84788. startPoint: Vector2;
  84789. /** Defines the mid point of the arc */
  84790. midPoint: Vector2;
  84791. /** Defines the end point of the arc */
  84792. endPoint: Vector2;
  84793. /**
  84794. * Defines the center point of the arc.
  84795. */
  84796. centerPoint: Vector2;
  84797. /**
  84798. * Defines the radius of the arc.
  84799. */
  84800. radius: number;
  84801. /**
  84802. * Defines the angle of the arc (from mid point to end point).
  84803. */
  84804. angle: Angle;
  84805. /**
  84806. * Defines the start angle of the arc (from start point to middle point).
  84807. */
  84808. startAngle: Angle;
  84809. /**
  84810. * Defines the orientation of the arc (clock wise/counter clock wise).
  84811. */
  84812. orientation: Orientation;
  84813. /**
  84814. * Creates an Arc object from the three given points : start, middle and end.
  84815. * @param startPoint Defines the start point of the arc
  84816. * @param midPoint Defines the midlle point of the arc
  84817. * @param endPoint Defines the end point of the arc
  84818. */
  84819. constructor(
  84820. /** Defines the start point of the arc */
  84821. startPoint: Vector2,
  84822. /** Defines the mid point of the arc */
  84823. midPoint: Vector2,
  84824. /** Defines the end point of the arc */
  84825. endPoint: Vector2);
  84826. }
  84827. /**
  84828. * Represents a 2D path made up of multiple 2D points
  84829. */
  84830. export class Path2 {
  84831. private _points;
  84832. private _length;
  84833. /**
  84834. * If the path start and end point are the same
  84835. */
  84836. closed: boolean;
  84837. /**
  84838. * Creates a Path2 object from the starting 2D coordinates x and y.
  84839. * @param x the starting points x value
  84840. * @param y the starting points y value
  84841. */
  84842. constructor(x: number, y: number);
  84843. /**
  84844. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  84845. * @param x the added points x value
  84846. * @param y the added points y value
  84847. * @returns the updated Path2.
  84848. */
  84849. addLineTo(x: number, y: number): Path2;
  84850. /**
  84851. * 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.
  84852. * @param midX middle point x value
  84853. * @param midY middle point y value
  84854. * @param endX end point x value
  84855. * @param endY end point y value
  84856. * @param numberOfSegments (default: 36)
  84857. * @returns the updated Path2.
  84858. */
  84859. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  84860. /**
  84861. * Closes the Path2.
  84862. * @returns the Path2.
  84863. */
  84864. close(): Path2;
  84865. /**
  84866. * Gets the sum of the distance between each sequential point in the path
  84867. * @returns the Path2 total length (float).
  84868. */
  84869. length(): number;
  84870. /**
  84871. * Gets the points which construct the path
  84872. * @returns the Path2 internal array of points.
  84873. */
  84874. getPoints(): Vector2[];
  84875. /**
  84876. * Retreives the point at the distance aways from the starting point
  84877. * @param normalizedLengthPosition the length along the path to retreive the point from
  84878. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  84879. */
  84880. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  84881. /**
  84882. * Creates a new path starting from an x and y position
  84883. * @param x starting x value
  84884. * @param y starting y value
  84885. * @returns a new Path2 starting at the coordinates (x, y).
  84886. */
  84887. static StartingAt(x: number, y: number): Path2;
  84888. }
  84889. /**
  84890. * Represents a 3D path made up of multiple 3D points
  84891. */
  84892. export class Path3D {
  84893. /**
  84894. * an array of Vector3, the curve axis of the Path3D
  84895. */
  84896. path: Vector3[];
  84897. private _curve;
  84898. private _distances;
  84899. private _tangents;
  84900. private _normals;
  84901. private _binormals;
  84902. private _raw;
  84903. private _alignTangentsWithPath;
  84904. private readonly _pointAtData;
  84905. /**
  84906. * new Path3D(path, normal, raw)
  84907. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  84908. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  84909. * @param path an array of Vector3, the curve axis of the Path3D
  84910. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  84911. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  84912. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  84913. */
  84914. constructor(
  84915. /**
  84916. * an array of Vector3, the curve axis of the Path3D
  84917. */
  84918. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  84919. /**
  84920. * Returns the Path3D array of successive Vector3 designing its curve.
  84921. * @returns the Path3D array of successive Vector3 designing its curve.
  84922. */
  84923. getCurve(): Vector3[];
  84924. /**
  84925. * Returns the Path3D array of successive Vector3 designing its curve.
  84926. * @returns the Path3D array of successive Vector3 designing its curve.
  84927. */
  84928. getPoints(): Vector3[];
  84929. /**
  84930. * @returns the computed length (float) of the path.
  84931. */
  84932. length(): number;
  84933. /**
  84934. * Returns an array populated with tangent vectors on each Path3D curve point.
  84935. * @returns an array populated with tangent vectors on each Path3D curve point.
  84936. */
  84937. getTangents(): Vector3[];
  84938. /**
  84939. * Returns an array populated with normal vectors on each Path3D curve point.
  84940. * @returns an array populated with normal vectors on each Path3D curve point.
  84941. */
  84942. getNormals(): Vector3[];
  84943. /**
  84944. * Returns an array populated with binormal vectors on each Path3D curve point.
  84945. * @returns an array populated with binormal vectors on each Path3D curve point.
  84946. */
  84947. getBinormals(): Vector3[];
  84948. /**
  84949. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  84950. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  84951. */
  84952. getDistances(): number[];
  84953. /**
  84954. * Returns an interpolated point along this path
  84955. * @param position the position of the point along this path, from 0.0 to 1.0
  84956. * @returns a new Vector3 as the point
  84957. */
  84958. getPointAt(position: number): Vector3;
  84959. /**
  84960. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  84961. * @param position the position of the point along this path, from 0.0 to 1.0
  84962. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  84963. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  84964. */
  84965. getTangentAt(position: number, interpolated?: boolean): Vector3;
  84966. /**
  84967. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  84968. * @param position the position of the point along this path, from 0.0 to 1.0
  84969. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  84970. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  84971. */
  84972. getNormalAt(position: number, interpolated?: boolean): Vector3;
  84973. /**
  84974. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  84975. * @param position the position of the point along this path, from 0.0 to 1.0
  84976. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  84977. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  84978. */
  84979. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  84980. /**
  84981. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  84982. * @param position the position of the point along this path, from 0.0 to 1.0
  84983. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  84984. */
  84985. getDistanceAt(position: number): number;
  84986. /**
  84987. * Returns the array index of the previous point of an interpolated point along this path
  84988. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  84989. * @returns the array index
  84990. */
  84991. getPreviousPointIndexAt(position: number): number;
  84992. /**
  84993. * 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)
  84994. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  84995. * @returns the sub position
  84996. */
  84997. getSubPositionAt(position: number): number;
  84998. /**
  84999. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  85000. * @param target the vector of which to get the closest position to
  85001. * @returns the position of the closest virtual point on this path to the target vector
  85002. */
  85003. getClosestPositionTo(target: Vector3): number;
  85004. /**
  85005. * Returns a sub path (slice) of this path
  85006. * @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
  85007. * @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
  85008. * @returns a sub path (slice) of this path
  85009. */
  85010. slice(start?: number, end?: number): Path3D;
  85011. /**
  85012. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  85013. * @param path path which all values are copied into the curves points
  85014. * @param firstNormal which should be projected onto the curve
  85015. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  85016. * @returns the same object updated.
  85017. */
  85018. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  85019. private _compute;
  85020. private _getFirstNonNullVector;
  85021. private _getLastNonNullVector;
  85022. private _normalVector;
  85023. /**
  85024. * Updates the point at data for an interpolated point along this curve
  85025. * @param position the position of the point along this curve, from 0.0 to 1.0
  85026. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  85027. * @returns the (updated) point at data
  85028. */
  85029. private _updatePointAtData;
  85030. /**
  85031. * Updates the point at data from the specified parameters
  85032. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  85033. * @param point the interpolated point
  85034. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  85035. */
  85036. private _setPointAtData;
  85037. /**
  85038. * Updates the point at interpolation matrix for the tangents, normals and binormals
  85039. */
  85040. private _updateInterpolationMatrix;
  85041. }
  85042. /**
  85043. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  85044. * A Curve3 is designed from a series of successive Vector3.
  85045. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  85046. */
  85047. export class Curve3 {
  85048. private _points;
  85049. private _length;
  85050. /**
  85051. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  85052. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  85053. * @param v1 (Vector3) the control point
  85054. * @param v2 (Vector3) the end point of the Quadratic Bezier
  85055. * @param nbPoints (integer) the wanted number of points in the curve
  85056. * @returns the created Curve3
  85057. */
  85058. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  85059. /**
  85060. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  85061. * @param v0 (Vector3) the origin point of the Cubic Bezier
  85062. * @param v1 (Vector3) the first control point
  85063. * @param v2 (Vector3) the second control point
  85064. * @param v3 (Vector3) the end point of the Cubic Bezier
  85065. * @param nbPoints (integer) the wanted number of points in the curve
  85066. * @returns the created Curve3
  85067. */
  85068. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  85069. /**
  85070. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  85071. * @param p1 (Vector3) the origin point of the Hermite Spline
  85072. * @param t1 (Vector3) the tangent vector at the origin point
  85073. * @param p2 (Vector3) the end point of the Hermite Spline
  85074. * @param t2 (Vector3) the tangent vector at the end point
  85075. * @param nbPoints (integer) the wanted number of points in the curve
  85076. * @returns the created Curve3
  85077. */
  85078. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  85079. /**
  85080. * Returns a Curve3 object along a CatmullRom Spline curve :
  85081. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  85082. * @param nbPoints (integer) the wanted number of points between each curve control points
  85083. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  85084. * @returns the created Curve3
  85085. */
  85086. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  85087. /**
  85088. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  85089. * A Curve3 is designed from a series of successive Vector3.
  85090. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  85091. * @param points points which make up the curve
  85092. */
  85093. constructor(points: Vector3[]);
  85094. /**
  85095. * @returns the Curve3 stored array of successive Vector3
  85096. */
  85097. getPoints(): Vector3[];
  85098. /**
  85099. * @returns the computed length (float) of the curve.
  85100. */
  85101. length(): number;
  85102. /**
  85103. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  85104. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  85105. * curveA and curveB keep unchanged.
  85106. * @param curve the curve to continue from this curve
  85107. * @returns the newly constructed curve
  85108. */
  85109. continue(curve: DeepImmutable<Curve3>): Curve3;
  85110. private _computeLength;
  85111. }
  85112. }
  85113. declare module BABYLON {
  85114. /**
  85115. * This represents the main contract an easing function should follow.
  85116. * Easing functions are used throughout the animation system.
  85117. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  85118. */
  85119. export interface IEasingFunction {
  85120. /**
  85121. * Given an input gradient between 0 and 1, this returns the corrseponding value
  85122. * of the easing function.
  85123. * The link below provides some of the most common examples of easing functions.
  85124. * @see https://easings.net/
  85125. * @param gradient Defines the value between 0 and 1 we want the easing value for
  85126. * @returns the corresponding value on the curve defined by the easing function
  85127. */
  85128. ease(gradient: number): number;
  85129. }
  85130. /**
  85131. * Base class used for every default easing function.
  85132. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  85133. */
  85134. export class EasingFunction implements IEasingFunction {
  85135. /**
  85136. * Interpolation follows the mathematical formula associated with the easing function.
  85137. */
  85138. static readonly EASINGMODE_EASEIN: number;
  85139. /**
  85140. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  85141. */
  85142. static readonly EASINGMODE_EASEOUT: number;
  85143. /**
  85144. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  85145. */
  85146. static readonly EASINGMODE_EASEINOUT: number;
  85147. private _easingMode;
  85148. /**
  85149. * Sets the easing mode of the current function.
  85150. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  85151. */
  85152. setEasingMode(easingMode: number): void;
  85153. /**
  85154. * Gets the current easing mode.
  85155. * @returns the easing mode
  85156. */
  85157. getEasingMode(): number;
  85158. /**
  85159. * @hidden
  85160. */
  85161. easeInCore(gradient: number): number;
  85162. /**
  85163. * Given an input gradient between 0 and 1, this returns the corresponding value
  85164. * of the easing function.
  85165. * @param gradient Defines the value between 0 and 1 we want the easing value for
  85166. * @returns the corresponding value on the curve defined by the easing function
  85167. */
  85168. ease(gradient: number): number;
  85169. }
  85170. /**
  85171. * Easing function with a circle shape (see link below).
  85172. * @see https://easings.net/#easeInCirc
  85173. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  85174. */
  85175. export class CircleEase extends EasingFunction implements IEasingFunction {
  85176. /** @hidden */
  85177. easeInCore(gradient: number): number;
  85178. }
  85179. /**
  85180. * Easing function with a ease back shape (see link below).
  85181. * @see https://easings.net/#easeInBack
  85182. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  85183. */
  85184. export class BackEase extends EasingFunction implements IEasingFunction {
  85185. /** Defines the amplitude of the function */
  85186. amplitude: number;
  85187. /**
  85188. * Instantiates a back ease easing
  85189. * @see https://easings.net/#easeInBack
  85190. * @param amplitude Defines the amplitude of the function
  85191. */
  85192. constructor(
  85193. /** Defines the amplitude of the function */
  85194. amplitude?: number);
  85195. /** @hidden */
  85196. easeInCore(gradient: number): number;
  85197. }
  85198. /**
  85199. * Easing function with a bouncing shape (see link below).
  85200. * @see https://easings.net/#easeInBounce
  85201. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  85202. */
  85203. export class BounceEase extends EasingFunction implements IEasingFunction {
  85204. /** Defines the number of bounces */
  85205. bounces: number;
  85206. /** Defines the amplitude of the bounce */
  85207. bounciness: number;
  85208. /**
  85209. * Instantiates a bounce easing
  85210. * @see https://easings.net/#easeInBounce
  85211. * @param bounces Defines the number of bounces
  85212. * @param bounciness Defines the amplitude of the bounce
  85213. */
  85214. constructor(
  85215. /** Defines the number of bounces */
  85216. bounces?: number,
  85217. /** Defines the amplitude of the bounce */
  85218. bounciness?: number);
  85219. /** @hidden */
  85220. easeInCore(gradient: number): number;
  85221. }
  85222. /**
  85223. * Easing function with a power of 3 shape (see link below).
  85224. * @see https://easings.net/#easeInCubic
  85225. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  85226. */
  85227. export class CubicEase extends EasingFunction implements IEasingFunction {
  85228. /** @hidden */
  85229. easeInCore(gradient: number): number;
  85230. }
  85231. /**
  85232. * Easing function with an elastic shape (see link below).
  85233. * @see https://easings.net/#easeInElastic
  85234. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  85235. */
  85236. export class ElasticEase extends EasingFunction implements IEasingFunction {
  85237. /** Defines the number of oscillations*/
  85238. oscillations: number;
  85239. /** Defines the amplitude of the oscillations*/
  85240. springiness: number;
  85241. /**
  85242. * Instantiates an elastic easing function
  85243. * @see https://easings.net/#easeInElastic
  85244. * @param oscillations Defines the number of oscillations
  85245. * @param springiness Defines the amplitude of the oscillations
  85246. */
  85247. constructor(
  85248. /** Defines the number of oscillations*/
  85249. oscillations?: number,
  85250. /** Defines the amplitude of the oscillations*/
  85251. springiness?: number);
  85252. /** @hidden */
  85253. easeInCore(gradient: number): number;
  85254. }
  85255. /**
  85256. * Easing function with an exponential shape (see link below).
  85257. * @see https://easings.net/#easeInExpo
  85258. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  85259. */
  85260. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  85261. /** Defines the exponent of the function */
  85262. exponent: number;
  85263. /**
  85264. * Instantiates an exponential easing function
  85265. * @see https://easings.net/#easeInExpo
  85266. * @param exponent Defines the exponent of the function
  85267. */
  85268. constructor(
  85269. /** Defines the exponent of the function */
  85270. exponent?: number);
  85271. /** @hidden */
  85272. easeInCore(gradient: number): number;
  85273. }
  85274. /**
  85275. * Easing function with a power shape (see link below).
  85276. * @see https://easings.net/#easeInQuad
  85277. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  85278. */
  85279. export class PowerEase extends EasingFunction implements IEasingFunction {
  85280. /** Defines the power of the function */
  85281. power: number;
  85282. /**
  85283. * Instantiates an power base easing function
  85284. * @see https://easings.net/#easeInQuad
  85285. * @param power Defines the power of the function
  85286. */
  85287. constructor(
  85288. /** Defines the power of the function */
  85289. power?: number);
  85290. /** @hidden */
  85291. easeInCore(gradient: number): number;
  85292. }
  85293. /**
  85294. * Easing function with a power of 2 shape (see link below).
  85295. * @see https://easings.net/#easeInQuad
  85296. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  85297. */
  85298. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  85299. /** @hidden */
  85300. easeInCore(gradient: number): number;
  85301. }
  85302. /**
  85303. * Easing function with a power of 4 shape (see link below).
  85304. * @see https://easings.net/#easeInQuart
  85305. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  85306. */
  85307. export class QuarticEase extends EasingFunction implements IEasingFunction {
  85308. /** @hidden */
  85309. easeInCore(gradient: number): number;
  85310. }
  85311. /**
  85312. * Easing function with a power of 5 shape (see link below).
  85313. * @see https://easings.net/#easeInQuint
  85314. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  85315. */
  85316. export class QuinticEase extends EasingFunction implements IEasingFunction {
  85317. /** @hidden */
  85318. easeInCore(gradient: number): number;
  85319. }
  85320. /**
  85321. * Easing function with a sin shape (see link below).
  85322. * @see https://easings.net/#easeInSine
  85323. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  85324. */
  85325. export class SineEase extends EasingFunction implements IEasingFunction {
  85326. /** @hidden */
  85327. easeInCore(gradient: number): number;
  85328. }
  85329. /**
  85330. * Easing function with a bezier shape (see link below).
  85331. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  85332. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  85333. */
  85334. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  85335. /** Defines the x component of the start tangent in the bezier curve */
  85336. x1: number;
  85337. /** Defines the y component of the start tangent in the bezier curve */
  85338. y1: number;
  85339. /** Defines the x component of the end tangent in the bezier curve */
  85340. x2: number;
  85341. /** Defines the y component of the end tangent in the bezier curve */
  85342. y2: number;
  85343. /**
  85344. * Instantiates a bezier function
  85345. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  85346. * @param x1 Defines the x component of the start tangent in the bezier curve
  85347. * @param y1 Defines the y component of the start tangent in the bezier curve
  85348. * @param x2 Defines the x component of the end tangent in the bezier curve
  85349. * @param y2 Defines the y component of the end tangent in the bezier curve
  85350. */
  85351. constructor(
  85352. /** Defines the x component of the start tangent in the bezier curve */
  85353. x1?: number,
  85354. /** Defines the y component of the start tangent in the bezier curve */
  85355. y1?: number,
  85356. /** Defines the x component of the end tangent in the bezier curve */
  85357. x2?: number,
  85358. /** Defines the y component of the end tangent in the bezier curve */
  85359. y2?: number);
  85360. /** @hidden */
  85361. easeInCore(gradient: number): number;
  85362. }
  85363. }
  85364. declare module BABYLON {
  85365. /**
  85366. * Class used to hold a RBG color
  85367. */
  85368. export class Color3 {
  85369. /**
  85370. * Defines the red component (between 0 and 1, default is 0)
  85371. */
  85372. r: number;
  85373. /**
  85374. * Defines the green component (between 0 and 1, default is 0)
  85375. */
  85376. g: number;
  85377. /**
  85378. * Defines the blue component (between 0 and 1, default is 0)
  85379. */
  85380. b: number;
  85381. /**
  85382. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  85383. * @param r defines the red component (between 0 and 1, default is 0)
  85384. * @param g defines the green component (between 0 and 1, default is 0)
  85385. * @param b defines the blue component (between 0 and 1, default is 0)
  85386. */
  85387. constructor(
  85388. /**
  85389. * Defines the red component (between 0 and 1, default is 0)
  85390. */
  85391. r?: number,
  85392. /**
  85393. * Defines the green component (between 0 and 1, default is 0)
  85394. */
  85395. g?: number,
  85396. /**
  85397. * Defines the blue component (between 0 and 1, default is 0)
  85398. */
  85399. b?: number);
  85400. /**
  85401. * Creates a string with the Color3 current values
  85402. * @returns the string representation of the Color3 object
  85403. */
  85404. toString(): string;
  85405. /**
  85406. * Returns the string "Color3"
  85407. * @returns "Color3"
  85408. */
  85409. getClassName(): string;
  85410. /**
  85411. * Compute the Color3 hash code
  85412. * @returns an unique number that can be used to hash Color3 objects
  85413. */
  85414. getHashCode(): number;
  85415. /**
  85416. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  85417. * @param array defines the array where to store the r,g,b components
  85418. * @param index defines an optional index in the target array to define where to start storing values
  85419. * @returns the current Color3 object
  85420. */
  85421. toArray(array: FloatArray, index?: number): Color3;
  85422. /**
  85423. * Update the current color with values stored in an array from the starting index of the given array
  85424. * @param array defines the source array
  85425. * @param offset defines an offset in the source array
  85426. * @returns the current Color3 object
  85427. */
  85428. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  85429. /**
  85430. * Returns a new Color4 object from the current Color3 and the given alpha
  85431. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  85432. * @returns a new Color4 object
  85433. */
  85434. toColor4(alpha?: number): Color4;
  85435. /**
  85436. * Returns a new array populated with 3 numeric elements : red, green and blue values
  85437. * @returns the new array
  85438. */
  85439. asArray(): number[];
  85440. /**
  85441. * Returns the luminance value
  85442. * @returns a float value
  85443. */
  85444. toLuminance(): number;
  85445. /**
  85446. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  85447. * @param otherColor defines the second operand
  85448. * @returns the new Color3 object
  85449. */
  85450. multiply(otherColor: DeepImmutable<Color3>): Color3;
  85451. /**
  85452. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  85453. * @param otherColor defines the second operand
  85454. * @param result defines the Color3 object where to store the result
  85455. * @returns the current Color3
  85456. */
  85457. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  85458. /**
  85459. * Determines equality between Color3 objects
  85460. * @param otherColor defines the second operand
  85461. * @returns true if the rgb values are equal to the given ones
  85462. */
  85463. equals(otherColor: DeepImmutable<Color3>): boolean;
  85464. /**
  85465. * Determines equality between the current Color3 object and a set of r,b,g values
  85466. * @param r defines the red component to check
  85467. * @param g defines the green component to check
  85468. * @param b defines the blue component to check
  85469. * @returns true if the rgb values are equal to the given ones
  85470. */
  85471. equalsFloats(r: number, g: number, b: number): boolean;
  85472. /**
  85473. * Multiplies in place each rgb value by scale
  85474. * @param scale defines the scaling factor
  85475. * @returns the updated Color3
  85476. */
  85477. scale(scale: number): Color3;
  85478. /**
  85479. * Multiplies the rgb values by scale and stores the result into "result"
  85480. * @param scale defines the scaling factor
  85481. * @param result defines the Color3 object where to store the result
  85482. * @returns the unmodified current Color3
  85483. */
  85484. scaleToRef(scale: number, result: Color3): Color3;
  85485. /**
  85486. * Scale the current Color3 values by a factor and add the result to a given Color3
  85487. * @param scale defines the scale factor
  85488. * @param result defines color to store the result into
  85489. * @returns the unmodified current Color3
  85490. */
  85491. scaleAndAddToRef(scale: number, result: Color3): Color3;
  85492. /**
  85493. * Clamps the rgb values by the min and max values and stores the result into "result"
  85494. * @param min defines minimum clamping value (default is 0)
  85495. * @param max defines maximum clamping value (default is 1)
  85496. * @param result defines color to store the result into
  85497. * @returns the original Color3
  85498. */
  85499. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  85500. /**
  85501. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  85502. * @param otherColor defines the second operand
  85503. * @returns the new Color3
  85504. */
  85505. add(otherColor: DeepImmutable<Color3>): Color3;
  85506. /**
  85507. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  85508. * @param otherColor defines the second operand
  85509. * @param result defines Color3 object to store the result into
  85510. * @returns the unmodified current Color3
  85511. */
  85512. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  85513. /**
  85514. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  85515. * @param otherColor defines the second operand
  85516. * @returns the new Color3
  85517. */
  85518. subtract(otherColor: DeepImmutable<Color3>): Color3;
  85519. /**
  85520. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  85521. * @param otherColor defines the second operand
  85522. * @param result defines Color3 object to store the result into
  85523. * @returns the unmodified current Color3
  85524. */
  85525. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  85526. /**
  85527. * Copy the current object
  85528. * @returns a new Color3 copied the current one
  85529. */
  85530. clone(): Color3;
  85531. /**
  85532. * Copies the rgb values from the source in the current Color3
  85533. * @param source defines the source Color3 object
  85534. * @returns the updated Color3 object
  85535. */
  85536. copyFrom(source: DeepImmutable<Color3>): Color3;
  85537. /**
  85538. * Updates the Color3 rgb values from the given floats
  85539. * @param r defines the red component to read from
  85540. * @param g defines the green component to read from
  85541. * @param b defines the blue component to read from
  85542. * @returns the current Color3 object
  85543. */
  85544. copyFromFloats(r: number, g: number, b: number): Color3;
  85545. /**
  85546. * Updates the Color3 rgb values from the given floats
  85547. * @param r defines the red component to read from
  85548. * @param g defines the green component to read from
  85549. * @param b defines the blue component to read from
  85550. * @returns the current Color3 object
  85551. */
  85552. set(r: number, g: number, b: number): Color3;
  85553. /**
  85554. * Compute the Color3 hexadecimal code as a string
  85555. * @returns a string containing the hexadecimal representation of the Color3 object
  85556. */
  85557. toHexString(): string;
  85558. /**
  85559. * Computes a new Color3 converted from the current one to linear space
  85560. * @returns a new Color3 object
  85561. */
  85562. toLinearSpace(): Color3;
  85563. /**
  85564. * Converts current color in rgb space to HSV values
  85565. * @returns a new color3 representing the HSV values
  85566. */
  85567. toHSV(): Color3;
  85568. /**
  85569. * Converts current color in rgb space to HSV values
  85570. * @param result defines the Color3 where to store the HSV values
  85571. */
  85572. toHSVToRef(result: Color3): void;
  85573. /**
  85574. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  85575. * @param convertedColor defines the Color3 object where to store the linear space version
  85576. * @returns the unmodified Color3
  85577. */
  85578. toLinearSpaceToRef(convertedColor: Color3): Color3;
  85579. /**
  85580. * Computes a new Color3 converted from the current one to gamma space
  85581. * @returns a new Color3 object
  85582. */
  85583. toGammaSpace(): Color3;
  85584. /**
  85585. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  85586. * @param convertedColor defines the Color3 object where to store the gamma space version
  85587. * @returns the unmodified Color3
  85588. */
  85589. toGammaSpaceToRef(convertedColor: Color3): Color3;
  85590. private static _BlackReadOnly;
  85591. /**
  85592. * Convert Hue, saturation and value to a Color3 (RGB)
  85593. * @param hue defines the hue
  85594. * @param saturation defines the saturation
  85595. * @param value defines the value
  85596. * @param result defines the Color3 where to store the RGB values
  85597. */
  85598. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  85599. /**
  85600. * Creates a new Color3 from the string containing valid hexadecimal values
  85601. * @param hex defines a string containing valid hexadecimal values
  85602. * @returns a new Color3 object
  85603. */
  85604. static FromHexString(hex: string): Color3;
  85605. /**
  85606. * Creates a new Color3 from the starting index of the given array
  85607. * @param array defines the source array
  85608. * @param offset defines an offset in the source array
  85609. * @returns a new Color3 object
  85610. */
  85611. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  85612. /**
  85613. * Creates a new Color3 from the starting index element of the given array
  85614. * @param array defines the source array to read from
  85615. * @param offset defines the offset in the source array
  85616. * @param result defines the target Color3 object
  85617. */
  85618. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color3): void;
  85619. /**
  85620. * Creates a new Color3 from integer values (< 256)
  85621. * @param r defines the red component to read from (value between 0 and 255)
  85622. * @param g defines the green component to read from (value between 0 and 255)
  85623. * @param b defines the blue component to read from (value between 0 and 255)
  85624. * @returns a new Color3 object
  85625. */
  85626. static FromInts(r: number, g: number, b: number): Color3;
  85627. /**
  85628. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  85629. * @param start defines the start Color3 value
  85630. * @param end defines the end Color3 value
  85631. * @param amount defines the gradient value between start and end
  85632. * @returns a new Color3 object
  85633. */
  85634. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  85635. /**
  85636. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  85637. * @param left defines the start value
  85638. * @param right defines the end value
  85639. * @param amount defines the gradient factor
  85640. * @param result defines the Color3 object where to store the result
  85641. */
  85642. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  85643. /**
  85644. * Returns a Color3 value containing a red color
  85645. * @returns a new Color3 object
  85646. */
  85647. static Red(): Color3;
  85648. /**
  85649. * Returns a Color3 value containing a green color
  85650. * @returns a new Color3 object
  85651. */
  85652. static Green(): Color3;
  85653. /**
  85654. * Returns a Color3 value containing a blue color
  85655. * @returns a new Color3 object
  85656. */
  85657. static Blue(): Color3;
  85658. /**
  85659. * Returns a Color3 value containing a black color
  85660. * @returns a new Color3 object
  85661. */
  85662. static Black(): Color3;
  85663. /**
  85664. * Gets a Color3 value containing a black color that must not be updated
  85665. */
  85666. static get BlackReadOnly(): DeepImmutable<Color3>;
  85667. /**
  85668. * Returns a Color3 value containing a white color
  85669. * @returns a new Color3 object
  85670. */
  85671. static White(): Color3;
  85672. /**
  85673. * Returns a Color3 value containing a purple color
  85674. * @returns a new Color3 object
  85675. */
  85676. static Purple(): Color3;
  85677. /**
  85678. * Returns a Color3 value containing a magenta color
  85679. * @returns a new Color3 object
  85680. */
  85681. static Magenta(): Color3;
  85682. /**
  85683. * Returns a Color3 value containing a yellow color
  85684. * @returns a new Color3 object
  85685. */
  85686. static Yellow(): Color3;
  85687. /**
  85688. * Returns a Color3 value containing a gray color
  85689. * @returns a new Color3 object
  85690. */
  85691. static Gray(): Color3;
  85692. /**
  85693. * Returns a Color3 value containing a teal color
  85694. * @returns a new Color3 object
  85695. */
  85696. static Teal(): Color3;
  85697. /**
  85698. * Returns a Color3 value containing a random color
  85699. * @returns a new Color3 object
  85700. */
  85701. static Random(): Color3;
  85702. }
  85703. /**
  85704. * Class used to hold a RBGA color
  85705. */
  85706. export class Color4 {
  85707. /**
  85708. * Defines the red component (between 0 and 1, default is 0)
  85709. */
  85710. r: number;
  85711. /**
  85712. * Defines the green component (between 0 and 1, default is 0)
  85713. */
  85714. g: number;
  85715. /**
  85716. * Defines the blue component (between 0 and 1, default is 0)
  85717. */
  85718. b: number;
  85719. /**
  85720. * Defines the alpha component (between 0 and 1, default is 1)
  85721. */
  85722. a: number;
  85723. /**
  85724. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  85725. * @param r defines the red component (between 0 and 1, default is 0)
  85726. * @param g defines the green component (between 0 and 1, default is 0)
  85727. * @param b defines the blue component (between 0 and 1, default is 0)
  85728. * @param a defines the alpha component (between 0 and 1, default is 1)
  85729. */
  85730. constructor(
  85731. /**
  85732. * Defines the red component (between 0 and 1, default is 0)
  85733. */
  85734. r?: number,
  85735. /**
  85736. * Defines the green component (between 0 and 1, default is 0)
  85737. */
  85738. g?: number,
  85739. /**
  85740. * Defines the blue component (between 0 and 1, default is 0)
  85741. */
  85742. b?: number,
  85743. /**
  85744. * Defines the alpha component (between 0 and 1, default is 1)
  85745. */
  85746. a?: number);
  85747. /**
  85748. * Adds in place the given Color4 values to the current Color4 object
  85749. * @param right defines the second operand
  85750. * @returns the current updated Color4 object
  85751. */
  85752. addInPlace(right: DeepImmutable<Color4>): Color4;
  85753. /**
  85754. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  85755. * @returns the new array
  85756. */
  85757. asArray(): number[];
  85758. /**
  85759. * Stores from the starting index in the given array the Color4 successive values
  85760. * @param array defines the array where to store the r,g,b components
  85761. * @param index defines an optional index in the target array to define where to start storing values
  85762. * @returns the current Color4 object
  85763. */
  85764. toArray(array: number[], index?: number): Color4;
  85765. /**
  85766. * Update the current color with values stored in an array from the starting index of the given array
  85767. * @param array defines the source array
  85768. * @param offset defines an offset in the source array
  85769. * @returns the current Color4 object
  85770. */
  85771. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  85772. /**
  85773. * Determines equality between Color4 objects
  85774. * @param otherColor defines the second operand
  85775. * @returns true if the rgba values are equal to the given ones
  85776. */
  85777. equals(otherColor: DeepImmutable<Color4>): boolean;
  85778. /**
  85779. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  85780. * @param right defines the second operand
  85781. * @returns a new Color4 object
  85782. */
  85783. add(right: DeepImmutable<Color4>): Color4;
  85784. /**
  85785. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  85786. * @param right defines the second operand
  85787. * @returns a new Color4 object
  85788. */
  85789. subtract(right: DeepImmutable<Color4>): Color4;
  85790. /**
  85791. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  85792. * @param right defines the second operand
  85793. * @param result defines the Color4 object where to store the result
  85794. * @returns the current Color4 object
  85795. */
  85796. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  85797. /**
  85798. * Creates a new Color4 with the current Color4 values multiplied by scale
  85799. * @param scale defines the scaling factor to apply
  85800. * @returns a new Color4 object
  85801. */
  85802. scale(scale: number): Color4;
  85803. /**
  85804. * Multiplies the current Color4 values by scale and stores the result in "result"
  85805. * @param scale defines the scaling factor to apply
  85806. * @param result defines the Color4 object where to store the result
  85807. * @returns the current unmodified Color4
  85808. */
  85809. scaleToRef(scale: number, result: Color4): Color4;
  85810. /**
  85811. * Scale the current Color4 values by a factor and add the result to a given Color4
  85812. * @param scale defines the scale factor
  85813. * @param result defines the Color4 object where to store the result
  85814. * @returns the unmodified current Color4
  85815. */
  85816. scaleAndAddToRef(scale: number, result: Color4): Color4;
  85817. /**
  85818. * Clamps the rgb values by the min and max values and stores the result into "result"
  85819. * @param min defines minimum clamping value (default is 0)
  85820. * @param max defines maximum clamping value (default is 1)
  85821. * @param result defines color to store the result into.
  85822. * @returns the cuurent Color4
  85823. */
  85824. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  85825. /**
  85826. * Multipy an Color4 value by another and return a new Color4 object
  85827. * @param color defines the Color4 value to multiply by
  85828. * @returns a new Color4 object
  85829. */
  85830. multiply(color: Color4): Color4;
  85831. /**
  85832. * Multipy a Color4 value by another and push the result in a reference value
  85833. * @param color defines the Color4 value to multiply by
  85834. * @param result defines the Color4 to fill the result in
  85835. * @returns the result Color4
  85836. */
  85837. multiplyToRef(color: Color4, result: Color4): Color4;
  85838. /**
  85839. * Creates a string with the Color4 current values
  85840. * @returns the string representation of the Color4 object
  85841. */
  85842. toString(): string;
  85843. /**
  85844. * Returns the string "Color4"
  85845. * @returns "Color4"
  85846. */
  85847. getClassName(): string;
  85848. /**
  85849. * Compute the Color4 hash code
  85850. * @returns an unique number that can be used to hash Color4 objects
  85851. */
  85852. getHashCode(): number;
  85853. /**
  85854. * Creates a new Color4 copied from the current one
  85855. * @returns a new Color4 object
  85856. */
  85857. clone(): Color4;
  85858. /**
  85859. * Copies the given Color4 values into the current one
  85860. * @param source defines the source Color4 object
  85861. * @returns the current updated Color4 object
  85862. */
  85863. copyFrom(source: Color4): Color4;
  85864. /**
  85865. * Copies the given float values into the current one
  85866. * @param r defines the red component to read from
  85867. * @param g defines the green component to read from
  85868. * @param b defines the blue component to read from
  85869. * @param a defines the alpha component to read from
  85870. * @returns the current updated Color4 object
  85871. */
  85872. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  85873. /**
  85874. * Copies the given float values into the current one
  85875. * @param r defines the red component to read from
  85876. * @param g defines the green component to read from
  85877. * @param b defines the blue component to read from
  85878. * @param a defines the alpha component to read from
  85879. * @returns the current updated Color4 object
  85880. */
  85881. set(r: number, g: number, b: number, a: number): Color4;
  85882. /**
  85883. * Compute the Color4 hexadecimal code as a string
  85884. * @param returnAsColor3 defines if the string should only contains RGB values (off by default)
  85885. * @returns a string containing the hexadecimal representation of the Color4 object
  85886. */
  85887. toHexString(returnAsColor3?: boolean): string;
  85888. /**
  85889. * Computes a new Color4 converted from the current one to linear space
  85890. * @returns a new Color4 object
  85891. */
  85892. toLinearSpace(): Color4;
  85893. /**
  85894. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  85895. * @param convertedColor defines the Color4 object where to store the linear space version
  85896. * @returns the unmodified Color4
  85897. */
  85898. toLinearSpaceToRef(convertedColor: Color4): Color4;
  85899. /**
  85900. * Computes a new Color4 converted from the current one to gamma space
  85901. * @returns a new Color4 object
  85902. */
  85903. toGammaSpace(): Color4;
  85904. /**
  85905. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  85906. * @param convertedColor defines the Color4 object where to store the gamma space version
  85907. * @returns the unmodified Color4
  85908. */
  85909. toGammaSpaceToRef(convertedColor: Color4): Color4;
  85910. /**
  85911. * Creates a new Color4 from the string containing valid hexadecimal values
  85912. * @param hex defines a string containing valid hexadecimal values
  85913. * @returns a new Color4 object
  85914. */
  85915. static FromHexString(hex: string): Color4;
  85916. /**
  85917. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  85918. * @param left defines the start value
  85919. * @param right defines the end value
  85920. * @param amount defines the gradient factor
  85921. * @returns a new Color4 object
  85922. */
  85923. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  85924. /**
  85925. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  85926. * @param left defines the start value
  85927. * @param right defines the end value
  85928. * @param amount defines the gradient factor
  85929. * @param result defines the Color4 object where to store data
  85930. */
  85931. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  85932. /**
  85933. * Creates a new Color4 from a Color3 and an alpha value
  85934. * @param color3 defines the source Color3 to read from
  85935. * @param alpha defines the alpha component (1.0 by default)
  85936. * @returns a new Color4 object
  85937. */
  85938. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  85939. /**
  85940. * Creates a new Color4 from the starting index element of the given array
  85941. * @param array defines the source array to read from
  85942. * @param offset defines the offset in the source array
  85943. * @returns a new Color4 object
  85944. */
  85945. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  85946. /**
  85947. * Creates a new Color4 from the starting index element of the given array
  85948. * @param array defines the source array to read from
  85949. * @param offset defines the offset in the source array
  85950. * @param result defines the target Color4 object
  85951. */
  85952. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color4): void;
  85953. /**
  85954. * Creates a new Color3 from integer values (< 256)
  85955. * @param r defines the red component to read from (value between 0 and 255)
  85956. * @param g defines the green component to read from (value between 0 and 255)
  85957. * @param b defines the blue component to read from (value between 0 and 255)
  85958. * @param a defines the alpha component to read from (value between 0 and 255)
  85959. * @returns a new Color3 object
  85960. */
  85961. static FromInts(r: number, g: number, b: number, a: number): Color4;
  85962. /**
  85963. * Check the content of a given array and convert it to an array containing RGBA data
  85964. * If the original array was already containing count * 4 values then it is returned directly
  85965. * @param colors defines the array to check
  85966. * @param count defines the number of RGBA data to expect
  85967. * @returns an array containing count * 4 values (RGBA)
  85968. */
  85969. static CheckColors4(colors: number[], count: number): number[];
  85970. }
  85971. /**
  85972. * @hidden
  85973. */
  85974. export class TmpColors {
  85975. static Color3: Color3[];
  85976. static Color4: Color4[];
  85977. }
  85978. }
  85979. declare module BABYLON {
  85980. /**
  85981. * Defines an interface which represents an animation key frame
  85982. */
  85983. export interface IAnimationKey {
  85984. /**
  85985. * Frame of the key frame
  85986. */
  85987. frame: number;
  85988. /**
  85989. * Value at the specifies key frame
  85990. */
  85991. value: any;
  85992. /**
  85993. * The input tangent for the cubic hermite spline
  85994. */
  85995. inTangent?: any;
  85996. /**
  85997. * The output tangent for the cubic hermite spline
  85998. */
  85999. outTangent?: any;
  86000. /**
  86001. * The animation interpolation type
  86002. */
  86003. interpolation?: AnimationKeyInterpolation;
  86004. }
  86005. /**
  86006. * Enum for the animation key frame interpolation type
  86007. */
  86008. export enum AnimationKeyInterpolation {
  86009. /**
  86010. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  86011. */
  86012. STEP = 1
  86013. }
  86014. }
  86015. declare module BABYLON {
  86016. /**
  86017. * Represents the range of an animation
  86018. */
  86019. export class AnimationRange {
  86020. /**The name of the animation range**/
  86021. name: string;
  86022. /**The starting frame of the animation */
  86023. from: number;
  86024. /**The ending frame of the animation*/
  86025. to: number;
  86026. /**
  86027. * Initializes the range of an animation
  86028. * @param name The name of the animation range
  86029. * @param from The starting frame of the animation
  86030. * @param to The ending frame of the animation
  86031. */
  86032. constructor(
  86033. /**The name of the animation range**/
  86034. name: string,
  86035. /**The starting frame of the animation */
  86036. from: number,
  86037. /**The ending frame of the animation*/
  86038. to: number);
  86039. /**
  86040. * Makes a copy of the animation range
  86041. * @returns A copy of the animation range
  86042. */
  86043. clone(): AnimationRange;
  86044. }
  86045. }
  86046. declare module BABYLON {
  86047. /**
  86048. * Composed of a frame, and an action function
  86049. */
  86050. export class AnimationEvent {
  86051. /** The frame for which the event is triggered **/
  86052. frame: number;
  86053. /** The event to perform when triggered **/
  86054. action: (currentFrame: number) => void;
  86055. /** Specifies if the event should be triggered only once**/
  86056. onlyOnce?: boolean | undefined;
  86057. /**
  86058. * Specifies if the animation event is done
  86059. */
  86060. isDone: boolean;
  86061. /**
  86062. * Initializes the animation event
  86063. * @param frame The frame for which the event is triggered
  86064. * @param action The event to perform when triggered
  86065. * @param onlyOnce Specifies if the event should be triggered only once
  86066. */
  86067. constructor(
  86068. /** The frame for which the event is triggered **/
  86069. frame: number,
  86070. /** The event to perform when triggered **/
  86071. action: (currentFrame: number) => void,
  86072. /** Specifies if the event should be triggered only once**/
  86073. onlyOnce?: boolean | undefined);
  86074. /** @hidden */
  86075. _clone(): AnimationEvent;
  86076. }
  86077. }
  86078. declare module BABYLON {
  86079. /**
  86080. * Interface used to define a behavior
  86081. */
  86082. export interface Behavior<T> {
  86083. /** gets or sets behavior's name */
  86084. name: string;
  86085. /**
  86086. * Function called when the behavior needs to be initialized (after attaching it to a target)
  86087. */
  86088. init(): void;
  86089. /**
  86090. * Called when the behavior is attached to a target
  86091. * @param target defines the target where the behavior is attached to
  86092. */
  86093. attach(target: T): void;
  86094. /**
  86095. * Called when the behavior is detached from its target
  86096. */
  86097. detach(): void;
  86098. }
  86099. /**
  86100. * Interface implemented by classes supporting behaviors
  86101. */
  86102. export interface IBehaviorAware<T> {
  86103. /**
  86104. * Attach a behavior
  86105. * @param behavior defines the behavior to attach
  86106. * @returns the current host
  86107. */
  86108. addBehavior(behavior: Behavior<T>): T;
  86109. /**
  86110. * Remove a behavior from the current object
  86111. * @param behavior defines the behavior to detach
  86112. * @returns the current host
  86113. */
  86114. removeBehavior(behavior: Behavior<T>): T;
  86115. /**
  86116. * Gets a behavior using its name to search
  86117. * @param name defines the name to search
  86118. * @returns the behavior or null if not found
  86119. */
  86120. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  86121. }
  86122. }
  86123. declare module BABYLON {
  86124. /**
  86125. * Defines an array and its length.
  86126. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  86127. */
  86128. export interface ISmartArrayLike<T> {
  86129. /**
  86130. * The data of the array.
  86131. */
  86132. data: Array<T>;
  86133. /**
  86134. * The active length of the array.
  86135. */
  86136. length: number;
  86137. }
  86138. /**
  86139. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  86140. */
  86141. export class SmartArray<T> implements ISmartArrayLike<T> {
  86142. /**
  86143. * The full set of data from the array.
  86144. */
  86145. data: Array<T>;
  86146. /**
  86147. * The active length of the array.
  86148. */
  86149. length: number;
  86150. protected _id: number;
  86151. /**
  86152. * Instantiates a Smart Array.
  86153. * @param capacity defines the default capacity of the array.
  86154. */
  86155. constructor(capacity: number);
  86156. /**
  86157. * Pushes a value at the end of the active data.
  86158. * @param value defines the object to push in the array.
  86159. */
  86160. push(value: T): void;
  86161. /**
  86162. * Iterates over the active data and apply the lambda to them.
  86163. * @param func defines the action to apply on each value.
  86164. */
  86165. forEach(func: (content: T) => void): void;
  86166. /**
  86167. * Sorts the full sets of data.
  86168. * @param compareFn defines the comparison function to apply.
  86169. */
  86170. sort(compareFn: (a: T, b: T) => number): void;
  86171. /**
  86172. * Resets the active data to an empty array.
  86173. */
  86174. reset(): void;
  86175. /**
  86176. * Releases all the data from the array as well as the array.
  86177. */
  86178. dispose(): void;
  86179. /**
  86180. * Concats the active data with a given array.
  86181. * @param array defines the data to concatenate with.
  86182. */
  86183. concat(array: any): void;
  86184. /**
  86185. * Returns the position of a value in the active data.
  86186. * @param value defines the value to find the index for
  86187. * @returns the index if found in the active data otherwise -1
  86188. */
  86189. indexOf(value: T): number;
  86190. /**
  86191. * Returns whether an element is part of the active data.
  86192. * @param value defines the value to look for
  86193. * @returns true if found in the active data otherwise false
  86194. */
  86195. contains(value: T): boolean;
  86196. private static _GlobalId;
  86197. }
  86198. /**
  86199. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  86200. * The data in this array can only be present once
  86201. */
  86202. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  86203. private _duplicateId;
  86204. /**
  86205. * Pushes a value at the end of the active data.
  86206. * THIS DOES NOT PREVENT DUPPLICATE DATA
  86207. * @param value defines the object to push in the array.
  86208. */
  86209. push(value: T): void;
  86210. /**
  86211. * Pushes a value at the end of the active data.
  86212. * If the data is already present, it won t be added again
  86213. * @param value defines the object to push in the array.
  86214. * @returns true if added false if it was already present
  86215. */
  86216. pushNoDuplicate(value: T): boolean;
  86217. /**
  86218. * Resets the active data to an empty array.
  86219. */
  86220. reset(): void;
  86221. /**
  86222. * Concats the active data with a given array.
  86223. * This ensures no dupplicate will be present in the result.
  86224. * @param array defines the data to concatenate with.
  86225. */
  86226. concatWithNoDuplicate(array: any): void;
  86227. }
  86228. }
  86229. declare module BABYLON {
  86230. /**
  86231. * @ignore
  86232. * This is a list of all the different input types that are available in the application.
  86233. * Fo instance: ArcRotateCameraGamepadInput...
  86234. */
  86235. export var CameraInputTypes: {};
  86236. /**
  86237. * This is the contract to implement in order to create a new input class.
  86238. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  86239. */
  86240. export interface ICameraInput<TCamera extends Camera> {
  86241. /**
  86242. * Defines the camera the input is attached to.
  86243. */
  86244. camera: Nullable<TCamera>;
  86245. /**
  86246. * Gets the class name of the current intput.
  86247. * @returns the class name
  86248. */
  86249. getClassName(): string;
  86250. /**
  86251. * Get the friendly name associated with the input class.
  86252. * @returns the input friendly name
  86253. */
  86254. getSimpleName(): string;
  86255. /**
  86256. * Attach the input controls to a specific dom element to get the input from.
  86257. * @param element Defines the element the controls should be listened from
  86258. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  86259. */
  86260. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  86261. /**
  86262. * Detach the current controls from the specified dom element.
  86263. * @param element Defines the element to stop listening the inputs from
  86264. */
  86265. detachControl(element: Nullable<HTMLElement>): void;
  86266. /**
  86267. * Update the current camera state depending on the inputs that have been used this frame.
  86268. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  86269. */
  86270. checkInputs?: () => void;
  86271. }
  86272. /**
  86273. * Represents a map of input types to input instance or input index to input instance.
  86274. */
  86275. export interface CameraInputsMap<TCamera extends Camera> {
  86276. /**
  86277. * Accessor to the input by input type.
  86278. */
  86279. [name: string]: ICameraInput<TCamera>;
  86280. /**
  86281. * Accessor to the input by input index.
  86282. */
  86283. [idx: number]: ICameraInput<TCamera>;
  86284. }
  86285. /**
  86286. * This represents the input manager used within a camera.
  86287. * It helps dealing with all the different kind of input attached to a camera.
  86288. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  86289. */
  86290. export class CameraInputsManager<TCamera extends Camera> {
  86291. /**
  86292. * Defines the list of inputs attahed to the camera.
  86293. */
  86294. attached: CameraInputsMap<TCamera>;
  86295. /**
  86296. * Defines the dom element the camera is collecting inputs from.
  86297. * This is null if the controls have not been attached.
  86298. */
  86299. attachedElement: Nullable<HTMLElement>;
  86300. /**
  86301. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  86302. */
  86303. noPreventDefault: boolean;
  86304. /**
  86305. * Defined the camera the input manager belongs to.
  86306. */
  86307. camera: TCamera;
  86308. /**
  86309. * Update the current camera state depending on the inputs that have been used this frame.
  86310. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  86311. */
  86312. checkInputs: () => void;
  86313. /**
  86314. * Instantiate a new Camera Input Manager.
  86315. * @param camera Defines the camera the input manager blongs to
  86316. */
  86317. constructor(camera: TCamera);
  86318. /**
  86319. * Add an input method to a camera
  86320. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  86321. * @param input camera input method
  86322. */
  86323. add(input: ICameraInput<TCamera>): void;
  86324. /**
  86325. * Remove a specific input method from a camera
  86326. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  86327. * @param inputToRemove camera input method
  86328. */
  86329. remove(inputToRemove: ICameraInput<TCamera>): void;
  86330. /**
  86331. * Remove a specific input type from a camera
  86332. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  86333. * @param inputType the type of the input to remove
  86334. */
  86335. removeByType(inputType: string): void;
  86336. private _addCheckInputs;
  86337. /**
  86338. * Attach the input controls to the currently attached dom element to listen the events from.
  86339. * @param input Defines the input to attach
  86340. */
  86341. attachInput(input: ICameraInput<TCamera>): void;
  86342. /**
  86343. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  86344. * @param element Defines the dom element to collect the events from
  86345. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  86346. */
  86347. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  86348. /**
  86349. * Detach the current manager inputs controls from a specific dom element.
  86350. * @param element Defines the dom element to collect the events from
  86351. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  86352. */
  86353. detachElement(element: HTMLElement, disconnect?: boolean): void;
  86354. /**
  86355. * Rebuild the dynamic inputCheck function from the current list of
  86356. * defined inputs in the manager.
  86357. */
  86358. rebuildInputCheck(): void;
  86359. /**
  86360. * Remove all attached input methods from a camera
  86361. */
  86362. clear(): void;
  86363. /**
  86364. * Serialize the current input manager attached to a camera.
  86365. * This ensures than once parsed,
  86366. * the input associated to the camera will be identical to the current ones
  86367. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  86368. */
  86369. serialize(serializedCamera: any): void;
  86370. /**
  86371. * Parses an input manager serialized JSON to restore the previous list of inputs
  86372. * and states associated to a camera.
  86373. * @param parsedCamera Defines the JSON to parse
  86374. */
  86375. parse(parsedCamera: any): void;
  86376. }
  86377. }
  86378. declare module BABYLON {
  86379. /**
  86380. * Class used to store data that will be store in GPU memory
  86381. */
  86382. export class Buffer {
  86383. private _engine;
  86384. private _buffer;
  86385. /** @hidden */
  86386. _data: Nullable<DataArray>;
  86387. private _updatable;
  86388. private _instanced;
  86389. private _divisor;
  86390. /**
  86391. * Gets the byte stride.
  86392. */
  86393. readonly byteStride: number;
  86394. /**
  86395. * Constructor
  86396. * @param engine the engine
  86397. * @param data the data to use for this buffer
  86398. * @param updatable whether the data is updatable
  86399. * @param stride the stride (optional)
  86400. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  86401. * @param instanced whether the buffer is instanced (optional)
  86402. * @param useBytes set to true if the stride in in bytes (optional)
  86403. * @param divisor sets an optional divisor for instances (1 by default)
  86404. */
  86405. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  86406. /**
  86407. * Create a new VertexBuffer based on the current buffer
  86408. * @param kind defines the vertex buffer kind (position, normal, etc.)
  86409. * @param offset defines offset in the buffer (0 by default)
  86410. * @param size defines the size in floats of attributes (position is 3 for instance)
  86411. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  86412. * @param instanced defines if the vertex buffer contains indexed data
  86413. * @param useBytes defines if the offset and stride are in bytes *
  86414. * @param divisor sets an optional divisor for instances (1 by default)
  86415. * @returns the new vertex buffer
  86416. */
  86417. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  86418. /**
  86419. * Gets a boolean indicating if the Buffer is updatable?
  86420. * @returns true if the buffer is updatable
  86421. */
  86422. isUpdatable(): boolean;
  86423. /**
  86424. * Gets current buffer's data
  86425. * @returns a DataArray or null
  86426. */
  86427. getData(): Nullable<DataArray>;
  86428. /**
  86429. * Gets underlying native buffer
  86430. * @returns underlying native buffer
  86431. */
  86432. getBuffer(): Nullable<DataBuffer>;
  86433. /**
  86434. * Gets the stride in float32 units (i.e. byte stride / 4).
  86435. * May not be an integer if the byte stride is not divisible by 4.
  86436. * @returns the stride in float32 units
  86437. * @deprecated Please use byteStride instead.
  86438. */
  86439. getStrideSize(): number;
  86440. /**
  86441. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  86442. * @param data defines the data to store
  86443. */
  86444. create(data?: Nullable<DataArray>): void;
  86445. /** @hidden */
  86446. _rebuild(): void;
  86447. /**
  86448. * Update current buffer data
  86449. * @param data defines the data to store
  86450. */
  86451. update(data: DataArray): void;
  86452. /**
  86453. * Updates the data directly.
  86454. * @param data the new data
  86455. * @param offset the new offset
  86456. * @param vertexCount the vertex count (optional)
  86457. * @param useBytes set to true if the offset is in bytes
  86458. */
  86459. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  86460. /**
  86461. * Release all resources
  86462. */
  86463. dispose(): void;
  86464. }
  86465. /**
  86466. * Specialized buffer used to store vertex data
  86467. */
  86468. export class VertexBuffer {
  86469. /** @hidden */
  86470. _buffer: Buffer;
  86471. private _kind;
  86472. private _size;
  86473. private _ownsBuffer;
  86474. private _instanced;
  86475. private _instanceDivisor;
  86476. /**
  86477. * The byte type.
  86478. */
  86479. static readonly BYTE: number;
  86480. /**
  86481. * The unsigned byte type.
  86482. */
  86483. static readonly UNSIGNED_BYTE: number;
  86484. /**
  86485. * The short type.
  86486. */
  86487. static readonly SHORT: number;
  86488. /**
  86489. * The unsigned short type.
  86490. */
  86491. static readonly UNSIGNED_SHORT: number;
  86492. /**
  86493. * The integer type.
  86494. */
  86495. static readonly INT: number;
  86496. /**
  86497. * The unsigned integer type.
  86498. */
  86499. static readonly UNSIGNED_INT: number;
  86500. /**
  86501. * The float type.
  86502. */
  86503. static readonly FLOAT: number;
  86504. /**
  86505. * Gets or sets the instance divisor when in instanced mode
  86506. */
  86507. get instanceDivisor(): number;
  86508. set instanceDivisor(value: number);
  86509. /**
  86510. * Gets the byte stride.
  86511. */
  86512. readonly byteStride: number;
  86513. /**
  86514. * Gets the byte offset.
  86515. */
  86516. readonly byteOffset: number;
  86517. /**
  86518. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  86519. */
  86520. readonly normalized: boolean;
  86521. /**
  86522. * Gets the data type of each component in the array.
  86523. */
  86524. readonly type: number;
  86525. /**
  86526. * Constructor
  86527. * @param engine the engine
  86528. * @param data the data to use for this vertex buffer
  86529. * @param kind the vertex buffer kind
  86530. * @param updatable whether the data is updatable
  86531. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  86532. * @param stride the stride (optional)
  86533. * @param instanced whether the buffer is instanced (optional)
  86534. * @param offset the offset of the data (optional)
  86535. * @param size the number of components (optional)
  86536. * @param type the type of the component (optional)
  86537. * @param normalized whether the data contains normalized data (optional)
  86538. * @param useBytes set to true if stride and offset are in bytes (optional)
  86539. * @param divisor defines the instance divisor to use (1 by default)
  86540. */
  86541. 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);
  86542. /** @hidden */
  86543. _rebuild(): void;
  86544. /**
  86545. * Returns the kind of the VertexBuffer (string)
  86546. * @returns a string
  86547. */
  86548. getKind(): string;
  86549. /**
  86550. * Gets a boolean indicating if the VertexBuffer is updatable?
  86551. * @returns true if the buffer is updatable
  86552. */
  86553. isUpdatable(): boolean;
  86554. /**
  86555. * Gets current buffer's data
  86556. * @returns a DataArray or null
  86557. */
  86558. getData(): Nullable<DataArray>;
  86559. /**
  86560. * Gets underlying native buffer
  86561. * @returns underlying native buffer
  86562. */
  86563. getBuffer(): Nullable<DataBuffer>;
  86564. /**
  86565. * Gets the stride in float32 units (i.e. byte stride / 4).
  86566. * May not be an integer if the byte stride is not divisible by 4.
  86567. * @returns the stride in float32 units
  86568. * @deprecated Please use byteStride instead.
  86569. */
  86570. getStrideSize(): number;
  86571. /**
  86572. * Returns the offset as a multiple of the type byte length.
  86573. * @returns the offset in bytes
  86574. * @deprecated Please use byteOffset instead.
  86575. */
  86576. getOffset(): number;
  86577. /**
  86578. * Returns the number of components per vertex attribute (integer)
  86579. * @returns the size in float
  86580. */
  86581. getSize(): number;
  86582. /**
  86583. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  86584. * @returns true if this buffer is instanced
  86585. */
  86586. getIsInstanced(): boolean;
  86587. /**
  86588. * Returns the instancing divisor, zero for non-instanced (integer).
  86589. * @returns a number
  86590. */
  86591. getInstanceDivisor(): number;
  86592. /**
  86593. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  86594. * @param data defines the data to store
  86595. */
  86596. create(data?: DataArray): void;
  86597. /**
  86598. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  86599. * This function will create a new buffer if the current one is not updatable
  86600. * @param data defines the data to store
  86601. */
  86602. update(data: DataArray): void;
  86603. /**
  86604. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  86605. * Returns the directly updated WebGLBuffer.
  86606. * @param data the new data
  86607. * @param offset the new offset
  86608. * @param useBytes set to true if the offset is in bytes
  86609. */
  86610. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  86611. /**
  86612. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  86613. */
  86614. dispose(): void;
  86615. /**
  86616. * Enumerates each value of this vertex buffer as numbers.
  86617. * @param count the number of values to enumerate
  86618. * @param callback the callback function called for each value
  86619. */
  86620. forEach(count: number, callback: (value: number, index: number) => void): void;
  86621. /**
  86622. * Positions
  86623. */
  86624. static readonly PositionKind: string;
  86625. /**
  86626. * Normals
  86627. */
  86628. static readonly NormalKind: string;
  86629. /**
  86630. * Tangents
  86631. */
  86632. static readonly TangentKind: string;
  86633. /**
  86634. * Texture coordinates
  86635. */
  86636. static readonly UVKind: string;
  86637. /**
  86638. * Texture coordinates 2
  86639. */
  86640. static readonly UV2Kind: string;
  86641. /**
  86642. * Texture coordinates 3
  86643. */
  86644. static readonly UV3Kind: string;
  86645. /**
  86646. * Texture coordinates 4
  86647. */
  86648. static readonly UV4Kind: string;
  86649. /**
  86650. * Texture coordinates 5
  86651. */
  86652. static readonly UV5Kind: string;
  86653. /**
  86654. * Texture coordinates 6
  86655. */
  86656. static readonly UV6Kind: string;
  86657. /**
  86658. * Colors
  86659. */
  86660. static readonly ColorKind: string;
  86661. /**
  86662. * Matrix indices (for bones)
  86663. */
  86664. static readonly MatricesIndicesKind: string;
  86665. /**
  86666. * Matrix weights (for bones)
  86667. */
  86668. static readonly MatricesWeightsKind: string;
  86669. /**
  86670. * Additional matrix indices (for bones)
  86671. */
  86672. static readonly MatricesIndicesExtraKind: string;
  86673. /**
  86674. * Additional matrix weights (for bones)
  86675. */
  86676. static readonly MatricesWeightsExtraKind: string;
  86677. /**
  86678. * Deduces the stride given a kind.
  86679. * @param kind The kind string to deduce
  86680. * @returns The deduced stride
  86681. */
  86682. static DeduceStride(kind: string): number;
  86683. /**
  86684. * Gets the byte length of the given type.
  86685. * @param type the type
  86686. * @returns the number of bytes
  86687. */
  86688. static GetTypeByteLength(type: number): number;
  86689. /**
  86690. * Enumerates each value of the given parameters as numbers.
  86691. * @param data the data to enumerate
  86692. * @param byteOffset the byte offset of the data
  86693. * @param byteStride the byte stride of the data
  86694. * @param componentCount the number of components per element
  86695. * @param componentType the type of the component
  86696. * @param count the number of values to enumerate
  86697. * @param normalized whether the data is normalized
  86698. * @param callback the callback function called for each value
  86699. */
  86700. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  86701. private static _GetFloatValue;
  86702. }
  86703. }
  86704. declare module BABYLON {
  86705. /**
  86706. * The options Interface for creating a Capsule Mesh
  86707. */
  86708. export interface ICreateCapsuleOptions {
  86709. /** The Orientation of the capsule. Default : Vector3.Up() */
  86710. orientation?: Vector3;
  86711. /** Number of sub segments on the tube section of the capsule running parallel to orientation. */
  86712. subdivisions: number;
  86713. /** Number of cylindrical segments on the capsule. */
  86714. tessellation: number;
  86715. /** Height or Length of the capsule. */
  86716. height: number;
  86717. /** Radius of the capsule. */
  86718. radius: number;
  86719. /** Height or Length of the capsule. */
  86720. capSubdivisions: number;
  86721. /** Overwrite for the top radius. */
  86722. radiusTop?: number;
  86723. /** Overwrite for the bottom radius. */
  86724. radiusBottom?: number;
  86725. /** Overwrite for the top capSubdivisions. */
  86726. topCapSubdivisions?: number;
  86727. /** Overwrite for the bottom capSubdivisions. */
  86728. bottomCapSubdivisions?: number;
  86729. }
  86730. /**
  86731. * Class containing static functions to help procedurally build meshes
  86732. */
  86733. export class CapsuleBuilder {
  86734. /**
  86735. * Creates a capsule or a pill mesh
  86736. * @param name defines the name of the mesh
  86737. * @param options The constructors options.
  86738. * @param scene The scene the mesh is scoped to.
  86739. * @returns Capsule Mesh
  86740. */
  86741. static CreateCapsule(name: string, options: ICreateCapsuleOptions | undefined, scene: any): Mesh;
  86742. }
  86743. }
  86744. declare module BABYLON {
  86745. /**
  86746. * @hidden
  86747. */
  86748. export class IntersectionInfo {
  86749. bu: Nullable<number>;
  86750. bv: Nullable<number>;
  86751. distance: number;
  86752. faceId: number;
  86753. subMeshId: number;
  86754. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  86755. }
  86756. }
  86757. declare module BABYLON {
  86758. /**
  86759. * Class used to store bounding sphere information
  86760. */
  86761. export class BoundingSphere {
  86762. /**
  86763. * Gets the center of the bounding sphere in local space
  86764. */
  86765. readonly center: Vector3;
  86766. /**
  86767. * Radius of the bounding sphere in local space
  86768. */
  86769. radius: number;
  86770. /**
  86771. * Gets the center of the bounding sphere in world space
  86772. */
  86773. readonly centerWorld: Vector3;
  86774. /**
  86775. * Radius of the bounding sphere in world space
  86776. */
  86777. radiusWorld: number;
  86778. /**
  86779. * Gets the minimum vector in local space
  86780. */
  86781. readonly minimum: Vector3;
  86782. /**
  86783. * Gets the maximum vector in local space
  86784. */
  86785. readonly maximum: Vector3;
  86786. private _worldMatrix;
  86787. private static readonly TmpVector3;
  86788. /**
  86789. * Creates a new bounding sphere
  86790. * @param min defines the minimum vector (in local space)
  86791. * @param max defines the maximum vector (in local space)
  86792. * @param worldMatrix defines the new world matrix
  86793. */
  86794. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  86795. /**
  86796. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  86797. * @param min defines the new minimum vector (in local space)
  86798. * @param max defines the new maximum vector (in local space)
  86799. * @param worldMatrix defines the new world matrix
  86800. */
  86801. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  86802. /**
  86803. * Scale the current bounding sphere by applying a scale factor
  86804. * @param factor defines the scale factor to apply
  86805. * @returns the current bounding box
  86806. */
  86807. scale(factor: number): BoundingSphere;
  86808. /**
  86809. * Gets the world matrix of the bounding box
  86810. * @returns a matrix
  86811. */
  86812. getWorldMatrix(): DeepImmutable<Matrix>;
  86813. /** @hidden */
  86814. _update(worldMatrix: DeepImmutable<Matrix>): void;
  86815. /**
  86816. * Tests if the bounding sphere is intersecting the frustum planes
  86817. * @param frustumPlanes defines the frustum planes to test
  86818. * @returns true if there is an intersection
  86819. */
  86820. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  86821. /**
  86822. * Tests if the bounding sphere center is in between the frustum planes.
  86823. * Used for optimistic fast inclusion.
  86824. * @param frustumPlanes defines the frustum planes to test
  86825. * @returns true if the sphere center is in between the frustum planes
  86826. */
  86827. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  86828. /**
  86829. * Tests if a point is inside the bounding sphere
  86830. * @param point defines the point to test
  86831. * @returns true if the point is inside the bounding sphere
  86832. */
  86833. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  86834. /**
  86835. * Checks if two sphere intersct
  86836. * @param sphere0 sphere 0
  86837. * @param sphere1 sphere 1
  86838. * @returns true if the speres intersect
  86839. */
  86840. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  86841. }
  86842. }
  86843. declare module BABYLON {
  86844. /**
  86845. * Class used to store bounding box information
  86846. */
  86847. export class BoundingBox implements ICullable {
  86848. /**
  86849. * Gets the 8 vectors representing the bounding box in local space
  86850. */
  86851. readonly vectors: Vector3[];
  86852. /**
  86853. * Gets the center of the bounding box in local space
  86854. */
  86855. readonly center: Vector3;
  86856. /**
  86857. * Gets the center of the bounding box in world space
  86858. */
  86859. readonly centerWorld: Vector3;
  86860. /**
  86861. * Gets the extend size in local space
  86862. */
  86863. readonly extendSize: Vector3;
  86864. /**
  86865. * Gets the extend size in world space
  86866. */
  86867. readonly extendSizeWorld: Vector3;
  86868. /**
  86869. * Gets the OBB (object bounding box) directions
  86870. */
  86871. readonly directions: Vector3[];
  86872. /**
  86873. * Gets the 8 vectors representing the bounding box in world space
  86874. */
  86875. readonly vectorsWorld: Vector3[];
  86876. /**
  86877. * Gets the minimum vector in world space
  86878. */
  86879. readonly minimumWorld: Vector3;
  86880. /**
  86881. * Gets the maximum vector in world space
  86882. */
  86883. readonly maximumWorld: Vector3;
  86884. /**
  86885. * Gets the minimum vector in local space
  86886. */
  86887. readonly minimum: Vector3;
  86888. /**
  86889. * Gets the maximum vector in local space
  86890. */
  86891. readonly maximum: Vector3;
  86892. private _worldMatrix;
  86893. private static readonly TmpVector3;
  86894. /**
  86895. * @hidden
  86896. */
  86897. _tag: number;
  86898. /**
  86899. * Creates a new bounding box
  86900. * @param min defines the minimum vector (in local space)
  86901. * @param max defines the maximum vector (in local space)
  86902. * @param worldMatrix defines the new world matrix
  86903. */
  86904. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  86905. /**
  86906. * Recreates the entire bounding box from scratch as if we call the constructor in place
  86907. * @param min defines the new minimum vector (in local space)
  86908. * @param max defines the new maximum vector (in local space)
  86909. * @param worldMatrix defines the new world matrix
  86910. */
  86911. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  86912. /**
  86913. * Scale the current bounding box by applying a scale factor
  86914. * @param factor defines the scale factor to apply
  86915. * @returns the current bounding box
  86916. */
  86917. scale(factor: number): BoundingBox;
  86918. /**
  86919. * Gets the world matrix of the bounding box
  86920. * @returns a matrix
  86921. */
  86922. getWorldMatrix(): DeepImmutable<Matrix>;
  86923. /** @hidden */
  86924. _update(world: DeepImmutable<Matrix>): void;
  86925. /**
  86926. * Tests if the bounding box is intersecting the frustum planes
  86927. * @param frustumPlanes defines the frustum planes to test
  86928. * @returns true if there is an intersection
  86929. */
  86930. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  86931. /**
  86932. * Tests if the bounding box is entirely inside the frustum planes
  86933. * @param frustumPlanes defines the frustum planes to test
  86934. * @returns true if there is an inclusion
  86935. */
  86936. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  86937. /**
  86938. * Tests if a point is inside the bounding box
  86939. * @param point defines the point to test
  86940. * @returns true if the point is inside the bounding box
  86941. */
  86942. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  86943. /**
  86944. * Tests if the bounding box intersects with a bounding sphere
  86945. * @param sphere defines the sphere to test
  86946. * @returns true if there is an intersection
  86947. */
  86948. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  86949. /**
  86950. * Tests if the bounding box intersects with a box defined by a min and max vectors
  86951. * @param min defines the min vector to use
  86952. * @param max defines the max vector to use
  86953. * @returns true if there is an intersection
  86954. */
  86955. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  86956. /**
  86957. * Tests if two bounding boxes are intersections
  86958. * @param box0 defines the first box to test
  86959. * @param box1 defines the second box to test
  86960. * @returns true if there is an intersection
  86961. */
  86962. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  86963. /**
  86964. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  86965. * @param minPoint defines the minimum vector of the bounding box
  86966. * @param maxPoint defines the maximum vector of the bounding box
  86967. * @param sphereCenter defines the sphere center
  86968. * @param sphereRadius defines the sphere radius
  86969. * @returns true if there is an intersection
  86970. */
  86971. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  86972. /**
  86973. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  86974. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  86975. * @param frustumPlanes defines the frustum planes to test
  86976. * @return true if there is an inclusion
  86977. */
  86978. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  86979. /**
  86980. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  86981. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  86982. * @param frustumPlanes defines the frustum planes to test
  86983. * @return true if there is an intersection
  86984. */
  86985. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  86986. }
  86987. }
  86988. declare module BABYLON {
  86989. /** @hidden */
  86990. export class Collider {
  86991. /** Define if a collision was found */
  86992. collisionFound: boolean;
  86993. /**
  86994. * Define last intersection point in local space
  86995. */
  86996. intersectionPoint: Vector3;
  86997. /**
  86998. * Define last collided mesh
  86999. */
  87000. collidedMesh: Nullable<AbstractMesh>;
  87001. private _collisionPoint;
  87002. private _planeIntersectionPoint;
  87003. private _tempVector;
  87004. private _tempVector2;
  87005. private _tempVector3;
  87006. private _tempVector4;
  87007. private _edge;
  87008. private _baseToVertex;
  87009. private _destinationPoint;
  87010. private _slidePlaneNormal;
  87011. private _displacementVector;
  87012. /** @hidden */
  87013. _radius: Vector3;
  87014. /** @hidden */
  87015. _retry: number;
  87016. private _velocity;
  87017. private _basePoint;
  87018. private _epsilon;
  87019. /** @hidden */
  87020. _velocityWorldLength: number;
  87021. /** @hidden */
  87022. _basePointWorld: Vector3;
  87023. private _velocityWorld;
  87024. private _normalizedVelocity;
  87025. /** @hidden */
  87026. _initialVelocity: Vector3;
  87027. /** @hidden */
  87028. _initialPosition: Vector3;
  87029. private _nearestDistance;
  87030. private _collisionMask;
  87031. get collisionMask(): number;
  87032. set collisionMask(mask: number);
  87033. /**
  87034. * Gets the plane normal used to compute the sliding response (in local space)
  87035. */
  87036. get slidePlaneNormal(): Vector3;
  87037. /** @hidden */
  87038. _initialize(source: Vector3, dir: Vector3, e: number): void;
  87039. /** @hidden */
  87040. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  87041. /** @hidden */
  87042. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  87043. /** @hidden */
  87044. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  87045. /** @hidden */
  87046. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  87047. /** @hidden */
  87048. _getResponse(pos: Vector3, vel: Vector3): void;
  87049. }
  87050. }
  87051. declare module BABYLON {
  87052. /**
  87053. * Interface for cullable objects
  87054. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  87055. */
  87056. export interface ICullable {
  87057. /**
  87058. * Checks if the object or part of the object is in the frustum
  87059. * @param frustumPlanes Camera near/planes
  87060. * @returns true if the object is in frustum otherwise false
  87061. */
  87062. isInFrustum(frustumPlanes: Plane[]): boolean;
  87063. /**
  87064. * Checks if a cullable object (mesh...) is in the camera frustum
  87065. * Unlike isInFrustum this cheks the full bounding box
  87066. * @param frustumPlanes Camera near/planes
  87067. * @returns true if the object is in frustum otherwise false
  87068. */
  87069. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  87070. }
  87071. /**
  87072. * Info for a bounding data of a mesh
  87073. */
  87074. export class BoundingInfo implements ICullable {
  87075. /**
  87076. * Bounding box for the mesh
  87077. */
  87078. readonly boundingBox: BoundingBox;
  87079. /**
  87080. * Bounding sphere for the mesh
  87081. */
  87082. readonly boundingSphere: BoundingSphere;
  87083. private _isLocked;
  87084. private static readonly TmpVector3;
  87085. /**
  87086. * Constructs bounding info
  87087. * @param minimum min vector of the bounding box/sphere
  87088. * @param maximum max vector of the bounding box/sphere
  87089. * @param worldMatrix defines the new world matrix
  87090. */
  87091. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  87092. /**
  87093. * Recreates the entire bounding info from scratch as if we call the constructor in place
  87094. * @param min defines the new minimum vector (in local space)
  87095. * @param max defines the new maximum vector (in local space)
  87096. * @param worldMatrix defines the new world matrix
  87097. */
  87098. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  87099. /**
  87100. * min vector of the bounding box/sphere
  87101. */
  87102. get minimum(): Vector3;
  87103. /**
  87104. * max vector of the bounding box/sphere
  87105. */
  87106. get maximum(): Vector3;
  87107. /**
  87108. * If the info is locked and won't be updated to avoid perf overhead
  87109. */
  87110. get isLocked(): boolean;
  87111. set isLocked(value: boolean);
  87112. /**
  87113. * Updates the bounding sphere and box
  87114. * @param world world matrix to be used to update
  87115. */
  87116. update(world: DeepImmutable<Matrix>): void;
  87117. /**
  87118. * Recreate the bounding info to be centered around a specific point given a specific extend.
  87119. * @param center New center of the bounding info
  87120. * @param extend New extend of the bounding info
  87121. * @returns the current bounding info
  87122. */
  87123. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  87124. /**
  87125. * Scale the current bounding info by applying a scale factor
  87126. * @param factor defines the scale factor to apply
  87127. * @returns the current bounding info
  87128. */
  87129. scale(factor: number): BoundingInfo;
  87130. /**
  87131. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  87132. * @param frustumPlanes defines the frustum to test
  87133. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  87134. * @returns true if the bounding info is in the frustum planes
  87135. */
  87136. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  87137. /**
  87138. * Gets the world distance between the min and max points of the bounding box
  87139. */
  87140. get diagonalLength(): number;
  87141. /**
  87142. * Checks if a cullable object (mesh...) is in the camera frustum
  87143. * Unlike isInFrustum this cheks the full bounding box
  87144. * @param frustumPlanes Camera near/planes
  87145. * @returns true if the object is in frustum otherwise false
  87146. */
  87147. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  87148. /** @hidden */
  87149. _checkCollision(collider: Collider): boolean;
  87150. /**
  87151. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  87152. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  87153. * @param point the point to check intersection with
  87154. * @returns if the point intersects
  87155. */
  87156. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  87157. /**
  87158. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  87159. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  87160. * @param boundingInfo the bounding info to check intersection with
  87161. * @param precise if the intersection should be done using OBB
  87162. * @returns if the bounding info intersects
  87163. */
  87164. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  87165. }
  87166. }
  87167. declare module BABYLON {
  87168. /**
  87169. * Extracts minimum and maximum values from a list of indexed positions
  87170. * @param positions defines the positions to use
  87171. * @param indices defines the indices to the positions
  87172. * @param indexStart defines the start index
  87173. * @param indexCount defines the end index
  87174. * @param bias defines bias value to add to the result
  87175. * @return minimum and maximum values
  87176. */
  87177. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  87178. minimum: Vector3;
  87179. maximum: Vector3;
  87180. };
  87181. /**
  87182. * Extracts minimum and maximum values from a list of positions
  87183. * @param positions defines the positions to use
  87184. * @param start defines the start index in the positions array
  87185. * @param count defines the number of positions to handle
  87186. * @param bias defines bias value to add to the result
  87187. * @param stride defines the stride size to use (distance between two positions in the positions array)
  87188. * @return minimum and maximum values
  87189. */
  87190. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  87191. minimum: Vector3;
  87192. maximum: Vector3;
  87193. };
  87194. }
  87195. declare module BABYLON {
  87196. /** @hidden */
  87197. export class WebGLDataBuffer extends DataBuffer {
  87198. private _buffer;
  87199. constructor(resource: WebGLBuffer);
  87200. get underlyingResource(): any;
  87201. }
  87202. }
  87203. declare module BABYLON {
  87204. /** @hidden */
  87205. export class WebGLPipelineContext implements IPipelineContext {
  87206. engine: ThinEngine;
  87207. program: Nullable<WebGLProgram>;
  87208. context?: WebGLRenderingContext;
  87209. vertexShader?: WebGLShader;
  87210. fragmentShader?: WebGLShader;
  87211. isParallelCompiled: boolean;
  87212. onCompiled?: () => void;
  87213. transformFeedback?: WebGLTransformFeedback | null;
  87214. vertexCompilationError: Nullable<string>;
  87215. fragmentCompilationError: Nullable<string>;
  87216. programLinkError: Nullable<string>;
  87217. programValidationError: Nullable<string>;
  87218. get isAsync(): boolean;
  87219. get isReady(): boolean;
  87220. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  87221. _getVertexShaderCode(): string | null;
  87222. _getFragmentShaderCode(): string | null;
  87223. }
  87224. }
  87225. declare module BABYLON {
  87226. interface ThinEngine {
  87227. /**
  87228. * Create an uniform buffer
  87229. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  87230. * @param elements defines the content of the uniform buffer
  87231. * @returns the webGL uniform buffer
  87232. */
  87233. createUniformBuffer(elements: FloatArray): DataBuffer;
  87234. /**
  87235. * Create a dynamic uniform buffer
  87236. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  87237. * @param elements defines the content of the uniform buffer
  87238. * @returns the webGL uniform buffer
  87239. */
  87240. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  87241. /**
  87242. * Update an existing uniform buffer
  87243. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  87244. * @param uniformBuffer defines the target uniform buffer
  87245. * @param elements defines the content to update
  87246. * @param offset defines the offset in the uniform buffer where update should start
  87247. * @param count defines the size of the data to update
  87248. */
  87249. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  87250. /**
  87251. * Bind an uniform buffer to the current webGL context
  87252. * @param buffer defines the buffer to bind
  87253. */
  87254. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  87255. /**
  87256. * Bind a buffer to the current webGL context at a given location
  87257. * @param buffer defines the buffer to bind
  87258. * @param location defines the index where to bind the buffer
  87259. */
  87260. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  87261. /**
  87262. * Bind a specific block at a given index in a specific shader program
  87263. * @param pipelineContext defines the pipeline context to use
  87264. * @param blockName defines the block name
  87265. * @param index defines the index where to bind the block
  87266. */
  87267. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  87268. }
  87269. }
  87270. declare module BABYLON {
  87271. /**
  87272. * Uniform buffer objects.
  87273. *
  87274. * Handles blocks of uniform on the GPU.
  87275. *
  87276. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  87277. *
  87278. * For more information, please refer to :
  87279. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  87280. */
  87281. export class UniformBuffer {
  87282. private _engine;
  87283. private _buffer;
  87284. private _data;
  87285. private _bufferData;
  87286. private _dynamic?;
  87287. private _uniformLocations;
  87288. private _uniformSizes;
  87289. private _uniformLocationPointer;
  87290. private _needSync;
  87291. private _noUBO;
  87292. private _currentEffect;
  87293. /** @hidden */
  87294. _alreadyBound: boolean;
  87295. private static _MAX_UNIFORM_SIZE;
  87296. private static _tempBuffer;
  87297. /**
  87298. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  87299. * This is dynamic to allow compat with webgl 1 and 2.
  87300. * You will need to pass the name of the uniform as well as the value.
  87301. */
  87302. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  87303. /**
  87304. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  87305. * This is dynamic to allow compat with webgl 1 and 2.
  87306. * You will need to pass the name of the uniform as well as the value.
  87307. */
  87308. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  87309. /**
  87310. * Lambda to Update a single float in a uniform buffer.
  87311. * This is dynamic to allow compat with webgl 1 and 2.
  87312. * You will need to pass the name of the uniform as well as the value.
  87313. */
  87314. updateFloat: (name: string, x: number) => void;
  87315. /**
  87316. * Lambda to Update a vec2 of float in a uniform buffer.
  87317. * This is dynamic to allow compat with webgl 1 and 2.
  87318. * You will need to pass the name of the uniform as well as the value.
  87319. */
  87320. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  87321. /**
  87322. * Lambda to Update a vec3 of float in a uniform buffer.
  87323. * This is dynamic to allow compat with webgl 1 and 2.
  87324. * You will need to pass the name of the uniform as well as the value.
  87325. */
  87326. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  87327. /**
  87328. * Lambda to Update a vec4 of float in a uniform buffer.
  87329. * This is dynamic to allow compat with webgl 1 and 2.
  87330. * You will need to pass the name of the uniform as well as the value.
  87331. */
  87332. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  87333. /**
  87334. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  87335. * This is dynamic to allow compat with webgl 1 and 2.
  87336. * You will need to pass the name of the uniform as well as the value.
  87337. */
  87338. updateMatrix: (name: string, mat: Matrix) => void;
  87339. /**
  87340. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  87341. * This is dynamic to allow compat with webgl 1 and 2.
  87342. * You will need to pass the name of the uniform as well as the value.
  87343. */
  87344. updateVector3: (name: string, vector: Vector3) => void;
  87345. /**
  87346. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  87347. * This is dynamic to allow compat with webgl 1 and 2.
  87348. * You will need to pass the name of the uniform as well as the value.
  87349. */
  87350. updateVector4: (name: string, vector: Vector4) => void;
  87351. /**
  87352. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  87353. * This is dynamic to allow compat with webgl 1 and 2.
  87354. * You will need to pass the name of the uniform as well as the value.
  87355. */
  87356. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  87357. /**
  87358. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  87359. * This is dynamic to allow compat with webgl 1 and 2.
  87360. * You will need to pass the name of the uniform as well as the value.
  87361. */
  87362. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  87363. /**
  87364. * Instantiates a new Uniform buffer objects.
  87365. *
  87366. * Handles blocks of uniform on the GPU.
  87367. *
  87368. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  87369. *
  87370. * For more information, please refer to :
  87371. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  87372. * @param engine Define the engine the buffer is associated with
  87373. * @param data Define the data contained in the buffer
  87374. * @param dynamic Define if the buffer is updatable
  87375. */
  87376. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  87377. /**
  87378. * Indicates if the buffer is using the WebGL2 UBO implementation,
  87379. * or just falling back on setUniformXXX calls.
  87380. */
  87381. get useUbo(): boolean;
  87382. /**
  87383. * Indicates if the WebGL underlying uniform buffer is in sync
  87384. * with the javascript cache data.
  87385. */
  87386. get isSync(): boolean;
  87387. /**
  87388. * Indicates if the WebGL underlying uniform buffer is dynamic.
  87389. * Also, a dynamic UniformBuffer will disable cache verification and always
  87390. * update the underlying WebGL uniform buffer to the GPU.
  87391. * @returns if Dynamic, otherwise false
  87392. */
  87393. isDynamic(): boolean;
  87394. /**
  87395. * The data cache on JS side.
  87396. * @returns the underlying data as a float array
  87397. */
  87398. getData(): Float32Array;
  87399. /**
  87400. * The underlying WebGL Uniform buffer.
  87401. * @returns the webgl buffer
  87402. */
  87403. getBuffer(): Nullable<DataBuffer>;
  87404. /**
  87405. * std140 layout specifies how to align data within an UBO structure.
  87406. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  87407. * for specs.
  87408. */
  87409. private _fillAlignment;
  87410. /**
  87411. * Adds an uniform in the buffer.
  87412. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  87413. * for the layout to be correct !
  87414. * @param name Name of the uniform, as used in the uniform block in the shader.
  87415. * @param size Data size, or data directly.
  87416. */
  87417. addUniform(name: string, size: number | number[]): void;
  87418. /**
  87419. * Adds a Matrix 4x4 to the uniform buffer.
  87420. * @param name Name of the uniform, as used in the uniform block in the shader.
  87421. * @param mat A 4x4 matrix.
  87422. */
  87423. addMatrix(name: string, mat: Matrix): void;
  87424. /**
  87425. * Adds a vec2 to the uniform buffer.
  87426. * @param name Name of the uniform, as used in the uniform block in the shader.
  87427. * @param x Define the x component value of the vec2
  87428. * @param y Define the y component value of the vec2
  87429. */
  87430. addFloat2(name: string, x: number, y: number): void;
  87431. /**
  87432. * Adds a vec3 to the uniform buffer.
  87433. * @param name Name of the uniform, as used in the uniform block in the shader.
  87434. * @param x Define the x component value of the vec3
  87435. * @param y Define the y component value of the vec3
  87436. * @param z Define the z component value of the vec3
  87437. */
  87438. addFloat3(name: string, x: number, y: number, z: number): void;
  87439. /**
  87440. * Adds a vec3 to the uniform buffer.
  87441. * @param name Name of the uniform, as used in the uniform block in the shader.
  87442. * @param color Define the vec3 from a Color
  87443. */
  87444. addColor3(name: string, color: Color3): void;
  87445. /**
  87446. * Adds a vec4 to the uniform buffer.
  87447. * @param name Name of the uniform, as used in the uniform block in the shader.
  87448. * @param color Define the rgb components from a Color
  87449. * @param alpha Define the a component of the vec4
  87450. */
  87451. addColor4(name: string, color: Color3, alpha: number): void;
  87452. /**
  87453. * Adds a vec3 to the uniform buffer.
  87454. * @param name Name of the uniform, as used in the uniform block in the shader.
  87455. * @param vector Define the vec3 components from a Vector
  87456. */
  87457. addVector3(name: string, vector: Vector3): void;
  87458. /**
  87459. * Adds a Matrix 3x3 to the uniform buffer.
  87460. * @param name Name of the uniform, as used in the uniform block in the shader.
  87461. */
  87462. addMatrix3x3(name: string): void;
  87463. /**
  87464. * Adds a Matrix 2x2 to the uniform buffer.
  87465. * @param name Name of the uniform, as used in the uniform block in the shader.
  87466. */
  87467. addMatrix2x2(name: string): void;
  87468. /**
  87469. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  87470. */
  87471. create(): void;
  87472. /** @hidden */
  87473. _rebuild(): void;
  87474. /**
  87475. * Updates the WebGL Uniform Buffer on the GPU.
  87476. * If the `dynamic` flag is set to true, no cache comparison is done.
  87477. * Otherwise, the buffer will be updated only if the cache differs.
  87478. */
  87479. update(): void;
  87480. /**
  87481. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  87482. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  87483. * @param data Define the flattened data
  87484. * @param size Define the size of the data.
  87485. */
  87486. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  87487. private _valueCache;
  87488. private _cacheMatrix;
  87489. private _updateMatrix3x3ForUniform;
  87490. private _updateMatrix3x3ForEffect;
  87491. private _updateMatrix2x2ForEffect;
  87492. private _updateMatrix2x2ForUniform;
  87493. private _updateFloatForEffect;
  87494. private _updateFloatForUniform;
  87495. private _updateFloat2ForEffect;
  87496. private _updateFloat2ForUniform;
  87497. private _updateFloat3ForEffect;
  87498. private _updateFloat3ForUniform;
  87499. private _updateFloat4ForEffect;
  87500. private _updateFloat4ForUniform;
  87501. private _updateMatrixForEffect;
  87502. private _updateMatrixForUniform;
  87503. private _updateVector3ForEffect;
  87504. private _updateVector3ForUniform;
  87505. private _updateVector4ForEffect;
  87506. private _updateVector4ForUniform;
  87507. private _updateColor3ForEffect;
  87508. private _updateColor3ForUniform;
  87509. private _updateColor4ForEffect;
  87510. private _updateColor4ForUniform;
  87511. /**
  87512. * Sets a sampler uniform on the effect.
  87513. * @param name Define the name of the sampler.
  87514. * @param texture Define the texture to set in the sampler
  87515. */
  87516. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  87517. /**
  87518. * Directly updates the value of the uniform in the cache AND on the GPU.
  87519. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  87520. * @param data Define the flattened data
  87521. */
  87522. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  87523. /**
  87524. * Binds this uniform buffer to an effect.
  87525. * @param effect Define the effect to bind the buffer to
  87526. * @param name Name of the uniform block in the shader.
  87527. */
  87528. bindToEffect(effect: Effect, name: string): void;
  87529. /**
  87530. * Disposes the uniform buffer.
  87531. */
  87532. dispose(): void;
  87533. }
  87534. }
  87535. declare module BABYLON {
  87536. /**
  87537. * Enum that determines the text-wrapping mode to use.
  87538. */
  87539. export enum InspectableType {
  87540. /**
  87541. * Checkbox for booleans
  87542. */
  87543. Checkbox = 0,
  87544. /**
  87545. * Sliders for numbers
  87546. */
  87547. Slider = 1,
  87548. /**
  87549. * Vector3
  87550. */
  87551. Vector3 = 2,
  87552. /**
  87553. * Quaternions
  87554. */
  87555. Quaternion = 3,
  87556. /**
  87557. * Color3
  87558. */
  87559. Color3 = 4,
  87560. /**
  87561. * String
  87562. */
  87563. String = 5
  87564. }
  87565. /**
  87566. * Interface used to define custom inspectable properties.
  87567. * This interface is used by the inspector to display custom property grids
  87568. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  87569. */
  87570. export interface IInspectable {
  87571. /**
  87572. * Gets the label to display
  87573. */
  87574. label: string;
  87575. /**
  87576. * Gets the name of the property to edit
  87577. */
  87578. propertyName: string;
  87579. /**
  87580. * Gets the type of the editor to use
  87581. */
  87582. type: InspectableType;
  87583. /**
  87584. * Gets the minimum value of the property when using in "slider" mode
  87585. */
  87586. min?: number;
  87587. /**
  87588. * Gets the maximum value of the property when using in "slider" mode
  87589. */
  87590. max?: number;
  87591. /**
  87592. * Gets the setp to use when using in "slider" mode
  87593. */
  87594. step?: number;
  87595. }
  87596. }
  87597. declare module BABYLON {
  87598. /**
  87599. * Class used to provide helper for timing
  87600. */
  87601. export class TimingTools {
  87602. /**
  87603. * Polyfill for setImmediate
  87604. * @param action defines the action to execute after the current execution block
  87605. */
  87606. static SetImmediate(action: () => void): void;
  87607. }
  87608. }
  87609. declare module BABYLON {
  87610. /**
  87611. * Class used to enable instatition of objects by class name
  87612. */
  87613. export class InstantiationTools {
  87614. /**
  87615. * Use this object to register external classes like custom textures or material
  87616. * to allow the laoders to instantiate them
  87617. */
  87618. static RegisteredExternalClasses: {
  87619. [key: string]: Object;
  87620. };
  87621. /**
  87622. * Tries to instantiate a new object from a given class name
  87623. * @param className defines the class name to instantiate
  87624. * @returns the new object or null if the system was not able to do the instantiation
  87625. */
  87626. static Instantiate(className: string): any;
  87627. }
  87628. }
  87629. declare module BABYLON {
  87630. /**
  87631. * Define options used to create a depth texture
  87632. */
  87633. export class DepthTextureCreationOptions {
  87634. /** Specifies whether or not a stencil should be allocated in the texture */
  87635. generateStencil?: boolean;
  87636. /** Specifies whether or not bilinear filtering is enable on the texture */
  87637. bilinearFiltering?: boolean;
  87638. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  87639. comparisonFunction?: number;
  87640. /** Specifies if the created texture is a cube texture */
  87641. isCube?: boolean;
  87642. }
  87643. }
  87644. declare module BABYLON {
  87645. interface ThinEngine {
  87646. /**
  87647. * Creates a depth stencil cube texture.
  87648. * This is only available in WebGL 2.
  87649. * @param size The size of face edge in the cube texture.
  87650. * @param options The options defining the cube texture.
  87651. * @returns The cube texture
  87652. */
  87653. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  87654. /**
  87655. * Creates a cube texture
  87656. * @param rootUrl defines the url where the files to load is located
  87657. * @param scene defines the current scene
  87658. * @param files defines the list of files to load (1 per face)
  87659. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  87660. * @param onLoad defines an optional callback raised when the texture is loaded
  87661. * @param onError defines an optional callback raised if there is an issue to load the texture
  87662. * @param format defines the format of the data
  87663. * @param forcedExtension defines the extension to use to pick the right loader
  87664. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  87665. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  87666. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  87667. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  87668. * @returns the cube texture as an InternalTexture
  87669. */
  87670. 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;
  87671. /**
  87672. * Creates a cube texture
  87673. * @param rootUrl defines the url where the files to load is located
  87674. * @param scene defines the current scene
  87675. * @param files defines the list of files to load (1 per face)
  87676. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  87677. * @param onLoad defines an optional callback raised when the texture is loaded
  87678. * @param onError defines an optional callback raised if there is an issue to load the texture
  87679. * @param format defines the format of the data
  87680. * @param forcedExtension defines the extension to use to pick the right loader
  87681. * @returns the cube texture as an InternalTexture
  87682. */
  87683. 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;
  87684. /**
  87685. * Creates a cube texture
  87686. * @param rootUrl defines the url where the files to load is located
  87687. * @param scene defines the current scene
  87688. * @param files defines the list of files to load (1 per face)
  87689. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  87690. * @param onLoad defines an optional callback raised when the texture is loaded
  87691. * @param onError defines an optional callback raised if there is an issue to load the texture
  87692. * @param format defines the format of the data
  87693. * @param forcedExtension defines the extension to use to pick the right loader
  87694. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  87695. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  87696. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  87697. * @returns the cube texture as an InternalTexture
  87698. */
  87699. 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;
  87700. /** @hidden */
  87701. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  87702. /** @hidden */
  87703. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  87704. /** @hidden */
  87705. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  87706. /** @hidden */
  87707. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  87708. /**
  87709. * @hidden
  87710. */
  87711. _setCubeMapTextureParams(loadMipmap: boolean): void;
  87712. }
  87713. }
  87714. declare module BABYLON {
  87715. /**
  87716. * Class for creating a cube texture
  87717. */
  87718. export class CubeTexture extends BaseTexture {
  87719. private _delayedOnLoad;
  87720. /**
  87721. * Observable triggered once the texture has been loaded.
  87722. */
  87723. onLoadObservable: Observable<CubeTexture>;
  87724. /**
  87725. * The url of the texture
  87726. */
  87727. url: string;
  87728. /**
  87729. * Gets or sets the center of the bounding box associated with the cube texture.
  87730. * It must define where the camera used to render the texture was set
  87731. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  87732. */
  87733. boundingBoxPosition: Vector3;
  87734. private _boundingBoxSize;
  87735. /**
  87736. * Gets or sets the size of the bounding box associated with the cube texture
  87737. * When defined, the cubemap will switch to local mode
  87738. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  87739. * @example https://www.babylonjs-playground.com/#RNASML
  87740. */
  87741. set boundingBoxSize(value: Vector3);
  87742. /**
  87743. * Returns the bounding box size
  87744. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  87745. */
  87746. get boundingBoxSize(): Vector3;
  87747. protected _rotationY: number;
  87748. /**
  87749. * Sets texture matrix rotation angle around Y axis in radians.
  87750. */
  87751. set rotationY(value: number);
  87752. /**
  87753. * Gets texture matrix rotation angle around Y axis radians.
  87754. */
  87755. get rotationY(): number;
  87756. /**
  87757. * Are mip maps generated for this texture or not.
  87758. */
  87759. get noMipmap(): boolean;
  87760. private _noMipmap;
  87761. private _files;
  87762. protected _forcedExtension: Nullable<string>;
  87763. private _extensions;
  87764. private _textureMatrix;
  87765. private _format;
  87766. private _createPolynomials;
  87767. /**
  87768. * Creates a cube texture from an array of image urls
  87769. * @param files defines an array of image urls
  87770. * @param scene defines the hosting scene
  87771. * @param noMipmap specifies if mip maps are not used
  87772. * @returns a cube texture
  87773. */
  87774. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  87775. /**
  87776. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  87777. * @param url defines the url of the prefiltered texture
  87778. * @param scene defines the scene the texture is attached to
  87779. * @param forcedExtension defines the extension of the file if different from the url
  87780. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  87781. * @return the prefiltered texture
  87782. */
  87783. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  87784. /**
  87785. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  87786. * as prefiltered data.
  87787. * @param rootUrl defines the url of the texture or the root name of the six images
  87788. * @param null defines the scene or engine the texture is attached to
  87789. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  87790. * @param noMipmap defines if mipmaps should be created or not
  87791. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  87792. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  87793. * @param onError defines a callback triggered in case of error during load
  87794. * @param format defines the internal format to use for the texture once loaded
  87795. * @param prefiltered defines whether or not the texture is created from prefiltered data
  87796. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  87797. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  87798. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  87799. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  87800. * @return the cube texture
  87801. */
  87802. 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);
  87803. /**
  87804. * Get the current class name of the texture useful for serialization or dynamic coding.
  87805. * @returns "CubeTexture"
  87806. */
  87807. getClassName(): string;
  87808. /**
  87809. * Update the url (and optional buffer) of this texture if url was null during construction.
  87810. * @param url the url of the texture
  87811. * @param forcedExtension defines the extension to use
  87812. * @param onLoad callback called when the texture is loaded (defaults to null)
  87813. * @param prefiltered Defines whether the updated texture is prefiltered or not
  87814. */
  87815. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  87816. /**
  87817. * Delays loading of the cube texture
  87818. * @param forcedExtension defines the extension to use
  87819. */
  87820. delayLoad(forcedExtension?: string): void;
  87821. /**
  87822. * Returns the reflection texture matrix
  87823. * @returns the reflection texture matrix
  87824. */
  87825. getReflectionTextureMatrix(): Matrix;
  87826. /**
  87827. * Sets the reflection texture matrix
  87828. * @param value Reflection texture matrix
  87829. */
  87830. setReflectionTextureMatrix(value: Matrix): void;
  87831. /**
  87832. * Parses text to create a cube texture
  87833. * @param parsedTexture define the serialized text to read from
  87834. * @param scene defines the hosting scene
  87835. * @param rootUrl defines the root url of the cube texture
  87836. * @returns a cube texture
  87837. */
  87838. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  87839. /**
  87840. * Makes a clone, or deep copy, of the cube texture
  87841. * @returns a new cube texture
  87842. */
  87843. clone(): CubeTexture;
  87844. }
  87845. }
  87846. declare module BABYLON {
  87847. /**
  87848. * Manages the defines for the Material
  87849. */
  87850. export class MaterialDefines {
  87851. /** @hidden */
  87852. protected _keys: string[];
  87853. private _isDirty;
  87854. /** @hidden */
  87855. _renderId: number;
  87856. /** @hidden */
  87857. _areLightsDirty: boolean;
  87858. /** @hidden */
  87859. _areLightsDisposed: boolean;
  87860. /** @hidden */
  87861. _areAttributesDirty: boolean;
  87862. /** @hidden */
  87863. _areTexturesDirty: boolean;
  87864. /** @hidden */
  87865. _areFresnelDirty: boolean;
  87866. /** @hidden */
  87867. _areMiscDirty: boolean;
  87868. /** @hidden */
  87869. _areImageProcessingDirty: boolean;
  87870. /** @hidden */
  87871. _normals: boolean;
  87872. /** @hidden */
  87873. _uvs: boolean;
  87874. /** @hidden */
  87875. _needNormals: boolean;
  87876. /** @hidden */
  87877. _needUVs: boolean;
  87878. [id: string]: any;
  87879. /**
  87880. * Specifies if the material needs to be re-calculated
  87881. */
  87882. get isDirty(): boolean;
  87883. /**
  87884. * Marks the material to indicate that it has been re-calculated
  87885. */
  87886. markAsProcessed(): void;
  87887. /**
  87888. * Marks the material to indicate that it needs to be re-calculated
  87889. */
  87890. markAsUnprocessed(): void;
  87891. /**
  87892. * Marks the material to indicate all of its defines need to be re-calculated
  87893. */
  87894. markAllAsDirty(): void;
  87895. /**
  87896. * Marks the material to indicate that image processing needs to be re-calculated
  87897. */
  87898. markAsImageProcessingDirty(): void;
  87899. /**
  87900. * Marks the material to indicate the lights need to be re-calculated
  87901. * @param disposed Defines whether the light is dirty due to dispose or not
  87902. */
  87903. markAsLightDirty(disposed?: boolean): void;
  87904. /**
  87905. * Marks the attribute state as changed
  87906. */
  87907. markAsAttributesDirty(): void;
  87908. /**
  87909. * Marks the texture state as changed
  87910. */
  87911. markAsTexturesDirty(): void;
  87912. /**
  87913. * Marks the fresnel state as changed
  87914. */
  87915. markAsFresnelDirty(): void;
  87916. /**
  87917. * Marks the misc state as changed
  87918. */
  87919. markAsMiscDirty(): void;
  87920. /**
  87921. * Rebuilds the material defines
  87922. */
  87923. rebuild(): void;
  87924. /**
  87925. * Specifies if two material defines are equal
  87926. * @param other - A material define instance to compare to
  87927. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  87928. */
  87929. isEqual(other: MaterialDefines): boolean;
  87930. /**
  87931. * Clones this instance's defines to another instance
  87932. * @param other - material defines to clone values to
  87933. */
  87934. cloneTo(other: MaterialDefines): void;
  87935. /**
  87936. * Resets the material define values
  87937. */
  87938. reset(): void;
  87939. /**
  87940. * Converts the material define values to a string
  87941. * @returns - String of material define information
  87942. */
  87943. toString(): string;
  87944. }
  87945. }
  87946. declare module BABYLON {
  87947. /**
  87948. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  87949. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  87950. * 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;
  87951. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  87952. */
  87953. export class ColorCurves {
  87954. private _dirty;
  87955. private _tempColor;
  87956. private _globalCurve;
  87957. private _highlightsCurve;
  87958. private _midtonesCurve;
  87959. private _shadowsCurve;
  87960. private _positiveCurve;
  87961. private _negativeCurve;
  87962. private _globalHue;
  87963. private _globalDensity;
  87964. private _globalSaturation;
  87965. private _globalExposure;
  87966. /**
  87967. * Gets the global Hue value.
  87968. * 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).
  87969. */
  87970. get globalHue(): number;
  87971. /**
  87972. * Sets the global Hue value.
  87973. * 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).
  87974. */
  87975. set globalHue(value: number);
  87976. /**
  87977. * Gets the global Density value.
  87978. * 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.
  87979. * Values less than zero provide a filter of opposite hue.
  87980. */
  87981. get globalDensity(): number;
  87982. /**
  87983. * Sets the global Density value.
  87984. * 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.
  87985. * Values less than zero provide a filter of opposite hue.
  87986. */
  87987. set globalDensity(value: number);
  87988. /**
  87989. * Gets the global Saturation value.
  87990. * 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.
  87991. */
  87992. get globalSaturation(): number;
  87993. /**
  87994. * Sets the global Saturation value.
  87995. * 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.
  87996. */
  87997. set globalSaturation(value: number);
  87998. /**
  87999. * Gets the global Exposure value.
  88000. * 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.
  88001. */
  88002. get globalExposure(): number;
  88003. /**
  88004. * Sets the global Exposure value.
  88005. * 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.
  88006. */
  88007. set globalExposure(value: number);
  88008. private _highlightsHue;
  88009. private _highlightsDensity;
  88010. private _highlightsSaturation;
  88011. private _highlightsExposure;
  88012. /**
  88013. * Gets the highlights Hue value.
  88014. * 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).
  88015. */
  88016. get highlightsHue(): number;
  88017. /**
  88018. * Sets the highlights Hue value.
  88019. * 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).
  88020. */
  88021. set highlightsHue(value: number);
  88022. /**
  88023. * Gets the highlights Density value.
  88024. * 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.
  88025. * Values less than zero provide a filter of opposite hue.
  88026. */
  88027. get highlightsDensity(): number;
  88028. /**
  88029. * Sets the highlights Density value.
  88030. * 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.
  88031. * Values less than zero provide a filter of opposite hue.
  88032. */
  88033. set highlightsDensity(value: number);
  88034. /**
  88035. * Gets the highlights Saturation value.
  88036. * 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.
  88037. */
  88038. get highlightsSaturation(): number;
  88039. /**
  88040. * Sets the highlights Saturation value.
  88041. * 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.
  88042. */
  88043. set highlightsSaturation(value: number);
  88044. /**
  88045. * Gets the highlights Exposure value.
  88046. * 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.
  88047. */
  88048. get highlightsExposure(): number;
  88049. /**
  88050. * Sets the highlights Exposure value.
  88051. * 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.
  88052. */
  88053. set highlightsExposure(value: number);
  88054. private _midtonesHue;
  88055. private _midtonesDensity;
  88056. private _midtonesSaturation;
  88057. private _midtonesExposure;
  88058. /**
  88059. * Gets the midtones Hue value.
  88060. * 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).
  88061. */
  88062. get midtonesHue(): number;
  88063. /**
  88064. * Sets the midtones Hue value.
  88065. * 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).
  88066. */
  88067. set midtonesHue(value: number);
  88068. /**
  88069. * Gets the midtones Density value.
  88070. * 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.
  88071. * Values less than zero provide a filter of opposite hue.
  88072. */
  88073. get midtonesDensity(): number;
  88074. /**
  88075. * Sets the midtones Density value.
  88076. * 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.
  88077. * Values less than zero provide a filter of opposite hue.
  88078. */
  88079. set midtonesDensity(value: number);
  88080. /**
  88081. * Gets the midtones Saturation value.
  88082. * 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.
  88083. */
  88084. get midtonesSaturation(): number;
  88085. /**
  88086. * Sets the midtones Saturation value.
  88087. * 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.
  88088. */
  88089. set midtonesSaturation(value: number);
  88090. /**
  88091. * Gets the midtones Exposure value.
  88092. * 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.
  88093. */
  88094. get midtonesExposure(): number;
  88095. /**
  88096. * Sets the midtones Exposure value.
  88097. * 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.
  88098. */
  88099. set midtonesExposure(value: number);
  88100. private _shadowsHue;
  88101. private _shadowsDensity;
  88102. private _shadowsSaturation;
  88103. private _shadowsExposure;
  88104. /**
  88105. * Gets the shadows Hue value.
  88106. * 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).
  88107. */
  88108. get shadowsHue(): number;
  88109. /**
  88110. * Sets the shadows Hue value.
  88111. * 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).
  88112. */
  88113. set shadowsHue(value: number);
  88114. /**
  88115. * Gets the shadows Density value.
  88116. * 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.
  88117. * Values less than zero provide a filter of opposite hue.
  88118. */
  88119. get shadowsDensity(): number;
  88120. /**
  88121. * Sets the shadows Density value.
  88122. * 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.
  88123. * Values less than zero provide a filter of opposite hue.
  88124. */
  88125. set shadowsDensity(value: number);
  88126. /**
  88127. * Gets the shadows Saturation value.
  88128. * 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.
  88129. */
  88130. get shadowsSaturation(): number;
  88131. /**
  88132. * Sets the shadows Saturation value.
  88133. * 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.
  88134. */
  88135. set shadowsSaturation(value: number);
  88136. /**
  88137. * Gets the shadows Exposure value.
  88138. * 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.
  88139. */
  88140. get shadowsExposure(): number;
  88141. /**
  88142. * Sets the shadows Exposure value.
  88143. * 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.
  88144. */
  88145. set shadowsExposure(value: number);
  88146. /**
  88147. * Returns the class name
  88148. * @returns The class name
  88149. */
  88150. getClassName(): string;
  88151. /**
  88152. * Binds the color curves to the shader.
  88153. * @param colorCurves The color curve to bind
  88154. * @param effect The effect to bind to
  88155. * @param positiveUniform The positive uniform shader parameter
  88156. * @param neutralUniform The neutral uniform shader parameter
  88157. * @param negativeUniform The negative uniform shader parameter
  88158. */
  88159. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  88160. /**
  88161. * Prepare the list of uniforms associated with the ColorCurves effects.
  88162. * @param uniformsList The list of uniforms used in the effect
  88163. */
  88164. static PrepareUniforms(uniformsList: string[]): void;
  88165. /**
  88166. * Returns color grading data based on a hue, density, saturation and exposure value.
  88167. * @param filterHue The hue of the color filter.
  88168. * @param filterDensity The density of the color filter.
  88169. * @param saturation The saturation.
  88170. * @param exposure The exposure.
  88171. * @param result The result data container.
  88172. */
  88173. private getColorGradingDataToRef;
  88174. /**
  88175. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  88176. * @param value The input slider value in range [-100,100].
  88177. * @returns Adjusted value.
  88178. */
  88179. private static applyColorGradingSliderNonlinear;
  88180. /**
  88181. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  88182. * @param hue The hue (H) input.
  88183. * @param saturation The saturation (S) input.
  88184. * @param brightness The brightness (B) input.
  88185. * @result An RGBA color represented as Vector4.
  88186. */
  88187. private static fromHSBToRef;
  88188. /**
  88189. * Returns a value clamped between min and max
  88190. * @param value The value to clamp
  88191. * @param min The minimum of value
  88192. * @param max The maximum of value
  88193. * @returns The clamped value.
  88194. */
  88195. private static clamp;
  88196. /**
  88197. * Clones the current color curve instance.
  88198. * @return The cloned curves
  88199. */
  88200. clone(): ColorCurves;
  88201. /**
  88202. * Serializes the current color curve instance to a json representation.
  88203. * @return a JSON representation
  88204. */
  88205. serialize(): any;
  88206. /**
  88207. * Parses the color curve from a json representation.
  88208. * @param source the JSON source to parse
  88209. * @return The parsed curves
  88210. */
  88211. static Parse(source: any): ColorCurves;
  88212. }
  88213. }
  88214. declare module BABYLON {
  88215. /**
  88216. * Interface to follow in your material defines to integrate easily the
  88217. * Image proccessing functions.
  88218. * @hidden
  88219. */
  88220. export interface IImageProcessingConfigurationDefines {
  88221. IMAGEPROCESSING: boolean;
  88222. VIGNETTE: boolean;
  88223. VIGNETTEBLENDMODEMULTIPLY: boolean;
  88224. VIGNETTEBLENDMODEOPAQUE: boolean;
  88225. TONEMAPPING: boolean;
  88226. TONEMAPPING_ACES: boolean;
  88227. CONTRAST: boolean;
  88228. EXPOSURE: boolean;
  88229. COLORCURVES: boolean;
  88230. COLORGRADING: boolean;
  88231. COLORGRADING3D: boolean;
  88232. SAMPLER3DGREENDEPTH: boolean;
  88233. SAMPLER3DBGRMAP: boolean;
  88234. IMAGEPROCESSINGPOSTPROCESS: boolean;
  88235. }
  88236. /**
  88237. * @hidden
  88238. */
  88239. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  88240. IMAGEPROCESSING: boolean;
  88241. VIGNETTE: boolean;
  88242. VIGNETTEBLENDMODEMULTIPLY: boolean;
  88243. VIGNETTEBLENDMODEOPAQUE: boolean;
  88244. TONEMAPPING: boolean;
  88245. TONEMAPPING_ACES: boolean;
  88246. CONTRAST: boolean;
  88247. COLORCURVES: boolean;
  88248. COLORGRADING: boolean;
  88249. COLORGRADING3D: boolean;
  88250. SAMPLER3DGREENDEPTH: boolean;
  88251. SAMPLER3DBGRMAP: boolean;
  88252. IMAGEPROCESSINGPOSTPROCESS: boolean;
  88253. EXPOSURE: boolean;
  88254. constructor();
  88255. }
  88256. /**
  88257. * This groups together the common properties used for image processing either in direct forward pass
  88258. * or through post processing effect depending on the use of the image processing pipeline in your scene
  88259. * or not.
  88260. */
  88261. export class ImageProcessingConfiguration {
  88262. /**
  88263. * Default tone mapping applied in BabylonJS.
  88264. */
  88265. static readonly TONEMAPPING_STANDARD: number;
  88266. /**
  88267. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  88268. * to other engines rendering to increase portability.
  88269. */
  88270. static readonly TONEMAPPING_ACES: number;
  88271. /**
  88272. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  88273. */
  88274. colorCurves: Nullable<ColorCurves>;
  88275. private _colorCurvesEnabled;
  88276. /**
  88277. * Gets wether the color curves effect is enabled.
  88278. */
  88279. get colorCurvesEnabled(): boolean;
  88280. /**
  88281. * Sets wether the color curves effect is enabled.
  88282. */
  88283. set colorCurvesEnabled(value: boolean);
  88284. private _colorGradingTexture;
  88285. /**
  88286. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  88287. */
  88288. get colorGradingTexture(): Nullable<BaseTexture>;
  88289. /**
  88290. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  88291. */
  88292. set colorGradingTexture(value: Nullable<BaseTexture>);
  88293. private _colorGradingEnabled;
  88294. /**
  88295. * Gets wether the color grading effect is enabled.
  88296. */
  88297. get colorGradingEnabled(): boolean;
  88298. /**
  88299. * Sets wether the color grading effect is enabled.
  88300. */
  88301. set colorGradingEnabled(value: boolean);
  88302. private _colorGradingWithGreenDepth;
  88303. /**
  88304. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  88305. */
  88306. get colorGradingWithGreenDepth(): boolean;
  88307. /**
  88308. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  88309. */
  88310. set colorGradingWithGreenDepth(value: boolean);
  88311. private _colorGradingBGR;
  88312. /**
  88313. * Gets wether the color grading texture contains BGR values.
  88314. */
  88315. get colorGradingBGR(): boolean;
  88316. /**
  88317. * Sets wether the color grading texture contains BGR values.
  88318. */
  88319. set colorGradingBGR(value: boolean);
  88320. /** @hidden */
  88321. _exposure: number;
  88322. /**
  88323. * Gets the Exposure used in the effect.
  88324. */
  88325. get exposure(): number;
  88326. /**
  88327. * Sets the Exposure used in the effect.
  88328. */
  88329. set exposure(value: number);
  88330. private _toneMappingEnabled;
  88331. /**
  88332. * Gets wether the tone mapping effect is enabled.
  88333. */
  88334. get toneMappingEnabled(): boolean;
  88335. /**
  88336. * Sets wether the tone mapping effect is enabled.
  88337. */
  88338. set toneMappingEnabled(value: boolean);
  88339. private _toneMappingType;
  88340. /**
  88341. * Gets the type of tone mapping effect.
  88342. */
  88343. get toneMappingType(): number;
  88344. /**
  88345. * Sets the type of tone mapping effect used in BabylonJS.
  88346. */
  88347. set toneMappingType(value: number);
  88348. protected _contrast: number;
  88349. /**
  88350. * Gets the contrast used in the effect.
  88351. */
  88352. get contrast(): number;
  88353. /**
  88354. * Sets the contrast used in the effect.
  88355. */
  88356. set contrast(value: number);
  88357. /**
  88358. * Vignette stretch size.
  88359. */
  88360. vignetteStretch: number;
  88361. /**
  88362. * Vignette centre X Offset.
  88363. */
  88364. vignetteCentreX: number;
  88365. /**
  88366. * Vignette centre Y Offset.
  88367. */
  88368. vignetteCentreY: number;
  88369. /**
  88370. * Vignette weight or intensity of the vignette effect.
  88371. */
  88372. vignetteWeight: number;
  88373. /**
  88374. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  88375. * if vignetteEnabled is set to true.
  88376. */
  88377. vignetteColor: Color4;
  88378. /**
  88379. * Camera field of view used by the Vignette effect.
  88380. */
  88381. vignetteCameraFov: number;
  88382. private _vignetteBlendMode;
  88383. /**
  88384. * Gets the vignette blend mode allowing different kind of effect.
  88385. */
  88386. get vignetteBlendMode(): number;
  88387. /**
  88388. * Sets the vignette blend mode allowing different kind of effect.
  88389. */
  88390. set vignetteBlendMode(value: number);
  88391. private _vignetteEnabled;
  88392. /**
  88393. * Gets wether the vignette effect is enabled.
  88394. */
  88395. get vignetteEnabled(): boolean;
  88396. /**
  88397. * Sets wether the vignette effect is enabled.
  88398. */
  88399. set vignetteEnabled(value: boolean);
  88400. private _applyByPostProcess;
  88401. /**
  88402. * Gets wether the image processing is applied through a post process or not.
  88403. */
  88404. get applyByPostProcess(): boolean;
  88405. /**
  88406. * Sets wether the image processing is applied through a post process or not.
  88407. */
  88408. set applyByPostProcess(value: boolean);
  88409. private _isEnabled;
  88410. /**
  88411. * Gets wether the image processing is enabled or not.
  88412. */
  88413. get isEnabled(): boolean;
  88414. /**
  88415. * Sets wether the image processing is enabled or not.
  88416. */
  88417. set isEnabled(value: boolean);
  88418. /**
  88419. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  88420. */
  88421. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  88422. /**
  88423. * Method called each time the image processing information changes requires to recompile the effect.
  88424. */
  88425. protected _updateParameters(): void;
  88426. /**
  88427. * Gets the current class name.
  88428. * @return "ImageProcessingConfiguration"
  88429. */
  88430. getClassName(): string;
  88431. /**
  88432. * Prepare the list of uniforms associated with the Image Processing effects.
  88433. * @param uniforms The list of uniforms used in the effect
  88434. * @param defines the list of defines currently in use
  88435. */
  88436. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  88437. /**
  88438. * Prepare the list of samplers associated with the Image Processing effects.
  88439. * @param samplersList The list of uniforms used in the effect
  88440. * @param defines the list of defines currently in use
  88441. */
  88442. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  88443. /**
  88444. * Prepare the list of defines associated to the shader.
  88445. * @param defines the list of defines to complete
  88446. * @param forPostProcess Define if we are currently in post process mode or not
  88447. */
  88448. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  88449. /**
  88450. * Returns true if all the image processing information are ready.
  88451. * @returns True if ready, otherwise, false
  88452. */
  88453. isReady(): boolean;
  88454. /**
  88455. * Binds the image processing to the shader.
  88456. * @param effect The effect to bind to
  88457. * @param overrideAspectRatio Override the aspect ratio of the effect
  88458. */
  88459. bind(effect: Effect, overrideAspectRatio?: number): void;
  88460. /**
  88461. * Clones the current image processing instance.
  88462. * @return The cloned image processing
  88463. */
  88464. clone(): ImageProcessingConfiguration;
  88465. /**
  88466. * Serializes the current image processing instance to a json representation.
  88467. * @return a JSON representation
  88468. */
  88469. serialize(): any;
  88470. /**
  88471. * Parses the image processing from a json representation.
  88472. * @param source the JSON source to parse
  88473. * @return The parsed image processing
  88474. */
  88475. static Parse(source: any): ImageProcessingConfiguration;
  88476. private static _VIGNETTEMODE_MULTIPLY;
  88477. private static _VIGNETTEMODE_OPAQUE;
  88478. /**
  88479. * Used to apply the vignette as a mix with the pixel color.
  88480. */
  88481. static get VIGNETTEMODE_MULTIPLY(): number;
  88482. /**
  88483. * Used to apply the vignette as a replacement of the pixel color.
  88484. */
  88485. static get VIGNETTEMODE_OPAQUE(): number;
  88486. }
  88487. }
  88488. declare module BABYLON {
  88489. /** @hidden */
  88490. export var postprocessVertexShader: {
  88491. name: string;
  88492. shader: string;
  88493. };
  88494. }
  88495. declare module BABYLON {
  88496. /**
  88497. * Type used to define a render target texture size (either with a number or with a rect width and height)
  88498. */
  88499. export type RenderTargetTextureSize = number | {
  88500. width: number;
  88501. height: number;
  88502. layers?: number;
  88503. };
  88504. interface ThinEngine {
  88505. /**
  88506. * Creates a new render target texture
  88507. * @param size defines the size of the texture
  88508. * @param options defines the options used to create the texture
  88509. * @returns a new render target texture stored in an InternalTexture
  88510. */
  88511. createRenderTargetTexture(size: RenderTargetTextureSize, options: boolean | RenderTargetCreationOptions): InternalTexture;
  88512. /**
  88513. * Creates a depth stencil texture.
  88514. * This is only available in WebGL 2 or with the depth texture extension available.
  88515. * @param size The size of face edge in the texture.
  88516. * @param options The options defining the texture.
  88517. * @returns The texture
  88518. */
  88519. createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): InternalTexture;
  88520. /** @hidden */
  88521. _createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): InternalTexture;
  88522. }
  88523. }
  88524. declare module BABYLON {
  88525. /**
  88526. * Defines the kind of connection point for node based material
  88527. */
  88528. export enum NodeMaterialBlockConnectionPointTypes {
  88529. /** Float */
  88530. Float = 1,
  88531. /** Int */
  88532. Int = 2,
  88533. /** Vector2 */
  88534. Vector2 = 4,
  88535. /** Vector3 */
  88536. Vector3 = 8,
  88537. /** Vector4 */
  88538. Vector4 = 16,
  88539. /** Color3 */
  88540. Color3 = 32,
  88541. /** Color4 */
  88542. Color4 = 64,
  88543. /** Matrix */
  88544. Matrix = 128,
  88545. /** Custom object */
  88546. Object = 256,
  88547. /** Detect type based on connection */
  88548. AutoDetect = 1024,
  88549. /** Output type that will be defined by input type */
  88550. BasedOnInput = 2048
  88551. }
  88552. }
  88553. declare module BABYLON {
  88554. /**
  88555. * Enum used to define the target of a block
  88556. */
  88557. export enum NodeMaterialBlockTargets {
  88558. /** Vertex shader */
  88559. Vertex = 1,
  88560. /** Fragment shader */
  88561. Fragment = 2,
  88562. /** Neutral */
  88563. Neutral = 4,
  88564. /** Vertex and Fragment */
  88565. VertexAndFragment = 3
  88566. }
  88567. }
  88568. declare module BABYLON {
  88569. /**
  88570. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  88571. */
  88572. export enum NodeMaterialBlockConnectionPointMode {
  88573. /** Value is an uniform */
  88574. Uniform = 0,
  88575. /** Value is a mesh attribute */
  88576. Attribute = 1,
  88577. /** Value is a varying between vertex and fragment shaders */
  88578. Varying = 2,
  88579. /** Mode is undefined */
  88580. Undefined = 3
  88581. }
  88582. }
  88583. declare module BABYLON {
  88584. /**
  88585. * Enum used to define system values e.g. values automatically provided by the system
  88586. */
  88587. export enum NodeMaterialSystemValues {
  88588. /** World */
  88589. World = 1,
  88590. /** View */
  88591. View = 2,
  88592. /** Projection */
  88593. Projection = 3,
  88594. /** ViewProjection */
  88595. ViewProjection = 4,
  88596. /** WorldView */
  88597. WorldView = 5,
  88598. /** WorldViewProjection */
  88599. WorldViewProjection = 6,
  88600. /** CameraPosition */
  88601. CameraPosition = 7,
  88602. /** Fog Color */
  88603. FogColor = 8,
  88604. /** Delta time */
  88605. DeltaTime = 9
  88606. }
  88607. }
  88608. declare module BABYLON {
  88609. /** Defines supported spaces */
  88610. export enum Space {
  88611. /** Local (object) space */
  88612. LOCAL = 0,
  88613. /** World space */
  88614. WORLD = 1,
  88615. /** Bone space */
  88616. BONE = 2
  88617. }
  88618. /** Defines the 3 main axes */
  88619. export class Axis {
  88620. /** X axis */
  88621. static X: Vector3;
  88622. /** Y axis */
  88623. static Y: Vector3;
  88624. /** Z axis */
  88625. static Z: Vector3;
  88626. }
  88627. }
  88628. declare module BABYLON {
  88629. /**
  88630. * Represents a camera frustum
  88631. */
  88632. export class Frustum {
  88633. /**
  88634. * Gets the planes representing the frustum
  88635. * @param transform matrix to be applied to the returned planes
  88636. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  88637. */
  88638. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  88639. /**
  88640. * Gets the near frustum plane transformed by the transform matrix
  88641. * @param transform transformation matrix to be applied to the resulting frustum plane
  88642. * @param frustumPlane the resuling frustum plane
  88643. */
  88644. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  88645. /**
  88646. * Gets the far frustum plane transformed by the transform matrix
  88647. * @param transform transformation matrix to be applied to the resulting frustum plane
  88648. * @param frustumPlane the resuling frustum plane
  88649. */
  88650. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  88651. /**
  88652. * Gets the left frustum plane transformed by the transform matrix
  88653. * @param transform transformation matrix to be applied to the resulting frustum plane
  88654. * @param frustumPlane the resuling frustum plane
  88655. */
  88656. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  88657. /**
  88658. * Gets the right frustum plane transformed by the transform matrix
  88659. * @param transform transformation matrix to be applied to the resulting frustum plane
  88660. * @param frustumPlane the resuling frustum plane
  88661. */
  88662. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  88663. /**
  88664. * Gets the top frustum plane transformed by the transform matrix
  88665. * @param transform transformation matrix to be applied to the resulting frustum plane
  88666. * @param frustumPlane the resuling frustum plane
  88667. */
  88668. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  88669. /**
  88670. * Gets the bottom frustum plane transformed by the transform matrix
  88671. * @param transform transformation matrix to be applied to the resulting frustum plane
  88672. * @param frustumPlane the resuling frustum plane
  88673. */
  88674. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  88675. /**
  88676. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  88677. * @param transform transformation matrix to be applied to the resulting frustum planes
  88678. * @param frustumPlanes the resuling frustum planes
  88679. */
  88680. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  88681. }
  88682. }
  88683. declare module BABYLON {
  88684. /**
  88685. * Interface for the size containing width and height
  88686. */
  88687. export interface ISize {
  88688. /**
  88689. * Width
  88690. */
  88691. width: number;
  88692. /**
  88693. * Heighht
  88694. */
  88695. height: number;
  88696. }
  88697. /**
  88698. * Size containing widht and height
  88699. */
  88700. export class Size implements ISize {
  88701. /**
  88702. * Width
  88703. */
  88704. width: number;
  88705. /**
  88706. * Height
  88707. */
  88708. height: number;
  88709. /**
  88710. * Creates a Size object from the given width and height (floats).
  88711. * @param width width of the new size
  88712. * @param height height of the new size
  88713. */
  88714. constructor(width: number, height: number);
  88715. /**
  88716. * Returns a string with the Size width and height
  88717. * @returns a string with the Size width and height
  88718. */
  88719. toString(): string;
  88720. /**
  88721. * "Size"
  88722. * @returns the string "Size"
  88723. */
  88724. getClassName(): string;
  88725. /**
  88726. * Returns the Size hash code.
  88727. * @returns a hash code for a unique width and height
  88728. */
  88729. getHashCode(): number;
  88730. /**
  88731. * Updates the current size from the given one.
  88732. * @param src the given size
  88733. */
  88734. copyFrom(src: Size): void;
  88735. /**
  88736. * Updates in place the current Size from the given floats.
  88737. * @param width width of the new size
  88738. * @param height height of the new size
  88739. * @returns the updated Size.
  88740. */
  88741. copyFromFloats(width: number, height: number): Size;
  88742. /**
  88743. * Updates in place the current Size from the given floats.
  88744. * @param width width to set
  88745. * @param height height to set
  88746. * @returns the updated Size.
  88747. */
  88748. set(width: number, height: number): Size;
  88749. /**
  88750. * Multiplies the width and height by numbers
  88751. * @param w factor to multiple the width by
  88752. * @param h factor to multiple the height by
  88753. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  88754. */
  88755. multiplyByFloats(w: number, h: number): Size;
  88756. /**
  88757. * Clones the size
  88758. * @returns a new Size copied from the given one.
  88759. */
  88760. clone(): Size;
  88761. /**
  88762. * True if the current Size and the given one width and height are strictly equal.
  88763. * @param other the other size to compare against
  88764. * @returns True if the current Size and the given one width and height are strictly equal.
  88765. */
  88766. equals(other: Size): boolean;
  88767. /**
  88768. * The surface of the Size : width * height (float).
  88769. */
  88770. get surface(): number;
  88771. /**
  88772. * Create a new size of zero
  88773. * @returns a new Size set to (0.0, 0.0)
  88774. */
  88775. static Zero(): Size;
  88776. /**
  88777. * Sums the width and height of two sizes
  88778. * @param otherSize size to add to this size
  88779. * @returns a new Size set as the addition result of the current Size and the given one.
  88780. */
  88781. add(otherSize: Size): Size;
  88782. /**
  88783. * Subtracts the width and height of two
  88784. * @param otherSize size to subtract to this size
  88785. * @returns a new Size set as the subtraction result of the given one from the current Size.
  88786. */
  88787. subtract(otherSize: Size): Size;
  88788. /**
  88789. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  88790. * @param start starting size to lerp between
  88791. * @param end end size to lerp between
  88792. * @param amount amount to lerp between the start and end values
  88793. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  88794. */
  88795. static Lerp(start: Size, end: Size, amount: number): Size;
  88796. }
  88797. }
  88798. declare module BABYLON {
  88799. /**
  88800. * Contains position and normal vectors for a vertex
  88801. */
  88802. export class PositionNormalVertex {
  88803. /** the position of the vertex (defaut: 0,0,0) */
  88804. position: Vector3;
  88805. /** the normal of the vertex (defaut: 0,1,0) */
  88806. normal: Vector3;
  88807. /**
  88808. * Creates a PositionNormalVertex
  88809. * @param position the position of the vertex (defaut: 0,0,0)
  88810. * @param normal the normal of the vertex (defaut: 0,1,0)
  88811. */
  88812. constructor(
  88813. /** the position of the vertex (defaut: 0,0,0) */
  88814. position?: Vector3,
  88815. /** the normal of the vertex (defaut: 0,1,0) */
  88816. normal?: Vector3);
  88817. /**
  88818. * Clones the PositionNormalVertex
  88819. * @returns the cloned PositionNormalVertex
  88820. */
  88821. clone(): PositionNormalVertex;
  88822. }
  88823. /**
  88824. * Contains position, normal and uv vectors for a vertex
  88825. */
  88826. export class PositionNormalTextureVertex {
  88827. /** the position of the vertex (defaut: 0,0,0) */
  88828. position: Vector3;
  88829. /** the normal of the vertex (defaut: 0,1,0) */
  88830. normal: Vector3;
  88831. /** the uv of the vertex (default: 0,0) */
  88832. uv: Vector2;
  88833. /**
  88834. * Creates a PositionNormalTextureVertex
  88835. * @param position the position of the vertex (defaut: 0,0,0)
  88836. * @param normal the normal of the vertex (defaut: 0,1,0)
  88837. * @param uv the uv of the vertex (default: 0,0)
  88838. */
  88839. constructor(
  88840. /** the position of the vertex (defaut: 0,0,0) */
  88841. position?: Vector3,
  88842. /** the normal of the vertex (defaut: 0,1,0) */
  88843. normal?: Vector3,
  88844. /** the uv of the vertex (default: 0,0) */
  88845. uv?: Vector2);
  88846. /**
  88847. * Clones the PositionNormalTextureVertex
  88848. * @returns the cloned PositionNormalTextureVertex
  88849. */
  88850. clone(): PositionNormalTextureVertex;
  88851. }
  88852. }
  88853. declare module BABYLON {
  88854. /**
  88855. * Enum defining the type of animations supported by InputBlock
  88856. */
  88857. export enum AnimatedInputBlockTypes {
  88858. /** No animation */
  88859. None = 0,
  88860. /** Time based animation. Will only work for floats */
  88861. Time = 1
  88862. }
  88863. }
  88864. declare module BABYLON {
  88865. /**
  88866. * Interface describing all the common properties and methods a shadow light needs to implement.
  88867. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  88868. * as well as binding the different shadow properties to the effects.
  88869. */
  88870. export interface IShadowLight extends Light {
  88871. /**
  88872. * The light id in the scene (used in scene.findLighById for instance)
  88873. */
  88874. id: string;
  88875. /**
  88876. * The position the shdow will be casted from.
  88877. */
  88878. position: Vector3;
  88879. /**
  88880. * In 2d mode (needCube being false), the direction used to cast the shadow.
  88881. */
  88882. direction: Vector3;
  88883. /**
  88884. * The transformed position. Position of the light in world space taking parenting in account.
  88885. */
  88886. transformedPosition: Vector3;
  88887. /**
  88888. * The transformed direction. Direction of the light in world space taking parenting in account.
  88889. */
  88890. transformedDirection: Vector3;
  88891. /**
  88892. * The friendly name of the light in the scene.
  88893. */
  88894. name: string;
  88895. /**
  88896. * Defines the shadow projection clipping minimum z value.
  88897. */
  88898. shadowMinZ: number;
  88899. /**
  88900. * Defines the shadow projection clipping maximum z value.
  88901. */
  88902. shadowMaxZ: number;
  88903. /**
  88904. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  88905. * @returns true if the information has been computed, false if it does not need to (no parenting)
  88906. */
  88907. computeTransformedInformation(): boolean;
  88908. /**
  88909. * Gets the scene the light belongs to.
  88910. * @returns The scene
  88911. */
  88912. getScene(): Scene;
  88913. /**
  88914. * Callback defining a custom Projection Matrix Builder.
  88915. * This can be used to override the default projection matrix computation.
  88916. */
  88917. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  88918. /**
  88919. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  88920. * @param matrix The materix to updated with the projection information
  88921. * @param viewMatrix The transform matrix of the light
  88922. * @param renderList The list of mesh to render in the map
  88923. * @returns The current light
  88924. */
  88925. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  88926. /**
  88927. * Gets the current depth scale used in ESM.
  88928. * @returns The scale
  88929. */
  88930. getDepthScale(): number;
  88931. /**
  88932. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  88933. * @returns true if a cube texture needs to be use
  88934. */
  88935. needCube(): boolean;
  88936. /**
  88937. * Detects if the projection matrix requires to be recomputed this frame.
  88938. * @returns true if it requires to be recomputed otherwise, false.
  88939. */
  88940. needProjectionMatrixCompute(): boolean;
  88941. /**
  88942. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  88943. */
  88944. forceProjectionMatrixCompute(): void;
  88945. /**
  88946. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  88947. * @param faceIndex The index of the face we are computed the direction to generate shadow
  88948. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  88949. */
  88950. getShadowDirection(faceIndex?: number): Vector3;
  88951. /**
  88952. * Gets the minZ used for shadow according to both the scene and the light.
  88953. * @param activeCamera The camera we are returning the min for
  88954. * @returns the depth min z
  88955. */
  88956. getDepthMinZ(activeCamera: Camera): number;
  88957. /**
  88958. * Gets the maxZ used for shadow according to both the scene and the light.
  88959. * @param activeCamera The camera we are returning the max for
  88960. * @returns the depth max z
  88961. */
  88962. getDepthMaxZ(activeCamera: Camera): number;
  88963. }
  88964. /**
  88965. * Base implementation IShadowLight
  88966. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  88967. */
  88968. export abstract class ShadowLight extends Light implements IShadowLight {
  88969. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  88970. protected _position: Vector3;
  88971. protected _setPosition(value: Vector3): void;
  88972. /**
  88973. * Sets the position the shadow will be casted from. Also use as the light position for both
  88974. * point and spot lights.
  88975. */
  88976. get position(): Vector3;
  88977. /**
  88978. * Sets the position the shadow will be casted from. Also use as the light position for both
  88979. * point and spot lights.
  88980. */
  88981. set position(value: Vector3);
  88982. protected _direction: Vector3;
  88983. protected _setDirection(value: Vector3): void;
  88984. /**
  88985. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  88986. * Also use as the light direction on spot and directional lights.
  88987. */
  88988. get direction(): Vector3;
  88989. /**
  88990. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  88991. * Also use as the light direction on spot and directional lights.
  88992. */
  88993. set direction(value: Vector3);
  88994. protected _shadowMinZ: number;
  88995. /**
  88996. * Gets the shadow projection clipping minimum z value.
  88997. */
  88998. get shadowMinZ(): number;
  88999. /**
  89000. * Sets the shadow projection clipping minimum z value.
  89001. */
  89002. set shadowMinZ(value: number);
  89003. protected _shadowMaxZ: number;
  89004. /**
  89005. * Sets the shadow projection clipping maximum z value.
  89006. */
  89007. get shadowMaxZ(): number;
  89008. /**
  89009. * Gets the shadow projection clipping maximum z value.
  89010. */
  89011. set shadowMaxZ(value: number);
  89012. /**
  89013. * Callback defining a custom Projection Matrix Builder.
  89014. * This can be used to override the default projection matrix computation.
  89015. */
  89016. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  89017. /**
  89018. * The transformed position. Position of the light in world space taking parenting in account.
  89019. */
  89020. transformedPosition: Vector3;
  89021. /**
  89022. * The transformed direction. Direction of the light in world space taking parenting in account.
  89023. */
  89024. transformedDirection: Vector3;
  89025. private _needProjectionMatrixCompute;
  89026. /**
  89027. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  89028. * @returns true if the information has been computed, false if it does not need to (no parenting)
  89029. */
  89030. computeTransformedInformation(): boolean;
  89031. /**
  89032. * Return the depth scale used for the shadow map.
  89033. * @returns the depth scale.
  89034. */
  89035. getDepthScale(): number;
  89036. /**
  89037. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  89038. * @param faceIndex The index of the face we are computed the direction to generate shadow
  89039. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  89040. */
  89041. getShadowDirection(faceIndex?: number): Vector3;
  89042. /**
  89043. * Returns the ShadowLight absolute position in the World.
  89044. * @returns the position vector in world space
  89045. */
  89046. getAbsolutePosition(): Vector3;
  89047. /**
  89048. * Sets the ShadowLight direction toward the passed target.
  89049. * @param target The point to target in local space
  89050. * @returns the updated ShadowLight direction
  89051. */
  89052. setDirectionToTarget(target: Vector3): Vector3;
  89053. /**
  89054. * Returns the light rotation in euler definition.
  89055. * @returns the x y z rotation in local space.
  89056. */
  89057. getRotation(): Vector3;
  89058. /**
  89059. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  89060. * @returns true if a cube texture needs to be use
  89061. */
  89062. needCube(): boolean;
  89063. /**
  89064. * Detects if the projection matrix requires to be recomputed this frame.
  89065. * @returns true if it requires to be recomputed otherwise, false.
  89066. */
  89067. needProjectionMatrixCompute(): boolean;
  89068. /**
  89069. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  89070. */
  89071. forceProjectionMatrixCompute(): void;
  89072. /** @hidden */
  89073. _initCache(): void;
  89074. /** @hidden */
  89075. _isSynchronized(): boolean;
  89076. /**
  89077. * Computes the world matrix of the node
  89078. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  89079. * @returns the world matrix
  89080. */
  89081. computeWorldMatrix(force?: boolean): Matrix;
  89082. /**
  89083. * Gets the minZ used for shadow according to both the scene and the light.
  89084. * @param activeCamera The camera we are returning the min for
  89085. * @returns the depth min z
  89086. */
  89087. getDepthMinZ(activeCamera: Camera): number;
  89088. /**
  89089. * Gets the maxZ used for shadow according to both the scene and the light.
  89090. * @param activeCamera The camera we are returning the max for
  89091. * @returns the depth max z
  89092. */
  89093. getDepthMaxZ(activeCamera: Camera): number;
  89094. /**
  89095. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  89096. * @param matrix The materix to updated with the projection information
  89097. * @param viewMatrix The transform matrix of the light
  89098. * @param renderList The list of mesh to render in the map
  89099. * @returns The current light
  89100. */
  89101. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  89102. }
  89103. }
  89104. declare module BABYLON {
  89105. /** @hidden */
  89106. export var packingFunctions: {
  89107. name: string;
  89108. shader: string;
  89109. };
  89110. }
  89111. declare module BABYLON {
  89112. /** @hidden */
  89113. export var bayerDitherFunctions: {
  89114. name: string;
  89115. shader: string;
  89116. };
  89117. }
  89118. declare module BABYLON {
  89119. /** @hidden */
  89120. export var shadowMapFragmentDeclaration: {
  89121. name: string;
  89122. shader: string;
  89123. };
  89124. }
  89125. declare module BABYLON {
  89126. /** @hidden */
  89127. export var clipPlaneFragmentDeclaration: {
  89128. name: string;
  89129. shader: string;
  89130. };
  89131. }
  89132. declare module BABYLON {
  89133. /** @hidden */
  89134. export var clipPlaneFragment: {
  89135. name: string;
  89136. shader: string;
  89137. };
  89138. }
  89139. declare module BABYLON {
  89140. /** @hidden */
  89141. export var shadowMapFragment: {
  89142. name: string;
  89143. shader: string;
  89144. };
  89145. }
  89146. declare module BABYLON {
  89147. /** @hidden */
  89148. export var shadowMapPixelShader: {
  89149. name: string;
  89150. shader: string;
  89151. };
  89152. }
  89153. declare module BABYLON {
  89154. /** @hidden */
  89155. export var bonesDeclaration: {
  89156. name: string;
  89157. shader: string;
  89158. };
  89159. }
  89160. declare module BABYLON {
  89161. /** @hidden */
  89162. export var morphTargetsVertexGlobalDeclaration: {
  89163. name: string;
  89164. shader: string;
  89165. };
  89166. }
  89167. declare module BABYLON {
  89168. /** @hidden */
  89169. export var morphTargetsVertexDeclaration: {
  89170. name: string;
  89171. shader: string;
  89172. };
  89173. }
  89174. declare module BABYLON {
  89175. /** @hidden */
  89176. export var instancesDeclaration: {
  89177. name: string;
  89178. shader: string;
  89179. };
  89180. }
  89181. declare module BABYLON {
  89182. /** @hidden */
  89183. export var helperFunctions: {
  89184. name: string;
  89185. shader: string;
  89186. };
  89187. }
  89188. declare module BABYLON {
  89189. /** @hidden */
  89190. export var shadowMapVertexDeclaration: {
  89191. name: string;
  89192. shader: string;
  89193. };
  89194. }
  89195. declare module BABYLON {
  89196. /** @hidden */
  89197. export var clipPlaneVertexDeclaration: {
  89198. name: string;
  89199. shader: string;
  89200. };
  89201. }
  89202. declare module BABYLON {
  89203. /** @hidden */
  89204. export var morphTargetsVertex: {
  89205. name: string;
  89206. shader: string;
  89207. };
  89208. }
  89209. declare module BABYLON {
  89210. /** @hidden */
  89211. export var instancesVertex: {
  89212. name: string;
  89213. shader: string;
  89214. };
  89215. }
  89216. declare module BABYLON {
  89217. /** @hidden */
  89218. export var bonesVertex: {
  89219. name: string;
  89220. shader: string;
  89221. };
  89222. }
  89223. declare module BABYLON {
  89224. /** @hidden */
  89225. export var shadowMapVertexNormalBias: {
  89226. name: string;
  89227. shader: string;
  89228. };
  89229. }
  89230. declare module BABYLON {
  89231. /** @hidden */
  89232. export var shadowMapVertexMetric: {
  89233. name: string;
  89234. shader: string;
  89235. };
  89236. }
  89237. declare module BABYLON {
  89238. /** @hidden */
  89239. export var clipPlaneVertex: {
  89240. name: string;
  89241. shader: string;
  89242. };
  89243. }
  89244. declare module BABYLON {
  89245. /** @hidden */
  89246. export var shadowMapVertexShader: {
  89247. name: string;
  89248. shader: string;
  89249. };
  89250. }
  89251. declare module BABYLON {
  89252. /** @hidden */
  89253. export var depthBoxBlurPixelShader: {
  89254. name: string;
  89255. shader: string;
  89256. };
  89257. }
  89258. declare module BABYLON {
  89259. /** @hidden */
  89260. export var shadowMapFragmentSoftTransparentShadow: {
  89261. name: string;
  89262. shader: string;
  89263. };
  89264. }
  89265. declare module BABYLON {
  89266. /**
  89267. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  89268. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  89269. */
  89270. export class EffectFallbacks implements IEffectFallbacks {
  89271. private _defines;
  89272. private _currentRank;
  89273. private _maxRank;
  89274. private _mesh;
  89275. /**
  89276. * Removes the fallback from the bound mesh.
  89277. */
  89278. unBindMesh(): void;
  89279. /**
  89280. * Adds a fallback on the specified property.
  89281. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  89282. * @param define The name of the define in the shader
  89283. */
  89284. addFallback(rank: number, define: string): void;
  89285. /**
  89286. * Sets the mesh to use CPU skinning when needing to fallback.
  89287. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  89288. * @param mesh The mesh to use the fallbacks.
  89289. */
  89290. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  89291. /**
  89292. * Checks to see if more fallbacks are still availible.
  89293. */
  89294. get hasMoreFallbacks(): boolean;
  89295. /**
  89296. * Removes the defines that should be removed when falling back.
  89297. * @param currentDefines defines the current define statements for the shader.
  89298. * @param effect defines the current effect we try to compile
  89299. * @returns The resulting defines with defines of the current rank removed.
  89300. */
  89301. reduce(currentDefines: string, effect: Effect): string;
  89302. }
  89303. }
  89304. declare module BABYLON {
  89305. /**
  89306. * Interface used to define Action
  89307. */
  89308. export interface IAction {
  89309. /**
  89310. * Trigger for the action
  89311. */
  89312. trigger: number;
  89313. /** Options of the trigger */
  89314. triggerOptions: any;
  89315. /**
  89316. * Gets the trigger parameters
  89317. * @returns the trigger parameters
  89318. */
  89319. getTriggerParameter(): any;
  89320. /**
  89321. * Internal only - executes current action event
  89322. * @hidden
  89323. */
  89324. _executeCurrent(evt?: ActionEvent): void;
  89325. /**
  89326. * Serialize placeholder for child classes
  89327. * @param parent of child
  89328. * @returns the serialized object
  89329. */
  89330. serialize(parent: any): any;
  89331. /**
  89332. * Internal only
  89333. * @hidden
  89334. */
  89335. _prepare(): void;
  89336. /**
  89337. * Internal only - manager for action
  89338. * @hidden
  89339. */
  89340. _actionManager: Nullable<AbstractActionManager>;
  89341. /**
  89342. * Adds action to chain of actions, may be a DoNothingAction
  89343. * @param action defines the next action to execute
  89344. * @returns The action passed in
  89345. * @see https://www.babylonjs-playground.com/#1T30HR#0
  89346. */
  89347. then(action: IAction): IAction;
  89348. }
  89349. /**
  89350. * The action to be carried out following a trigger
  89351. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  89352. */
  89353. export class Action implements IAction {
  89354. /** the trigger, with or without parameters, for the action */
  89355. triggerOptions: any;
  89356. /**
  89357. * Trigger for the action
  89358. */
  89359. trigger: number;
  89360. /**
  89361. * Internal only - manager for action
  89362. * @hidden
  89363. */
  89364. _actionManager: ActionManager;
  89365. private _nextActiveAction;
  89366. private _child;
  89367. private _condition?;
  89368. private _triggerParameter;
  89369. /**
  89370. * An event triggered prior to action being executed.
  89371. */
  89372. onBeforeExecuteObservable: Observable<Action>;
  89373. /**
  89374. * Creates a new Action
  89375. * @param triggerOptions the trigger, with or without parameters, for the action
  89376. * @param condition an optional determinant of action
  89377. */
  89378. constructor(
  89379. /** the trigger, with or without parameters, for the action */
  89380. triggerOptions: any, condition?: Condition);
  89381. /**
  89382. * Internal only
  89383. * @hidden
  89384. */
  89385. _prepare(): void;
  89386. /**
  89387. * Gets the trigger parameters
  89388. * @returns the trigger parameters
  89389. */
  89390. getTriggerParameter(): any;
  89391. /**
  89392. * Internal only - executes current action event
  89393. * @hidden
  89394. */
  89395. _executeCurrent(evt?: ActionEvent): void;
  89396. /**
  89397. * Execute placeholder for child classes
  89398. * @param evt optional action event
  89399. */
  89400. execute(evt?: ActionEvent): void;
  89401. /**
  89402. * Skips to next active action
  89403. */
  89404. skipToNextActiveAction(): void;
  89405. /**
  89406. * Adds action to chain of actions, may be a DoNothingAction
  89407. * @param action defines the next action to execute
  89408. * @returns The action passed in
  89409. * @see https://www.babylonjs-playground.com/#1T30HR#0
  89410. */
  89411. then(action: Action): Action;
  89412. /**
  89413. * Internal only
  89414. * @hidden
  89415. */
  89416. _getProperty(propertyPath: string): string;
  89417. /**
  89418. * Internal only
  89419. * @hidden
  89420. */
  89421. _getEffectiveTarget(target: any, propertyPath: string): any;
  89422. /**
  89423. * Serialize placeholder for child classes
  89424. * @param parent of child
  89425. * @returns the serialized object
  89426. */
  89427. serialize(parent: any): any;
  89428. /**
  89429. * Internal only called by serialize
  89430. * @hidden
  89431. */
  89432. protected _serialize(serializedAction: any, parent?: any): any;
  89433. /**
  89434. * Internal only
  89435. * @hidden
  89436. */
  89437. static _SerializeValueAsString: (value: any) => string;
  89438. /**
  89439. * Internal only
  89440. * @hidden
  89441. */
  89442. static _GetTargetProperty: (target: Scene | Node) => {
  89443. name: string;
  89444. targetType: string;
  89445. value: string;
  89446. };
  89447. }
  89448. }
  89449. declare module BABYLON {
  89450. /**
  89451. * A Condition applied to an Action
  89452. */
  89453. export class Condition {
  89454. /**
  89455. * Internal only - manager for action
  89456. * @hidden
  89457. */
  89458. _actionManager: ActionManager;
  89459. /**
  89460. * Internal only
  89461. * @hidden
  89462. */
  89463. _evaluationId: number;
  89464. /**
  89465. * Internal only
  89466. * @hidden
  89467. */
  89468. _currentResult: boolean;
  89469. /**
  89470. * Creates a new Condition
  89471. * @param actionManager the manager of the action the condition is applied to
  89472. */
  89473. constructor(actionManager: ActionManager);
  89474. /**
  89475. * Check if the current condition is valid
  89476. * @returns a boolean
  89477. */
  89478. isValid(): boolean;
  89479. /**
  89480. * Internal only
  89481. * @hidden
  89482. */
  89483. _getProperty(propertyPath: string): string;
  89484. /**
  89485. * Internal only
  89486. * @hidden
  89487. */
  89488. _getEffectiveTarget(target: any, propertyPath: string): any;
  89489. /**
  89490. * Serialize placeholder for child classes
  89491. * @returns the serialized object
  89492. */
  89493. serialize(): any;
  89494. /**
  89495. * Internal only
  89496. * @hidden
  89497. */
  89498. protected _serialize(serializedCondition: any): any;
  89499. }
  89500. /**
  89501. * Defines specific conditional operators as extensions of Condition
  89502. */
  89503. export class ValueCondition extends Condition {
  89504. /** path to specify the property of the target the conditional operator uses */
  89505. propertyPath: string;
  89506. /** the value compared by the conditional operator against the current value of the property */
  89507. value: any;
  89508. /** the conditional operator, default ValueCondition.IsEqual */
  89509. operator: number;
  89510. /**
  89511. * Internal only
  89512. * @hidden
  89513. */
  89514. private static _IsEqual;
  89515. /**
  89516. * Internal only
  89517. * @hidden
  89518. */
  89519. private static _IsDifferent;
  89520. /**
  89521. * Internal only
  89522. * @hidden
  89523. */
  89524. private static _IsGreater;
  89525. /**
  89526. * Internal only
  89527. * @hidden
  89528. */
  89529. private static _IsLesser;
  89530. /**
  89531. * returns the number for IsEqual
  89532. */
  89533. static get IsEqual(): number;
  89534. /**
  89535. * Returns the number for IsDifferent
  89536. */
  89537. static get IsDifferent(): number;
  89538. /**
  89539. * Returns the number for IsGreater
  89540. */
  89541. static get IsGreater(): number;
  89542. /**
  89543. * Returns the number for IsLesser
  89544. */
  89545. static get IsLesser(): number;
  89546. /**
  89547. * Internal only The action manager for the condition
  89548. * @hidden
  89549. */
  89550. _actionManager: ActionManager;
  89551. /**
  89552. * Internal only
  89553. * @hidden
  89554. */
  89555. private _target;
  89556. /**
  89557. * Internal only
  89558. * @hidden
  89559. */
  89560. private _effectiveTarget;
  89561. /**
  89562. * Internal only
  89563. * @hidden
  89564. */
  89565. private _property;
  89566. /**
  89567. * Creates a new ValueCondition
  89568. * @param actionManager manager for the action the condition applies to
  89569. * @param target for the action
  89570. * @param propertyPath path to specify the property of the target the conditional operator uses
  89571. * @param value the value compared by the conditional operator against the current value of the property
  89572. * @param operator the conditional operator, default ValueCondition.IsEqual
  89573. */
  89574. constructor(actionManager: ActionManager, target: any,
  89575. /** path to specify the property of the target the conditional operator uses */
  89576. propertyPath: string,
  89577. /** the value compared by the conditional operator against the current value of the property */
  89578. value: any,
  89579. /** the conditional operator, default ValueCondition.IsEqual */
  89580. operator?: number);
  89581. /**
  89582. * Compares the given value with the property value for the specified conditional operator
  89583. * @returns the result of the comparison
  89584. */
  89585. isValid(): boolean;
  89586. /**
  89587. * Serialize the ValueCondition into a JSON compatible object
  89588. * @returns serialization object
  89589. */
  89590. serialize(): any;
  89591. /**
  89592. * Gets the name of the conditional operator for the ValueCondition
  89593. * @param operator the conditional operator
  89594. * @returns the name
  89595. */
  89596. static GetOperatorName(operator: number): string;
  89597. }
  89598. /**
  89599. * Defines a predicate condition as an extension of Condition
  89600. */
  89601. export class PredicateCondition extends Condition {
  89602. /** defines the predicate function used to validate the condition */
  89603. predicate: () => boolean;
  89604. /**
  89605. * Internal only - manager for action
  89606. * @hidden
  89607. */
  89608. _actionManager: ActionManager;
  89609. /**
  89610. * Creates a new PredicateCondition
  89611. * @param actionManager manager for the action the condition applies to
  89612. * @param predicate defines the predicate function used to validate the condition
  89613. */
  89614. constructor(actionManager: ActionManager,
  89615. /** defines the predicate function used to validate the condition */
  89616. predicate: () => boolean);
  89617. /**
  89618. * @returns the validity of the predicate condition
  89619. */
  89620. isValid(): boolean;
  89621. }
  89622. /**
  89623. * Defines a state condition as an extension of Condition
  89624. */
  89625. export class StateCondition extends Condition {
  89626. /** Value to compare with target state */
  89627. value: string;
  89628. /**
  89629. * Internal only - manager for action
  89630. * @hidden
  89631. */
  89632. _actionManager: ActionManager;
  89633. /**
  89634. * Internal only
  89635. * @hidden
  89636. */
  89637. private _target;
  89638. /**
  89639. * Creates a new StateCondition
  89640. * @param actionManager manager for the action the condition applies to
  89641. * @param target of the condition
  89642. * @param value to compare with target state
  89643. */
  89644. constructor(actionManager: ActionManager, target: any,
  89645. /** Value to compare with target state */
  89646. value: string);
  89647. /**
  89648. * Gets a boolean indicating if the current condition is met
  89649. * @returns the validity of the state
  89650. */
  89651. isValid(): boolean;
  89652. /**
  89653. * Serialize the StateCondition into a JSON compatible object
  89654. * @returns serialization object
  89655. */
  89656. serialize(): any;
  89657. }
  89658. }
  89659. declare module BABYLON {
  89660. /**
  89661. * This defines an action responsible to toggle a boolean once triggered.
  89662. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  89663. */
  89664. export class SwitchBooleanAction extends Action {
  89665. /**
  89666. * The path to the boolean property in the target object
  89667. */
  89668. propertyPath: string;
  89669. private _target;
  89670. private _effectiveTarget;
  89671. private _property;
  89672. /**
  89673. * Instantiate the action
  89674. * @param triggerOptions defines the trigger options
  89675. * @param target defines the object containing the boolean
  89676. * @param propertyPath defines the path to the boolean property in the target object
  89677. * @param condition defines the trigger related conditions
  89678. */
  89679. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  89680. /** @hidden */
  89681. _prepare(): void;
  89682. /**
  89683. * Execute the action toggle the boolean value.
  89684. */
  89685. execute(): void;
  89686. /**
  89687. * Serializes the actions and its related information.
  89688. * @param parent defines the object to serialize in
  89689. * @returns the serialized object
  89690. */
  89691. serialize(parent: any): any;
  89692. }
  89693. /**
  89694. * This defines an action responsible to set a the state field of the target
  89695. * to a desired value once triggered.
  89696. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  89697. */
  89698. export class SetStateAction extends Action {
  89699. /**
  89700. * The value to store in the state field.
  89701. */
  89702. value: string;
  89703. private _target;
  89704. /**
  89705. * Instantiate the action
  89706. * @param triggerOptions defines the trigger options
  89707. * @param target defines the object containing the state property
  89708. * @param value defines the value to store in the state field
  89709. * @param condition defines the trigger related conditions
  89710. */
  89711. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  89712. /**
  89713. * Execute the action and store the value on the target state property.
  89714. */
  89715. execute(): void;
  89716. /**
  89717. * Serializes the actions and its related information.
  89718. * @param parent defines the object to serialize in
  89719. * @returns the serialized object
  89720. */
  89721. serialize(parent: any): any;
  89722. }
  89723. /**
  89724. * This defines an action responsible to set a property of the target
  89725. * to a desired value once triggered.
  89726. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  89727. */
  89728. export class SetValueAction extends Action {
  89729. /**
  89730. * The path of the property to set in the target.
  89731. */
  89732. propertyPath: string;
  89733. /**
  89734. * The value to set in the property
  89735. */
  89736. value: any;
  89737. private _target;
  89738. private _effectiveTarget;
  89739. private _property;
  89740. /**
  89741. * Instantiate the action
  89742. * @param triggerOptions defines the trigger options
  89743. * @param target defines the object containing the property
  89744. * @param propertyPath defines the path of the property to set in the target
  89745. * @param value defines the value to set in the property
  89746. * @param condition defines the trigger related conditions
  89747. */
  89748. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  89749. /** @hidden */
  89750. _prepare(): void;
  89751. /**
  89752. * Execute the action and set the targetted property to the desired value.
  89753. */
  89754. execute(): void;
  89755. /**
  89756. * Serializes the actions and its related information.
  89757. * @param parent defines the object to serialize in
  89758. * @returns the serialized object
  89759. */
  89760. serialize(parent: any): any;
  89761. }
  89762. /**
  89763. * This defines an action responsible to increment the target value
  89764. * to a desired value once triggered.
  89765. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  89766. */
  89767. export class IncrementValueAction extends Action {
  89768. /**
  89769. * The path of the property to increment in the target.
  89770. */
  89771. propertyPath: string;
  89772. /**
  89773. * The value we should increment the property by.
  89774. */
  89775. value: any;
  89776. private _target;
  89777. private _effectiveTarget;
  89778. private _property;
  89779. /**
  89780. * Instantiate the action
  89781. * @param triggerOptions defines the trigger options
  89782. * @param target defines the object containing the property
  89783. * @param propertyPath defines the path of the property to increment in the target
  89784. * @param value defines the value value we should increment the property by
  89785. * @param condition defines the trigger related conditions
  89786. */
  89787. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  89788. /** @hidden */
  89789. _prepare(): void;
  89790. /**
  89791. * Execute the action and increment the target of the value amount.
  89792. */
  89793. execute(): void;
  89794. /**
  89795. * Serializes the actions and its related information.
  89796. * @param parent defines the object to serialize in
  89797. * @returns the serialized object
  89798. */
  89799. serialize(parent: any): any;
  89800. }
  89801. /**
  89802. * This defines an action responsible to start an animation once triggered.
  89803. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  89804. */
  89805. export class PlayAnimationAction extends Action {
  89806. /**
  89807. * Where the animation should start (animation frame)
  89808. */
  89809. from: number;
  89810. /**
  89811. * Where the animation should stop (animation frame)
  89812. */
  89813. to: number;
  89814. /**
  89815. * Define if the animation should loop or stop after the first play.
  89816. */
  89817. loop?: boolean;
  89818. private _target;
  89819. /**
  89820. * Instantiate the action
  89821. * @param triggerOptions defines the trigger options
  89822. * @param target defines the target animation or animation name
  89823. * @param from defines from where the animation should start (animation frame)
  89824. * @param end defines where the animation should stop (animation frame)
  89825. * @param loop defines if the animation should loop or stop after the first play
  89826. * @param condition defines the trigger related conditions
  89827. */
  89828. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  89829. /** @hidden */
  89830. _prepare(): void;
  89831. /**
  89832. * Execute the action and play the animation.
  89833. */
  89834. execute(): void;
  89835. /**
  89836. * Serializes the actions and its related information.
  89837. * @param parent defines the object to serialize in
  89838. * @returns the serialized object
  89839. */
  89840. serialize(parent: any): any;
  89841. }
  89842. /**
  89843. * This defines an action responsible to stop an animation once triggered.
  89844. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  89845. */
  89846. export class StopAnimationAction extends Action {
  89847. private _target;
  89848. /**
  89849. * Instantiate the action
  89850. * @param triggerOptions defines the trigger options
  89851. * @param target defines the target animation or animation name
  89852. * @param condition defines the trigger related conditions
  89853. */
  89854. constructor(triggerOptions: any, target: any, condition?: Condition);
  89855. /** @hidden */
  89856. _prepare(): void;
  89857. /**
  89858. * Execute the action and stop the animation.
  89859. */
  89860. execute(): void;
  89861. /**
  89862. * Serializes the actions and its related information.
  89863. * @param parent defines the object to serialize in
  89864. * @returns the serialized object
  89865. */
  89866. serialize(parent: any): any;
  89867. }
  89868. /**
  89869. * This defines an action responsible that does nothing once triggered.
  89870. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  89871. */
  89872. export class DoNothingAction extends Action {
  89873. /**
  89874. * Instantiate the action
  89875. * @param triggerOptions defines the trigger options
  89876. * @param condition defines the trigger related conditions
  89877. */
  89878. constructor(triggerOptions?: any, condition?: Condition);
  89879. /**
  89880. * Execute the action and do nothing.
  89881. */
  89882. execute(): void;
  89883. /**
  89884. * Serializes the actions and its related information.
  89885. * @param parent defines the object to serialize in
  89886. * @returns the serialized object
  89887. */
  89888. serialize(parent: any): any;
  89889. }
  89890. /**
  89891. * This defines an action responsible to trigger several actions once triggered.
  89892. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  89893. */
  89894. export class CombineAction extends Action {
  89895. /**
  89896. * The list of aggregated animations to run.
  89897. */
  89898. children: Action[];
  89899. /**
  89900. * Instantiate the action
  89901. * @param triggerOptions defines the trigger options
  89902. * @param children defines the list of aggregated animations to run
  89903. * @param condition defines the trigger related conditions
  89904. */
  89905. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  89906. /** @hidden */
  89907. _prepare(): void;
  89908. /**
  89909. * Execute the action and executes all the aggregated actions.
  89910. */
  89911. execute(evt: ActionEvent): void;
  89912. /**
  89913. * Serializes the actions and its related information.
  89914. * @param parent defines the object to serialize in
  89915. * @returns the serialized object
  89916. */
  89917. serialize(parent: any): any;
  89918. }
  89919. /**
  89920. * This defines an action responsible to run code (external event) once triggered.
  89921. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  89922. */
  89923. export class ExecuteCodeAction extends Action {
  89924. /**
  89925. * The callback function to run.
  89926. */
  89927. func: (evt: ActionEvent) => void;
  89928. /**
  89929. * Instantiate the action
  89930. * @param triggerOptions defines the trigger options
  89931. * @param func defines the callback function to run
  89932. * @param condition defines the trigger related conditions
  89933. */
  89934. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  89935. /**
  89936. * Execute the action and run the attached code.
  89937. */
  89938. execute(evt: ActionEvent): void;
  89939. }
  89940. /**
  89941. * This defines an action responsible to set the parent property of the target once triggered.
  89942. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  89943. */
  89944. export class SetParentAction extends Action {
  89945. private _parent;
  89946. private _target;
  89947. /**
  89948. * Instantiate the action
  89949. * @param triggerOptions defines the trigger options
  89950. * @param target defines the target containing the parent property
  89951. * @param parent defines from where the animation should start (animation frame)
  89952. * @param condition defines the trigger related conditions
  89953. */
  89954. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  89955. /** @hidden */
  89956. _prepare(): void;
  89957. /**
  89958. * Execute the action and set the parent property.
  89959. */
  89960. execute(): void;
  89961. /**
  89962. * Serializes the actions and its related information.
  89963. * @param parent defines the object to serialize in
  89964. * @returns the serialized object
  89965. */
  89966. serialize(parent: any): any;
  89967. }
  89968. }
  89969. declare module BABYLON {
  89970. /**
  89971. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  89972. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  89973. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  89974. */
  89975. export class ActionManager extends AbstractActionManager {
  89976. /**
  89977. * Nothing
  89978. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  89979. */
  89980. static readonly NothingTrigger: number;
  89981. /**
  89982. * On pick
  89983. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  89984. */
  89985. static readonly OnPickTrigger: number;
  89986. /**
  89987. * On left pick
  89988. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  89989. */
  89990. static readonly OnLeftPickTrigger: number;
  89991. /**
  89992. * On right pick
  89993. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  89994. */
  89995. static readonly OnRightPickTrigger: number;
  89996. /**
  89997. * On center pick
  89998. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  89999. */
  90000. static readonly OnCenterPickTrigger: number;
  90001. /**
  90002. * On pick down
  90003. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90004. */
  90005. static readonly OnPickDownTrigger: number;
  90006. /**
  90007. * On double pick
  90008. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90009. */
  90010. static readonly OnDoublePickTrigger: number;
  90011. /**
  90012. * On pick up
  90013. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90014. */
  90015. static readonly OnPickUpTrigger: number;
  90016. /**
  90017. * On pick out.
  90018. * This trigger will only be raised if you also declared a OnPickDown
  90019. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90020. */
  90021. static readonly OnPickOutTrigger: number;
  90022. /**
  90023. * On long press
  90024. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90025. */
  90026. static readonly OnLongPressTrigger: number;
  90027. /**
  90028. * On pointer over
  90029. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90030. */
  90031. static readonly OnPointerOverTrigger: number;
  90032. /**
  90033. * On pointer out
  90034. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90035. */
  90036. static readonly OnPointerOutTrigger: number;
  90037. /**
  90038. * On every frame
  90039. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90040. */
  90041. static readonly OnEveryFrameTrigger: number;
  90042. /**
  90043. * On intersection enter
  90044. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90045. */
  90046. static readonly OnIntersectionEnterTrigger: number;
  90047. /**
  90048. * On intersection exit
  90049. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90050. */
  90051. static readonly OnIntersectionExitTrigger: number;
  90052. /**
  90053. * On key down
  90054. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90055. */
  90056. static readonly OnKeyDownTrigger: number;
  90057. /**
  90058. * On key up
  90059. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90060. */
  90061. static readonly OnKeyUpTrigger: number;
  90062. private _scene;
  90063. /**
  90064. * Creates a new action manager
  90065. * @param scene defines the hosting scene
  90066. */
  90067. constructor(scene: Scene);
  90068. /**
  90069. * Releases all associated resources
  90070. */
  90071. dispose(): void;
  90072. /**
  90073. * Gets hosting scene
  90074. * @returns the hosting scene
  90075. */
  90076. getScene(): Scene;
  90077. /**
  90078. * Does this action manager handles actions of any of the given triggers
  90079. * @param triggers defines the triggers to be tested
  90080. * @return a boolean indicating whether one (or more) of the triggers is handled
  90081. */
  90082. hasSpecificTriggers(triggers: number[]): boolean;
  90083. /**
  90084. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  90085. * speed.
  90086. * @param triggerA defines the trigger to be tested
  90087. * @param triggerB defines the trigger to be tested
  90088. * @return a boolean indicating whether one (or more) of the triggers is handled
  90089. */
  90090. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  90091. /**
  90092. * Does this action manager handles actions of a given trigger
  90093. * @param trigger defines the trigger to be tested
  90094. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  90095. * @return whether the trigger is handled
  90096. */
  90097. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  90098. /**
  90099. * Does this action manager has pointer triggers
  90100. */
  90101. get hasPointerTriggers(): boolean;
  90102. /**
  90103. * Does this action manager has pick triggers
  90104. */
  90105. get hasPickTriggers(): boolean;
  90106. /**
  90107. * Registers an action to this action manager
  90108. * @param action defines the action to be registered
  90109. * @return the action amended (prepared) after registration
  90110. */
  90111. registerAction(action: IAction): Nullable<IAction>;
  90112. /**
  90113. * Unregisters an action to this action manager
  90114. * @param action defines the action to be unregistered
  90115. * @return a boolean indicating whether the action has been unregistered
  90116. */
  90117. unregisterAction(action: IAction): Boolean;
  90118. /**
  90119. * Process a specific trigger
  90120. * @param trigger defines the trigger to process
  90121. * @param evt defines the event details to be processed
  90122. */
  90123. processTrigger(trigger: number, evt?: IActionEvent): void;
  90124. /** @hidden */
  90125. _getEffectiveTarget(target: any, propertyPath: string): any;
  90126. /** @hidden */
  90127. _getProperty(propertyPath: string): string;
  90128. /**
  90129. * Serialize this manager to a JSON object
  90130. * @param name defines the property name to store this manager
  90131. * @returns a JSON representation of this manager
  90132. */
  90133. serialize(name: string): any;
  90134. /**
  90135. * Creates a new ActionManager from a JSON data
  90136. * @param parsedActions defines the JSON data to read from
  90137. * @param object defines the hosting mesh
  90138. * @param scene defines the hosting scene
  90139. */
  90140. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  90141. /**
  90142. * Get a trigger name by index
  90143. * @param trigger defines the trigger index
  90144. * @returns a trigger name
  90145. */
  90146. static GetTriggerName(trigger: number): string;
  90147. }
  90148. }
  90149. declare module BABYLON {
  90150. /**
  90151. * Class used to represent a sprite
  90152. * @see https://doc.babylonjs.com/babylon101/sprites
  90153. */
  90154. export class Sprite implements IAnimatable {
  90155. /** defines the name */
  90156. name: string;
  90157. /** Gets or sets the current world position */
  90158. position: Vector3;
  90159. /** Gets or sets the main color */
  90160. color: Color4;
  90161. /** Gets or sets the width */
  90162. width: number;
  90163. /** Gets or sets the height */
  90164. height: number;
  90165. /** Gets or sets rotation angle */
  90166. angle: number;
  90167. /** Gets or sets the cell index in the sprite sheet */
  90168. cellIndex: number;
  90169. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  90170. cellRef: string;
  90171. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  90172. invertU: boolean;
  90173. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  90174. invertV: boolean;
  90175. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  90176. disposeWhenFinishedAnimating: boolean;
  90177. /** Gets the list of attached animations */
  90178. animations: Nullable<Array<Animation>>;
  90179. /** Gets or sets a boolean indicating if the sprite can be picked */
  90180. isPickable: boolean;
  90181. /** Gets or sets a boolean indicating that sprite texture alpha will be used for precise picking (false by default) */
  90182. useAlphaForPicking: boolean;
  90183. /** @hidden */
  90184. _xOffset: number;
  90185. /** @hidden */
  90186. _yOffset: number;
  90187. /** @hidden */
  90188. _xSize: number;
  90189. /** @hidden */
  90190. _ySize: number;
  90191. /**
  90192. * Gets or sets the associated action manager
  90193. */
  90194. actionManager: Nullable<ActionManager>;
  90195. /**
  90196. * An event triggered when the control has been disposed
  90197. */
  90198. onDisposeObservable: Observable<Sprite>;
  90199. private _animationStarted;
  90200. private _loopAnimation;
  90201. private _fromIndex;
  90202. private _toIndex;
  90203. private _delay;
  90204. private _direction;
  90205. private _manager;
  90206. private _time;
  90207. private _onAnimationEnd;
  90208. /**
  90209. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  90210. */
  90211. isVisible: boolean;
  90212. /**
  90213. * Gets or sets the sprite size
  90214. */
  90215. get size(): number;
  90216. set size(value: number);
  90217. /**
  90218. * Returns a boolean indicating if the animation is started
  90219. */
  90220. get animationStarted(): boolean;
  90221. /**
  90222. * Gets or sets the unique id of the sprite
  90223. */
  90224. uniqueId: number;
  90225. /**
  90226. * Gets the manager of this sprite
  90227. */
  90228. get manager(): ISpriteManager;
  90229. /**
  90230. * Creates a new Sprite
  90231. * @param name defines the name
  90232. * @param manager defines the manager
  90233. */
  90234. constructor(
  90235. /** defines the name */
  90236. name: string, manager: ISpriteManager);
  90237. /**
  90238. * Returns the string "Sprite"
  90239. * @returns "Sprite"
  90240. */
  90241. getClassName(): string;
  90242. /** Gets or sets the initial key for the animation (setting it will restart the animation) */
  90243. get fromIndex(): number;
  90244. set fromIndex(value: number);
  90245. /** Gets or sets the end key for the animation (setting it will restart the animation) */
  90246. get toIndex(): number;
  90247. set toIndex(value: number);
  90248. /** Gets or sets a boolean indicating if the animation is looping (setting it will restart the animation) */
  90249. get loopAnimation(): boolean;
  90250. set loopAnimation(value: boolean);
  90251. /** Gets or sets the delay between cell changes (setting it will restart the animation) */
  90252. get delay(): number;
  90253. set delay(value: number);
  90254. /**
  90255. * Starts an animation
  90256. * @param from defines the initial key
  90257. * @param to defines the end key
  90258. * @param loop defines if the animation must loop
  90259. * @param delay defines the start delay (in ms)
  90260. * @param onAnimationEnd defines a callback to call when animation ends
  90261. */
  90262. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd?: Nullable<() => void>): void;
  90263. /** Stops current animation (if any) */
  90264. stopAnimation(): void;
  90265. /** @hidden */
  90266. _animate(deltaTime: number): void;
  90267. /** Release associated resources */
  90268. dispose(): void;
  90269. /**
  90270. * Serializes the sprite to a JSON object
  90271. * @returns the JSON object
  90272. */
  90273. serialize(): any;
  90274. /**
  90275. * Parses a JSON object to create a new sprite
  90276. * @param parsedSprite The JSON object to parse
  90277. * @param manager defines the hosting manager
  90278. * @returns the new sprite
  90279. */
  90280. static Parse(parsedSprite: any, manager: SpriteManager): Sprite;
  90281. }
  90282. }
  90283. declare module BABYLON {
  90284. /**
  90285. * Information about the result of picking within a scene
  90286. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  90287. */
  90288. export class PickingInfo {
  90289. /** @hidden */
  90290. _pickingUnavailable: boolean;
  90291. /**
  90292. * If the pick collided with an object
  90293. */
  90294. hit: boolean;
  90295. /**
  90296. * Distance away where the pick collided
  90297. */
  90298. distance: number;
  90299. /**
  90300. * The location of pick collision
  90301. */
  90302. pickedPoint: Nullable<Vector3>;
  90303. /**
  90304. * The mesh corresponding the the pick collision
  90305. */
  90306. pickedMesh: Nullable<AbstractMesh>;
  90307. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  90308. bu: number;
  90309. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  90310. bv: number;
  90311. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  90312. faceId: number;
  90313. /** The index of the face on the subMesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  90314. subMeshFaceId: number;
  90315. /** Id of the the submesh that was picked */
  90316. subMeshId: number;
  90317. /** If a sprite was picked, this will be the sprite the pick collided with */
  90318. pickedSprite: Nullable<Sprite>;
  90319. /** If we are pikcing a mesh with thin instance, this will give you the picked thin instance */
  90320. thinInstanceIndex: number;
  90321. /**
  90322. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  90323. */
  90324. originMesh: Nullable<AbstractMesh>;
  90325. /**
  90326. * The ray that was used to perform the picking.
  90327. */
  90328. ray: Nullable<Ray>;
  90329. /**
  90330. * Gets the normal correspodning to the face the pick collided with
  90331. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  90332. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  90333. * @returns The normal correspodning to the face the pick collided with
  90334. */
  90335. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  90336. /**
  90337. * Gets the texture coordinates of where the pick occured
  90338. * @returns the vector containing the coordnates of the texture
  90339. */
  90340. getTextureCoordinates(): Nullable<Vector2>;
  90341. }
  90342. }
  90343. declare module BABYLON {
  90344. /**
  90345. * Class representing a ray with position and direction
  90346. */
  90347. export class Ray {
  90348. /** origin point */
  90349. origin: Vector3;
  90350. /** direction */
  90351. direction: Vector3;
  90352. /** length of the ray */
  90353. length: number;
  90354. private static readonly _TmpVector3;
  90355. private _tmpRay;
  90356. /**
  90357. * Creates a new ray
  90358. * @param origin origin point
  90359. * @param direction direction
  90360. * @param length length of the ray
  90361. */
  90362. constructor(
  90363. /** origin point */
  90364. origin: Vector3,
  90365. /** direction */
  90366. direction: Vector3,
  90367. /** length of the ray */
  90368. length?: number);
  90369. /**
  90370. * Checks if the ray intersects a box
  90371. * This does not account for the ray lenght by design to improve perfs.
  90372. * @param minimum bound of the box
  90373. * @param maximum bound of the box
  90374. * @param intersectionTreshold extra extend to be added to the box in all direction
  90375. * @returns if the box was hit
  90376. */
  90377. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  90378. /**
  90379. * Checks if the ray intersects a box
  90380. * This does not account for the ray lenght by design to improve perfs.
  90381. * @param box the bounding box to check
  90382. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  90383. * @returns if the box was hit
  90384. */
  90385. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  90386. /**
  90387. * If the ray hits a sphere
  90388. * @param sphere the bounding sphere to check
  90389. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  90390. * @returns true if it hits the sphere
  90391. */
  90392. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  90393. /**
  90394. * If the ray hits a triange
  90395. * @param vertex0 triangle vertex
  90396. * @param vertex1 triangle vertex
  90397. * @param vertex2 triangle vertex
  90398. * @returns intersection information if hit
  90399. */
  90400. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  90401. /**
  90402. * Checks if ray intersects a plane
  90403. * @param plane the plane to check
  90404. * @returns the distance away it was hit
  90405. */
  90406. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  90407. /**
  90408. * Calculate the intercept of a ray on a given axis
  90409. * @param axis to check 'x' | 'y' | 'z'
  90410. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  90411. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  90412. */
  90413. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  90414. /**
  90415. * Checks if ray intersects a mesh
  90416. * @param mesh the mesh to check
  90417. * @param fastCheck defines if the first intersection will be used (and not the closest)
  90418. * @returns picking info of the intersecton
  90419. */
  90420. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  90421. /**
  90422. * Checks if ray intersects a mesh
  90423. * @param meshes the meshes to check
  90424. * @param fastCheck defines if the first intersection will be used (and not the closest)
  90425. * @param results array to store result in
  90426. * @returns Array of picking infos
  90427. */
  90428. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  90429. private _comparePickingInfo;
  90430. private static smallnum;
  90431. private static rayl;
  90432. /**
  90433. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  90434. * @param sega the first point of the segment to test the intersection against
  90435. * @param segb the second point of the segment to test the intersection against
  90436. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  90437. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  90438. */
  90439. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  90440. /**
  90441. * Update the ray from viewport position
  90442. * @param x position
  90443. * @param y y position
  90444. * @param viewportWidth viewport width
  90445. * @param viewportHeight viewport height
  90446. * @param world world matrix
  90447. * @param view view matrix
  90448. * @param projection projection matrix
  90449. * @returns this ray updated
  90450. */
  90451. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  90452. /**
  90453. * Creates a ray with origin and direction of 0,0,0
  90454. * @returns the new ray
  90455. */
  90456. static Zero(): Ray;
  90457. /**
  90458. * Creates a new ray from screen space and viewport
  90459. * @param x position
  90460. * @param y y position
  90461. * @param viewportWidth viewport width
  90462. * @param viewportHeight viewport height
  90463. * @param world world matrix
  90464. * @param view view matrix
  90465. * @param projection projection matrix
  90466. * @returns new ray
  90467. */
  90468. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  90469. /**
  90470. * 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
  90471. * transformed to the given world matrix.
  90472. * @param origin The origin point
  90473. * @param end The end point
  90474. * @param world a matrix to transform the ray to. Default is the identity matrix.
  90475. * @returns the new ray
  90476. */
  90477. static CreateNewFromTo(origin: Vector3, end: Vector3, world?: DeepImmutable<Matrix>): Ray;
  90478. /**
  90479. * Transforms a ray by a matrix
  90480. * @param ray ray to transform
  90481. * @param matrix matrix to apply
  90482. * @returns the resulting new ray
  90483. */
  90484. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  90485. /**
  90486. * Transforms a ray by a matrix
  90487. * @param ray ray to transform
  90488. * @param matrix matrix to apply
  90489. * @param result ray to store result in
  90490. */
  90491. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  90492. /**
  90493. * Unproject a ray from screen space to object space
  90494. * @param sourceX defines the screen space x coordinate to use
  90495. * @param sourceY defines the screen space y coordinate to use
  90496. * @param viewportWidth defines the current width of the viewport
  90497. * @param viewportHeight defines the current height of the viewport
  90498. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  90499. * @param view defines the view matrix to use
  90500. * @param projection defines the projection matrix to use
  90501. */
  90502. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  90503. }
  90504. /**
  90505. * Type used to define predicate used to select faces when a mesh intersection is detected
  90506. */
  90507. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  90508. interface Scene {
  90509. /** @hidden */
  90510. _tempPickingRay: Nullable<Ray>;
  90511. /** @hidden */
  90512. _cachedRayForTransform: Ray;
  90513. /** @hidden */
  90514. _pickWithRayInverseMatrix: Matrix;
  90515. /** @hidden */
  90516. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  90517. /** @hidden */
  90518. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  90519. /** @hidden */
  90520. _internalPickForMesh(pickingInfo: Nullable<PickingInfo>, rayFunction: (world: Matrix) => Ray, mesh: AbstractMesh, world: Matrix, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  90521. }
  90522. }
  90523. declare module BABYLON {
  90524. /**
  90525. * Groups all the scene component constants in one place to ease maintenance.
  90526. * @hidden
  90527. */
  90528. export class SceneComponentConstants {
  90529. static readonly NAME_EFFECTLAYER: string;
  90530. static readonly NAME_LAYER: string;
  90531. static readonly NAME_LENSFLARESYSTEM: string;
  90532. static readonly NAME_BOUNDINGBOXRENDERER: string;
  90533. static readonly NAME_PARTICLESYSTEM: string;
  90534. static readonly NAME_GAMEPAD: string;
  90535. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  90536. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  90537. static readonly NAME_PREPASSRENDERER: string;
  90538. static readonly NAME_DEPTHRENDERER: string;
  90539. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  90540. static readonly NAME_SPRITE: string;
  90541. static readonly NAME_OUTLINERENDERER: string;
  90542. static readonly NAME_PROCEDURALTEXTURE: string;
  90543. static readonly NAME_SHADOWGENERATOR: string;
  90544. static readonly NAME_OCTREE: string;
  90545. static readonly NAME_PHYSICSENGINE: string;
  90546. static readonly NAME_AUDIO: string;
  90547. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  90548. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  90549. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  90550. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  90551. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  90552. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  90553. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  90554. static readonly STEP_BEFORECAMERADRAW_PREPASS: number;
  90555. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  90556. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  90557. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  90558. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  90559. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  90560. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  90561. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  90562. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  90563. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  90564. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  90565. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  90566. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  90567. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  90568. static readonly STEP_AFTERCAMERADRAW_PREPASS: number;
  90569. static readonly STEP_AFTERRENDER_AUDIO: number;
  90570. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  90571. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  90572. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  90573. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  90574. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  90575. static readonly STEP_BEFORECLEARSTAGE_PREPASS: number;
  90576. static readonly STEP_POINTERMOVE_SPRITE: number;
  90577. static readonly STEP_POINTERDOWN_SPRITE: number;
  90578. static readonly STEP_POINTERUP_SPRITE: number;
  90579. }
  90580. /**
  90581. * This represents a scene component.
  90582. *
  90583. * This is used to decouple the dependency the scene is having on the different workloads like
  90584. * layers, post processes...
  90585. */
  90586. export interface ISceneComponent {
  90587. /**
  90588. * The name of the component. Each component must have a unique name.
  90589. */
  90590. name: string;
  90591. /**
  90592. * The scene the component belongs to.
  90593. */
  90594. scene: Scene;
  90595. /**
  90596. * Register the component to one instance of a scene.
  90597. */
  90598. register(): void;
  90599. /**
  90600. * Rebuilds the elements related to this component in case of
  90601. * context lost for instance.
  90602. */
  90603. rebuild(): void;
  90604. /**
  90605. * Disposes the component and the associated ressources.
  90606. */
  90607. dispose(): void;
  90608. }
  90609. /**
  90610. * This represents a SERIALIZABLE scene component.
  90611. *
  90612. * This extends Scene Component to add Serialization methods on top.
  90613. */
  90614. export interface ISceneSerializableComponent extends ISceneComponent {
  90615. /**
  90616. * Adds all the elements from the container to the scene
  90617. * @param container the container holding the elements
  90618. */
  90619. addFromContainer(container: AbstractScene): void;
  90620. /**
  90621. * Removes all the elements in the container from the scene
  90622. * @param container contains the elements to remove
  90623. * @param dispose if the removed element should be disposed (default: false)
  90624. */
  90625. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  90626. /**
  90627. * Serializes the component data to the specified json object
  90628. * @param serializationObject The object to serialize to
  90629. */
  90630. serialize(serializationObject: any): void;
  90631. }
  90632. /**
  90633. * Strong typing of a Mesh related stage step action
  90634. */
  90635. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  90636. /**
  90637. * Strong typing of a Evaluate Sub Mesh related stage step action
  90638. */
  90639. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  90640. /**
  90641. * Strong typing of a Active Mesh related stage step action
  90642. */
  90643. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  90644. /**
  90645. * Strong typing of a Camera related stage step action
  90646. */
  90647. export type CameraStageAction = (camera: Camera) => void;
  90648. /**
  90649. * Strong typing of a Camera Frame buffer related stage step action
  90650. */
  90651. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  90652. /**
  90653. * Strong typing of a Render Target related stage step action
  90654. */
  90655. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  90656. /**
  90657. * Strong typing of a RenderingGroup related stage step action
  90658. */
  90659. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  90660. /**
  90661. * Strong typing of a Mesh Render related stage step action
  90662. */
  90663. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  90664. /**
  90665. * Strong typing of a simple stage step action
  90666. */
  90667. export type SimpleStageAction = () => void;
  90668. /**
  90669. * Strong typing of a render target action.
  90670. */
  90671. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  90672. /**
  90673. * Strong typing of a pointer move action.
  90674. */
  90675. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  90676. /**
  90677. * Strong typing of a pointer up/down action.
  90678. */
  90679. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  90680. /**
  90681. * Representation of a stage in the scene (Basically a list of ordered steps)
  90682. * @hidden
  90683. */
  90684. export class Stage<T extends Function> extends Array<{
  90685. index: number;
  90686. component: ISceneComponent;
  90687. action: T;
  90688. }> {
  90689. /**
  90690. * Hide ctor from the rest of the world.
  90691. * @param items The items to add.
  90692. */
  90693. private constructor();
  90694. /**
  90695. * Creates a new Stage.
  90696. * @returns A new instance of a Stage
  90697. */
  90698. static Create<T extends Function>(): Stage<T>;
  90699. /**
  90700. * Registers a step in an ordered way in the targeted stage.
  90701. * @param index Defines the position to register the step in
  90702. * @param component Defines the component attached to the step
  90703. * @param action Defines the action to launch during the step
  90704. */
  90705. registerStep(index: number, component: ISceneComponent, action: T): void;
  90706. /**
  90707. * Clears all the steps from the stage.
  90708. */
  90709. clear(): void;
  90710. }
  90711. }
  90712. declare module BABYLON {
  90713. interface Scene {
  90714. /** @hidden */
  90715. _pointerOverSprite: Nullable<Sprite>;
  90716. /** @hidden */
  90717. _pickedDownSprite: Nullable<Sprite>;
  90718. /** @hidden */
  90719. _tempSpritePickingRay: Nullable<Ray>;
  90720. /**
  90721. * All of the sprite managers added to this scene
  90722. * @see https://doc.babylonjs.com/babylon101/sprites
  90723. */
  90724. spriteManagers: Array<ISpriteManager>;
  90725. /**
  90726. * An event triggered when sprites rendering is about to start
  90727. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  90728. */
  90729. onBeforeSpritesRenderingObservable: Observable<Scene>;
  90730. /**
  90731. * An event triggered when sprites rendering is done
  90732. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  90733. */
  90734. onAfterSpritesRenderingObservable: Observable<Scene>;
  90735. /** @hidden */
  90736. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  90737. /** Launch a ray to try to pick a sprite in the scene
  90738. * @param x position on screen
  90739. * @param y position on screen
  90740. * @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
  90741. * @param fastCheck defines if the first intersection will be used (and not the closest)
  90742. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  90743. * @returns a PickingInfo
  90744. */
  90745. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  90746. /** Use the given ray to pick a sprite in the scene
  90747. * @param ray The ray (in world space) to use to pick meshes
  90748. * @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
  90749. * @param fastCheck defines if the first intersection will be used (and not the closest)
  90750. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  90751. * @returns a PickingInfo
  90752. */
  90753. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  90754. /** @hidden */
  90755. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  90756. /** Launch a ray to try to pick sprites in the scene
  90757. * @param x position on screen
  90758. * @param y position on screen
  90759. * @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
  90760. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  90761. * @returns a PickingInfo array
  90762. */
  90763. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  90764. /** Use the given ray to pick sprites in the scene
  90765. * @param ray The ray (in world space) to use to pick meshes
  90766. * @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
  90767. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  90768. * @returns a PickingInfo array
  90769. */
  90770. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  90771. /**
  90772. * Force the sprite under the pointer
  90773. * @param sprite defines the sprite to use
  90774. */
  90775. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  90776. /**
  90777. * Gets the sprite under the pointer
  90778. * @returns a Sprite or null if no sprite is under the pointer
  90779. */
  90780. getPointerOverSprite(): Nullable<Sprite>;
  90781. }
  90782. /**
  90783. * Defines the sprite scene component responsible to manage sprites
  90784. * in a given scene.
  90785. */
  90786. export class SpriteSceneComponent implements ISceneComponent {
  90787. /**
  90788. * The component name helpfull to identify the component in the list of scene components.
  90789. */
  90790. readonly name: string;
  90791. /**
  90792. * The scene the component belongs to.
  90793. */
  90794. scene: Scene;
  90795. /** @hidden */
  90796. private _spritePredicate;
  90797. /**
  90798. * Creates a new instance of the component for the given scene
  90799. * @param scene Defines the scene to register the component in
  90800. */
  90801. constructor(scene: Scene);
  90802. /**
  90803. * Registers the component in a given scene
  90804. */
  90805. register(): void;
  90806. /**
  90807. * Rebuilds the elements related to this component in case of
  90808. * context lost for instance.
  90809. */
  90810. rebuild(): void;
  90811. /**
  90812. * Disposes the component and the associated ressources.
  90813. */
  90814. dispose(): void;
  90815. private _pickSpriteButKeepRay;
  90816. private _pointerMove;
  90817. private _pointerDown;
  90818. private _pointerUp;
  90819. }
  90820. }
  90821. declare module BABYLON {
  90822. /** @hidden */
  90823. export var fogFragmentDeclaration: {
  90824. name: string;
  90825. shader: string;
  90826. };
  90827. }
  90828. declare module BABYLON {
  90829. /** @hidden */
  90830. export var fogFragment: {
  90831. name: string;
  90832. shader: string;
  90833. };
  90834. }
  90835. declare module BABYLON {
  90836. /** @hidden */
  90837. export var spritesPixelShader: {
  90838. name: string;
  90839. shader: string;
  90840. };
  90841. }
  90842. declare module BABYLON {
  90843. /** @hidden */
  90844. export var fogVertexDeclaration: {
  90845. name: string;
  90846. shader: string;
  90847. };
  90848. }
  90849. declare module BABYLON {
  90850. /** @hidden */
  90851. export var spritesVertexShader: {
  90852. name: string;
  90853. shader: string;
  90854. };
  90855. }
  90856. declare module BABYLON {
  90857. /**
  90858. * Defines the minimum interface to fullfil in order to be a sprite manager.
  90859. */
  90860. export interface ISpriteManager extends IDisposable {
  90861. /**
  90862. * Gets manager's name
  90863. */
  90864. name: string;
  90865. /**
  90866. * Restricts the camera to viewing objects with the same layerMask.
  90867. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  90868. */
  90869. layerMask: number;
  90870. /**
  90871. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  90872. */
  90873. isPickable: boolean;
  90874. /**
  90875. * Gets the hosting scene
  90876. */
  90877. scene: Scene;
  90878. /**
  90879. * Specifies the rendering group id for this mesh (0 by default)
  90880. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  90881. */
  90882. renderingGroupId: number;
  90883. /**
  90884. * Defines the list of sprites managed by the manager.
  90885. */
  90886. sprites: Array<Sprite>;
  90887. /**
  90888. * Gets or sets the spritesheet texture
  90889. */
  90890. texture: Texture;
  90891. /** Defines the default width of a cell in the spritesheet */
  90892. cellWidth: number;
  90893. /** Defines the default height of a cell in the spritesheet */
  90894. cellHeight: number;
  90895. /**
  90896. * Tests the intersection of a sprite with a specific ray.
  90897. * @param ray The ray we are sending to test the collision
  90898. * @param camera The camera space we are sending rays in
  90899. * @param predicate A predicate allowing excluding sprites from the list of object to test
  90900. * @param fastCheck defines if the first intersection will be used (and not the closest)
  90901. * @returns picking info or null.
  90902. */
  90903. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  90904. /**
  90905. * Intersects the sprites with a ray
  90906. * @param ray defines the ray to intersect with
  90907. * @param camera defines the current active camera
  90908. * @param predicate defines a predicate used to select candidate sprites
  90909. * @returns null if no hit or a PickingInfo array
  90910. */
  90911. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  90912. /**
  90913. * Renders the list of sprites on screen.
  90914. */
  90915. render(): void;
  90916. }
  90917. /**
  90918. * Class used to manage multiple sprites on the same spritesheet
  90919. * @see https://doc.babylonjs.com/babylon101/sprites
  90920. */
  90921. export class SpriteManager implements ISpriteManager {
  90922. /** defines the manager's name */
  90923. name: string;
  90924. /** Define the Url to load snippets */
  90925. static SnippetUrl: string;
  90926. /** Snippet ID if the manager was created from the snippet server */
  90927. snippetId: string;
  90928. /** Gets the list of sprites */
  90929. sprites: Sprite[];
  90930. /** Gets or sets the rendering group id (0 by default) */
  90931. renderingGroupId: number;
  90932. /** Gets or sets camera layer mask */
  90933. layerMask: number;
  90934. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  90935. fogEnabled: boolean;
  90936. /** Gets or sets a boolean indicating if the sprites are pickable */
  90937. isPickable: boolean;
  90938. /** Defines the default width of a cell in the spritesheet */
  90939. cellWidth: number;
  90940. /** Defines the default height of a cell in the spritesheet */
  90941. cellHeight: number;
  90942. /** Associative array from JSON sprite data file */
  90943. private _cellData;
  90944. /** Array of sprite names from JSON sprite data file */
  90945. private _spriteMap;
  90946. /** True when packed cell data from JSON file is ready*/
  90947. private _packedAndReady;
  90948. private _textureContent;
  90949. private _useInstancing;
  90950. /**
  90951. * An event triggered when the manager is disposed.
  90952. */
  90953. onDisposeObservable: Observable<SpriteManager>;
  90954. private _onDisposeObserver;
  90955. /**
  90956. * Callback called when the manager is disposed
  90957. */
  90958. set onDispose(callback: () => void);
  90959. private _capacity;
  90960. private _fromPacked;
  90961. private _spriteTexture;
  90962. private _epsilon;
  90963. private _scene;
  90964. private _vertexData;
  90965. private _buffer;
  90966. private _vertexBuffers;
  90967. private _spriteBuffer;
  90968. private _indexBuffer;
  90969. private _effectBase;
  90970. private _effectFog;
  90971. private _vertexBufferSize;
  90972. /**
  90973. * Gets or sets the unique id of the sprite
  90974. */
  90975. uniqueId: number;
  90976. /**
  90977. * Gets the array of sprites
  90978. */
  90979. get children(): Sprite[];
  90980. /**
  90981. * Gets the hosting scene
  90982. */
  90983. get scene(): Scene;
  90984. /**
  90985. * Gets the capacity of the manager
  90986. */
  90987. get capacity(): number;
  90988. /**
  90989. * Gets or sets the spritesheet texture
  90990. */
  90991. get texture(): Texture;
  90992. set texture(value: Texture);
  90993. private _blendMode;
  90994. /**
  90995. * Blend mode use to render the particle, it can be any of
  90996. * the static Constants.ALPHA_x properties provided in this class.
  90997. * Default value is Constants.ALPHA_COMBINE
  90998. */
  90999. get blendMode(): number;
  91000. set blendMode(blendMode: number);
  91001. /** Disables writing to the depth buffer when rendering the sprites.
  91002. * It can be handy to disable depth writing when using textures without alpha channel
  91003. * and setting some specific blend modes.
  91004. */
  91005. disableDepthWrite: boolean;
  91006. /**
  91007. * Creates a new sprite manager
  91008. * @param name defines the manager's name
  91009. * @param imgUrl defines the sprite sheet url
  91010. * @param capacity defines the maximum allowed number of sprites
  91011. * @param cellSize defines the size of a sprite cell
  91012. * @param scene defines the hosting scene
  91013. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  91014. * @param samplingMode defines the smapling mode to use with spritesheet
  91015. * @param fromPacked set to false; do not alter
  91016. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  91017. */
  91018. constructor(
  91019. /** defines the manager's name */
  91020. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  91021. /**
  91022. * Returns the string "SpriteManager"
  91023. * @returns "SpriteManager"
  91024. */
  91025. getClassName(): string;
  91026. private _makePacked;
  91027. private _appendSpriteVertex;
  91028. private _checkTextureAlpha;
  91029. /**
  91030. * Intersects the sprites with a ray
  91031. * @param ray defines the ray to intersect with
  91032. * @param camera defines the current active camera
  91033. * @param predicate defines a predicate used to select candidate sprites
  91034. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  91035. * @returns null if no hit or a PickingInfo
  91036. */
  91037. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  91038. /**
  91039. * Intersects the sprites with a ray
  91040. * @param ray defines the ray to intersect with
  91041. * @param camera defines the current active camera
  91042. * @param predicate defines a predicate used to select candidate sprites
  91043. * @returns null if no hit or a PickingInfo array
  91044. */
  91045. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  91046. /**
  91047. * Render all child sprites
  91048. */
  91049. render(): void;
  91050. /**
  91051. * Release associated resources
  91052. */
  91053. dispose(): void;
  91054. /**
  91055. * Serializes the sprite manager to a JSON object
  91056. * @param serializeTexture defines if the texture must be serialized as well
  91057. * @returns the JSON object
  91058. */
  91059. serialize(serializeTexture?: boolean): any;
  91060. /**
  91061. * Parses a JSON object to create a new sprite manager.
  91062. * @param parsedManager The JSON object to parse
  91063. * @param scene The scene to create the sprite managerin
  91064. * @param rootUrl The root url to use to load external dependencies like texture
  91065. * @returns the new sprite manager
  91066. */
  91067. static Parse(parsedManager: any, scene: Scene, rootUrl: string): SpriteManager;
  91068. /**
  91069. * Creates a sprite manager from a snippet saved in a remote file
  91070. * @param name defines the name of the sprite manager to create (can be null or empty to use the one from the json data)
  91071. * @param url defines the url to load from
  91072. * @param scene defines the hosting scene
  91073. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  91074. * @returns a promise that will resolve to the new sprite manager
  91075. */
  91076. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  91077. /**
  91078. * Creates a sprite manager from a snippet saved by the sprite editor
  91079. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  91080. * @param scene defines the hosting scene
  91081. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  91082. * @returns a promise that will resolve to the new sprite manager
  91083. */
  91084. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  91085. }
  91086. }
  91087. declare module BABYLON {
  91088. /** Interface used by value gradients (color, factor, ...) */
  91089. export interface IValueGradient {
  91090. /**
  91091. * Gets or sets the gradient value (between 0 and 1)
  91092. */
  91093. gradient: number;
  91094. }
  91095. /** Class used to store color4 gradient */
  91096. export class ColorGradient implements IValueGradient {
  91097. /**
  91098. * Gets or sets the gradient value (between 0 and 1)
  91099. */
  91100. gradient: number;
  91101. /**
  91102. * Gets or sets first associated color
  91103. */
  91104. color1: Color4;
  91105. /**
  91106. * Gets or sets second associated color
  91107. */
  91108. color2?: Color4 | undefined;
  91109. /**
  91110. * Creates a new color4 gradient
  91111. * @param gradient gets or sets the gradient value (between 0 and 1)
  91112. * @param color1 gets or sets first associated color
  91113. * @param color2 gets or sets first second color
  91114. */
  91115. constructor(
  91116. /**
  91117. * Gets or sets the gradient value (between 0 and 1)
  91118. */
  91119. gradient: number,
  91120. /**
  91121. * Gets or sets first associated color
  91122. */
  91123. color1: Color4,
  91124. /**
  91125. * Gets or sets second associated color
  91126. */
  91127. color2?: Color4 | undefined);
  91128. /**
  91129. * Will get a color picked randomly between color1 and color2.
  91130. * If color2 is undefined then color1 will be used
  91131. * @param result defines the target Color4 to store the result in
  91132. */
  91133. getColorToRef(result: Color4): void;
  91134. }
  91135. /** Class used to store color 3 gradient */
  91136. export class Color3Gradient implements IValueGradient {
  91137. /**
  91138. * Gets or sets the gradient value (between 0 and 1)
  91139. */
  91140. gradient: number;
  91141. /**
  91142. * Gets or sets the associated color
  91143. */
  91144. color: Color3;
  91145. /**
  91146. * Creates a new color3 gradient
  91147. * @param gradient gets or sets the gradient value (between 0 and 1)
  91148. * @param color gets or sets associated color
  91149. */
  91150. constructor(
  91151. /**
  91152. * Gets or sets the gradient value (between 0 and 1)
  91153. */
  91154. gradient: number,
  91155. /**
  91156. * Gets or sets the associated color
  91157. */
  91158. color: Color3);
  91159. }
  91160. /** Class used to store factor gradient */
  91161. export class FactorGradient implements IValueGradient {
  91162. /**
  91163. * Gets or sets the gradient value (between 0 and 1)
  91164. */
  91165. gradient: number;
  91166. /**
  91167. * Gets or sets first associated factor
  91168. */
  91169. factor1: number;
  91170. /**
  91171. * Gets or sets second associated factor
  91172. */
  91173. factor2?: number | undefined;
  91174. /**
  91175. * Creates a new factor gradient
  91176. * @param gradient gets or sets the gradient value (between 0 and 1)
  91177. * @param factor1 gets or sets first associated factor
  91178. * @param factor2 gets or sets second associated factor
  91179. */
  91180. constructor(
  91181. /**
  91182. * Gets or sets the gradient value (between 0 and 1)
  91183. */
  91184. gradient: number,
  91185. /**
  91186. * Gets or sets first associated factor
  91187. */
  91188. factor1: number,
  91189. /**
  91190. * Gets or sets second associated factor
  91191. */
  91192. factor2?: number | undefined);
  91193. /**
  91194. * Will get a number picked randomly between factor1 and factor2.
  91195. * If factor2 is undefined then factor1 will be used
  91196. * @returns the picked number
  91197. */
  91198. getFactor(): number;
  91199. }
  91200. /**
  91201. * Helper used to simplify some generic gradient tasks
  91202. */
  91203. export class GradientHelper {
  91204. /**
  91205. * Gets the current gradient from an array of IValueGradient
  91206. * @param ratio defines the current ratio to get
  91207. * @param gradients defines the array of IValueGradient
  91208. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  91209. */
  91210. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  91211. }
  91212. }
  91213. declare module BABYLON {
  91214. interface ThinEngine {
  91215. /**
  91216. * Creates a raw texture
  91217. * @param data defines the data to store in the texture
  91218. * @param width defines the width of the texture
  91219. * @param height defines the height of the texture
  91220. * @param format defines the format of the data
  91221. * @param generateMipMaps defines if the engine should generate the mip levels
  91222. * @param invertY defines if data must be stored with Y axis inverted
  91223. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  91224. * @param compression defines the compression used (null by default)
  91225. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  91226. * @returns the raw texture inside an InternalTexture
  91227. */
  91228. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  91229. /**
  91230. * Update a raw texture
  91231. * @param texture defines the texture to update
  91232. * @param data defines the data to store in the texture
  91233. * @param format defines the format of the data
  91234. * @param invertY defines if data must be stored with Y axis inverted
  91235. */
  91236. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  91237. /**
  91238. * Update a raw texture
  91239. * @param texture defines the texture to update
  91240. * @param data defines the data to store in the texture
  91241. * @param format defines the format of the data
  91242. * @param invertY defines if data must be stored with Y axis inverted
  91243. * @param compression defines the compression used (null by default)
  91244. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  91245. */
  91246. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  91247. /**
  91248. * Creates a new raw cube texture
  91249. * @param data defines the array of data to use to create each face
  91250. * @param size defines the size of the textures
  91251. * @param format defines the format of the data
  91252. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  91253. * @param generateMipMaps defines if the engine should generate the mip levels
  91254. * @param invertY defines if data must be stored with Y axis inverted
  91255. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  91256. * @param compression defines the compression used (null by default)
  91257. * @returns the cube texture as an InternalTexture
  91258. */
  91259. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  91260. /**
  91261. * Update a raw cube texture
  91262. * @param texture defines the texture to udpdate
  91263. * @param data defines the data to store
  91264. * @param format defines the data format
  91265. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  91266. * @param invertY defines if data must be stored with Y axis inverted
  91267. */
  91268. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  91269. /**
  91270. * Update a raw cube texture
  91271. * @param texture defines the texture to udpdate
  91272. * @param data defines the data to store
  91273. * @param format defines the data format
  91274. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  91275. * @param invertY defines if data must be stored with Y axis inverted
  91276. * @param compression defines the compression used (null by default)
  91277. */
  91278. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  91279. /**
  91280. * Update a raw cube texture
  91281. * @param texture defines the texture to udpdate
  91282. * @param data defines the data to store
  91283. * @param format defines the data format
  91284. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  91285. * @param invertY defines if data must be stored with Y axis inverted
  91286. * @param compression defines the compression used (null by default)
  91287. * @param level defines which level of the texture to update
  91288. */
  91289. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  91290. /**
  91291. * Creates a new raw cube texture from a specified url
  91292. * @param url defines the url where the data is located
  91293. * @param scene defines the current scene
  91294. * @param size defines the size of the textures
  91295. * @param format defines the format of the data
  91296. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  91297. * @param noMipmap defines if the engine should avoid generating the mip levels
  91298. * @param callback defines a callback used to extract texture data from loaded data
  91299. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  91300. * @param onLoad defines a callback called when texture is loaded
  91301. * @param onError defines a callback called if there is an error
  91302. * @returns the cube texture as an InternalTexture
  91303. */
  91304. 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;
  91305. /**
  91306. * Creates a new raw cube texture from a specified url
  91307. * @param url defines the url where the data is located
  91308. * @param scene defines the current scene
  91309. * @param size defines the size of the textures
  91310. * @param format defines the format of the data
  91311. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  91312. * @param noMipmap defines if the engine should avoid generating the mip levels
  91313. * @param callback defines a callback used to extract texture data from loaded data
  91314. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  91315. * @param onLoad defines a callback called when texture is loaded
  91316. * @param onError defines a callback called if there is an error
  91317. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  91318. * @param invertY defines if data must be stored with Y axis inverted
  91319. * @returns the cube texture as an InternalTexture
  91320. */
  91321. 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;
  91322. /**
  91323. * Creates a new raw 3D texture
  91324. * @param data defines the data used to create the texture
  91325. * @param width defines the width of the texture
  91326. * @param height defines the height of the texture
  91327. * @param depth defines the depth of the texture
  91328. * @param format defines the format of the texture
  91329. * @param generateMipMaps defines if the engine must generate mip levels
  91330. * @param invertY defines if data must be stored with Y axis inverted
  91331. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  91332. * @param compression defines the compressed used (can be null)
  91333. * @param textureType defines the compressed used (can be null)
  91334. * @returns a new raw 3D texture (stored in an InternalTexture)
  91335. */
  91336. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  91337. /**
  91338. * Update a raw 3D texture
  91339. * @param texture defines the texture to update
  91340. * @param data defines the data to store
  91341. * @param format defines the data format
  91342. * @param invertY defines if data must be stored with Y axis inverted
  91343. */
  91344. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  91345. /**
  91346. * Update a raw 3D texture
  91347. * @param texture defines the texture to update
  91348. * @param data defines the data to store
  91349. * @param format defines the data format
  91350. * @param invertY defines if data must be stored with Y axis inverted
  91351. * @param compression defines the used compression (can be null)
  91352. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  91353. */
  91354. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  91355. /**
  91356. * Creates a new raw 2D array texture
  91357. * @param data defines the data used to create the texture
  91358. * @param width defines the width of the texture
  91359. * @param height defines the height of the texture
  91360. * @param depth defines the number of layers of the texture
  91361. * @param format defines the format of the texture
  91362. * @param generateMipMaps defines if the engine must generate mip levels
  91363. * @param invertY defines if data must be stored with Y axis inverted
  91364. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  91365. * @param compression defines the compressed used (can be null)
  91366. * @param textureType defines the compressed used (can be null)
  91367. * @returns a new raw 2D array texture (stored in an InternalTexture)
  91368. */
  91369. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  91370. /**
  91371. * Update a raw 2D array texture
  91372. * @param texture defines the texture to update
  91373. * @param data defines the data to store
  91374. * @param format defines the data format
  91375. * @param invertY defines if data must be stored with Y axis inverted
  91376. */
  91377. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  91378. /**
  91379. * Update a raw 2D array texture
  91380. * @param texture defines the texture to update
  91381. * @param data defines the data to store
  91382. * @param format defines the data format
  91383. * @param invertY defines if data must be stored with Y axis inverted
  91384. * @param compression defines the used compression (can be null)
  91385. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  91386. */
  91387. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  91388. }
  91389. }
  91390. declare module BABYLON {
  91391. /**
  91392. * Raw texture can help creating a texture directly from an array of data.
  91393. * This can be super useful if you either get the data from an uncompressed source or
  91394. * if you wish to create your texture pixel by pixel.
  91395. */
  91396. export class RawTexture extends Texture {
  91397. /**
  91398. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  91399. */
  91400. format: number;
  91401. /**
  91402. * Instantiates a new RawTexture.
  91403. * Raw texture can help creating a texture directly from an array of data.
  91404. * This can be super useful if you either get the data from an uncompressed source or
  91405. * if you wish to create your texture pixel by pixel.
  91406. * @param data define the array of data to use to create the texture
  91407. * @param width define the width of the texture
  91408. * @param height define the height of the texture
  91409. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  91410. * @param sceneOrEngine defines the scene or engine the texture will belong to
  91411. * @param generateMipMaps define whether mip maps should be generated or not
  91412. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  91413. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  91414. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  91415. */
  91416. constructor(data: ArrayBufferView, width: number, height: number,
  91417. /**
  91418. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  91419. */
  91420. format: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  91421. /**
  91422. * Updates the texture underlying data.
  91423. * @param data Define the new data of the texture
  91424. */
  91425. update(data: ArrayBufferView): void;
  91426. /**
  91427. * Creates a luminance texture from some data.
  91428. * @param data Define the texture data
  91429. * @param width Define the width of the texture
  91430. * @param height Define the height of the texture
  91431. * @param sceneOrEngine defines the scene or engine the texture will belong to
  91432. * @param generateMipMaps Define whether or not to create mip maps for the texture
  91433. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  91434. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  91435. * @returns the luminance texture
  91436. */
  91437. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  91438. /**
  91439. * Creates a luminance alpha texture from some data.
  91440. * @param data Define the texture data
  91441. * @param width Define the width of the texture
  91442. * @param height Define the height of the texture
  91443. * @param sceneOrEngine defines the scene or engine the texture will belong to
  91444. * @param generateMipMaps Define whether or not to create mip maps for the texture
  91445. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  91446. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  91447. * @returns the luminance alpha texture
  91448. */
  91449. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  91450. /**
  91451. * Creates an alpha texture from some data.
  91452. * @param data Define the texture data
  91453. * @param width Define the width of the texture
  91454. * @param height Define the height of the texture
  91455. * @param sceneOrEngine defines the scene or engine the texture will belong to
  91456. * @param generateMipMaps Define whether or not to create mip maps for the texture
  91457. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  91458. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  91459. * @returns the alpha texture
  91460. */
  91461. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  91462. /**
  91463. * Creates a RGB texture from some data.
  91464. * @param data Define the texture data
  91465. * @param width Define the width of the texture
  91466. * @param height Define the height of the texture
  91467. * @param sceneOrEngine defines the scene or engine the texture will belong to
  91468. * @param generateMipMaps Define whether or not to create mip maps for the texture
  91469. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  91470. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  91471. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  91472. * @returns the RGB alpha texture
  91473. */
  91474. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  91475. /**
  91476. * Creates a RGBA texture from some data.
  91477. * @param data Define the texture data
  91478. * @param width Define the width of the texture
  91479. * @param height Define the height of the texture
  91480. * @param sceneOrEngine defines the scene or engine the texture will belong to
  91481. * @param generateMipMaps Define whether or not to create mip maps for the texture
  91482. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  91483. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  91484. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  91485. * @returns the RGBA texture
  91486. */
  91487. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  91488. /**
  91489. * Creates a R texture from some data.
  91490. * @param data Define the texture data
  91491. * @param width Define the width of the texture
  91492. * @param height Define the height of the texture
  91493. * @param sceneOrEngine defines the scene or engine the texture will belong to
  91494. * @param generateMipMaps Define whether or not to create mip maps for the texture
  91495. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  91496. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  91497. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  91498. * @returns the R texture
  91499. */
  91500. static CreateRTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  91501. }
  91502. }
  91503. declare module BABYLON {
  91504. interface ThinEngine {
  91505. /**
  91506. * Update a dynamic index buffer
  91507. * @param indexBuffer defines the target index buffer
  91508. * @param indices defines the data to update
  91509. * @param offset defines the offset in the target index buffer where update should start
  91510. */
  91511. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  91512. /**
  91513. * Updates a dynamic vertex buffer.
  91514. * @param vertexBuffer the vertex buffer to update
  91515. * @param data the data used to update the vertex buffer
  91516. * @param byteOffset the byte offset of the data
  91517. * @param byteLength the byte length of the data
  91518. */
  91519. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  91520. }
  91521. }
  91522. declare module BABYLON {
  91523. interface AbstractScene {
  91524. /**
  91525. * The list of procedural textures added to the scene
  91526. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  91527. */
  91528. proceduralTextures: Array<ProceduralTexture>;
  91529. }
  91530. /**
  91531. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  91532. * in a given scene.
  91533. */
  91534. export class ProceduralTextureSceneComponent implements ISceneComponent {
  91535. /**
  91536. * The component name helpfull to identify the component in the list of scene components.
  91537. */
  91538. readonly name: string;
  91539. /**
  91540. * The scene the component belongs to.
  91541. */
  91542. scene: Scene;
  91543. /**
  91544. * Creates a new instance of the component for the given scene
  91545. * @param scene Defines the scene to register the component in
  91546. */
  91547. constructor(scene: Scene);
  91548. /**
  91549. * Registers the component in a given scene
  91550. */
  91551. register(): void;
  91552. /**
  91553. * Rebuilds the elements related to this component in case of
  91554. * context lost for instance.
  91555. */
  91556. rebuild(): void;
  91557. /**
  91558. * Disposes the component and the associated ressources.
  91559. */
  91560. dispose(): void;
  91561. private _beforeClear;
  91562. }
  91563. }
  91564. declare module BABYLON {
  91565. interface ThinEngine {
  91566. /**
  91567. * Creates a new render target cube texture
  91568. * @param size defines the size of the texture
  91569. * @param options defines the options used to create the texture
  91570. * @returns a new render target cube texture stored in an InternalTexture
  91571. */
  91572. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  91573. }
  91574. }
  91575. declare module BABYLON {
  91576. /** @hidden */
  91577. export var proceduralVertexShader: {
  91578. name: string;
  91579. shader: string;
  91580. };
  91581. }
  91582. declare module BABYLON {
  91583. /**
  91584. * 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.
  91585. * This is the base class of any Procedural texture and contains most of the shareable code.
  91586. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  91587. */
  91588. export class ProceduralTexture extends Texture {
  91589. /**
  91590. * Define if the texture is enabled or not (disabled texture will not render)
  91591. */
  91592. isEnabled: boolean;
  91593. /**
  91594. * Define if the texture must be cleared before rendering (default is true)
  91595. */
  91596. autoClear: boolean;
  91597. /**
  91598. * Callback called when the texture is generated
  91599. */
  91600. onGenerated: () => void;
  91601. /**
  91602. * Event raised when the texture is generated
  91603. */
  91604. onGeneratedObservable: Observable<ProceduralTexture>;
  91605. /**
  91606. * Event raised before the texture is generated
  91607. */
  91608. onBeforeGenerationObservable: Observable<ProceduralTexture>;
  91609. /**
  91610. * Gets or sets the node material used to create this texture (null if the texture was manually created)
  91611. */
  91612. nodeMaterialSource: Nullable<NodeMaterial>;
  91613. /** @hidden */
  91614. _generateMipMaps: boolean;
  91615. /** @hidden **/
  91616. _effect: Effect;
  91617. /** @hidden */
  91618. _textures: {
  91619. [key: string]: Texture;
  91620. };
  91621. /** @hidden */
  91622. protected _fallbackTexture: Nullable<Texture>;
  91623. private _size;
  91624. private _currentRefreshId;
  91625. private _frameId;
  91626. private _refreshRate;
  91627. private _vertexBuffers;
  91628. private _indexBuffer;
  91629. private _uniforms;
  91630. private _samplers;
  91631. private _fragment;
  91632. private _floats;
  91633. private _ints;
  91634. private _floatsArrays;
  91635. private _colors3;
  91636. private _colors4;
  91637. private _vectors2;
  91638. private _vectors3;
  91639. private _matrices;
  91640. private _fallbackTextureUsed;
  91641. private _fullEngine;
  91642. private _cachedDefines;
  91643. private _contentUpdateId;
  91644. private _contentData;
  91645. /**
  91646. * Instantiates a new procedural texture.
  91647. * 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.
  91648. * This is the base class of any Procedural texture and contains most of the shareable code.
  91649. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  91650. * @param name Define the name of the texture
  91651. * @param size Define the size of the texture to create
  91652. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  91653. * @param scene Define the scene the texture belongs to
  91654. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  91655. * @param generateMipMaps Define if the texture should creates mip maps or not
  91656. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  91657. */
  91658. constructor(name: string, size: RenderTargetTextureSize, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  91659. /**
  91660. * The effect that is created when initializing the post process.
  91661. * @returns The created effect corresponding the the postprocess.
  91662. */
  91663. getEffect(): Effect;
  91664. /**
  91665. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  91666. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  91667. */
  91668. getContent(): Nullable<ArrayBufferView>;
  91669. private _createIndexBuffer;
  91670. /** @hidden */
  91671. _rebuild(): void;
  91672. /**
  91673. * Resets the texture in order to recreate its associated resources.
  91674. * This can be called in case of context loss
  91675. */
  91676. reset(): void;
  91677. protected _getDefines(): string;
  91678. /**
  91679. * Is the texture ready to be used ? (rendered at least once)
  91680. * @returns true if ready, otherwise, false.
  91681. */
  91682. isReady(): boolean;
  91683. /**
  91684. * Resets the refresh counter of the texture and start bak from scratch.
  91685. * Could be useful to regenerate the texture if it is setup to render only once.
  91686. */
  91687. resetRefreshCounter(): void;
  91688. /**
  91689. * Set the fragment shader to use in order to render the texture.
  91690. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  91691. */
  91692. setFragment(fragment: any): void;
  91693. /**
  91694. * Define the refresh rate of the texture or the rendering frequency.
  91695. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  91696. */
  91697. get refreshRate(): number;
  91698. set refreshRate(value: number);
  91699. /** @hidden */
  91700. _shouldRender(): boolean;
  91701. /**
  91702. * Get the size the texture is rendering at.
  91703. * @returns the size (on cube texture it is always squared)
  91704. */
  91705. getRenderSize(): RenderTargetTextureSize;
  91706. /**
  91707. * Resize the texture to new value.
  91708. * @param size Define the new size the texture should have
  91709. * @param generateMipMaps Define whether the new texture should create mip maps
  91710. */
  91711. resize(size: number, generateMipMaps: boolean): void;
  91712. private _checkUniform;
  91713. /**
  91714. * Set a texture in the shader program used to render.
  91715. * @param name Define the name of the uniform samplers as defined in the shader
  91716. * @param texture Define the texture to bind to this sampler
  91717. * @return the texture itself allowing "fluent" like uniform updates
  91718. */
  91719. setTexture(name: string, texture: Texture): ProceduralTexture;
  91720. /**
  91721. * Set a float in the shader.
  91722. * @param name Define the name of the uniform as defined in the shader
  91723. * @param value Define the value to give to the uniform
  91724. * @return the texture itself allowing "fluent" like uniform updates
  91725. */
  91726. setFloat(name: string, value: number): ProceduralTexture;
  91727. /**
  91728. * Set a int in the shader.
  91729. * @param name Define the name of the uniform as defined in the shader
  91730. * @param value Define the value to give to the uniform
  91731. * @return the texture itself allowing "fluent" like uniform updates
  91732. */
  91733. setInt(name: string, value: number): ProceduralTexture;
  91734. /**
  91735. * Set an array of floats in the shader.
  91736. * @param name Define the name of the uniform as defined in the shader
  91737. * @param value Define the value to give to the uniform
  91738. * @return the texture itself allowing "fluent" like uniform updates
  91739. */
  91740. setFloats(name: string, value: number[]): ProceduralTexture;
  91741. /**
  91742. * Set a vec3 in the shader from a Color3.
  91743. * @param name Define the name of the uniform as defined in the shader
  91744. * @param value Define the value to give to the uniform
  91745. * @return the texture itself allowing "fluent" like uniform updates
  91746. */
  91747. setColor3(name: string, value: Color3): ProceduralTexture;
  91748. /**
  91749. * Set a vec4 in the shader from a Color4.
  91750. * @param name Define the name of the uniform as defined in the shader
  91751. * @param value Define the value to give to the uniform
  91752. * @return the texture itself allowing "fluent" like uniform updates
  91753. */
  91754. setColor4(name: string, value: Color4): ProceduralTexture;
  91755. /**
  91756. * Set a vec2 in the shader from a Vector2.
  91757. * @param name Define the name of the uniform as defined in the shader
  91758. * @param value Define the value to give to the uniform
  91759. * @return the texture itself allowing "fluent" like uniform updates
  91760. */
  91761. setVector2(name: string, value: Vector2): ProceduralTexture;
  91762. /**
  91763. * Set a vec3 in the shader from a Vector3.
  91764. * @param name Define the name of the uniform as defined in the shader
  91765. * @param value Define the value to give to the uniform
  91766. * @return the texture itself allowing "fluent" like uniform updates
  91767. */
  91768. setVector3(name: string, value: Vector3): ProceduralTexture;
  91769. /**
  91770. * Set a mat4 in the shader from a MAtrix.
  91771. * @param name Define the name of the uniform as defined in the shader
  91772. * @param value Define the value to give to the uniform
  91773. * @return the texture itself allowing "fluent" like uniform updates
  91774. */
  91775. setMatrix(name: string, value: Matrix): ProceduralTexture;
  91776. /**
  91777. * Render the texture to its associated render target.
  91778. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  91779. */
  91780. render(useCameraPostProcess?: boolean): void;
  91781. /**
  91782. * Clone the texture.
  91783. * @returns the cloned texture
  91784. */
  91785. clone(): ProceduralTexture;
  91786. /**
  91787. * Dispose the texture and release its asoociated resources.
  91788. */
  91789. dispose(): void;
  91790. }
  91791. }
  91792. declare module BABYLON {
  91793. /**
  91794. * This represents the base class for particle system in Babylon.
  91795. * 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.
  91796. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  91797. * @example https://doc.babylonjs.com/babylon101/particles
  91798. */
  91799. export class BaseParticleSystem {
  91800. /**
  91801. * Source color is added to the destination color without alpha affecting the result
  91802. */
  91803. static BLENDMODE_ONEONE: number;
  91804. /**
  91805. * Blend current color and particle color using particle’s alpha
  91806. */
  91807. static BLENDMODE_STANDARD: number;
  91808. /**
  91809. * Add current color and particle color multiplied by particle’s alpha
  91810. */
  91811. static BLENDMODE_ADD: number;
  91812. /**
  91813. * Multiply current color with particle color
  91814. */
  91815. static BLENDMODE_MULTIPLY: number;
  91816. /**
  91817. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  91818. */
  91819. static BLENDMODE_MULTIPLYADD: number;
  91820. /**
  91821. * List of animations used by the particle system.
  91822. */
  91823. animations: Animation[];
  91824. /**
  91825. * Gets or sets the unique id of the particle system
  91826. */
  91827. uniqueId: number;
  91828. /**
  91829. * The id of the Particle system.
  91830. */
  91831. id: string;
  91832. /**
  91833. * The friendly name of the Particle system.
  91834. */
  91835. name: string;
  91836. /**
  91837. * Snippet ID if the particle system was created from the snippet server
  91838. */
  91839. snippetId: string;
  91840. /**
  91841. * The rendering group used by the Particle system to chose when to render.
  91842. */
  91843. renderingGroupId: number;
  91844. /**
  91845. * The emitter represents the Mesh or position we are attaching the particle system to.
  91846. */
  91847. emitter: Nullable<AbstractMesh | Vector3>;
  91848. /**
  91849. * The maximum number of particles to emit per frame
  91850. */
  91851. emitRate: number;
  91852. /**
  91853. * If you want to launch only a few particles at once, that can be done, as well.
  91854. */
  91855. manualEmitCount: number;
  91856. /**
  91857. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  91858. */
  91859. updateSpeed: number;
  91860. /**
  91861. * The amount of time the particle system is running (depends of the overall update speed).
  91862. */
  91863. targetStopDuration: number;
  91864. /**
  91865. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  91866. */
  91867. disposeOnStop: boolean;
  91868. /**
  91869. * Minimum power of emitting particles.
  91870. */
  91871. minEmitPower: number;
  91872. /**
  91873. * Maximum power of emitting particles.
  91874. */
  91875. maxEmitPower: number;
  91876. /**
  91877. * Minimum life time of emitting particles.
  91878. */
  91879. minLifeTime: number;
  91880. /**
  91881. * Maximum life time of emitting particles.
  91882. */
  91883. maxLifeTime: number;
  91884. /**
  91885. * Minimum Size of emitting particles.
  91886. */
  91887. minSize: number;
  91888. /**
  91889. * Maximum Size of emitting particles.
  91890. */
  91891. maxSize: number;
  91892. /**
  91893. * Minimum scale of emitting particles on X axis.
  91894. */
  91895. minScaleX: number;
  91896. /**
  91897. * Maximum scale of emitting particles on X axis.
  91898. */
  91899. maxScaleX: number;
  91900. /**
  91901. * Minimum scale of emitting particles on Y axis.
  91902. */
  91903. minScaleY: number;
  91904. /**
  91905. * Maximum scale of emitting particles on Y axis.
  91906. */
  91907. maxScaleY: number;
  91908. /**
  91909. * Gets or sets the minimal initial rotation in radians.
  91910. */
  91911. minInitialRotation: number;
  91912. /**
  91913. * Gets or sets the maximal initial rotation in radians.
  91914. */
  91915. maxInitialRotation: number;
  91916. /**
  91917. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  91918. */
  91919. minAngularSpeed: number;
  91920. /**
  91921. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  91922. */
  91923. maxAngularSpeed: number;
  91924. /**
  91925. * The texture used to render each particle. (this can be a spritesheet)
  91926. */
  91927. particleTexture: Nullable<BaseTexture>;
  91928. /**
  91929. * The layer mask we are rendering the particles through.
  91930. */
  91931. layerMask: number;
  91932. /**
  91933. * This can help using your own shader to render the particle system.
  91934. * The according effect will be created
  91935. */
  91936. customShader: any;
  91937. /**
  91938. * By default particle system starts as soon as they are created. This prevents the
  91939. * automatic start to happen and let you decide when to start emitting particles.
  91940. */
  91941. preventAutoStart: boolean;
  91942. private _noiseTexture;
  91943. /**
  91944. * Gets or sets a texture used to add random noise to particle positions
  91945. */
  91946. get noiseTexture(): Nullable<ProceduralTexture>;
  91947. set noiseTexture(value: Nullable<ProceduralTexture>);
  91948. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  91949. noiseStrength: Vector3;
  91950. /**
  91951. * Callback triggered when the particle animation is ending.
  91952. */
  91953. onAnimationEnd: Nullable<() => void>;
  91954. /**
  91955. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  91956. */
  91957. blendMode: number;
  91958. /**
  91959. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  91960. * to override the particles.
  91961. */
  91962. forceDepthWrite: boolean;
  91963. /** 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 */
  91964. preWarmCycles: number;
  91965. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  91966. preWarmStepOffset: number;
  91967. /**
  91968. * 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)
  91969. */
  91970. spriteCellChangeSpeed: number;
  91971. /**
  91972. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  91973. */
  91974. startSpriteCellID: number;
  91975. /**
  91976. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  91977. */
  91978. endSpriteCellID: number;
  91979. /**
  91980. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  91981. */
  91982. spriteCellWidth: number;
  91983. /**
  91984. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  91985. */
  91986. spriteCellHeight: number;
  91987. /**
  91988. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  91989. */
  91990. spriteRandomStartCell: boolean;
  91991. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  91992. translationPivot: Vector2;
  91993. /** @hidden */
  91994. protected _isAnimationSheetEnabled: boolean;
  91995. /**
  91996. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  91997. */
  91998. beginAnimationOnStart: boolean;
  91999. /**
  92000. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  92001. */
  92002. beginAnimationFrom: number;
  92003. /**
  92004. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  92005. */
  92006. beginAnimationTo: number;
  92007. /**
  92008. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  92009. */
  92010. beginAnimationLoop: boolean;
  92011. /**
  92012. * Gets or sets a world offset applied to all particles
  92013. */
  92014. worldOffset: Vector3;
  92015. /**
  92016. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  92017. */
  92018. get isAnimationSheetEnabled(): boolean;
  92019. set isAnimationSheetEnabled(value: boolean);
  92020. /**
  92021. * Get hosting scene
  92022. * @returns the scene
  92023. */
  92024. getScene(): Nullable<Scene>;
  92025. /**
  92026. * You can use gravity if you want to give an orientation to your particles.
  92027. */
  92028. gravity: Vector3;
  92029. protected _colorGradients: Nullable<Array<ColorGradient>>;
  92030. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  92031. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  92032. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  92033. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  92034. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  92035. protected _dragGradients: Nullable<Array<FactorGradient>>;
  92036. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  92037. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  92038. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  92039. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  92040. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  92041. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  92042. /**
  92043. * Defines the delay in milliseconds before starting the system (0 by default)
  92044. */
  92045. startDelay: number;
  92046. /**
  92047. * Gets the current list of drag gradients.
  92048. * You must use addDragGradient and removeDragGradient to udpate this list
  92049. * @returns the list of drag gradients
  92050. */
  92051. getDragGradients(): Nullable<Array<FactorGradient>>;
  92052. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  92053. limitVelocityDamping: number;
  92054. /**
  92055. * Gets the current list of limit velocity gradients.
  92056. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  92057. * @returns the list of limit velocity gradients
  92058. */
  92059. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  92060. /**
  92061. * Gets the current list of color gradients.
  92062. * You must use addColorGradient and removeColorGradient to udpate this list
  92063. * @returns the list of color gradients
  92064. */
  92065. getColorGradients(): Nullable<Array<ColorGradient>>;
  92066. /**
  92067. * Gets the current list of size gradients.
  92068. * You must use addSizeGradient and removeSizeGradient to udpate this list
  92069. * @returns the list of size gradients
  92070. */
  92071. getSizeGradients(): Nullable<Array<FactorGradient>>;
  92072. /**
  92073. * Gets the current list of color remap gradients.
  92074. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  92075. * @returns the list of color remap gradients
  92076. */
  92077. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  92078. /**
  92079. * Gets the current list of alpha remap gradients.
  92080. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  92081. * @returns the list of alpha remap gradients
  92082. */
  92083. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  92084. /**
  92085. * Gets the current list of life time gradients.
  92086. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  92087. * @returns the list of life time gradients
  92088. */
  92089. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  92090. /**
  92091. * Gets the current list of angular speed gradients.
  92092. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  92093. * @returns the list of angular speed gradients
  92094. */
  92095. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  92096. /**
  92097. * Gets the current list of velocity gradients.
  92098. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  92099. * @returns the list of velocity gradients
  92100. */
  92101. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  92102. /**
  92103. * Gets the current list of start size gradients.
  92104. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  92105. * @returns the list of start size gradients
  92106. */
  92107. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  92108. /**
  92109. * Gets the current list of emit rate gradients.
  92110. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  92111. * @returns the list of emit rate gradients
  92112. */
  92113. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  92114. /**
  92115. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  92116. * This only works when particleEmitterTyps is a BoxParticleEmitter
  92117. */
  92118. get direction1(): Vector3;
  92119. set direction1(value: Vector3);
  92120. /**
  92121. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  92122. * This only works when particleEmitterTyps is a BoxParticleEmitter
  92123. */
  92124. get direction2(): Vector3;
  92125. set direction2(value: Vector3);
  92126. /**
  92127. * 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.
  92128. * This only works when particleEmitterTyps is a BoxParticleEmitter
  92129. */
  92130. get minEmitBox(): Vector3;
  92131. set minEmitBox(value: Vector3);
  92132. /**
  92133. * 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.
  92134. * This only works when particleEmitterTyps is a BoxParticleEmitter
  92135. */
  92136. get maxEmitBox(): Vector3;
  92137. set maxEmitBox(value: Vector3);
  92138. /**
  92139. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  92140. */
  92141. color1: Color4;
  92142. /**
  92143. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  92144. */
  92145. color2: Color4;
  92146. /**
  92147. * Color the particle will have at the end of its lifetime
  92148. */
  92149. colorDead: Color4;
  92150. /**
  92151. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  92152. */
  92153. textureMask: Color4;
  92154. /**
  92155. * The particle emitter type defines the emitter used by the particle system.
  92156. * It can be for example box, sphere, or cone...
  92157. */
  92158. particleEmitterType: IParticleEmitterType;
  92159. /** @hidden */
  92160. _isSubEmitter: boolean;
  92161. /**
  92162. * Gets or sets the billboard mode to use when isBillboardBased = true.
  92163. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  92164. */
  92165. billboardMode: number;
  92166. protected _isBillboardBased: boolean;
  92167. /**
  92168. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  92169. */
  92170. get isBillboardBased(): boolean;
  92171. set isBillboardBased(value: boolean);
  92172. /**
  92173. * The scene the particle system belongs to.
  92174. */
  92175. protected _scene: Nullable<Scene>;
  92176. /**
  92177. * The engine the particle system belongs to.
  92178. */
  92179. protected _engine: ThinEngine;
  92180. /**
  92181. * Local cache of defines for image processing.
  92182. */
  92183. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  92184. /**
  92185. * Default configuration related to image processing available in the standard Material.
  92186. */
  92187. protected _imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  92188. /**
  92189. * Gets the image processing configuration used either in this material.
  92190. */
  92191. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  92192. /**
  92193. * Sets the Default image processing configuration used either in the this material.
  92194. *
  92195. * If sets to null, the scene one is in use.
  92196. */
  92197. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  92198. /**
  92199. * Attaches a new image processing configuration to the Standard Material.
  92200. * @param configuration
  92201. */
  92202. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  92203. /** @hidden */
  92204. protected _reset(): void;
  92205. /** @hidden */
  92206. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  92207. /**
  92208. * Instantiates a particle system.
  92209. * 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.
  92210. * @param name The name of the particle system
  92211. */
  92212. constructor(name: string);
  92213. /**
  92214. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  92215. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  92216. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  92217. * @returns the emitter
  92218. */
  92219. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  92220. /**
  92221. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  92222. * @param radius The radius of the hemisphere to emit from
  92223. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  92224. * @returns the emitter
  92225. */
  92226. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  92227. /**
  92228. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  92229. * @param radius The radius of the sphere to emit from
  92230. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  92231. * @returns the emitter
  92232. */
  92233. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  92234. /**
  92235. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  92236. * @param radius The radius of the sphere to emit from
  92237. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  92238. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  92239. * @returns the emitter
  92240. */
  92241. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  92242. /**
  92243. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  92244. * @param radius The radius of the emission cylinder
  92245. * @param height The height of the emission cylinder
  92246. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  92247. * @param directionRandomizer How much to randomize the particle direction [0-1]
  92248. * @returns the emitter
  92249. */
  92250. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  92251. /**
  92252. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  92253. * @param radius The radius of the cylinder to emit from
  92254. * @param height The height of the emission cylinder
  92255. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  92256. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  92257. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  92258. * @returns the emitter
  92259. */
  92260. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  92261. /**
  92262. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  92263. * @param radius The radius of the cone to emit from
  92264. * @param angle The base angle of the cone
  92265. * @returns the emitter
  92266. */
  92267. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  92268. /**
  92269. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  92270. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  92271. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  92272. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  92273. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  92274. * @returns the emitter
  92275. */
  92276. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  92277. }
  92278. }
  92279. declare module BABYLON {
  92280. /**
  92281. * Type of sub emitter
  92282. */
  92283. export enum SubEmitterType {
  92284. /**
  92285. * Attached to the particle over it's lifetime
  92286. */
  92287. ATTACHED = 0,
  92288. /**
  92289. * Created when the particle dies
  92290. */
  92291. END = 1
  92292. }
  92293. /**
  92294. * Sub emitter class used to emit particles from an existing particle
  92295. */
  92296. export class SubEmitter {
  92297. /**
  92298. * the particle system to be used by the sub emitter
  92299. */
  92300. particleSystem: ParticleSystem;
  92301. /**
  92302. * Type of the submitter (Default: END)
  92303. */
  92304. type: SubEmitterType;
  92305. /**
  92306. * 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)
  92307. * Note: This only is supported when using an emitter of type Mesh
  92308. */
  92309. inheritDirection: boolean;
  92310. /**
  92311. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  92312. */
  92313. inheritedVelocityAmount: number;
  92314. /**
  92315. * Creates a sub emitter
  92316. * @param particleSystem the particle system to be used by the sub emitter
  92317. */
  92318. constructor(
  92319. /**
  92320. * the particle system to be used by the sub emitter
  92321. */
  92322. particleSystem: ParticleSystem);
  92323. /**
  92324. * Clones the sub emitter
  92325. * @returns the cloned sub emitter
  92326. */
  92327. clone(): SubEmitter;
  92328. /**
  92329. * Serialize current object to a JSON object
  92330. * @returns the serialized object
  92331. */
  92332. serialize(): any;
  92333. /** @hidden */
  92334. static _ParseParticleSystem(system: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): ParticleSystem;
  92335. /**
  92336. * Creates a new SubEmitter from a serialized JSON version
  92337. * @param serializationObject defines the JSON object to read from
  92338. * @param sceneOrEngine defines the hosting scene or the hosting engine
  92339. * @param rootUrl defines the rootUrl for data loading
  92340. * @returns a new SubEmitter
  92341. */
  92342. static Parse(serializationObject: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): SubEmitter;
  92343. /** Release associated resources */
  92344. dispose(): void;
  92345. }
  92346. }
  92347. declare module BABYLON {
  92348. /** @hidden */
  92349. export var imageProcessingDeclaration: {
  92350. name: string;
  92351. shader: string;
  92352. };
  92353. }
  92354. declare module BABYLON {
  92355. /** @hidden */
  92356. export var imageProcessingFunctions: {
  92357. name: string;
  92358. shader: string;
  92359. };
  92360. }
  92361. declare module BABYLON {
  92362. /** @hidden */
  92363. export var particlesPixelShader: {
  92364. name: string;
  92365. shader: string;
  92366. };
  92367. }
  92368. declare module BABYLON {
  92369. /** @hidden */
  92370. export var particlesVertexShader: {
  92371. name: string;
  92372. shader: string;
  92373. };
  92374. }
  92375. declare module BABYLON {
  92376. /**
  92377. * Interface used to define entities containing multiple clip planes
  92378. */
  92379. export interface IClipPlanesHolder {
  92380. /**
  92381. * Gets or sets the active clipplane 1
  92382. */
  92383. clipPlane: Nullable<Plane>;
  92384. /**
  92385. * Gets or sets the active clipplane 2
  92386. */
  92387. clipPlane2: Nullable<Plane>;
  92388. /**
  92389. * Gets or sets the active clipplane 3
  92390. */
  92391. clipPlane3: Nullable<Plane>;
  92392. /**
  92393. * Gets or sets the active clipplane 4
  92394. */
  92395. clipPlane4: Nullable<Plane>;
  92396. /**
  92397. * Gets or sets the active clipplane 5
  92398. */
  92399. clipPlane5: Nullable<Plane>;
  92400. /**
  92401. * Gets or sets the active clipplane 6
  92402. */
  92403. clipPlane6: Nullable<Plane>;
  92404. }
  92405. }
  92406. declare module BABYLON {
  92407. /**
  92408. * "Static Class" containing a few commonly used helper while dealing with material for rendering purpose.
  92409. *
  92410. * It is complementary with MaterialHelper but provides completely independent functions (for tree shaking sake)
  92411. *
  92412. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  92413. */
  92414. export class ThinMaterialHelper {
  92415. /**
  92416. * Binds the clip plane information from the holder to the effect.
  92417. * @param effect The effect we are binding the data to
  92418. * @param holder The entity containing the clip plane information
  92419. */
  92420. static BindClipPlane(effect: Effect, holder: IClipPlanesHolder): void;
  92421. }
  92422. }
  92423. declare module BABYLON {
  92424. interface ThinEngine {
  92425. /**
  92426. * Sets alpha constants used by some alpha blending modes
  92427. * @param r defines the red component
  92428. * @param g defines the green component
  92429. * @param b defines the blue component
  92430. * @param a defines the alpha component
  92431. */
  92432. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  92433. /**
  92434. * Sets the current alpha mode
  92435. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  92436. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  92437. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  92438. */
  92439. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  92440. /**
  92441. * Gets the current alpha mode
  92442. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  92443. * @returns the current alpha mode
  92444. */
  92445. getAlphaMode(): number;
  92446. /**
  92447. * Sets the current alpha equation
  92448. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  92449. */
  92450. setAlphaEquation(equation: number): void;
  92451. /**
  92452. * Gets the current alpha equation.
  92453. * @returns the current alpha equation
  92454. */
  92455. getAlphaEquation(): number;
  92456. }
  92457. }
  92458. declare module BABYLON {
  92459. /**
  92460. * This represents a particle system in Babylon.
  92461. * 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.
  92462. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  92463. * @example https://doc.babylonjs.com/babylon101/particles
  92464. */
  92465. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  92466. /**
  92467. * Billboard mode will only apply to Y axis
  92468. */
  92469. static readonly BILLBOARDMODE_Y: number;
  92470. /**
  92471. * Billboard mode will apply to all axes
  92472. */
  92473. static readonly BILLBOARDMODE_ALL: number;
  92474. /**
  92475. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  92476. */
  92477. static readonly BILLBOARDMODE_STRETCHED: number;
  92478. /**
  92479. * This function can be defined to provide custom update for active particles.
  92480. * This function will be called instead of regular update (age, position, color, etc.).
  92481. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  92482. */
  92483. updateFunction: (particles: Particle[]) => void;
  92484. private _emitterWorldMatrix;
  92485. /**
  92486. * This function can be defined to specify initial direction for every new particle.
  92487. * It by default use the emitterType defined function
  92488. */
  92489. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  92490. /**
  92491. * This function can be defined to specify initial position for every new particle.
  92492. * It by default use the emitterType defined function
  92493. */
  92494. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  92495. /**
  92496. * @hidden
  92497. */
  92498. _inheritedVelocityOffset: Vector3;
  92499. /**
  92500. * An event triggered when the system is disposed
  92501. */
  92502. onDisposeObservable: Observable<IParticleSystem>;
  92503. private _onDisposeObserver;
  92504. /**
  92505. * Sets a callback that will be triggered when the system is disposed
  92506. */
  92507. set onDispose(callback: () => void);
  92508. private _particles;
  92509. private _epsilon;
  92510. private _capacity;
  92511. private _stockParticles;
  92512. private _newPartsExcess;
  92513. private _vertexData;
  92514. private _vertexBuffer;
  92515. private _vertexBuffers;
  92516. private _spriteBuffer;
  92517. private _indexBuffer;
  92518. private _effect;
  92519. private _customEffect;
  92520. private _cachedDefines;
  92521. private _scaledColorStep;
  92522. private _colorDiff;
  92523. private _scaledDirection;
  92524. private _scaledGravity;
  92525. private _currentRenderId;
  92526. private _alive;
  92527. private _useInstancing;
  92528. private _started;
  92529. private _stopped;
  92530. private _actualFrame;
  92531. private _scaledUpdateSpeed;
  92532. private _vertexBufferSize;
  92533. /** @hidden */
  92534. _currentEmitRateGradient: Nullable<FactorGradient>;
  92535. /** @hidden */
  92536. _currentEmitRate1: number;
  92537. /** @hidden */
  92538. _currentEmitRate2: number;
  92539. /** @hidden */
  92540. _currentStartSizeGradient: Nullable<FactorGradient>;
  92541. /** @hidden */
  92542. _currentStartSize1: number;
  92543. /** @hidden */
  92544. _currentStartSize2: number;
  92545. private readonly _rawTextureWidth;
  92546. private _rampGradientsTexture;
  92547. private _useRampGradients;
  92548. /** Gets or sets a matrix to use to compute projection */
  92549. defaultProjectionMatrix: Matrix;
  92550. /** Gets or sets a matrix to use to compute view */
  92551. defaultViewMatrix: Matrix;
  92552. /** Gets or sets a boolean indicating that ramp gradients must be used
  92553. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  92554. */
  92555. get useRampGradients(): boolean;
  92556. set useRampGradients(value: boolean);
  92557. /**
  92558. * 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.
  92559. * 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: [])
  92560. */
  92561. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  92562. private _subEmitters;
  92563. /**
  92564. * @hidden
  92565. * If the particle systems emitter should be disposed when the particle system is disposed
  92566. */
  92567. _disposeEmitterOnDispose: boolean;
  92568. /**
  92569. * The current active Sub-systems, this property is used by the root particle system only.
  92570. */
  92571. activeSubSystems: Array<ParticleSystem>;
  92572. /**
  92573. * Specifies if the particles are updated in emitter local space or world space
  92574. */
  92575. isLocal: boolean;
  92576. private _rootParticleSystem;
  92577. /**
  92578. * Gets the current list of active particles
  92579. */
  92580. get particles(): Particle[];
  92581. /**
  92582. * Gets the number of particles active at the same time.
  92583. * @returns The number of active particles.
  92584. */
  92585. getActiveCount(): number;
  92586. /**
  92587. * Returns the string "ParticleSystem"
  92588. * @returns a string containing the class name
  92589. */
  92590. getClassName(): string;
  92591. /**
  92592. * Gets a boolean indicating that the system is stopping
  92593. * @returns true if the system is currently stopping
  92594. */
  92595. isStopping(): boolean;
  92596. /**
  92597. * Gets the custom effect used to render the particles
  92598. * @param blendMode Blend mode for which the effect should be retrieved
  92599. * @returns The effect
  92600. */
  92601. getCustomEffect(blendMode?: number): Nullable<Effect>;
  92602. /**
  92603. * Sets the custom effect used to render the particles
  92604. * @param effect The effect to set
  92605. * @param blendMode Blend mode for which the effect should be set
  92606. */
  92607. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  92608. /** @hidden */
  92609. private _onBeforeDrawParticlesObservable;
  92610. /**
  92611. * Observable that will be called just before the particles are drawn
  92612. */
  92613. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  92614. /**
  92615. * Gets the name of the particle vertex shader
  92616. */
  92617. get vertexShaderName(): string;
  92618. /**
  92619. * Instantiates a particle system.
  92620. * 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.
  92621. * @param name The name of the particle system
  92622. * @param capacity The max number of particles alive at the same time
  92623. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  92624. * @param customEffect a custom effect used to change the way particles are rendered by default
  92625. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  92626. * @param epsilon Offset used to render the particles
  92627. */
  92628. constructor(name: string, capacity: number, sceneOrEngine: Scene | ThinEngine, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  92629. private _addFactorGradient;
  92630. private _removeFactorGradient;
  92631. /**
  92632. * Adds a new life time gradient
  92633. * @param gradient defines the gradient to use (between 0 and 1)
  92634. * @param factor defines the life time factor to affect to the specified gradient
  92635. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  92636. * @returns the current particle system
  92637. */
  92638. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  92639. /**
  92640. * Remove a specific life time gradient
  92641. * @param gradient defines the gradient to remove
  92642. * @returns the current particle system
  92643. */
  92644. removeLifeTimeGradient(gradient: number): IParticleSystem;
  92645. /**
  92646. * Adds a new size gradient
  92647. * @param gradient defines the gradient to use (between 0 and 1)
  92648. * @param factor defines the size factor to affect to the specified gradient
  92649. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  92650. * @returns the current particle system
  92651. */
  92652. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  92653. /**
  92654. * Remove a specific size gradient
  92655. * @param gradient defines the gradient to remove
  92656. * @returns the current particle system
  92657. */
  92658. removeSizeGradient(gradient: number): IParticleSystem;
  92659. /**
  92660. * Adds a new color remap gradient
  92661. * @param gradient defines the gradient to use (between 0 and 1)
  92662. * @param min defines the color remap minimal range
  92663. * @param max defines the color remap maximal range
  92664. * @returns the current particle system
  92665. */
  92666. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  92667. /**
  92668. * Remove a specific color remap gradient
  92669. * @param gradient defines the gradient to remove
  92670. * @returns the current particle system
  92671. */
  92672. removeColorRemapGradient(gradient: number): IParticleSystem;
  92673. /**
  92674. * Adds a new alpha remap gradient
  92675. * @param gradient defines the gradient to use (between 0 and 1)
  92676. * @param min defines the alpha remap minimal range
  92677. * @param max defines the alpha remap maximal range
  92678. * @returns the current particle system
  92679. */
  92680. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  92681. /**
  92682. * Remove a specific alpha remap gradient
  92683. * @param gradient defines the gradient to remove
  92684. * @returns the current particle system
  92685. */
  92686. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  92687. /**
  92688. * Adds a new angular speed gradient
  92689. * @param gradient defines the gradient to use (between 0 and 1)
  92690. * @param factor defines the angular speed to affect to the specified gradient
  92691. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  92692. * @returns the current particle system
  92693. */
  92694. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  92695. /**
  92696. * Remove a specific angular speed gradient
  92697. * @param gradient defines the gradient to remove
  92698. * @returns the current particle system
  92699. */
  92700. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  92701. /**
  92702. * Adds a new velocity gradient
  92703. * @param gradient defines the gradient to use (between 0 and 1)
  92704. * @param factor defines the velocity to affect to the specified gradient
  92705. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  92706. * @returns the current particle system
  92707. */
  92708. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  92709. /**
  92710. * Remove a specific velocity gradient
  92711. * @param gradient defines the gradient to remove
  92712. * @returns the current particle system
  92713. */
  92714. removeVelocityGradient(gradient: number): IParticleSystem;
  92715. /**
  92716. * Adds a new limit velocity gradient
  92717. * @param gradient defines the gradient to use (between 0 and 1)
  92718. * @param factor defines the limit velocity value to affect to the specified gradient
  92719. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  92720. * @returns the current particle system
  92721. */
  92722. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  92723. /**
  92724. * Remove a specific limit velocity gradient
  92725. * @param gradient defines the gradient to remove
  92726. * @returns the current particle system
  92727. */
  92728. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  92729. /**
  92730. * Adds a new drag gradient
  92731. * @param gradient defines the gradient to use (between 0 and 1)
  92732. * @param factor defines the drag value to affect to the specified gradient
  92733. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  92734. * @returns the current particle system
  92735. */
  92736. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  92737. /**
  92738. * Remove a specific drag gradient
  92739. * @param gradient defines the gradient to remove
  92740. * @returns the current particle system
  92741. */
  92742. removeDragGradient(gradient: number): IParticleSystem;
  92743. /**
  92744. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  92745. * @param gradient defines the gradient to use (between 0 and 1)
  92746. * @param factor defines the emit rate value to affect to the specified gradient
  92747. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  92748. * @returns the current particle system
  92749. */
  92750. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  92751. /**
  92752. * Remove a specific emit rate gradient
  92753. * @param gradient defines the gradient to remove
  92754. * @returns the current particle system
  92755. */
  92756. removeEmitRateGradient(gradient: number): IParticleSystem;
  92757. /**
  92758. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  92759. * @param gradient defines the gradient to use (between 0 and 1)
  92760. * @param factor defines the start size value to affect to the specified gradient
  92761. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  92762. * @returns the current particle system
  92763. */
  92764. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  92765. /**
  92766. * Remove a specific start size gradient
  92767. * @param gradient defines the gradient to remove
  92768. * @returns the current particle system
  92769. */
  92770. removeStartSizeGradient(gradient: number): IParticleSystem;
  92771. private _createRampGradientTexture;
  92772. /**
  92773. * Gets the current list of ramp gradients.
  92774. * You must use addRampGradient and removeRampGradient to udpate this list
  92775. * @returns the list of ramp gradients
  92776. */
  92777. getRampGradients(): Nullable<Array<Color3Gradient>>;
  92778. /** Force the system to rebuild all gradients that need to be resync */
  92779. forceRefreshGradients(): void;
  92780. private _syncRampGradientTexture;
  92781. /**
  92782. * Adds a new ramp gradient used to remap particle colors
  92783. * @param gradient defines the gradient to use (between 0 and 1)
  92784. * @param color defines the color to affect to the specified gradient
  92785. * @returns the current particle system
  92786. */
  92787. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  92788. /**
  92789. * Remove a specific ramp gradient
  92790. * @param gradient defines the gradient to remove
  92791. * @returns the current particle system
  92792. */
  92793. removeRampGradient(gradient: number): ParticleSystem;
  92794. /**
  92795. * Adds a new color gradient
  92796. * @param gradient defines the gradient to use (between 0 and 1)
  92797. * @param color1 defines the color to affect to the specified gradient
  92798. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  92799. * @returns this particle system
  92800. */
  92801. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  92802. /**
  92803. * Remove a specific color gradient
  92804. * @param gradient defines the gradient to remove
  92805. * @returns this particle system
  92806. */
  92807. removeColorGradient(gradient: number): IParticleSystem;
  92808. private _fetchR;
  92809. protected _reset(): void;
  92810. private _resetEffect;
  92811. private _createVertexBuffers;
  92812. private _createIndexBuffer;
  92813. /**
  92814. * Gets the maximum number of particles active at the same time.
  92815. * @returns The max number of active particles.
  92816. */
  92817. getCapacity(): number;
  92818. /**
  92819. * Gets whether there are still active particles in the system.
  92820. * @returns True if it is alive, otherwise false.
  92821. */
  92822. isAlive(): boolean;
  92823. /**
  92824. * Gets if the system has been started. (Note: this will still be true after stop is called)
  92825. * @returns True if it has been started, otherwise false.
  92826. */
  92827. isStarted(): boolean;
  92828. private _prepareSubEmitterInternalArray;
  92829. /**
  92830. * Starts the particle system and begins to emit
  92831. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  92832. */
  92833. start(delay?: number): void;
  92834. /**
  92835. * Stops the particle system.
  92836. * @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.
  92837. */
  92838. stop(stopSubEmitters?: boolean): void;
  92839. /**
  92840. * Remove all active particles
  92841. */
  92842. reset(): void;
  92843. /**
  92844. * @hidden (for internal use only)
  92845. */
  92846. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  92847. /**
  92848. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  92849. * Its lifetime will start back at 0.
  92850. */
  92851. recycleParticle: (particle: Particle) => void;
  92852. private _stopSubEmitters;
  92853. private _createParticle;
  92854. private _removeFromRoot;
  92855. private _emitFromParticle;
  92856. private _update;
  92857. /** @hidden */
  92858. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  92859. /** @hidden */
  92860. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  92861. /**
  92862. * Fill the defines array according to the current settings of the particle system
  92863. * @param defines Array to be updated
  92864. * @param blendMode blend mode to take into account when updating the array
  92865. */
  92866. fillDefines(defines: Array<string>, blendMode: number): void;
  92867. /**
  92868. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  92869. * @param uniforms Uniforms array to fill
  92870. * @param attributes Attributes array to fill
  92871. * @param samplers Samplers array to fill
  92872. */
  92873. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  92874. /** @hidden */
  92875. private _getEffect;
  92876. /**
  92877. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  92878. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  92879. */
  92880. animate(preWarmOnly?: boolean): void;
  92881. private _appendParticleVertices;
  92882. /**
  92883. * Rebuilds the particle system.
  92884. */
  92885. rebuild(): void;
  92886. /**
  92887. * Is this system ready to be used/rendered
  92888. * @return true if the system is ready
  92889. */
  92890. isReady(): boolean;
  92891. private _render;
  92892. /**
  92893. * Renders the particle system in its current state.
  92894. * @returns the current number of particles
  92895. */
  92896. render(): number;
  92897. /**
  92898. * Disposes the particle system and free the associated resources
  92899. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  92900. */
  92901. dispose(disposeTexture?: boolean): void;
  92902. /**
  92903. * Clones the particle system.
  92904. * @param name The name of the cloned object
  92905. * @param newEmitter The new emitter to use
  92906. * @returns the cloned particle system
  92907. */
  92908. clone(name: string, newEmitter: any): ParticleSystem;
  92909. /**
  92910. * Serializes the particle system to a JSON object
  92911. * @param serializeTexture defines if the texture must be serialized as well
  92912. * @returns the JSON object
  92913. */
  92914. serialize(serializeTexture?: boolean): any;
  92915. /** @hidden */
  92916. static _Serialize(serializationObject: any, particleSystem: IParticleSystem, serializeTexture: boolean): void;
  92917. /** @hidden */
  92918. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, sceneOrEngine: Scene | ThinEngine, rootUrl: string): void;
  92919. /**
  92920. * Parses a JSON object to create a particle system.
  92921. * @param parsedParticleSystem The JSON object to parse
  92922. * @param sceneOrEngine The scene or the engine to create the particle system in
  92923. * @param rootUrl The root url to use to load external dependencies like texture
  92924. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  92925. * @returns the Parsed particle system
  92926. */
  92927. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  92928. }
  92929. }
  92930. declare module BABYLON {
  92931. /**
  92932. * A particle represents one of the element emitted by a particle system.
  92933. * This is mainly define by its coordinates, direction, velocity and age.
  92934. */
  92935. export class Particle {
  92936. /**
  92937. * The particle system the particle belongs to.
  92938. */
  92939. particleSystem: ParticleSystem;
  92940. private static _Count;
  92941. /**
  92942. * Unique ID of the particle
  92943. */
  92944. id: number;
  92945. /**
  92946. * The world position of the particle in the scene.
  92947. */
  92948. position: Vector3;
  92949. /**
  92950. * The world direction of the particle in the scene.
  92951. */
  92952. direction: Vector3;
  92953. /**
  92954. * The color of the particle.
  92955. */
  92956. color: Color4;
  92957. /**
  92958. * The color change of the particle per step.
  92959. */
  92960. colorStep: Color4;
  92961. /**
  92962. * Defines how long will the life of the particle be.
  92963. */
  92964. lifeTime: number;
  92965. /**
  92966. * The current age of the particle.
  92967. */
  92968. age: number;
  92969. /**
  92970. * The current size of the particle.
  92971. */
  92972. size: number;
  92973. /**
  92974. * The current scale of the particle.
  92975. */
  92976. scale: Vector2;
  92977. /**
  92978. * The current angle of the particle.
  92979. */
  92980. angle: number;
  92981. /**
  92982. * Defines how fast is the angle changing.
  92983. */
  92984. angularSpeed: number;
  92985. /**
  92986. * Defines the cell index used by the particle to be rendered from a sprite.
  92987. */
  92988. cellIndex: number;
  92989. /**
  92990. * The information required to support color remapping
  92991. */
  92992. remapData: Vector4;
  92993. /** @hidden */
  92994. _randomCellOffset?: number;
  92995. /** @hidden */
  92996. _initialDirection: Nullable<Vector3>;
  92997. /** @hidden */
  92998. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  92999. /** @hidden */
  93000. _initialStartSpriteCellID: number;
  93001. /** @hidden */
  93002. _initialEndSpriteCellID: number;
  93003. /** @hidden */
  93004. _currentColorGradient: Nullable<ColorGradient>;
  93005. /** @hidden */
  93006. _currentColor1: Color4;
  93007. /** @hidden */
  93008. _currentColor2: Color4;
  93009. /** @hidden */
  93010. _currentSizeGradient: Nullable<FactorGradient>;
  93011. /** @hidden */
  93012. _currentSize1: number;
  93013. /** @hidden */
  93014. _currentSize2: number;
  93015. /** @hidden */
  93016. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  93017. /** @hidden */
  93018. _currentAngularSpeed1: number;
  93019. /** @hidden */
  93020. _currentAngularSpeed2: number;
  93021. /** @hidden */
  93022. _currentVelocityGradient: Nullable<FactorGradient>;
  93023. /** @hidden */
  93024. _currentVelocity1: number;
  93025. /** @hidden */
  93026. _currentVelocity2: number;
  93027. /** @hidden */
  93028. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  93029. /** @hidden */
  93030. _currentLimitVelocity1: number;
  93031. /** @hidden */
  93032. _currentLimitVelocity2: number;
  93033. /** @hidden */
  93034. _currentDragGradient: Nullable<FactorGradient>;
  93035. /** @hidden */
  93036. _currentDrag1: number;
  93037. /** @hidden */
  93038. _currentDrag2: number;
  93039. /** @hidden */
  93040. _randomNoiseCoordinates1: Vector3;
  93041. /** @hidden */
  93042. _randomNoiseCoordinates2: Vector3;
  93043. /** @hidden */
  93044. _localPosition?: Vector3;
  93045. /**
  93046. * Creates a new instance Particle
  93047. * @param particleSystem the particle system the particle belongs to
  93048. */
  93049. constructor(
  93050. /**
  93051. * The particle system the particle belongs to.
  93052. */
  93053. particleSystem: ParticleSystem);
  93054. private updateCellInfoFromSystem;
  93055. /**
  93056. * Defines how the sprite cell index is updated for the particle
  93057. */
  93058. updateCellIndex(): void;
  93059. /** @hidden */
  93060. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  93061. /** @hidden */
  93062. _inheritParticleInfoToSubEmitters(): void;
  93063. /** @hidden */
  93064. _reset(): void;
  93065. /**
  93066. * Copy the properties of particle to another one.
  93067. * @param other the particle to copy the information to.
  93068. */
  93069. copyTo(other: Particle): void;
  93070. }
  93071. }
  93072. declare module BABYLON {
  93073. /**
  93074. * Particle emitter represents a volume emitting particles.
  93075. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  93076. */
  93077. export interface IParticleEmitterType {
  93078. /**
  93079. * Called by the particle System when the direction is computed for the created particle.
  93080. * @param worldMatrix is the world matrix of the particle system
  93081. * @param directionToUpdate is the direction vector to update with the result
  93082. * @param particle is the particle we are computed the direction for
  93083. * @param isLocal defines if the direction should be set in local space
  93084. */
  93085. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  93086. /**
  93087. * Called by the particle System when the position is computed for the created particle.
  93088. * @param worldMatrix is the world matrix of the particle system
  93089. * @param positionToUpdate is the position vector to update with the result
  93090. * @param particle is the particle we are computed the position for
  93091. * @param isLocal defines if the position should be set in local space
  93092. */
  93093. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  93094. /**
  93095. * Clones the current emitter and returns a copy of it
  93096. * @returns the new emitter
  93097. */
  93098. clone(): IParticleEmitterType;
  93099. /**
  93100. * Called by the GPUParticleSystem to setup the update shader
  93101. * @param effect defines the update shader
  93102. */
  93103. applyToShader(effect: Effect): void;
  93104. /**
  93105. * Returns a string to use to update the GPU particles update shader
  93106. * @returns the effect defines string
  93107. */
  93108. getEffectDefines(): string;
  93109. /**
  93110. * Returns a string representing the class name
  93111. * @returns a string containing the class name
  93112. */
  93113. getClassName(): string;
  93114. /**
  93115. * Serializes the particle system to a JSON object.
  93116. * @returns the JSON object
  93117. */
  93118. serialize(): any;
  93119. /**
  93120. * Parse properties from a JSON object
  93121. * @param serializationObject defines the JSON object
  93122. * @param scene defines the hosting scene
  93123. */
  93124. parse(serializationObject: any, scene: Nullable<Scene>): void;
  93125. }
  93126. }
  93127. declare module BABYLON {
  93128. /**
  93129. * Particle emitter emitting particles from the inside of a box.
  93130. * It emits the particles randomly between 2 given directions.
  93131. */
  93132. export class BoxParticleEmitter implements IParticleEmitterType {
  93133. /**
  93134. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  93135. */
  93136. direction1: Vector3;
  93137. /**
  93138. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  93139. */
  93140. direction2: Vector3;
  93141. /**
  93142. * 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.
  93143. */
  93144. minEmitBox: Vector3;
  93145. /**
  93146. * 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.
  93147. */
  93148. maxEmitBox: Vector3;
  93149. /**
  93150. * Creates a new instance BoxParticleEmitter
  93151. */
  93152. constructor();
  93153. /**
  93154. * Called by the particle System when the direction is computed for the created particle.
  93155. * @param worldMatrix is the world matrix of the particle system
  93156. * @param directionToUpdate is the direction vector to update with the result
  93157. * @param particle is the particle we are computed the direction for
  93158. * @param isLocal defines if the direction should be set in local space
  93159. */
  93160. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  93161. /**
  93162. * Called by the particle System when the position is computed for the created particle.
  93163. * @param worldMatrix is the world matrix of the particle system
  93164. * @param positionToUpdate is the position vector to update with the result
  93165. * @param particle is the particle we are computed the position for
  93166. * @param isLocal defines if the position should be set in local space
  93167. */
  93168. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  93169. /**
  93170. * Clones the current emitter and returns a copy of it
  93171. * @returns the new emitter
  93172. */
  93173. clone(): BoxParticleEmitter;
  93174. /**
  93175. * Called by the GPUParticleSystem to setup the update shader
  93176. * @param effect defines the update shader
  93177. */
  93178. applyToShader(effect: Effect): void;
  93179. /**
  93180. * Returns a string to use to update the GPU particles update shader
  93181. * @returns a string containng the defines string
  93182. */
  93183. getEffectDefines(): string;
  93184. /**
  93185. * Returns the string "BoxParticleEmitter"
  93186. * @returns a string containing the class name
  93187. */
  93188. getClassName(): string;
  93189. /**
  93190. * Serializes the particle system to a JSON object.
  93191. * @returns the JSON object
  93192. */
  93193. serialize(): any;
  93194. /**
  93195. * Parse properties from a JSON object
  93196. * @param serializationObject defines the JSON object
  93197. */
  93198. parse(serializationObject: any): void;
  93199. }
  93200. }
  93201. declare module BABYLON {
  93202. /**
  93203. * Particle emitter emitting particles from the inside of a cone.
  93204. * It emits the particles alongside the cone volume from the base to the particle.
  93205. * The emission direction might be randomized.
  93206. */
  93207. export class ConeParticleEmitter implements IParticleEmitterType {
  93208. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  93209. directionRandomizer: number;
  93210. private _radius;
  93211. private _angle;
  93212. private _height;
  93213. /**
  93214. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  93215. */
  93216. radiusRange: number;
  93217. /**
  93218. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  93219. */
  93220. heightRange: number;
  93221. /**
  93222. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  93223. */
  93224. emitFromSpawnPointOnly: boolean;
  93225. /**
  93226. * Gets or sets the radius of the emission cone
  93227. */
  93228. get radius(): number;
  93229. set radius(value: number);
  93230. /**
  93231. * Gets or sets the angle of the emission cone
  93232. */
  93233. get angle(): number;
  93234. set angle(value: number);
  93235. private _buildHeight;
  93236. /**
  93237. * Creates a new instance ConeParticleEmitter
  93238. * @param radius the radius of the emission cone (1 by default)
  93239. * @param angle the cone base angle (PI by default)
  93240. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  93241. */
  93242. constructor(radius?: number, angle?: number,
  93243. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  93244. directionRandomizer?: number);
  93245. /**
  93246. * Called by the particle System when the direction is computed for the created particle.
  93247. * @param worldMatrix is the world matrix of the particle system
  93248. * @param directionToUpdate is the direction vector to update with the result
  93249. * @param particle is the particle we are computed the direction for
  93250. * @param isLocal defines if the direction should be set in local space
  93251. */
  93252. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  93253. /**
  93254. * Called by the particle System when the position is computed for the created particle.
  93255. * @param worldMatrix is the world matrix of the particle system
  93256. * @param positionToUpdate is the position vector to update with the result
  93257. * @param particle is the particle we are computed the position for
  93258. * @param isLocal defines if the position should be set in local space
  93259. */
  93260. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  93261. /**
  93262. * Clones the current emitter and returns a copy of it
  93263. * @returns the new emitter
  93264. */
  93265. clone(): ConeParticleEmitter;
  93266. /**
  93267. * Called by the GPUParticleSystem to setup the update shader
  93268. * @param effect defines the update shader
  93269. */
  93270. applyToShader(effect: Effect): void;
  93271. /**
  93272. * Returns a string to use to update the GPU particles update shader
  93273. * @returns a string containng the defines string
  93274. */
  93275. getEffectDefines(): string;
  93276. /**
  93277. * Returns the string "ConeParticleEmitter"
  93278. * @returns a string containing the class name
  93279. */
  93280. getClassName(): string;
  93281. /**
  93282. * Serializes the particle system to a JSON object.
  93283. * @returns the JSON object
  93284. */
  93285. serialize(): any;
  93286. /**
  93287. * Parse properties from a JSON object
  93288. * @param serializationObject defines the JSON object
  93289. */
  93290. parse(serializationObject: any): void;
  93291. }
  93292. }
  93293. declare module BABYLON {
  93294. /**
  93295. * Particle emitter emitting particles from the inside of a cylinder.
  93296. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  93297. */
  93298. export class CylinderParticleEmitter implements IParticleEmitterType {
  93299. /**
  93300. * The radius of the emission cylinder.
  93301. */
  93302. radius: number;
  93303. /**
  93304. * The height of the emission cylinder.
  93305. */
  93306. height: number;
  93307. /**
  93308. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  93309. */
  93310. radiusRange: number;
  93311. /**
  93312. * How much to randomize the particle direction [0-1].
  93313. */
  93314. directionRandomizer: number;
  93315. /**
  93316. * Creates a new instance CylinderParticleEmitter
  93317. * @param radius the radius of the emission cylinder (1 by default)
  93318. * @param height the height of the emission cylinder (1 by default)
  93319. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  93320. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  93321. */
  93322. constructor(
  93323. /**
  93324. * The radius of the emission cylinder.
  93325. */
  93326. radius?: number,
  93327. /**
  93328. * The height of the emission cylinder.
  93329. */
  93330. height?: number,
  93331. /**
  93332. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  93333. */
  93334. radiusRange?: number,
  93335. /**
  93336. * How much to randomize the particle direction [0-1].
  93337. */
  93338. directionRandomizer?: number);
  93339. /**
  93340. * Called by the particle System when the direction is computed for the created particle.
  93341. * @param worldMatrix is the world matrix of the particle system
  93342. * @param directionToUpdate is the direction vector to update with the result
  93343. * @param particle is the particle we are computed the direction for
  93344. * @param isLocal defines if the direction should be set in local space
  93345. */
  93346. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  93347. /**
  93348. * Called by the particle System when the position is computed for the created particle.
  93349. * @param worldMatrix is the world matrix of the particle system
  93350. * @param positionToUpdate is the position vector to update with the result
  93351. * @param particle is the particle we are computed the position for
  93352. * @param isLocal defines if the position should be set in local space
  93353. */
  93354. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  93355. /**
  93356. * Clones the current emitter and returns a copy of it
  93357. * @returns the new emitter
  93358. */
  93359. clone(): CylinderParticleEmitter;
  93360. /**
  93361. * Called by the GPUParticleSystem to setup the update shader
  93362. * @param effect defines the update shader
  93363. */
  93364. applyToShader(effect: Effect): void;
  93365. /**
  93366. * Returns a string to use to update the GPU particles update shader
  93367. * @returns a string containng the defines string
  93368. */
  93369. getEffectDefines(): string;
  93370. /**
  93371. * Returns the string "CylinderParticleEmitter"
  93372. * @returns a string containing the class name
  93373. */
  93374. getClassName(): string;
  93375. /**
  93376. * Serializes the particle system to a JSON object.
  93377. * @returns the JSON object
  93378. */
  93379. serialize(): any;
  93380. /**
  93381. * Parse properties from a JSON object
  93382. * @param serializationObject defines the JSON object
  93383. */
  93384. parse(serializationObject: any): void;
  93385. }
  93386. /**
  93387. * Particle emitter emitting particles from the inside of a cylinder.
  93388. * It emits the particles randomly between two vectors.
  93389. */
  93390. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  93391. /**
  93392. * The min limit of the emission direction.
  93393. */
  93394. direction1: Vector3;
  93395. /**
  93396. * The max limit of the emission direction.
  93397. */
  93398. direction2: Vector3;
  93399. /**
  93400. * Creates a new instance CylinderDirectedParticleEmitter
  93401. * @param radius the radius of the emission cylinder (1 by default)
  93402. * @param height the height of the emission cylinder (1 by default)
  93403. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  93404. * @param direction1 the min limit of the emission direction (up vector by default)
  93405. * @param direction2 the max limit of the emission direction (up vector by default)
  93406. */
  93407. constructor(radius?: number, height?: number, radiusRange?: number,
  93408. /**
  93409. * The min limit of the emission direction.
  93410. */
  93411. direction1?: Vector3,
  93412. /**
  93413. * The max limit of the emission direction.
  93414. */
  93415. direction2?: Vector3);
  93416. /**
  93417. * Called by the particle System when the direction is computed for the created particle.
  93418. * @param worldMatrix is the world matrix of the particle system
  93419. * @param directionToUpdate is the direction vector to update with the result
  93420. * @param particle is the particle we are computed the direction for
  93421. */
  93422. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  93423. /**
  93424. * Clones the current emitter and returns a copy of it
  93425. * @returns the new emitter
  93426. */
  93427. clone(): CylinderDirectedParticleEmitter;
  93428. /**
  93429. * Called by the GPUParticleSystem to setup the update shader
  93430. * @param effect defines the update shader
  93431. */
  93432. applyToShader(effect: Effect): void;
  93433. /**
  93434. * Returns a string to use to update the GPU particles update shader
  93435. * @returns a string containng the defines string
  93436. */
  93437. getEffectDefines(): string;
  93438. /**
  93439. * Returns the string "CylinderDirectedParticleEmitter"
  93440. * @returns a string containing the class name
  93441. */
  93442. getClassName(): string;
  93443. /**
  93444. * Serializes the particle system to a JSON object.
  93445. * @returns the JSON object
  93446. */
  93447. serialize(): any;
  93448. /**
  93449. * Parse properties from a JSON object
  93450. * @param serializationObject defines the JSON object
  93451. */
  93452. parse(serializationObject: any): void;
  93453. }
  93454. }
  93455. declare module BABYLON {
  93456. /**
  93457. * Particle emitter emitting particles from the inside of a hemisphere.
  93458. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  93459. */
  93460. export class HemisphericParticleEmitter implements IParticleEmitterType {
  93461. /**
  93462. * The radius of the emission hemisphere.
  93463. */
  93464. radius: number;
  93465. /**
  93466. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  93467. */
  93468. radiusRange: number;
  93469. /**
  93470. * How much to randomize the particle direction [0-1].
  93471. */
  93472. directionRandomizer: number;
  93473. /**
  93474. * Creates a new instance HemisphericParticleEmitter
  93475. * @param radius the radius of the emission hemisphere (1 by default)
  93476. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  93477. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  93478. */
  93479. constructor(
  93480. /**
  93481. * The radius of the emission hemisphere.
  93482. */
  93483. radius?: number,
  93484. /**
  93485. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  93486. */
  93487. radiusRange?: number,
  93488. /**
  93489. * How much to randomize the particle direction [0-1].
  93490. */
  93491. directionRandomizer?: number);
  93492. /**
  93493. * Called by the particle System when the direction is computed for the created particle.
  93494. * @param worldMatrix is the world matrix of the particle system
  93495. * @param directionToUpdate is the direction vector to update with the result
  93496. * @param particle is the particle we are computed the direction for
  93497. * @param isLocal defines if the direction should be set in local space
  93498. */
  93499. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  93500. /**
  93501. * Called by the particle System when the position is computed for the created particle.
  93502. * @param worldMatrix is the world matrix of the particle system
  93503. * @param positionToUpdate is the position vector to update with the result
  93504. * @param particle is the particle we are computed the position for
  93505. * @param isLocal defines if the position should be set in local space
  93506. */
  93507. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  93508. /**
  93509. * Clones the current emitter and returns a copy of it
  93510. * @returns the new emitter
  93511. */
  93512. clone(): HemisphericParticleEmitter;
  93513. /**
  93514. * Called by the GPUParticleSystem to setup the update shader
  93515. * @param effect defines the update shader
  93516. */
  93517. applyToShader(effect: Effect): void;
  93518. /**
  93519. * Returns a string to use to update the GPU particles update shader
  93520. * @returns a string containng the defines string
  93521. */
  93522. getEffectDefines(): string;
  93523. /**
  93524. * Returns the string "HemisphericParticleEmitter"
  93525. * @returns a string containing the class name
  93526. */
  93527. getClassName(): string;
  93528. /**
  93529. * Serializes the particle system to a JSON object.
  93530. * @returns the JSON object
  93531. */
  93532. serialize(): any;
  93533. /**
  93534. * Parse properties from a JSON object
  93535. * @param serializationObject defines the JSON object
  93536. */
  93537. parse(serializationObject: any): void;
  93538. }
  93539. }
  93540. declare module BABYLON {
  93541. /**
  93542. * Particle emitter emitting particles from a point.
  93543. * It emits the particles randomly between 2 given directions.
  93544. */
  93545. export class PointParticleEmitter implements IParticleEmitterType {
  93546. /**
  93547. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  93548. */
  93549. direction1: Vector3;
  93550. /**
  93551. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  93552. */
  93553. direction2: Vector3;
  93554. /**
  93555. * Creates a new instance PointParticleEmitter
  93556. */
  93557. constructor();
  93558. /**
  93559. * Called by the particle System when the direction is computed for the created particle.
  93560. * @param worldMatrix is the world matrix of the particle system
  93561. * @param directionToUpdate is the direction vector to update with the result
  93562. * @param particle is the particle we are computed the direction for
  93563. * @param isLocal defines if the direction should be set in local space
  93564. */
  93565. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  93566. /**
  93567. * Called by the particle System when the position is computed for the created particle.
  93568. * @param worldMatrix is the world matrix of the particle system
  93569. * @param positionToUpdate is the position vector to update with the result
  93570. * @param particle is the particle we are computed the position for
  93571. * @param isLocal defines if the position should be set in local space
  93572. */
  93573. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  93574. /**
  93575. * Clones the current emitter and returns a copy of it
  93576. * @returns the new emitter
  93577. */
  93578. clone(): PointParticleEmitter;
  93579. /**
  93580. * Called by the GPUParticleSystem to setup the update shader
  93581. * @param effect defines the update shader
  93582. */
  93583. applyToShader(effect: Effect): void;
  93584. /**
  93585. * Returns a string to use to update the GPU particles update shader
  93586. * @returns a string containng the defines string
  93587. */
  93588. getEffectDefines(): string;
  93589. /**
  93590. * Returns the string "PointParticleEmitter"
  93591. * @returns a string containing the class name
  93592. */
  93593. getClassName(): string;
  93594. /**
  93595. * Serializes the particle system to a JSON object.
  93596. * @returns the JSON object
  93597. */
  93598. serialize(): any;
  93599. /**
  93600. * Parse properties from a JSON object
  93601. * @param serializationObject defines the JSON object
  93602. */
  93603. parse(serializationObject: any): void;
  93604. }
  93605. }
  93606. declare module BABYLON {
  93607. /**
  93608. * Particle emitter emitting particles from the inside of a sphere.
  93609. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  93610. */
  93611. export class SphereParticleEmitter implements IParticleEmitterType {
  93612. /**
  93613. * The radius of the emission sphere.
  93614. */
  93615. radius: number;
  93616. /**
  93617. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  93618. */
  93619. radiusRange: number;
  93620. /**
  93621. * How much to randomize the particle direction [0-1].
  93622. */
  93623. directionRandomizer: number;
  93624. /**
  93625. * Creates a new instance SphereParticleEmitter
  93626. * @param radius the radius of the emission sphere (1 by default)
  93627. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  93628. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  93629. */
  93630. constructor(
  93631. /**
  93632. * The radius of the emission sphere.
  93633. */
  93634. radius?: number,
  93635. /**
  93636. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  93637. */
  93638. radiusRange?: number,
  93639. /**
  93640. * How much to randomize the particle direction [0-1].
  93641. */
  93642. directionRandomizer?: number);
  93643. /**
  93644. * Called by the particle System when the direction is computed for the created particle.
  93645. * @param worldMatrix is the world matrix of the particle system
  93646. * @param directionToUpdate is the direction vector to update with the result
  93647. * @param particle is the particle we are computed the direction for
  93648. * @param isLocal defines if the direction should be set in local space
  93649. */
  93650. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  93651. /**
  93652. * Called by the particle System when the position is computed for the created particle.
  93653. * @param worldMatrix is the world matrix of the particle system
  93654. * @param positionToUpdate is the position vector to update with the result
  93655. * @param particle is the particle we are computed the position for
  93656. * @param isLocal defines if the position should be set in local space
  93657. */
  93658. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  93659. /**
  93660. * Clones the current emitter and returns a copy of it
  93661. * @returns the new emitter
  93662. */
  93663. clone(): SphereParticleEmitter;
  93664. /**
  93665. * Called by the GPUParticleSystem to setup the update shader
  93666. * @param effect defines the update shader
  93667. */
  93668. applyToShader(effect: Effect): void;
  93669. /**
  93670. * Returns a string to use to update the GPU particles update shader
  93671. * @returns a string containng the defines string
  93672. */
  93673. getEffectDefines(): string;
  93674. /**
  93675. * Returns the string "SphereParticleEmitter"
  93676. * @returns a string containing the class name
  93677. */
  93678. getClassName(): string;
  93679. /**
  93680. * Serializes the particle system to a JSON object.
  93681. * @returns the JSON object
  93682. */
  93683. serialize(): any;
  93684. /**
  93685. * Parse properties from a JSON object
  93686. * @param serializationObject defines the JSON object
  93687. */
  93688. parse(serializationObject: any): void;
  93689. }
  93690. /**
  93691. * Particle emitter emitting particles from the inside of a sphere.
  93692. * It emits the particles randomly between two vectors.
  93693. */
  93694. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  93695. /**
  93696. * The min limit of the emission direction.
  93697. */
  93698. direction1: Vector3;
  93699. /**
  93700. * The max limit of the emission direction.
  93701. */
  93702. direction2: Vector3;
  93703. /**
  93704. * Creates a new instance SphereDirectedParticleEmitter
  93705. * @param radius the radius of the emission sphere (1 by default)
  93706. * @param direction1 the min limit of the emission direction (up vector by default)
  93707. * @param direction2 the max limit of the emission direction (up vector by default)
  93708. */
  93709. constructor(radius?: number,
  93710. /**
  93711. * The min limit of the emission direction.
  93712. */
  93713. direction1?: Vector3,
  93714. /**
  93715. * The max limit of the emission direction.
  93716. */
  93717. direction2?: Vector3);
  93718. /**
  93719. * Called by the particle System when the direction is computed for the created particle.
  93720. * @param worldMatrix is the world matrix of the particle system
  93721. * @param directionToUpdate is the direction vector to update with the result
  93722. * @param particle is the particle we are computed the direction for
  93723. */
  93724. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  93725. /**
  93726. * Clones the current emitter and returns a copy of it
  93727. * @returns the new emitter
  93728. */
  93729. clone(): SphereDirectedParticleEmitter;
  93730. /**
  93731. * Called by the GPUParticleSystem to setup the update shader
  93732. * @param effect defines the update shader
  93733. */
  93734. applyToShader(effect: Effect): void;
  93735. /**
  93736. * Returns a string to use to update the GPU particles update shader
  93737. * @returns a string containng the defines string
  93738. */
  93739. getEffectDefines(): string;
  93740. /**
  93741. * Returns the string "SphereDirectedParticleEmitter"
  93742. * @returns a string containing the class name
  93743. */
  93744. getClassName(): string;
  93745. /**
  93746. * Serializes the particle system to a JSON object.
  93747. * @returns the JSON object
  93748. */
  93749. serialize(): any;
  93750. /**
  93751. * Parse properties from a JSON object
  93752. * @param serializationObject defines the JSON object
  93753. */
  93754. parse(serializationObject: any): void;
  93755. }
  93756. }
  93757. declare module BABYLON {
  93758. /**
  93759. * Particle emitter emitting particles from a custom list of positions.
  93760. */
  93761. export class CustomParticleEmitter implements IParticleEmitterType {
  93762. /**
  93763. * Gets or sets the position generator that will create the inital position of each particle.
  93764. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  93765. */
  93766. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  93767. /**
  93768. * Gets or sets the destination generator that will create the final destination of each particle.
  93769. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  93770. */
  93771. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  93772. /**
  93773. * Creates a new instance CustomParticleEmitter
  93774. */
  93775. constructor();
  93776. /**
  93777. * Called by the particle System when the direction is computed for the created particle.
  93778. * @param worldMatrix is the world matrix of the particle system
  93779. * @param directionToUpdate is the direction vector to update with the result
  93780. * @param particle is the particle we are computed the direction for
  93781. * @param isLocal defines if the direction should be set in local space
  93782. */
  93783. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  93784. /**
  93785. * Called by the particle System when the position is computed for the created particle.
  93786. * @param worldMatrix is the world matrix of the particle system
  93787. * @param positionToUpdate is the position vector to update with the result
  93788. * @param particle is the particle we are computed the position for
  93789. * @param isLocal defines if the position should be set in local space
  93790. */
  93791. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  93792. /**
  93793. * Clones the current emitter and returns a copy of it
  93794. * @returns the new emitter
  93795. */
  93796. clone(): CustomParticleEmitter;
  93797. /**
  93798. * Called by the GPUParticleSystem to setup the update shader
  93799. * @param effect defines the update shader
  93800. */
  93801. applyToShader(effect: Effect): void;
  93802. /**
  93803. * Returns a string to use to update the GPU particles update shader
  93804. * @returns a string containng the defines string
  93805. */
  93806. getEffectDefines(): string;
  93807. /**
  93808. * Returns the string "PointParticleEmitter"
  93809. * @returns a string containing the class name
  93810. */
  93811. getClassName(): string;
  93812. /**
  93813. * Serializes the particle system to a JSON object.
  93814. * @returns the JSON object
  93815. */
  93816. serialize(): any;
  93817. /**
  93818. * Parse properties from a JSON object
  93819. * @param serializationObject defines the JSON object
  93820. */
  93821. parse(serializationObject: any): void;
  93822. }
  93823. }
  93824. declare module BABYLON {
  93825. /**
  93826. * Particle emitter emitting particles from the inside of a box.
  93827. * It emits the particles randomly between 2 given directions.
  93828. */
  93829. export class MeshParticleEmitter implements IParticleEmitterType {
  93830. private _indices;
  93831. private _positions;
  93832. private _normals;
  93833. private _storedNormal;
  93834. private _mesh;
  93835. /**
  93836. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  93837. */
  93838. direction1: Vector3;
  93839. /**
  93840. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  93841. */
  93842. direction2: Vector3;
  93843. /**
  93844. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  93845. */
  93846. useMeshNormalsForDirection: boolean;
  93847. /** Defines the mesh to use as source */
  93848. get mesh(): Nullable<AbstractMesh>;
  93849. set mesh(value: Nullable<AbstractMesh>);
  93850. /**
  93851. * Creates a new instance MeshParticleEmitter
  93852. * @param mesh defines the mesh to use as source
  93853. */
  93854. constructor(mesh?: Nullable<AbstractMesh>);
  93855. /**
  93856. * Called by the particle System when the direction is computed for the created particle.
  93857. * @param worldMatrix is the world matrix of the particle system
  93858. * @param directionToUpdate is the direction vector to update with the result
  93859. * @param particle is the particle we are computed the direction for
  93860. * @param isLocal defines if the direction should be set in local space
  93861. */
  93862. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  93863. /**
  93864. * Called by the particle System when the position is computed for the created particle.
  93865. * @param worldMatrix is the world matrix of the particle system
  93866. * @param positionToUpdate is the position vector to update with the result
  93867. * @param particle is the particle we are computed the position for
  93868. * @param isLocal defines if the position should be set in local space
  93869. */
  93870. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  93871. /**
  93872. * Clones the current emitter and returns a copy of it
  93873. * @returns the new emitter
  93874. */
  93875. clone(): MeshParticleEmitter;
  93876. /**
  93877. * Called by the GPUParticleSystem to setup the update shader
  93878. * @param effect defines the update shader
  93879. */
  93880. applyToShader(effect: Effect): void;
  93881. /**
  93882. * Returns a string to use to update the GPU particles update shader
  93883. * @returns a string containng the defines string
  93884. */
  93885. getEffectDefines(): string;
  93886. /**
  93887. * Returns the string "BoxParticleEmitter"
  93888. * @returns a string containing the class name
  93889. */
  93890. getClassName(): string;
  93891. /**
  93892. * Serializes the particle system to a JSON object.
  93893. * @returns the JSON object
  93894. */
  93895. serialize(): any;
  93896. /**
  93897. * Parse properties from a JSON object
  93898. * @param serializationObject defines the JSON object
  93899. * @param scene defines the hosting scene
  93900. */
  93901. parse(serializationObject: any, scene: Nullable<Scene>): void;
  93902. }
  93903. }
  93904. declare module BABYLON {
  93905. /**
  93906. * Interface representing a particle system in Babylon.js.
  93907. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  93908. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  93909. */
  93910. export interface IParticleSystem {
  93911. /**
  93912. * List of animations used by the particle system.
  93913. */
  93914. animations: Animation[];
  93915. /**
  93916. * The id of the Particle system.
  93917. */
  93918. id: string;
  93919. /**
  93920. * The name of the Particle system.
  93921. */
  93922. name: string;
  93923. /**
  93924. * The emitter represents the Mesh or position we are attaching the particle system to.
  93925. */
  93926. emitter: Nullable<AbstractMesh | Vector3>;
  93927. /**
  93928. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  93929. */
  93930. isBillboardBased: boolean;
  93931. /**
  93932. * The rendering group used by the Particle system to chose when to render.
  93933. */
  93934. renderingGroupId: number;
  93935. /**
  93936. * The layer mask we are rendering the particles through.
  93937. */
  93938. layerMask: number;
  93939. /**
  93940. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  93941. */
  93942. updateSpeed: number;
  93943. /**
  93944. * The amount of time the particle system is running (depends of the overall update speed).
  93945. */
  93946. targetStopDuration: number;
  93947. /**
  93948. * The texture used to render each particle. (this can be a spritesheet)
  93949. */
  93950. particleTexture: Nullable<BaseTexture>;
  93951. /**
  93952. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  93953. */
  93954. blendMode: number;
  93955. /**
  93956. * Minimum life time of emitting particles.
  93957. */
  93958. minLifeTime: number;
  93959. /**
  93960. * Maximum life time of emitting particles.
  93961. */
  93962. maxLifeTime: number;
  93963. /**
  93964. * Minimum Size of emitting particles.
  93965. */
  93966. minSize: number;
  93967. /**
  93968. * Maximum Size of emitting particles.
  93969. */
  93970. maxSize: number;
  93971. /**
  93972. * Minimum scale of emitting particles on X axis.
  93973. */
  93974. minScaleX: number;
  93975. /**
  93976. * Maximum scale of emitting particles on X axis.
  93977. */
  93978. maxScaleX: number;
  93979. /**
  93980. * Minimum scale of emitting particles on Y axis.
  93981. */
  93982. minScaleY: number;
  93983. /**
  93984. * Maximum scale of emitting particles on Y axis.
  93985. */
  93986. maxScaleY: number;
  93987. /**
  93988. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  93989. */
  93990. color1: Color4;
  93991. /**
  93992. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  93993. */
  93994. color2: Color4;
  93995. /**
  93996. * Color the particle will have at the end of its lifetime.
  93997. */
  93998. colorDead: Color4;
  93999. /**
  94000. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  94001. */
  94002. emitRate: number;
  94003. /**
  94004. * You can use gravity if you want to give an orientation to your particles.
  94005. */
  94006. gravity: Vector3;
  94007. /**
  94008. * Minimum power of emitting particles.
  94009. */
  94010. minEmitPower: number;
  94011. /**
  94012. * Maximum power of emitting particles.
  94013. */
  94014. maxEmitPower: number;
  94015. /**
  94016. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  94017. */
  94018. minAngularSpeed: number;
  94019. /**
  94020. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  94021. */
  94022. maxAngularSpeed: number;
  94023. /**
  94024. * Gets or sets the minimal initial rotation in radians.
  94025. */
  94026. minInitialRotation: number;
  94027. /**
  94028. * Gets or sets the maximal initial rotation in radians.
  94029. */
  94030. maxInitialRotation: number;
  94031. /**
  94032. * The particle emitter type defines the emitter used by the particle system.
  94033. * It can be for example box, sphere, or cone...
  94034. */
  94035. particleEmitterType: Nullable<IParticleEmitterType>;
  94036. /**
  94037. * Defines the delay in milliseconds before starting the system (0 by default)
  94038. */
  94039. startDelay: number;
  94040. /**
  94041. * 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
  94042. */
  94043. preWarmCycles: number;
  94044. /**
  94045. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  94046. */
  94047. preWarmStepOffset: number;
  94048. /**
  94049. * 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)
  94050. */
  94051. spriteCellChangeSpeed: number;
  94052. /**
  94053. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  94054. */
  94055. startSpriteCellID: number;
  94056. /**
  94057. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  94058. */
  94059. endSpriteCellID: number;
  94060. /**
  94061. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  94062. */
  94063. spriteCellWidth: number;
  94064. /**
  94065. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  94066. */
  94067. spriteCellHeight: number;
  94068. /**
  94069. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  94070. */
  94071. spriteRandomStartCell: boolean;
  94072. /**
  94073. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  94074. */
  94075. isAnimationSheetEnabled: boolean;
  94076. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  94077. translationPivot: Vector2;
  94078. /**
  94079. * Gets or sets a texture used to add random noise to particle positions
  94080. */
  94081. noiseTexture: Nullable<BaseTexture>;
  94082. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  94083. noiseStrength: Vector3;
  94084. /**
  94085. * Gets or sets the billboard mode to use when isBillboardBased = true.
  94086. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  94087. */
  94088. billboardMode: number;
  94089. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  94090. limitVelocityDamping: number;
  94091. /**
  94092. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  94093. */
  94094. beginAnimationOnStart: boolean;
  94095. /**
  94096. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  94097. */
  94098. beginAnimationFrom: number;
  94099. /**
  94100. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  94101. */
  94102. beginAnimationTo: number;
  94103. /**
  94104. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  94105. */
  94106. beginAnimationLoop: boolean;
  94107. /**
  94108. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  94109. */
  94110. disposeOnStop: boolean;
  94111. /**
  94112. * Specifies if the particles are updated in emitter local space or world space
  94113. */
  94114. isLocal: boolean;
  94115. /** Snippet ID if the particle system was created from the snippet server */
  94116. snippetId: string;
  94117. /** Gets or sets a matrix to use to compute projection */
  94118. defaultProjectionMatrix: Matrix;
  94119. /**
  94120. * Gets the maximum number of particles active at the same time.
  94121. * @returns The max number of active particles.
  94122. */
  94123. getCapacity(): number;
  94124. /**
  94125. * Gets the number of particles active at the same time.
  94126. * @returns The number of active particles.
  94127. */
  94128. getActiveCount(): number;
  94129. /**
  94130. * Gets if the system has been started. (Note: this will still be true after stop is called)
  94131. * @returns True if it has been started, otherwise false.
  94132. */
  94133. isStarted(): boolean;
  94134. /**
  94135. * Animates the particle system for this frame.
  94136. */
  94137. animate(): void;
  94138. /**
  94139. * Renders the particle system in its current state.
  94140. * @returns the current number of particles
  94141. */
  94142. render(): number;
  94143. /**
  94144. * Dispose the particle system and frees its associated resources.
  94145. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  94146. */
  94147. dispose(disposeTexture?: boolean): void;
  94148. /**
  94149. * An event triggered when the system is disposed
  94150. */
  94151. onDisposeObservable: Observable<IParticleSystem>;
  94152. /**
  94153. * Clones the particle system.
  94154. * @param name The name of the cloned object
  94155. * @param newEmitter The new emitter to use
  94156. * @returns the cloned particle system
  94157. */
  94158. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  94159. /**
  94160. * Serializes the particle system to a JSON object
  94161. * @param serializeTexture defines if the texture must be serialized as well
  94162. * @returns the JSON object
  94163. */
  94164. serialize(serializeTexture: boolean): any;
  94165. /**
  94166. * Rebuild the particle system
  94167. */
  94168. rebuild(): void;
  94169. /** Force the system to rebuild all gradients that need to be resync */
  94170. forceRefreshGradients(): void;
  94171. /**
  94172. * Starts the particle system and begins to emit
  94173. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  94174. */
  94175. start(delay?: number): void;
  94176. /**
  94177. * Stops the particle system.
  94178. */
  94179. stop(): void;
  94180. /**
  94181. * Remove all active particles
  94182. */
  94183. reset(): void;
  94184. /**
  94185. * Gets a boolean indicating that the system is stopping
  94186. * @returns true if the system is currently stopping
  94187. */
  94188. isStopping(): boolean;
  94189. /**
  94190. * Is this system ready to be used/rendered
  94191. * @return true if the system is ready
  94192. */
  94193. isReady(): boolean;
  94194. /**
  94195. * Returns the string "ParticleSystem"
  94196. * @returns a string containing the class name
  94197. */
  94198. getClassName(): string;
  94199. /**
  94200. * Gets the custom effect used to render the particles
  94201. * @param blendMode Blend mode for which the effect should be retrieved
  94202. * @returns The effect
  94203. */
  94204. getCustomEffect(blendMode: number): Nullable<Effect>;
  94205. /**
  94206. * Sets the custom effect used to render the particles
  94207. * @param effect The effect to set
  94208. * @param blendMode Blend mode for which the effect should be set
  94209. */
  94210. setCustomEffect(effect: Nullable<Effect>, blendMode: number): void;
  94211. /**
  94212. * Fill the defines array according to the current settings of the particle system
  94213. * @param defines Array to be updated
  94214. * @param blendMode blend mode to take into account when updating the array
  94215. */
  94216. fillDefines(defines: Array<string>, blendMode: number): void;
  94217. /**
  94218. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  94219. * @param uniforms Uniforms array to fill
  94220. * @param attributes Attributes array to fill
  94221. * @param samplers Samplers array to fill
  94222. */
  94223. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  94224. /**
  94225. * Observable that will be called just before the particles are drawn
  94226. */
  94227. onBeforeDrawParticlesObservable: Observable<Nullable<Effect>>;
  94228. /**
  94229. * Gets the name of the particle vertex shader
  94230. */
  94231. vertexShaderName: string;
  94232. /**
  94233. * Adds a new color gradient
  94234. * @param gradient defines the gradient to use (between 0 and 1)
  94235. * @param color1 defines the color to affect to the specified gradient
  94236. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  94237. * @returns the current particle system
  94238. */
  94239. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  94240. /**
  94241. * Remove a specific color gradient
  94242. * @param gradient defines the gradient to remove
  94243. * @returns the current particle system
  94244. */
  94245. removeColorGradient(gradient: number): IParticleSystem;
  94246. /**
  94247. * Adds a new size gradient
  94248. * @param gradient defines the gradient to use (between 0 and 1)
  94249. * @param factor defines the size factor to affect to the specified gradient
  94250. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  94251. * @returns the current particle system
  94252. */
  94253. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  94254. /**
  94255. * Remove a specific size gradient
  94256. * @param gradient defines the gradient to remove
  94257. * @returns the current particle system
  94258. */
  94259. removeSizeGradient(gradient: number): IParticleSystem;
  94260. /**
  94261. * Gets the current list of color gradients.
  94262. * You must use addColorGradient and removeColorGradient to udpate this list
  94263. * @returns the list of color gradients
  94264. */
  94265. getColorGradients(): Nullable<Array<ColorGradient>>;
  94266. /**
  94267. * Gets the current list of size gradients.
  94268. * You must use addSizeGradient and removeSizeGradient to udpate this list
  94269. * @returns the list of size gradients
  94270. */
  94271. getSizeGradients(): Nullable<Array<FactorGradient>>;
  94272. /**
  94273. * Gets the current list of angular speed gradients.
  94274. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  94275. * @returns the list of angular speed gradients
  94276. */
  94277. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  94278. /**
  94279. * Adds a new angular speed gradient
  94280. * @param gradient defines the gradient to use (between 0 and 1)
  94281. * @param factor defines the angular speed to affect to the specified gradient
  94282. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  94283. * @returns the current particle system
  94284. */
  94285. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  94286. /**
  94287. * Remove a specific angular speed gradient
  94288. * @param gradient defines the gradient to remove
  94289. * @returns the current particle system
  94290. */
  94291. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  94292. /**
  94293. * Gets the current list of velocity gradients.
  94294. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  94295. * @returns the list of velocity gradients
  94296. */
  94297. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  94298. /**
  94299. * Adds a new velocity gradient
  94300. * @param gradient defines the gradient to use (between 0 and 1)
  94301. * @param factor defines the velocity to affect to the specified gradient
  94302. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  94303. * @returns the current particle system
  94304. */
  94305. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  94306. /**
  94307. * Remove a specific velocity gradient
  94308. * @param gradient defines the gradient to remove
  94309. * @returns the current particle system
  94310. */
  94311. removeVelocityGradient(gradient: number): IParticleSystem;
  94312. /**
  94313. * Gets the current list of limit velocity gradients.
  94314. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  94315. * @returns the list of limit velocity gradients
  94316. */
  94317. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  94318. /**
  94319. * Adds a new limit velocity gradient
  94320. * @param gradient defines the gradient to use (between 0 and 1)
  94321. * @param factor defines the limit velocity to affect to the specified gradient
  94322. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  94323. * @returns the current particle system
  94324. */
  94325. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  94326. /**
  94327. * Remove a specific limit velocity gradient
  94328. * @param gradient defines the gradient to remove
  94329. * @returns the current particle system
  94330. */
  94331. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  94332. /**
  94333. * Adds a new drag gradient
  94334. * @param gradient defines the gradient to use (between 0 and 1)
  94335. * @param factor defines the drag to affect to the specified gradient
  94336. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  94337. * @returns the current particle system
  94338. */
  94339. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  94340. /**
  94341. * Remove a specific drag gradient
  94342. * @param gradient defines the gradient to remove
  94343. * @returns the current particle system
  94344. */
  94345. removeDragGradient(gradient: number): IParticleSystem;
  94346. /**
  94347. * Gets the current list of drag gradients.
  94348. * You must use addDragGradient and removeDragGradient to udpate this list
  94349. * @returns the list of drag gradients
  94350. */
  94351. getDragGradients(): Nullable<Array<FactorGradient>>;
  94352. /**
  94353. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  94354. * @param gradient defines the gradient to use (between 0 and 1)
  94355. * @param factor defines the emit rate to affect to the specified gradient
  94356. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  94357. * @returns the current particle system
  94358. */
  94359. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  94360. /**
  94361. * Remove a specific emit rate gradient
  94362. * @param gradient defines the gradient to remove
  94363. * @returns the current particle system
  94364. */
  94365. removeEmitRateGradient(gradient: number): IParticleSystem;
  94366. /**
  94367. * Gets the current list of emit rate gradients.
  94368. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  94369. * @returns the list of emit rate gradients
  94370. */
  94371. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  94372. /**
  94373. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  94374. * @param gradient defines the gradient to use (between 0 and 1)
  94375. * @param factor defines the start size to affect to the specified gradient
  94376. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  94377. * @returns the current particle system
  94378. */
  94379. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  94380. /**
  94381. * Remove a specific start size gradient
  94382. * @param gradient defines the gradient to remove
  94383. * @returns the current particle system
  94384. */
  94385. removeStartSizeGradient(gradient: number): IParticleSystem;
  94386. /**
  94387. * Gets the current list of start size gradients.
  94388. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  94389. * @returns the list of start size gradients
  94390. */
  94391. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  94392. /**
  94393. * Adds a new life time gradient
  94394. * @param gradient defines the gradient to use (between 0 and 1)
  94395. * @param factor defines the life time factor to affect to the specified gradient
  94396. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  94397. * @returns the current particle system
  94398. */
  94399. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  94400. /**
  94401. * Remove a specific life time gradient
  94402. * @param gradient defines the gradient to remove
  94403. * @returns the current particle system
  94404. */
  94405. removeLifeTimeGradient(gradient: number): IParticleSystem;
  94406. /**
  94407. * Gets the current list of life time gradients.
  94408. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  94409. * @returns the list of life time gradients
  94410. */
  94411. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  94412. /**
  94413. * Gets the current list of color gradients.
  94414. * You must use addColorGradient and removeColorGradient to udpate this list
  94415. * @returns the list of color gradients
  94416. */
  94417. getColorGradients(): Nullable<Array<ColorGradient>>;
  94418. /**
  94419. * Adds a new ramp gradient used to remap particle colors
  94420. * @param gradient defines the gradient to use (between 0 and 1)
  94421. * @param color defines the color to affect to the specified gradient
  94422. * @returns the current particle system
  94423. */
  94424. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  94425. /**
  94426. * Gets the current list of ramp gradients.
  94427. * You must use addRampGradient and removeRampGradient to udpate this list
  94428. * @returns the list of ramp gradients
  94429. */
  94430. getRampGradients(): Nullable<Array<Color3Gradient>>;
  94431. /** Gets or sets a boolean indicating that ramp gradients must be used
  94432. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  94433. */
  94434. useRampGradients: boolean;
  94435. /**
  94436. * Adds a new color remap gradient
  94437. * @param gradient defines the gradient to use (between 0 and 1)
  94438. * @param min defines the color remap minimal range
  94439. * @param max defines the color remap maximal range
  94440. * @returns the current particle system
  94441. */
  94442. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  94443. /**
  94444. * Gets the current list of color remap gradients.
  94445. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  94446. * @returns the list of color remap gradients
  94447. */
  94448. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  94449. /**
  94450. * Adds a new alpha remap gradient
  94451. * @param gradient defines the gradient to use (between 0 and 1)
  94452. * @param min defines the alpha remap minimal range
  94453. * @param max defines the alpha remap maximal range
  94454. * @returns the current particle system
  94455. */
  94456. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  94457. /**
  94458. * Gets the current list of alpha remap gradients.
  94459. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  94460. * @returns the list of alpha remap gradients
  94461. */
  94462. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  94463. /**
  94464. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  94465. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  94466. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  94467. * @returns the emitter
  94468. */
  94469. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  94470. /**
  94471. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  94472. * @param radius The radius of the hemisphere to emit from
  94473. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  94474. * @returns the emitter
  94475. */
  94476. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  94477. /**
  94478. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  94479. * @param radius The radius of the sphere to emit from
  94480. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  94481. * @returns the emitter
  94482. */
  94483. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  94484. /**
  94485. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  94486. * @param radius The radius of the sphere to emit from
  94487. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  94488. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  94489. * @returns the emitter
  94490. */
  94491. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  94492. /**
  94493. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  94494. * @param radius The radius of the emission cylinder
  94495. * @param height The height of the emission cylinder
  94496. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  94497. * @param directionRandomizer How much to randomize the particle direction [0-1]
  94498. * @returns the emitter
  94499. */
  94500. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  94501. /**
  94502. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  94503. * @param radius The radius of the cylinder to emit from
  94504. * @param height The height of the emission cylinder
  94505. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  94506. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  94507. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  94508. * @returns the emitter
  94509. */
  94510. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  94511. /**
  94512. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  94513. * @param radius The radius of the cone to emit from
  94514. * @param angle The base angle of the cone
  94515. * @returns the emitter
  94516. */
  94517. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  94518. /**
  94519. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  94520. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  94521. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  94522. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  94523. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  94524. * @returns the emitter
  94525. */
  94526. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  94527. /**
  94528. * Get hosting scene
  94529. * @returns the scene
  94530. */
  94531. getScene(): Nullable<Scene>;
  94532. }
  94533. }
  94534. declare module BABYLON {
  94535. /**
  94536. * 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.
  94537. * @see https://doc.babylonjs.com/how_to/transformnode
  94538. */
  94539. export class TransformNode extends Node {
  94540. /**
  94541. * Object will not rotate to face the camera
  94542. */
  94543. static BILLBOARDMODE_NONE: number;
  94544. /**
  94545. * Object will rotate to face the camera but only on the x axis
  94546. */
  94547. static BILLBOARDMODE_X: number;
  94548. /**
  94549. * Object will rotate to face the camera but only on the y axis
  94550. */
  94551. static BILLBOARDMODE_Y: number;
  94552. /**
  94553. * Object will rotate to face the camera but only on the z axis
  94554. */
  94555. static BILLBOARDMODE_Z: number;
  94556. /**
  94557. * Object will rotate to face the camera
  94558. */
  94559. static BILLBOARDMODE_ALL: number;
  94560. /**
  94561. * Object will rotate to face the camera's position instead of orientation
  94562. */
  94563. static BILLBOARDMODE_USE_POSITION: number;
  94564. private static _TmpRotation;
  94565. private static _TmpScaling;
  94566. private static _TmpTranslation;
  94567. private _forward;
  94568. private _forwardInverted;
  94569. private _up;
  94570. private _right;
  94571. private _rightInverted;
  94572. private _position;
  94573. private _rotation;
  94574. private _rotationQuaternion;
  94575. protected _scaling: Vector3;
  94576. protected _isDirty: boolean;
  94577. private _transformToBoneReferal;
  94578. private _isAbsoluteSynced;
  94579. private _billboardMode;
  94580. /**
  94581. * Gets or sets the billboard mode. Default is 0.
  94582. *
  94583. * | Value | Type | Description |
  94584. * | --- | --- | --- |
  94585. * | 0 | BILLBOARDMODE_NONE | |
  94586. * | 1 | BILLBOARDMODE_X | |
  94587. * | 2 | BILLBOARDMODE_Y | |
  94588. * | 4 | BILLBOARDMODE_Z | |
  94589. * | 7 | BILLBOARDMODE_ALL | |
  94590. *
  94591. */
  94592. get billboardMode(): number;
  94593. set billboardMode(value: number);
  94594. private _preserveParentRotationForBillboard;
  94595. /**
  94596. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  94597. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  94598. */
  94599. get preserveParentRotationForBillboard(): boolean;
  94600. set preserveParentRotationForBillboard(value: boolean);
  94601. /**
  94602. * 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
  94603. */
  94604. scalingDeterminant: number;
  94605. private _infiniteDistance;
  94606. /**
  94607. * Gets or sets the distance of the object to max, often used by skybox
  94608. */
  94609. get infiniteDistance(): boolean;
  94610. set infiniteDistance(value: boolean);
  94611. /**
  94612. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  94613. * By default the system will update normals to compensate
  94614. */
  94615. ignoreNonUniformScaling: boolean;
  94616. /**
  94617. * 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
  94618. */
  94619. reIntegrateRotationIntoRotationQuaternion: boolean;
  94620. /** @hidden */
  94621. _poseMatrix: Nullable<Matrix>;
  94622. /** @hidden */
  94623. _localMatrix: Matrix;
  94624. private _usePivotMatrix;
  94625. private _absolutePosition;
  94626. private _absoluteScaling;
  94627. private _absoluteRotationQuaternion;
  94628. private _pivotMatrix;
  94629. private _pivotMatrixInverse;
  94630. /** @hidden */
  94631. _postMultiplyPivotMatrix: boolean;
  94632. protected _isWorldMatrixFrozen: boolean;
  94633. /** @hidden */
  94634. _indexInSceneTransformNodesArray: number;
  94635. /**
  94636. * An event triggered after the world matrix is updated
  94637. */
  94638. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  94639. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  94640. /**
  94641. * Gets a string identifying the name of the class
  94642. * @returns "TransformNode" string
  94643. */
  94644. getClassName(): string;
  94645. /**
  94646. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  94647. */
  94648. get position(): Vector3;
  94649. set position(newPosition: Vector3);
  94650. /**
  94651. * 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)).
  94652. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  94653. */
  94654. get rotation(): Vector3;
  94655. set rotation(newRotation: Vector3);
  94656. /**
  94657. * 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)).
  94658. */
  94659. get scaling(): Vector3;
  94660. set scaling(newScaling: Vector3);
  94661. /**
  94662. * 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).
  94663. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  94664. */
  94665. get rotationQuaternion(): Nullable<Quaternion>;
  94666. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  94667. /**
  94668. * The forward direction of that transform in world space.
  94669. */
  94670. get forward(): Vector3;
  94671. /**
  94672. * The up direction of that transform in world space.
  94673. */
  94674. get up(): Vector3;
  94675. /**
  94676. * The right direction of that transform in world space.
  94677. */
  94678. get right(): Vector3;
  94679. /**
  94680. * Copies the parameter passed Matrix into the mesh Pose matrix.
  94681. * @param matrix the matrix to copy the pose from
  94682. * @returns this TransformNode.
  94683. */
  94684. updatePoseMatrix(matrix: Matrix): TransformNode;
  94685. /**
  94686. * Returns the mesh Pose matrix.
  94687. * @returns the pose matrix
  94688. */
  94689. getPoseMatrix(): Matrix;
  94690. /** @hidden */
  94691. _isSynchronized(): boolean;
  94692. /** @hidden */
  94693. _initCache(): void;
  94694. /**
  94695. * Flag the transform node as dirty (Forcing it to update everything)
  94696. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  94697. * @returns this transform node
  94698. */
  94699. markAsDirty(property: string): TransformNode;
  94700. /**
  94701. * Returns the current mesh absolute position.
  94702. * Returns a Vector3.
  94703. */
  94704. get absolutePosition(): Vector3;
  94705. /**
  94706. * Returns the current mesh absolute scaling.
  94707. * Returns a Vector3.
  94708. */
  94709. get absoluteScaling(): Vector3;
  94710. /**
  94711. * Returns the current mesh absolute rotation.
  94712. * Returns a Quaternion.
  94713. */
  94714. get absoluteRotationQuaternion(): Quaternion;
  94715. /**
  94716. * Sets a new matrix to apply before all other transformation
  94717. * @param matrix defines the transform matrix
  94718. * @returns the current TransformNode
  94719. */
  94720. setPreTransformMatrix(matrix: Matrix): TransformNode;
  94721. /**
  94722. * Sets a new pivot matrix to the current node
  94723. * @param matrix defines the new pivot matrix to use
  94724. * @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
  94725. * @returns the current TransformNode
  94726. */
  94727. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  94728. /**
  94729. * Returns the mesh pivot matrix.
  94730. * Default : Identity.
  94731. * @returns the matrix
  94732. */
  94733. getPivotMatrix(): Matrix;
  94734. /**
  94735. * Instantiate (when possible) or clone that node with its hierarchy
  94736. * @param newParent defines the new parent to use for the instance (or clone)
  94737. * @param options defines options to configure how copy is done
  94738. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  94739. * @returns an instance (or a clone) of the current node with its hiearchy
  94740. */
  94741. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  94742. doNotInstantiate: boolean;
  94743. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  94744. /**
  94745. * Prevents the World matrix to be computed any longer
  94746. * @param newWorldMatrix defines an optional matrix to use as world matrix
  94747. * @returns the TransformNode.
  94748. */
  94749. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  94750. /**
  94751. * Allows back the World matrix computation.
  94752. * @returns the TransformNode.
  94753. */
  94754. unfreezeWorldMatrix(): this;
  94755. /**
  94756. * True if the World matrix has been frozen.
  94757. */
  94758. get isWorldMatrixFrozen(): boolean;
  94759. /**
  94760. * Retuns the mesh absolute position in the World.
  94761. * @returns a Vector3.
  94762. */
  94763. getAbsolutePosition(): Vector3;
  94764. /**
  94765. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  94766. * @param absolutePosition the absolute position to set
  94767. * @returns the TransformNode.
  94768. */
  94769. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  94770. /**
  94771. * Sets the mesh position in its local space.
  94772. * @param vector3 the position to set in localspace
  94773. * @returns the TransformNode.
  94774. */
  94775. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  94776. /**
  94777. * Returns the mesh position in the local space from the current World matrix values.
  94778. * @returns a new Vector3.
  94779. */
  94780. getPositionExpressedInLocalSpace(): Vector3;
  94781. /**
  94782. * Translates the mesh along the passed Vector3 in its local space.
  94783. * @param vector3 the distance to translate in localspace
  94784. * @returns the TransformNode.
  94785. */
  94786. locallyTranslate(vector3: Vector3): TransformNode;
  94787. private static _lookAtVectorCache;
  94788. /**
  94789. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  94790. * @param targetPoint the position (must be in same space as current mesh) to look at
  94791. * @param yawCor optional yaw (y-axis) correction in radians
  94792. * @param pitchCor optional pitch (x-axis) correction in radians
  94793. * @param rollCor optional roll (z-axis) correction in radians
  94794. * @param space the choosen space of the target
  94795. * @returns the TransformNode.
  94796. */
  94797. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  94798. /**
  94799. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  94800. * This Vector3 is expressed in the World space.
  94801. * @param localAxis axis to rotate
  94802. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  94803. */
  94804. getDirection(localAxis: Vector3): Vector3;
  94805. /**
  94806. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  94807. * localAxis is expressed in the mesh local space.
  94808. * result is computed in the Wordl space from the mesh World matrix.
  94809. * @param localAxis axis to rotate
  94810. * @param result the resulting transformnode
  94811. * @returns this TransformNode.
  94812. */
  94813. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  94814. /**
  94815. * Sets this transform node rotation to the given local axis.
  94816. * @param localAxis the axis in local space
  94817. * @param yawCor optional yaw (y-axis) correction in radians
  94818. * @param pitchCor optional pitch (x-axis) correction in radians
  94819. * @param rollCor optional roll (z-axis) correction in radians
  94820. * @returns this TransformNode
  94821. */
  94822. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  94823. /**
  94824. * Sets a new pivot point to the current node
  94825. * @param point defines the new pivot point to use
  94826. * @param space defines if the point is in world or local space (local by default)
  94827. * @returns the current TransformNode
  94828. */
  94829. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  94830. /**
  94831. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  94832. * @returns the pivot point
  94833. */
  94834. getPivotPoint(): Vector3;
  94835. /**
  94836. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  94837. * @param result the vector3 to store the result
  94838. * @returns this TransformNode.
  94839. */
  94840. getPivotPointToRef(result: Vector3): TransformNode;
  94841. /**
  94842. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  94843. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  94844. */
  94845. getAbsolutePivotPoint(): Vector3;
  94846. /**
  94847. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  94848. * @param result vector3 to store the result
  94849. * @returns this TransformNode.
  94850. */
  94851. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  94852. /**
  94853. * Defines the passed node as the parent of the current node.
  94854. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  94855. * @see https://doc.babylonjs.com/how_to/parenting
  94856. * @param node the node ot set as the parent
  94857. * @returns this TransformNode.
  94858. */
  94859. setParent(node: Nullable<Node>): TransformNode;
  94860. private _nonUniformScaling;
  94861. /**
  94862. * True if the scaling property of this object is non uniform eg. (1,2,1)
  94863. */
  94864. get nonUniformScaling(): boolean;
  94865. /** @hidden */
  94866. _updateNonUniformScalingState(value: boolean): boolean;
  94867. /**
  94868. * Attach the current TransformNode to another TransformNode associated with a bone
  94869. * @param bone Bone affecting the TransformNode
  94870. * @param affectedTransformNode TransformNode associated with the bone
  94871. * @returns this object
  94872. */
  94873. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  94874. /**
  94875. * Detach the transform node if its associated with a bone
  94876. * @returns this object
  94877. */
  94878. detachFromBone(): TransformNode;
  94879. private static _rotationAxisCache;
  94880. /**
  94881. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  94882. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  94883. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  94884. * The passed axis is also normalized.
  94885. * @param axis the axis to rotate around
  94886. * @param amount the amount to rotate in radians
  94887. * @param space Space to rotate in (Default: local)
  94888. * @returns the TransformNode.
  94889. */
  94890. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  94891. /**
  94892. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  94893. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  94894. * The passed axis is also normalized. .
  94895. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  94896. * @param point the point to rotate around
  94897. * @param axis the axis to rotate around
  94898. * @param amount the amount to rotate in radians
  94899. * @returns the TransformNode
  94900. */
  94901. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  94902. /**
  94903. * Translates the mesh along the axis vector for the passed distance in the given space.
  94904. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  94905. * @param axis the axis to translate in
  94906. * @param distance the distance to translate
  94907. * @param space Space to rotate in (Default: local)
  94908. * @returns the TransformNode.
  94909. */
  94910. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  94911. /**
  94912. * Adds a rotation step to the mesh current rotation.
  94913. * x, y, z are Euler angles expressed in radians.
  94914. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  94915. * This means this rotation is made in the mesh local space only.
  94916. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  94917. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  94918. * ```javascript
  94919. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  94920. * ```
  94921. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  94922. * 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.
  94923. * @param x Rotation to add
  94924. * @param y Rotation to add
  94925. * @param z Rotation to add
  94926. * @returns the TransformNode.
  94927. */
  94928. addRotation(x: number, y: number, z: number): TransformNode;
  94929. /**
  94930. * @hidden
  94931. */
  94932. protected _getEffectiveParent(): Nullable<Node>;
  94933. /**
  94934. * Computes the world matrix of the node
  94935. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  94936. * @returns the world matrix
  94937. */
  94938. computeWorldMatrix(force?: boolean): Matrix;
  94939. /**
  94940. * Resets this nodeTransform's local matrix to Matrix.Identity().
  94941. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  94942. */
  94943. resetLocalMatrix(independentOfChildren?: boolean): void;
  94944. protected _afterComputeWorldMatrix(): void;
  94945. /**
  94946. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  94947. * @param func callback function to add
  94948. *
  94949. * @returns the TransformNode.
  94950. */
  94951. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  94952. /**
  94953. * Removes a registered callback function.
  94954. * @param func callback function to remove
  94955. * @returns the TransformNode.
  94956. */
  94957. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  94958. /**
  94959. * Gets the position of the current mesh in camera space
  94960. * @param camera defines the camera to use
  94961. * @returns a position
  94962. */
  94963. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  94964. /**
  94965. * Returns the distance from the mesh to the active camera
  94966. * @param camera defines the camera to use
  94967. * @returns the distance
  94968. */
  94969. getDistanceToCamera(camera?: Nullable<Camera>): number;
  94970. /**
  94971. * Clone the current transform node
  94972. * @param name Name of the new clone
  94973. * @param newParent New parent for the clone
  94974. * @param doNotCloneChildren Do not clone children hierarchy
  94975. * @returns the new transform node
  94976. */
  94977. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  94978. /**
  94979. * Serializes the objects information.
  94980. * @param currentSerializationObject defines the object to serialize in
  94981. * @returns the serialized object
  94982. */
  94983. serialize(currentSerializationObject?: any): any;
  94984. /**
  94985. * Returns a new TransformNode object parsed from the source provided.
  94986. * @param parsedTransformNode is the source.
  94987. * @param scene the scne the object belongs to
  94988. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  94989. * @returns a new TransformNode object parsed from the source provided.
  94990. */
  94991. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  94992. /**
  94993. * Get all child-transformNodes of this node
  94994. * @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
  94995. * @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
  94996. * @returns an array of TransformNode
  94997. */
  94998. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  94999. /**
  95000. * Releases resources associated with this transform node.
  95001. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  95002. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  95003. */
  95004. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  95005. /**
  95006. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  95007. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  95008. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  95009. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  95010. * @returns the current mesh
  95011. */
  95012. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  95013. private _syncAbsoluteScalingAndRotation;
  95014. }
  95015. }
  95016. declare module BABYLON {
  95017. /**
  95018. * Class used to override all child animations of a given target
  95019. */
  95020. export class AnimationPropertiesOverride {
  95021. /**
  95022. * Gets or sets a value indicating if animation blending must be used
  95023. */
  95024. enableBlending: boolean;
  95025. /**
  95026. * Gets or sets the blending speed to use when enableBlending is true
  95027. */
  95028. blendingSpeed: number;
  95029. /**
  95030. * Gets or sets the default loop mode to use
  95031. */
  95032. loopMode: number;
  95033. }
  95034. }
  95035. declare module BABYLON {
  95036. /**
  95037. * Class used to store bone information
  95038. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  95039. */
  95040. export class Bone extends Node {
  95041. /**
  95042. * defines the bone name
  95043. */
  95044. name: string;
  95045. private static _tmpVecs;
  95046. private static _tmpQuat;
  95047. private static _tmpMats;
  95048. /**
  95049. * Gets the list of child bones
  95050. */
  95051. children: Bone[];
  95052. /** Gets the animations associated with this bone */
  95053. animations: Animation[];
  95054. /**
  95055. * Gets or sets bone length
  95056. */
  95057. length: number;
  95058. /**
  95059. * @hidden Internal only
  95060. * Set this value to map this bone to a different index in the transform matrices
  95061. * Set this value to -1 to exclude the bone from the transform matrices
  95062. */
  95063. _index: Nullable<number>;
  95064. private _skeleton;
  95065. private _localMatrix;
  95066. private _restPose;
  95067. private _bindPose;
  95068. private _baseMatrix;
  95069. private _absoluteTransform;
  95070. private _invertedAbsoluteTransform;
  95071. private _parent;
  95072. private _scalingDeterminant;
  95073. private _worldTransform;
  95074. private _localScaling;
  95075. private _localRotation;
  95076. private _localPosition;
  95077. private _needToDecompose;
  95078. private _needToCompose;
  95079. /** @hidden */
  95080. _linkedTransformNode: Nullable<TransformNode>;
  95081. /** @hidden */
  95082. _waitingTransformNodeId: Nullable<string>;
  95083. /** @hidden */
  95084. get _matrix(): Matrix;
  95085. /** @hidden */
  95086. set _matrix(value: Matrix);
  95087. /**
  95088. * Create a new bone
  95089. * @param name defines the bone name
  95090. * @param skeleton defines the parent skeleton
  95091. * @param parentBone defines the parent (can be null if the bone is the root)
  95092. * @param localMatrix defines the local matrix
  95093. * @param restPose defines the rest pose matrix
  95094. * @param baseMatrix defines the base matrix
  95095. * @param index defines index of the bone in the hiearchy
  95096. */
  95097. constructor(
  95098. /**
  95099. * defines the bone name
  95100. */
  95101. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  95102. /**
  95103. * Gets the current object class name.
  95104. * @return the class name
  95105. */
  95106. getClassName(): string;
  95107. /**
  95108. * Gets the parent skeleton
  95109. * @returns a skeleton
  95110. */
  95111. getSkeleton(): Skeleton;
  95112. /**
  95113. * Gets parent bone
  95114. * @returns a bone or null if the bone is the root of the bone hierarchy
  95115. */
  95116. getParent(): Nullable<Bone>;
  95117. /**
  95118. * Returns an array containing the root bones
  95119. * @returns an array containing the root bones
  95120. */
  95121. getChildren(): Array<Bone>;
  95122. /**
  95123. * Gets the node index in matrix array generated for rendering
  95124. * @returns the node index
  95125. */
  95126. getIndex(): number;
  95127. /**
  95128. * Sets the parent bone
  95129. * @param parent defines the parent (can be null if the bone is the root)
  95130. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  95131. */
  95132. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  95133. /**
  95134. * Gets the local matrix
  95135. * @returns a matrix
  95136. */
  95137. getLocalMatrix(): Matrix;
  95138. /**
  95139. * Gets the base matrix (initial matrix which remains unchanged)
  95140. * @returns a matrix
  95141. */
  95142. getBaseMatrix(): Matrix;
  95143. /**
  95144. * Gets the rest pose matrix
  95145. * @returns a matrix
  95146. */
  95147. getRestPose(): Matrix;
  95148. /**
  95149. * Sets the rest pose matrix
  95150. * @param matrix the local-space rest pose to set for this bone
  95151. */
  95152. setRestPose(matrix: Matrix): void;
  95153. /**
  95154. * Gets the bind pose matrix
  95155. * @returns the bind pose matrix
  95156. */
  95157. getBindPose(): Matrix;
  95158. /**
  95159. * Sets the bind pose matrix
  95160. * @param matrix the local-space bind pose to set for this bone
  95161. */
  95162. setBindPose(matrix: Matrix): void;
  95163. /**
  95164. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  95165. */
  95166. getWorldMatrix(): Matrix;
  95167. /**
  95168. * Sets the local matrix to rest pose matrix
  95169. */
  95170. returnToRest(): void;
  95171. /**
  95172. * Gets the inverse of the absolute transform matrix.
  95173. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  95174. * @returns a matrix
  95175. */
  95176. getInvertedAbsoluteTransform(): Matrix;
  95177. /**
  95178. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  95179. * @returns a matrix
  95180. */
  95181. getAbsoluteTransform(): Matrix;
  95182. /**
  95183. * Links with the given transform node.
  95184. * The local matrix of this bone is copied from the transform node every frame.
  95185. * @param transformNode defines the transform node to link to
  95186. */
  95187. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  95188. /**
  95189. * Gets the node used to drive the bone's transformation
  95190. * @returns a transform node or null
  95191. */
  95192. getTransformNode(): Nullable<TransformNode>;
  95193. /** Gets or sets current position (in local space) */
  95194. get position(): Vector3;
  95195. set position(newPosition: Vector3);
  95196. /** Gets or sets current rotation (in local space) */
  95197. get rotation(): Vector3;
  95198. set rotation(newRotation: Vector3);
  95199. /** Gets or sets current rotation quaternion (in local space) */
  95200. get rotationQuaternion(): Quaternion;
  95201. set rotationQuaternion(newRotation: Quaternion);
  95202. /** Gets or sets current scaling (in local space) */
  95203. get scaling(): Vector3;
  95204. set scaling(newScaling: Vector3);
  95205. /**
  95206. * Gets the animation properties override
  95207. */
  95208. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  95209. private _decompose;
  95210. private _compose;
  95211. /**
  95212. * Update the base and local matrices
  95213. * @param matrix defines the new base or local matrix
  95214. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  95215. * @param updateLocalMatrix defines if the local matrix should be updated
  95216. */
  95217. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  95218. /** @hidden */
  95219. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  95220. /**
  95221. * Flag the bone as dirty (Forcing it to update everything)
  95222. */
  95223. markAsDirty(): void;
  95224. /** @hidden */
  95225. _markAsDirtyAndCompose(): void;
  95226. private _markAsDirtyAndDecompose;
  95227. /**
  95228. * Translate the bone in local or world space
  95229. * @param vec The amount to translate the bone
  95230. * @param space The space that the translation is in
  95231. * @param mesh The mesh that this bone is attached to. This is only used in world space
  95232. */
  95233. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  95234. /**
  95235. * Set the postion of the bone in local or world space
  95236. * @param position The position to set the bone
  95237. * @param space The space that the position is in
  95238. * @param mesh The mesh that this bone is attached to. This is only used in world space
  95239. */
  95240. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  95241. /**
  95242. * Set the absolute position of the bone (world space)
  95243. * @param position The position to set the bone
  95244. * @param mesh The mesh that this bone is attached to
  95245. */
  95246. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  95247. /**
  95248. * Scale the bone on the x, y and z axes (in local space)
  95249. * @param x The amount to scale the bone on the x axis
  95250. * @param y The amount to scale the bone on the y axis
  95251. * @param z The amount to scale the bone on the z axis
  95252. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  95253. */
  95254. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  95255. /**
  95256. * Set the bone scaling in local space
  95257. * @param scale defines the scaling vector
  95258. */
  95259. setScale(scale: Vector3): void;
  95260. /**
  95261. * Gets the current scaling in local space
  95262. * @returns the current scaling vector
  95263. */
  95264. getScale(): Vector3;
  95265. /**
  95266. * Gets the current scaling in local space and stores it in a target vector
  95267. * @param result defines the target vector
  95268. */
  95269. getScaleToRef(result: Vector3): void;
  95270. /**
  95271. * Set the yaw, pitch, and roll of the bone in local or world space
  95272. * @param yaw The rotation of the bone on the y axis
  95273. * @param pitch The rotation of the bone on the x axis
  95274. * @param roll The rotation of the bone on the z axis
  95275. * @param space The space that the axes of rotation are in
  95276. * @param mesh The mesh that this bone is attached to. This is only used in world space
  95277. */
  95278. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  95279. /**
  95280. * Add a rotation to the bone on an axis in local or world space
  95281. * @param axis The axis to rotate the bone on
  95282. * @param amount The amount to rotate the bone
  95283. * @param space The space that the axis is in
  95284. * @param mesh The mesh that this bone is attached to. This is only used in world space
  95285. */
  95286. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  95287. /**
  95288. * Set the rotation of the bone to a particular axis angle in local or world space
  95289. * @param axis The axis to rotate the bone on
  95290. * @param angle The angle that the bone should be rotated to
  95291. * @param space The space that the axis is in
  95292. * @param mesh The mesh that this bone is attached to. This is only used in world space
  95293. */
  95294. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  95295. /**
  95296. * Set the euler rotation of the bone in local of world space
  95297. * @param rotation The euler rotation that the bone should be set to
  95298. * @param space The space that the rotation is in
  95299. * @param mesh The mesh that this bone is attached to. This is only used in world space
  95300. */
  95301. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  95302. /**
  95303. * Set the quaternion rotation of the bone in local of world space
  95304. * @param quat The quaternion rotation that the bone should be set to
  95305. * @param space The space that the rotation is in
  95306. * @param mesh The mesh that this bone is attached to. This is only used in world space
  95307. */
  95308. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  95309. /**
  95310. * Set the rotation matrix of the bone in local of world space
  95311. * @param rotMat The rotation matrix that the bone should be set to
  95312. * @param space The space that the rotation is in
  95313. * @param mesh The mesh that this bone is attached to. This is only used in world space
  95314. */
  95315. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  95316. private _rotateWithMatrix;
  95317. private _getNegativeRotationToRef;
  95318. /**
  95319. * Get the position of the bone in local or world space
  95320. * @param space The space that the returned position is in
  95321. * @param mesh The mesh that this bone is attached to. This is only used in world space
  95322. * @returns The position of the bone
  95323. */
  95324. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  95325. /**
  95326. * Copy the position of the bone to a vector3 in local or world space
  95327. * @param space The space that the returned position is in
  95328. * @param mesh The mesh that this bone is attached to. This is only used in world space
  95329. * @param result The vector3 to copy the position to
  95330. */
  95331. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  95332. /**
  95333. * Get the absolute position of the bone (world space)
  95334. * @param mesh The mesh that this bone is attached to
  95335. * @returns The absolute position of the bone
  95336. */
  95337. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  95338. /**
  95339. * Copy the absolute position of the bone (world space) to the result param
  95340. * @param mesh The mesh that this bone is attached to
  95341. * @param result The vector3 to copy the absolute position to
  95342. */
  95343. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  95344. /**
  95345. * Compute the absolute transforms of this bone and its children
  95346. */
  95347. computeAbsoluteTransforms(): void;
  95348. /**
  95349. * Get the world direction from an axis that is in the local space of the bone
  95350. * @param localAxis The local direction that is used to compute the world direction
  95351. * @param mesh The mesh that this bone is attached to
  95352. * @returns The world direction
  95353. */
  95354. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  95355. /**
  95356. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  95357. * @param localAxis The local direction that is used to compute the world direction
  95358. * @param mesh The mesh that this bone is attached to
  95359. * @param result The vector3 that the world direction will be copied to
  95360. */
  95361. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  95362. /**
  95363. * Get the euler rotation of the bone in local or world space
  95364. * @param space The space that the rotation should be in
  95365. * @param mesh The mesh that this bone is attached to. This is only used in world space
  95366. * @returns The euler rotation
  95367. */
  95368. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  95369. /**
  95370. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  95371. * @param space The space that the rotation should be in
  95372. * @param mesh The mesh that this bone is attached to. This is only used in world space
  95373. * @param result The vector3 that the rotation should be copied to
  95374. */
  95375. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  95376. /**
  95377. * Get the quaternion rotation of the bone in either local or world space
  95378. * @param space The space that the rotation should be in
  95379. * @param mesh The mesh that this bone is attached to. This is only used in world space
  95380. * @returns The quaternion rotation
  95381. */
  95382. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  95383. /**
  95384. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  95385. * @param space The space that the rotation should be in
  95386. * @param mesh The mesh that this bone is attached to. This is only used in world space
  95387. * @param result The quaternion that the rotation should be copied to
  95388. */
  95389. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  95390. /**
  95391. * Get the rotation matrix of the bone in local or world space
  95392. * @param space The space that the rotation should be in
  95393. * @param mesh The mesh that this bone is attached to. This is only used in world space
  95394. * @returns The rotation matrix
  95395. */
  95396. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  95397. /**
  95398. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  95399. * @param space The space that the rotation should be in
  95400. * @param mesh The mesh that this bone is attached to. This is only used in world space
  95401. * @param result The quaternion that the rotation should be copied to
  95402. */
  95403. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  95404. /**
  95405. * Get the world position of a point that is in the local space of the bone
  95406. * @param position The local position
  95407. * @param mesh The mesh that this bone is attached to
  95408. * @returns The world position
  95409. */
  95410. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  95411. /**
  95412. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  95413. * @param position The local position
  95414. * @param mesh The mesh that this bone is attached to
  95415. * @param result The vector3 that the world position should be copied to
  95416. */
  95417. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  95418. /**
  95419. * Get the local position of a point that is in world space
  95420. * @param position The world position
  95421. * @param mesh The mesh that this bone is attached to
  95422. * @returns The local position
  95423. */
  95424. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  95425. /**
  95426. * Get the local position of a point that is in world space and copy it to the result param
  95427. * @param position The world position
  95428. * @param mesh The mesh that this bone is attached to
  95429. * @param result The vector3 that the local position should be copied to
  95430. */
  95431. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  95432. }
  95433. }
  95434. declare module BABYLON {
  95435. /**
  95436. * Defines a runtime animation
  95437. */
  95438. export class RuntimeAnimation {
  95439. private _events;
  95440. /**
  95441. * The current frame of the runtime animation
  95442. */
  95443. private _currentFrame;
  95444. /**
  95445. * The animation used by the runtime animation
  95446. */
  95447. private _animation;
  95448. /**
  95449. * The target of the runtime animation
  95450. */
  95451. private _target;
  95452. /**
  95453. * The initiating animatable
  95454. */
  95455. private _host;
  95456. /**
  95457. * The original value of the runtime animation
  95458. */
  95459. private _originalValue;
  95460. /**
  95461. * The original blend value of the runtime animation
  95462. */
  95463. private _originalBlendValue;
  95464. /**
  95465. * The offsets cache of the runtime animation
  95466. */
  95467. private _offsetsCache;
  95468. /**
  95469. * The high limits cache of the runtime animation
  95470. */
  95471. private _highLimitsCache;
  95472. /**
  95473. * Specifies if the runtime animation has been stopped
  95474. */
  95475. private _stopped;
  95476. /**
  95477. * The blending factor of the runtime animation
  95478. */
  95479. private _blendingFactor;
  95480. /**
  95481. * The BabylonJS scene
  95482. */
  95483. private _scene;
  95484. /**
  95485. * The current value of the runtime animation
  95486. */
  95487. private _currentValue;
  95488. /** @hidden */
  95489. _animationState: _IAnimationState;
  95490. /**
  95491. * The active target of the runtime animation
  95492. */
  95493. private _activeTargets;
  95494. private _currentActiveTarget;
  95495. private _directTarget;
  95496. /**
  95497. * The target path of the runtime animation
  95498. */
  95499. private _targetPath;
  95500. /**
  95501. * The weight of the runtime animation
  95502. */
  95503. private _weight;
  95504. /**
  95505. * The ratio offset of the runtime animation
  95506. */
  95507. private _ratioOffset;
  95508. /**
  95509. * The previous delay of the runtime animation
  95510. */
  95511. private _previousDelay;
  95512. /**
  95513. * The previous ratio of the runtime animation
  95514. */
  95515. private _previousRatio;
  95516. private _enableBlending;
  95517. private _keys;
  95518. private _minFrame;
  95519. private _maxFrame;
  95520. private _minValue;
  95521. private _maxValue;
  95522. private _targetIsArray;
  95523. /**
  95524. * Gets the current frame of the runtime animation
  95525. */
  95526. get currentFrame(): number;
  95527. /**
  95528. * Gets the weight of the runtime animation
  95529. */
  95530. get weight(): number;
  95531. /**
  95532. * Gets the current value of the runtime animation
  95533. */
  95534. get currentValue(): any;
  95535. /**
  95536. * Gets the target path of the runtime animation
  95537. */
  95538. get targetPath(): string;
  95539. /**
  95540. * Gets the actual target of the runtime animation
  95541. */
  95542. get target(): any;
  95543. /**
  95544. * Gets the additive state of the runtime animation
  95545. */
  95546. get isAdditive(): boolean;
  95547. /** @hidden */
  95548. _onLoop: () => void;
  95549. /**
  95550. * Create a new RuntimeAnimation object
  95551. * @param target defines the target of the animation
  95552. * @param animation defines the source animation object
  95553. * @param scene defines the hosting scene
  95554. * @param host defines the initiating Animatable
  95555. */
  95556. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  95557. private _preparePath;
  95558. /**
  95559. * Gets the animation from the runtime animation
  95560. */
  95561. get animation(): Animation;
  95562. /**
  95563. * Resets the runtime animation to the beginning
  95564. * @param restoreOriginal defines whether to restore the target property to the original value
  95565. */
  95566. reset(restoreOriginal?: boolean): void;
  95567. /**
  95568. * Specifies if the runtime animation is stopped
  95569. * @returns Boolean specifying if the runtime animation is stopped
  95570. */
  95571. isStopped(): boolean;
  95572. /**
  95573. * Disposes of the runtime animation
  95574. */
  95575. dispose(): void;
  95576. /**
  95577. * Apply the interpolated value to the target
  95578. * @param currentValue defines the value computed by the animation
  95579. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  95580. */
  95581. setValue(currentValue: any, weight: number): void;
  95582. private _getOriginalValues;
  95583. private _setValue;
  95584. /**
  95585. * Gets the loop pmode of the runtime animation
  95586. * @returns Loop Mode
  95587. */
  95588. private _getCorrectLoopMode;
  95589. /**
  95590. * Move the current animation to a given frame
  95591. * @param frame defines the frame to move to
  95592. */
  95593. goToFrame(frame: number): void;
  95594. /**
  95595. * @hidden Internal use only
  95596. */
  95597. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  95598. /**
  95599. * Execute the current animation
  95600. * @param delay defines the delay to add to the current frame
  95601. * @param from defines the lower bound of the animation range
  95602. * @param to defines the upper bound of the animation range
  95603. * @param loop defines if the current animation must loop
  95604. * @param speedRatio defines the current speed ratio
  95605. * @param weight defines the weight of the animation (default is -1 so no weight)
  95606. * @param onLoop optional callback called when animation loops
  95607. * @returns a boolean indicating if the animation is running
  95608. */
  95609. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  95610. }
  95611. }
  95612. declare module BABYLON {
  95613. /**
  95614. * Class used to store an actual running animation
  95615. */
  95616. export class Animatable {
  95617. /** defines the target object */
  95618. target: any;
  95619. /** defines the starting frame number (default is 0) */
  95620. fromFrame: number;
  95621. /** defines the ending frame number (default is 100) */
  95622. toFrame: number;
  95623. /** defines if the animation must loop (default is false) */
  95624. loopAnimation: boolean;
  95625. /** defines a callback to call when animation ends if it is not looping */
  95626. onAnimationEnd?: (() => void) | null | undefined;
  95627. /** defines a callback to call when animation loops */
  95628. onAnimationLoop?: (() => void) | null | undefined;
  95629. /** defines whether the animation should be evaluated additively */
  95630. isAdditive: boolean;
  95631. private _localDelayOffset;
  95632. private _pausedDelay;
  95633. private _runtimeAnimations;
  95634. private _paused;
  95635. private _scene;
  95636. private _speedRatio;
  95637. private _weight;
  95638. private _syncRoot;
  95639. /**
  95640. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  95641. * This will only apply for non looping animation (default is true)
  95642. */
  95643. disposeOnEnd: boolean;
  95644. /**
  95645. * Gets a boolean indicating if the animation has started
  95646. */
  95647. animationStarted: boolean;
  95648. /**
  95649. * Observer raised when the animation ends
  95650. */
  95651. onAnimationEndObservable: Observable<Animatable>;
  95652. /**
  95653. * Observer raised when the animation loops
  95654. */
  95655. onAnimationLoopObservable: Observable<Animatable>;
  95656. /**
  95657. * Gets the root Animatable used to synchronize and normalize animations
  95658. */
  95659. get syncRoot(): Nullable<Animatable>;
  95660. /**
  95661. * Gets the current frame of the first RuntimeAnimation
  95662. * Used to synchronize Animatables
  95663. */
  95664. get masterFrame(): number;
  95665. /**
  95666. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  95667. */
  95668. get weight(): number;
  95669. set weight(value: number);
  95670. /**
  95671. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  95672. */
  95673. get speedRatio(): number;
  95674. set speedRatio(value: number);
  95675. /**
  95676. * Creates a new Animatable
  95677. * @param scene defines the hosting scene
  95678. * @param target defines the target object
  95679. * @param fromFrame defines the starting frame number (default is 0)
  95680. * @param toFrame defines the ending frame number (default is 100)
  95681. * @param loopAnimation defines if the animation must loop (default is false)
  95682. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  95683. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  95684. * @param animations defines a group of animation to add to the new Animatable
  95685. * @param onAnimationLoop defines a callback to call when animation loops
  95686. * @param isAdditive defines whether the animation should be evaluated additively
  95687. */
  95688. constructor(scene: Scene,
  95689. /** defines the target object */
  95690. target: any,
  95691. /** defines the starting frame number (default is 0) */
  95692. fromFrame?: number,
  95693. /** defines the ending frame number (default is 100) */
  95694. toFrame?: number,
  95695. /** defines if the animation must loop (default is false) */
  95696. loopAnimation?: boolean, speedRatio?: number,
  95697. /** defines a callback to call when animation ends if it is not looping */
  95698. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  95699. /** defines a callback to call when animation loops */
  95700. onAnimationLoop?: (() => void) | null | undefined,
  95701. /** defines whether the animation should be evaluated additively */
  95702. isAdditive?: boolean);
  95703. /**
  95704. * Synchronize and normalize current Animatable with a source Animatable
  95705. * This is useful when using animation weights and when animations are not of the same length
  95706. * @param root defines the root Animatable to synchronize with
  95707. * @returns the current Animatable
  95708. */
  95709. syncWith(root: Animatable): Animatable;
  95710. /**
  95711. * Gets the list of runtime animations
  95712. * @returns an array of RuntimeAnimation
  95713. */
  95714. getAnimations(): RuntimeAnimation[];
  95715. /**
  95716. * Adds more animations to the current animatable
  95717. * @param target defines the target of the animations
  95718. * @param animations defines the new animations to add
  95719. */
  95720. appendAnimations(target: any, animations: Animation[]): void;
  95721. /**
  95722. * Gets the source animation for a specific property
  95723. * @param property defines the propertyu to look for
  95724. * @returns null or the source animation for the given property
  95725. */
  95726. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  95727. /**
  95728. * Gets the runtime animation for a specific property
  95729. * @param property defines the propertyu to look for
  95730. * @returns null or the runtime animation for the given property
  95731. */
  95732. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  95733. /**
  95734. * Resets the animatable to its original state
  95735. */
  95736. reset(): void;
  95737. /**
  95738. * Allows the animatable to blend with current running animations
  95739. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  95740. * @param blendingSpeed defines the blending speed to use
  95741. */
  95742. enableBlending(blendingSpeed: number): void;
  95743. /**
  95744. * Disable animation blending
  95745. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  95746. */
  95747. disableBlending(): void;
  95748. /**
  95749. * Jump directly to a given frame
  95750. * @param frame defines the frame to jump to
  95751. */
  95752. goToFrame(frame: number): void;
  95753. /**
  95754. * Pause the animation
  95755. */
  95756. pause(): void;
  95757. /**
  95758. * Restart the animation
  95759. */
  95760. restart(): void;
  95761. private _raiseOnAnimationEnd;
  95762. /**
  95763. * Stop and delete the current animation
  95764. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  95765. * @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)
  95766. */
  95767. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  95768. /**
  95769. * Wait asynchronously for the animation to end
  95770. * @returns a promise which will be fullfilled when the animation ends
  95771. */
  95772. waitAsync(): Promise<Animatable>;
  95773. /** @hidden */
  95774. _animate(delay: number): boolean;
  95775. }
  95776. interface Scene {
  95777. /** @hidden */
  95778. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  95779. /** @hidden */
  95780. _processLateAnimationBindingsForMatrices(holder: {
  95781. totalWeight: number;
  95782. totalAdditiveWeight: number;
  95783. animations: RuntimeAnimation[];
  95784. additiveAnimations: RuntimeAnimation[];
  95785. originalValue: Matrix;
  95786. }): any;
  95787. /** @hidden */
  95788. _processLateAnimationBindingsForQuaternions(holder: {
  95789. totalWeight: number;
  95790. totalAdditiveWeight: number;
  95791. animations: RuntimeAnimation[];
  95792. additiveAnimations: RuntimeAnimation[];
  95793. originalValue: Quaternion;
  95794. }, refQuaternion: Quaternion): Quaternion;
  95795. /** @hidden */
  95796. _processLateAnimationBindings(): void;
  95797. /**
  95798. * Will start the animation sequence of a given target
  95799. * @param target defines the target
  95800. * @param from defines from which frame should animation start
  95801. * @param to defines until which frame should animation run.
  95802. * @param weight defines the weight to apply to the animation (1.0 by default)
  95803. * @param loop defines if the animation loops
  95804. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  95805. * @param onAnimationEnd defines the function to be executed when the animation ends
  95806. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  95807. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  95808. * @param onAnimationLoop defines the callback to call when an animation loops
  95809. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  95810. * @returns the animatable object created for this animation
  95811. */
  95812. 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;
  95813. /**
  95814. * Will start the animation sequence of a given target
  95815. * @param target defines the target
  95816. * @param from defines from which frame should animation start
  95817. * @param to defines until which frame should animation run.
  95818. * @param loop defines if the animation loops
  95819. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  95820. * @param onAnimationEnd defines the function to be executed when the animation ends
  95821. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  95822. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  95823. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  95824. * @param onAnimationLoop defines the callback to call when an animation loops
  95825. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  95826. * @returns the animatable object created for this animation
  95827. */
  95828. 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;
  95829. /**
  95830. * Will start the animation sequence of a given target and its hierarchy
  95831. * @param target defines the target
  95832. * @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.
  95833. * @param from defines from which frame should animation start
  95834. * @param to defines until which frame should animation run.
  95835. * @param loop defines if the animation loops
  95836. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  95837. * @param onAnimationEnd defines the function to be executed when the animation ends
  95838. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  95839. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  95840. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  95841. * @param onAnimationLoop defines the callback to call when an animation loops
  95842. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  95843. * @returns the list of created animatables
  95844. */
  95845. 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[];
  95846. /**
  95847. * Begin a new animation on a given node
  95848. * @param target defines the target where the animation will take place
  95849. * @param animations defines the list of animations to start
  95850. * @param from defines the initial value
  95851. * @param to defines the final value
  95852. * @param loop defines if you want animation to loop (off by default)
  95853. * @param speedRatio defines the speed ratio to apply to all animations
  95854. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  95855. * @param onAnimationLoop defines the callback to call when an animation loops
  95856. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  95857. * @returns the list of created animatables
  95858. */
  95859. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  95860. /**
  95861. * Begin a new animation on a given node and its hierarchy
  95862. * @param target defines the root node where the animation will take place
  95863. * @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.
  95864. * @param animations defines the list of animations to start
  95865. * @param from defines the initial value
  95866. * @param to defines the final value
  95867. * @param loop defines if you want animation to loop (off by default)
  95868. * @param speedRatio defines the speed ratio to apply to all animations
  95869. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  95870. * @param onAnimationLoop defines the callback to call when an animation loops
  95871. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  95872. * @returns the list of animatables created for all nodes
  95873. */
  95874. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  95875. /**
  95876. * Gets the animatable associated with a specific target
  95877. * @param target defines the target of the animatable
  95878. * @returns the required animatable if found
  95879. */
  95880. getAnimatableByTarget(target: any): Nullable<Animatable>;
  95881. /**
  95882. * Gets all animatables associated with a given target
  95883. * @param target defines the target to look animatables for
  95884. * @returns an array of Animatables
  95885. */
  95886. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  95887. /**
  95888. * Stops and removes all animations that have been applied to the scene
  95889. */
  95890. stopAllAnimations(): void;
  95891. /**
  95892. * Gets the current delta time used by animation engine
  95893. */
  95894. deltaTime: number;
  95895. }
  95896. interface Bone {
  95897. /**
  95898. * Copy an animation range from another bone
  95899. * @param source defines the source bone
  95900. * @param rangeName defines the range name to copy
  95901. * @param frameOffset defines the frame offset
  95902. * @param rescaleAsRequired defines if rescaling must be applied if required
  95903. * @param skelDimensionsRatio defines the scaling ratio
  95904. * @returns true if operation was successful
  95905. */
  95906. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  95907. }
  95908. }
  95909. declare module BABYLON {
  95910. /**
  95911. * Class used to handle skinning animations
  95912. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  95913. */
  95914. export class Skeleton implements IAnimatable {
  95915. /** defines the skeleton name */
  95916. name: string;
  95917. /** defines the skeleton Id */
  95918. id: string;
  95919. /**
  95920. * Defines the list of child bones
  95921. */
  95922. bones: Bone[];
  95923. /**
  95924. * Defines an estimate of the dimension of the skeleton at rest
  95925. */
  95926. dimensionsAtRest: Vector3;
  95927. /**
  95928. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  95929. */
  95930. needInitialSkinMatrix: boolean;
  95931. /**
  95932. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  95933. */
  95934. overrideMesh: Nullable<AbstractMesh>;
  95935. /**
  95936. * Gets the list of animations attached to this skeleton
  95937. */
  95938. animations: Array<Animation>;
  95939. private _scene;
  95940. private _isDirty;
  95941. private _transformMatrices;
  95942. private _transformMatrixTexture;
  95943. private _meshesWithPoseMatrix;
  95944. private _animatables;
  95945. private _identity;
  95946. private _synchronizedWithMesh;
  95947. private _ranges;
  95948. private _lastAbsoluteTransformsUpdateId;
  95949. private _canUseTextureForBones;
  95950. private _uniqueId;
  95951. /** @hidden */
  95952. _numBonesWithLinkedTransformNode: number;
  95953. /** @hidden */
  95954. _hasWaitingData: Nullable<boolean>;
  95955. /** @hidden */
  95956. _waitingOverrideMeshId: Nullable<string>;
  95957. /**
  95958. * Specifies if the skeleton should be serialized
  95959. */
  95960. doNotSerialize: boolean;
  95961. private _useTextureToStoreBoneMatrices;
  95962. /**
  95963. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  95964. * Please note that this option is not available if the hardware does not support it
  95965. */
  95966. get useTextureToStoreBoneMatrices(): boolean;
  95967. set useTextureToStoreBoneMatrices(value: boolean);
  95968. private _animationPropertiesOverride;
  95969. /**
  95970. * Gets or sets the animation properties override
  95971. */
  95972. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  95973. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  95974. /**
  95975. * List of inspectable custom properties (used by the Inspector)
  95976. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  95977. */
  95978. inspectableCustomProperties: IInspectable[];
  95979. /**
  95980. * An observable triggered before computing the skeleton's matrices
  95981. */
  95982. onBeforeComputeObservable: Observable<Skeleton>;
  95983. /**
  95984. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  95985. */
  95986. get isUsingTextureForMatrices(): boolean;
  95987. /**
  95988. * Gets the unique ID of this skeleton
  95989. */
  95990. get uniqueId(): number;
  95991. /**
  95992. * Creates a new skeleton
  95993. * @param name defines the skeleton name
  95994. * @param id defines the skeleton Id
  95995. * @param scene defines the hosting scene
  95996. */
  95997. constructor(
  95998. /** defines the skeleton name */
  95999. name: string,
  96000. /** defines the skeleton Id */
  96001. id: string, scene: Scene);
  96002. /**
  96003. * Gets the current object class name.
  96004. * @return the class name
  96005. */
  96006. getClassName(): string;
  96007. /**
  96008. * Returns an array containing the root bones
  96009. * @returns an array containing the root bones
  96010. */
  96011. getChildren(): Array<Bone>;
  96012. /**
  96013. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  96014. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  96015. * @returns a Float32Array containing matrices data
  96016. */
  96017. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  96018. /**
  96019. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  96020. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  96021. * @returns a raw texture containing the data
  96022. */
  96023. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  96024. /**
  96025. * Gets the current hosting scene
  96026. * @returns a scene object
  96027. */
  96028. getScene(): Scene;
  96029. /**
  96030. * Gets a string representing the current skeleton data
  96031. * @param fullDetails defines a boolean indicating if we want a verbose version
  96032. * @returns a string representing the current skeleton data
  96033. */
  96034. toString(fullDetails?: boolean): string;
  96035. /**
  96036. * Get bone's index searching by name
  96037. * @param name defines bone's name to search for
  96038. * @return the indice of the bone. Returns -1 if not found
  96039. */
  96040. getBoneIndexByName(name: string): number;
  96041. /**
  96042. * Creater a new animation range
  96043. * @param name defines the name of the range
  96044. * @param from defines the start key
  96045. * @param to defines the end key
  96046. */
  96047. createAnimationRange(name: string, from: number, to: number): void;
  96048. /**
  96049. * Delete a specific animation range
  96050. * @param name defines the name of the range
  96051. * @param deleteFrames defines if frames must be removed as well
  96052. */
  96053. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  96054. /**
  96055. * Gets a specific animation range
  96056. * @param name defines the name of the range to look for
  96057. * @returns the requested animation range or null if not found
  96058. */
  96059. getAnimationRange(name: string): Nullable<AnimationRange>;
  96060. /**
  96061. * Gets the list of all animation ranges defined on this skeleton
  96062. * @returns an array
  96063. */
  96064. getAnimationRanges(): Nullable<AnimationRange>[];
  96065. /**
  96066. * Copy animation range from a source skeleton.
  96067. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  96068. * @param source defines the source skeleton
  96069. * @param name defines the name of the range to copy
  96070. * @param rescaleAsRequired defines if rescaling must be applied if required
  96071. * @returns true if operation was successful
  96072. */
  96073. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  96074. /**
  96075. * Forces the skeleton to go to rest pose
  96076. */
  96077. returnToRest(): void;
  96078. private _getHighestAnimationFrame;
  96079. /**
  96080. * Begin a specific animation range
  96081. * @param name defines the name of the range to start
  96082. * @param loop defines if looping must be turned on (false by default)
  96083. * @param speedRatio defines the speed ratio to apply (1 by default)
  96084. * @param onAnimationEnd defines a callback which will be called when animation will end
  96085. * @returns a new animatable
  96086. */
  96087. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  96088. /**
  96089. * Convert the keyframes for a range of animation on a skeleton to be relative to a given reference frame.
  96090. * @param skeleton defines the Skeleton containing the animation range to convert
  96091. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  96092. * @param range defines the name of the AnimationRange belonging to the Skeleton to convert
  96093. * @returns the original skeleton
  96094. */
  96095. static MakeAnimationAdditive(skeleton: Skeleton, referenceFrame: number | undefined, range: string): Nullable<Skeleton>;
  96096. /** @hidden */
  96097. _markAsDirty(): void;
  96098. /** @hidden */
  96099. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  96100. /** @hidden */
  96101. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  96102. private _computeTransformMatrices;
  96103. /**
  96104. * Build all resources required to render a skeleton
  96105. */
  96106. prepare(): void;
  96107. /**
  96108. * Gets the list of animatables currently running for this skeleton
  96109. * @returns an array of animatables
  96110. */
  96111. getAnimatables(): IAnimatable[];
  96112. /**
  96113. * Clone the current skeleton
  96114. * @param name defines the name of the new skeleton
  96115. * @param id defines the id of the new skeleton
  96116. * @returns the new skeleton
  96117. */
  96118. clone(name: string, id?: string): Skeleton;
  96119. /**
  96120. * Enable animation blending for this skeleton
  96121. * @param blendingSpeed defines the blending speed to apply
  96122. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  96123. */
  96124. enableBlending(blendingSpeed?: number): void;
  96125. /**
  96126. * Releases all resources associated with the current skeleton
  96127. */
  96128. dispose(): void;
  96129. /**
  96130. * Serialize the skeleton in a JSON object
  96131. * @returns a JSON object
  96132. */
  96133. serialize(): any;
  96134. /**
  96135. * Creates a new skeleton from serialized data
  96136. * @param parsedSkeleton defines the serialized data
  96137. * @param scene defines the hosting scene
  96138. * @returns a new skeleton
  96139. */
  96140. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  96141. /**
  96142. * Compute all node absolute transforms
  96143. * @param forceUpdate defines if computation must be done even if cache is up to date
  96144. */
  96145. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  96146. /**
  96147. * Gets the root pose matrix
  96148. * @returns a matrix
  96149. */
  96150. getPoseMatrix(): Nullable<Matrix>;
  96151. /**
  96152. * Sorts bones per internal index
  96153. */
  96154. sortBones(): void;
  96155. private _sortBones;
  96156. }
  96157. }
  96158. declare module BABYLON {
  96159. /**
  96160. * Creates an instance based on a source mesh.
  96161. */
  96162. export class InstancedMesh extends AbstractMesh {
  96163. private _sourceMesh;
  96164. private _currentLOD;
  96165. /** @hidden */
  96166. _indexInSourceMeshInstanceArray: number;
  96167. constructor(name: string, source: Mesh);
  96168. /**
  96169. * Returns the string "InstancedMesh".
  96170. */
  96171. getClassName(): string;
  96172. /** Gets the list of lights affecting that mesh */
  96173. get lightSources(): Light[];
  96174. _resyncLightSources(): void;
  96175. _resyncLightSource(light: Light): void;
  96176. _removeLightSource(light: Light, dispose: boolean): void;
  96177. /**
  96178. * If the source mesh receives shadows
  96179. */
  96180. get receiveShadows(): boolean;
  96181. /**
  96182. * The material of the source mesh
  96183. */
  96184. get material(): Nullable<Material>;
  96185. /**
  96186. * Visibility of the source mesh
  96187. */
  96188. get visibility(): number;
  96189. /**
  96190. * Skeleton of the source mesh
  96191. */
  96192. get skeleton(): Nullable<Skeleton>;
  96193. /**
  96194. * Rendering ground id of the source mesh
  96195. */
  96196. get renderingGroupId(): number;
  96197. set renderingGroupId(value: number);
  96198. /**
  96199. * Returns the total number of vertices (integer).
  96200. */
  96201. getTotalVertices(): number;
  96202. /**
  96203. * Returns a positive integer : the total number of indices in this mesh geometry.
  96204. * @returns the numner of indices or zero if the mesh has no geometry.
  96205. */
  96206. getTotalIndices(): number;
  96207. /**
  96208. * The source mesh of the instance
  96209. */
  96210. get sourceMesh(): Mesh;
  96211. /**
  96212. * Creates a new InstancedMesh object from the mesh model.
  96213. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  96214. * @param name defines the name of the new instance
  96215. * @returns a new InstancedMesh
  96216. */
  96217. createInstance(name: string): InstancedMesh;
  96218. /**
  96219. * Is this node ready to be used/rendered
  96220. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  96221. * @return {boolean} is it ready
  96222. */
  96223. isReady(completeCheck?: boolean): boolean;
  96224. /**
  96225. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  96226. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  96227. * @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.
  96228. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  96229. */
  96230. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  96231. /**
  96232. * Sets the vertex data of the mesh geometry for the requested `kind`.
  96233. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  96234. * The `data` are either a numeric array either a Float32Array.
  96235. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  96236. * 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).
  96237. * Note that a new underlying VertexBuffer object is created each call.
  96238. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  96239. *
  96240. * Possible `kind` values :
  96241. * - VertexBuffer.PositionKind
  96242. * - VertexBuffer.UVKind
  96243. * - VertexBuffer.UV2Kind
  96244. * - VertexBuffer.UV3Kind
  96245. * - VertexBuffer.UV4Kind
  96246. * - VertexBuffer.UV5Kind
  96247. * - VertexBuffer.UV6Kind
  96248. * - VertexBuffer.ColorKind
  96249. * - VertexBuffer.MatricesIndicesKind
  96250. * - VertexBuffer.MatricesIndicesExtraKind
  96251. * - VertexBuffer.MatricesWeightsKind
  96252. * - VertexBuffer.MatricesWeightsExtraKind
  96253. *
  96254. * Returns the Mesh.
  96255. */
  96256. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  96257. /**
  96258. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  96259. * If the mesh has no geometry, it is simply returned as it is.
  96260. * The `data` are either a numeric array either a Float32Array.
  96261. * No new underlying VertexBuffer object is created.
  96262. * 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.
  96263. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  96264. *
  96265. * Possible `kind` values :
  96266. * - VertexBuffer.PositionKind
  96267. * - VertexBuffer.UVKind
  96268. * - VertexBuffer.UV2Kind
  96269. * - VertexBuffer.UV3Kind
  96270. * - VertexBuffer.UV4Kind
  96271. * - VertexBuffer.UV5Kind
  96272. * - VertexBuffer.UV6Kind
  96273. * - VertexBuffer.ColorKind
  96274. * - VertexBuffer.MatricesIndicesKind
  96275. * - VertexBuffer.MatricesIndicesExtraKind
  96276. * - VertexBuffer.MatricesWeightsKind
  96277. * - VertexBuffer.MatricesWeightsExtraKind
  96278. *
  96279. * Returns the Mesh.
  96280. */
  96281. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  96282. /**
  96283. * Sets the mesh indices.
  96284. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  96285. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  96286. * This method creates a new index buffer each call.
  96287. * Returns the Mesh.
  96288. */
  96289. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  96290. /**
  96291. * Boolean : True if the mesh owns the requested kind of data.
  96292. */
  96293. isVerticesDataPresent(kind: string): boolean;
  96294. /**
  96295. * Returns an array of indices (IndicesArray).
  96296. */
  96297. getIndices(): Nullable<IndicesArray>;
  96298. get _positions(): Nullable<Vector3[]>;
  96299. /**
  96300. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  96301. * This means the mesh underlying bounding box and sphere are recomputed.
  96302. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  96303. * @returns the current mesh
  96304. */
  96305. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  96306. /** @hidden */
  96307. _preActivate(): InstancedMesh;
  96308. /** @hidden */
  96309. _activate(renderId: number, intermediateRendering: boolean): boolean;
  96310. /** @hidden */
  96311. _postActivate(): void;
  96312. getWorldMatrix(): Matrix;
  96313. get isAnInstance(): boolean;
  96314. /**
  96315. * Returns the current associated LOD AbstractMesh.
  96316. */
  96317. getLOD(camera: Camera): AbstractMesh;
  96318. /** @hidden */
  96319. _preActivateForIntermediateRendering(renderId: number): Mesh;
  96320. /** @hidden */
  96321. _syncSubMeshes(): InstancedMesh;
  96322. /** @hidden */
  96323. _generatePointsArray(): boolean;
  96324. /** @hidden */
  96325. _updateBoundingInfo(): AbstractMesh;
  96326. /**
  96327. * Creates a new InstancedMesh from the current mesh.
  96328. * - name (string) : the cloned mesh name
  96329. * - newParent (optional Node) : the optional Node to parent the clone to.
  96330. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  96331. *
  96332. * Returns the clone.
  96333. */
  96334. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  96335. /**
  96336. * Disposes the InstancedMesh.
  96337. * Returns nothing.
  96338. */
  96339. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  96340. }
  96341. interface Mesh {
  96342. /**
  96343. * Register a custom buffer that will be instanced
  96344. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  96345. * @param kind defines the buffer kind
  96346. * @param stride defines the stride in floats
  96347. */
  96348. registerInstancedBuffer(kind: string, stride: number): void;
  96349. /**
  96350. * true to use the edge renderer for all instances of this mesh
  96351. */
  96352. edgesShareWithInstances: boolean;
  96353. /** @hidden */
  96354. _userInstancedBuffersStorage: {
  96355. data: {
  96356. [key: string]: Float32Array;
  96357. };
  96358. sizes: {
  96359. [key: string]: number;
  96360. };
  96361. vertexBuffers: {
  96362. [key: string]: Nullable<VertexBuffer>;
  96363. };
  96364. strides: {
  96365. [key: string]: number;
  96366. };
  96367. };
  96368. }
  96369. interface AbstractMesh {
  96370. /**
  96371. * Object used to store instanced buffers defined by user
  96372. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  96373. */
  96374. instancedBuffers: {
  96375. [key: string]: any;
  96376. };
  96377. }
  96378. }
  96379. declare module BABYLON {
  96380. /**
  96381. * Defines the options associated with the creation of a shader material.
  96382. */
  96383. export interface IShaderMaterialOptions {
  96384. /**
  96385. * Does the material work in alpha blend mode
  96386. */
  96387. needAlphaBlending: boolean;
  96388. /**
  96389. * Does the material work in alpha test mode
  96390. */
  96391. needAlphaTesting: boolean;
  96392. /**
  96393. * The list of attribute names used in the shader
  96394. */
  96395. attributes: string[];
  96396. /**
  96397. * The list of unifrom names used in the shader
  96398. */
  96399. uniforms: string[];
  96400. /**
  96401. * The list of UBO names used in the shader
  96402. */
  96403. uniformBuffers: string[];
  96404. /**
  96405. * The list of sampler names used in the shader
  96406. */
  96407. samplers: string[];
  96408. /**
  96409. * The list of defines used in the shader
  96410. */
  96411. defines: string[];
  96412. }
  96413. /**
  96414. * 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.
  96415. *
  96416. * This returned material effects how the mesh will look based on the code in the shaders.
  96417. *
  96418. * @see https://doc.babylonjs.com/how_to/shader_material
  96419. */
  96420. export class ShaderMaterial extends Material {
  96421. private _shaderPath;
  96422. private _options;
  96423. private _textures;
  96424. private _textureArrays;
  96425. private _floats;
  96426. private _ints;
  96427. private _floatsArrays;
  96428. private _colors3;
  96429. private _colors3Arrays;
  96430. private _colors4;
  96431. private _colors4Arrays;
  96432. private _vectors2;
  96433. private _vectors3;
  96434. private _vectors4;
  96435. private _matrices;
  96436. private _matrixArrays;
  96437. private _matrices3x3;
  96438. private _matrices2x2;
  96439. private _vectors2Arrays;
  96440. private _vectors3Arrays;
  96441. private _vectors4Arrays;
  96442. private _cachedWorldViewMatrix;
  96443. private _cachedWorldViewProjectionMatrix;
  96444. private _renderId;
  96445. private _multiview;
  96446. private _cachedDefines;
  96447. /** Define the Url to load snippets */
  96448. static SnippetUrl: string;
  96449. /** Snippet ID if the material was created from the snippet server */
  96450. snippetId: string;
  96451. /**
  96452. * Instantiate a new shader material.
  96453. * 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.
  96454. * This returned material effects how the mesh will look based on the code in the shaders.
  96455. * @see https://doc.babylonjs.com/how_to/shader_material
  96456. * @param name Define the name of the material in the scene
  96457. * @param scene Define the scene the material belongs to
  96458. * @param shaderPath Defines the route to the shader code in one of three ways:
  96459. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  96460. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  96461. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  96462. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  96463. * @param options Define the options used to create the shader
  96464. */
  96465. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  96466. /**
  96467. * Gets the shader path used to define the shader code
  96468. * It can be modified to trigger a new compilation
  96469. */
  96470. get shaderPath(): any;
  96471. /**
  96472. * Sets the shader path used to define the shader code
  96473. * It can be modified to trigger a new compilation
  96474. */
  96475. set shaderPath(shaderPath: any);
  96476. /**
  96477. * Gets the options used to compile the shader.
  96478. * They can be modified to trigger a new compilation
  96479. */
  96480. get options(): IShaderMaterialOptions;
  96481. /**
  96482. * Gets the current class name of the material e.g. "ShaderMaterial"
  96483. * Mainly use in serialization.
  96484. * @returns the class name
  96485. */
  96486. getClassName(): string;
  96487. /**
  96488. * Specifies if the material will require alpha blending
  96489. * @returns a boolean specifying if alpha blending is needed
  96490. */
  96491. needAlphaBlending(): boolean;
  96492. /**
  96493. * Specifies if this material should be rendered in alpha test mode
  96494. * @returns a boolean specifying if an alpha test is needed.
  96495. */
  96496. needAlphaTesting(): boolean;
  96497. private _checkUniform;
  96498. /**
  96499. * Set a texture in the shader.
  96500. * @param name Define the name of the uniform samplers as defined in the shader
  96501. * @param texture Define the texture to bind to this sampler
  96502. * @return the material itself allowing "fluent" like uniform updates
  96503. */
  96504. setTexture(name: string, texture: BaseTexture): ShaderMaterial;
  96505. /**
  96506. * Set a texture array in the shader.
  96507. * @param name Define the name of the uniform sampler array as defined in the shader
  96508. * @param textures Define the list of textures to bind to this sampler
  96509. * @return the material itself allowing "fluent" like uniform updates
  96510. */
  96511. setTextureArray(name: string, textures: BaseTexture[]): ShaderMaterial;
  96512. /**
  96513. * Set a float in the shader.
  96514. * @param name Define the name of the uniform as defined in the shader
  96515. * @param value Define the value to give to the uniform
  96516. * @return the material itself allowing "fluent" like uniform updates
  96517. */
  96518. setFloat(name: string, value: number): ShaderMaterial;
  96519. /**
  96520. * Set a int in the shader.
  96521. * @param name Define the name of the uniform as defined in the shader
  96522. * @param value Define the value to give to the uniform
  96523. * @return the material itself allowing "fluent" like uniform updates
  96524. */
  96525. setInt(name: string, value: number): ShaderMaterial;
  96526. /**
  96527. * Set an array of floats in the shader.
  96528. * @param name Define the name of the uniform as defined in the shader
  96529. * @param value Define the value to give to the uniform
  96530. * @return the material itself allowing "fluent" like uniform updates
  96531. */
  96532. setFloats(name: string, value: number[]): ShaderMaterial;
  96533. /**
  96534. * Set a vec3 in the shader from a Color3.
  96535. * @param name Define the name of the uniform as defined in the shader
  96536. * @param value Define the value to give to the uniform
  96537. * @return the material itself allowing "fluent" like uniform updates
  96538. */
  96539. setColor3(name: string, value: Color3): ShaderMaterial;
  96540. /**
  96541. * Set a vec3 array in the shader from a Color3 array.
  96542. * @param name Define the name of the uniform as defined in the shader
  96543. * @param value Define the value to give to the uniform
  96544. * @return the material itself allowing "fluent" like uniform updates
  96545. */
  96546. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  96547. /**
  96548. * Set a vec4 in the shader from a Color4.
  96549. * @param name Define the name of the uniform as defined in the shader
  96550. * @param value Define the value to give to the uniform
  96551. * @return the material itself allowing "fluent" like uniform updates
  96552. */
  96553. setColor4(name: string, value: Color4): ShaderMaterial;
  96554. /**
  96555. * Set a vec4 array in the shader from a Color4 array.
  96556. * @param name Define the name of the uniform as defined in the shader
  96557. * @param value Define the value to give to the uniform
  96558. * @return the material itself allowing "fluent" like uniform updates
  96559. */
  96560. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  96561. /**
  96562. * Set a vec2 in the shader from a Vector2.
  96563. * @param name Define the name of the uniform as defined in the shader
  96564. * @param value Define the value to give to the uniform
  96565. * @return the material itself allowing "fluent" like uniform updates
  96566. */
  96567. setVector2(name: string, value: Vector2): ShaderMaterial;
  96568. /**
  96569. * Set a vec3 in the shader from a Vector3.
  96570. * @param name Define the name of the uniform as defined in the shader
  96571. * @param value Define the value to give to the uniform
  96572. * @return the material itself allowing "fluent" like uniform updates
  96573. */
  96574. setVector3(name: string, value: Vector3): ShaderMaterial;
  96575. /**
  96576. * Set a vec4 in the shader from a Vector4.
  96577. * @param name Define the name of the uniform as defined in the shader
  96578. * @param value Define the value to give to the uniform
  96579. * @return the material itself allowing "fluent" like uniform updates
  96580. */
  96581. setVector4(name: string, value: Vector4): ShaderMaterial;
  96582. /**
  96583. * Set a mat4 in the shader from a Matrix.
  96584. * @param name Define the name of the uniform as defined in the shader
  96585. * @param value Define the value to give to the uniform
  96586. * @return the material itself allowing "fluent" like uniform updates
  96587. */
  96588. setMatrix(name: string, value: Matrix): ShaderMaterial;
  96589. /**
  96590. * Set a float32Array in the shader from a matrix array.
  96591. * @param name Define the name of the uniform as defined in the shader
  96592. * @param value Define the value to give to the uniform
  96593. * @return the material itself allowing "fluent" like uniform updates
  96594. */
  96595. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  96596. /**
  96597. * Set a mat3 in the shader from a Float32Array.
  96598. * @param name Define the name of the uniform as defined in the shader
  96599. * @param value Define the value to give to the uniform
  96600. * @return the material itself allowing "fluent" like uniform updates
  96601. */
  96602. setMatrix3x3(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  96603. /**
  96604. * Set a mat2 in the shader from a Float32Array.
  96605. * @param name Define the name of the uniform as defined in the shader
  96606. * @param value Define the value to give to the uniform
  96607. * @return the material itself allowing "fluent" like uniform updates
  96608. */
  96609. setMatrix2x2(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  96610. /**
  96611. * Set a vec2 array in the shader from a number array.
  96612. * @param name Define the name of the uniform as defined in the shader
  96613. * @param value Define the value to give to the uniform
  96614. * @return the material itself allowing "fluent" like uniform updates
  96615. */
  96616. setArray2(name: string, value: number[]): ShaderMaterial;
  96617. /**
  96618. * Set a vec3 array in the shader from a number array.
  96619. * @param name Define the name of the uniform as defined in the shader
  96620. * @param value Define the value to give to the uniform
  96621. * @return the material itself allowing "fluent" like uniform updates
  96622. */
  96623. setArray3(name: string, value: number[]): ShaderMaterial;
  96624. /**
  96625. * Set a vec4 array in the shader from a number array.
  96626. * @param name Define the name of the uniform as defined in the shader
  96627. * @param value Define the value to give to the uniform
  96628. * @return the material itself allowing "fluent" like uniform updates
  96629. */
  96630. setArray4(name: string, value: number[]): ShaderMaterial;
  96631. private _checkCache;
  96632. /**
  96633. * Specifies that the submesh is ready to be used
  96634. * @param mesh defines the mesh to check
  96635. * @param subMesh defines which submesh to check
  96636. * @param useInstances specifies that instances should be used
  96637. * @returns a boolean indicating that the submesh is ready or not
  96638. */
  96639. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  96640. /**
  96641. * Checks if the material is ready to render the requested mesh
  96642. * @param mesh Define the mesh to render
  96643. * @param useInstances Define whether or not the material is used with instances
  96644. * @returns true if ready, otherwise false
  96645. */
  96646. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  96647. /**
  96648. * Binds the world matrix to the material
  96649. * @param world defines the world transformation matrix
  96650. * @param effectOverride - If provided, use this effect instead of internal effect
  96651. */
  96652. bindOnlyWorldMatrix(world: Matrix, effectOverride?: Nullable<Effect>): void;
  96653. /**
  96654. * Binds the submesh to this material by preparing the effect and shader to draw
  96655. * @param world defines the world transformation matrix
  96656. * @param mesh defines the mesh containing the submesh
  96657. * @param subMesh defines the submesh to bind the material to
  96658. */
  96659. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  96660. /**
  96661. * Binds the material to the mesh
  96662. * @param world defines the world transformation matrix
  96663. * @param mesh defines the mesh to bind the material to
  96664. * @param effectOverride - If provided, use this effect instead of internal effect
  96665. */
  96666. bind(world: Matrix, mesh?: Mesh, effectOverride?: Nullable<Effect>): void;
  96667. protected _afterBind(mesh?: Mesh): void;
  96668. /**
  96669. * Gets the active textures from the material
  96670. * @returns an array of textures
  96671. */
  96672. getActiveTextures(): BaseTexture[];
  96673. /**
  96674. * Specifies if the material uses a texture
  96675. * @param texture defines the texture to check against the material
  96676. * @returns a boolean specifying if the material uses the texture
  96677. */
  96678. hasTexture(texture: BaseTexture): boolean;
  96679. /**
  96680. * Makes a duplicate of the material, and gives it a new name
  96681. * @param name defines the new name for the duplicated material
  96682. * @returns the cloned material
  96683. */
  96684. clone(name: string): ShaderMaterial;
  96685. /**
  96686. * Disposes the material
  96687. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  96688. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  96689. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  96690. */
  96691. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  96692. /**
  96693. * Serializes this material in a JSON representation
  96694. * @returns the serialized material object
  96695. */
  96696. serialize(): any;
  96697. /**
  96698. * Creates a shader material from parsed shader material data
  96699. * @param source defines the JSON represnetation of the material
  96700. * @param scene defines the hosting scene
  96701. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  96702. * @returns a new material
  96703. */
  96704. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  96705. /**
  96706. * Creates a new ShaderMaterial from a snippet saved in a remote file
  96707. * @param name defines the name of the ShaderMaterial to create (can be null or empty to use the one from the json data)
  96708. * @param url defines the url to load from
  96709. * @param scene defines the hosting scene
  96710. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  96711. * @returns a promise that will resolve to the new ShaderMaterial
  96712. */
  96713. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  96714. /**
  96715. * Creates a ShaderMaterial from a snippet saved by the Inspector
  96716. * @param snippetId defines the snippet to load
  96717. * @param scene defines the hosting scene
  96718. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  96719. * @returns a promise that will resolve to the new ShaderMaterial
  96720. */
  96721. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  96722. }
  96723. }
  96724. declare module BABYLON {
  96725. /** @hidden */
  96726. export var colorPixelShader: {
  96727. name: string;
  96728. shader: string;
  96729. };
  96730. }
  96731. declare module BABYLON {
  96732. /** @hidden */
  96733. export var colorVertexShader: {
  96734. name: string;
  96735. shader: string;
  96736. };
  96737. }
  96738. declare module BABYLON {
  96739. /**
  96740. * Line mesh
  96741. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  96742. */
  96743. export class LinesMesh extends Mesh {
  96744. /**
  96745. * If vertex color should be applied to the mesh
  96746. */
  96747. readonly useVertexColor?: boolean | undefined;
  96748. /**
  96749. * If vertex alpha should be applied to the mesh
  96750. */
  96751. readonly useVertexAlpha?: boolean | undefined;
  96752. /**
  96753. * Color of the line (Default: White)
  96754. */
  96755. color: Color3;
  96756. /**
  96757. * Alpha of the line (Default: 1)
  96758. */
  96759. alpha: number;
  96760. /**
  96761. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  96762. * This margin is expressed in world space coordinates, so its value may vary.
  96763. * Default value is 0.1
  96764. */
  96765. intersectionThreshold: number;
  96766. private _colorShader;
  96767. private color4;
  96768. /**
  96769. * Creates a new LinesMesh
  96770. * @param name defines the name
  96771. * @param scene defines the hosting scene
  96772. * @param parent defines the parent mesh if any
  96773. * @param source defines the optional source LinesMesh used to clone data from
  96774. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  96775. * When false, achieved by calling a clone(), also passing False.
  96776. * This will make creation of children, recursive.
  96777. * @param useVertexColor defines if this LinesMesh supports vertex color
  96778. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  96779. */
  96780. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  96781. /**
  96782. * If vertex color should be applied to the mesh
  96783. */
  96784. useVertexColor?: boolean | undefined,
  96785. /**
  96786. * If vertex alpha should be applied to the mesh
  96787. */
  96788. useVertexAlpha?: boolean | undefined);
  96789. private _addClipPlaneDefine;
  96790. private _removeClipPlaneDefine;
  96791. isReady(): boolean;
  96792. /**
  96793. * Returns the string "LineMesh"
  96794. */
  96795. getClassName(): string;
  96796. /**
  96797. * @hidden
  96798. */
  96799. get material(): Material;
  96800. /**
  96801. * @hidden
  96802. */
  96803. set material(value: Material);
  96804. /**
  96805. * @hidden
  96806. */
  96807. get checkCollisions(): boolean;
  96808. /** @hidden */
  96809. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  96810. /** @hidden */
  96811. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  96812. /**
  96813. * Disposes of the line mesh
  96814. * @param doNotRecurse If children should be disposed
  96815. */
  96816. dispose(doNotRecurse?: boolean): void;
  96817. /**
  96818. * Returns a new LineMesh object cloned from the current one.
  96819. */
  96820. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  96821. /**
  96822. * Creates a new InstancedLinesMesh object from the mesh model.
  96823. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  96824. * @param name defines the name of the new instance
  96825. * @returns a new InstancedLinesMesh
  96826. */
  96827. createInstance(name: string): InstancedLinesMesh;
  96828. }
  96829. /**
  96830. * Creates an instance based on a source LinesMesh
  96831. */
  96832. export class InstancedLinesMesh extends InstancedMesh {
  96833. /**
  96834. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  96835. * This margin is expressed in world space coordinates, so its value may vary.
  96836. * Initilized with the intersectionThreshold value of the source LinesMesh
  96837. */
  96838. intersectionThreshold: number;
  96839. constructor(name: string, source: LinesMesh);
  96840. /**
  96841. * Returns the string "InstancedLinesMesh".
  96842. */
  96843. getClassName(): string;
  96844. }
  96845. }
  96846. declare module BABYLON {
  96847. /** @hidden */
  96848. export var linePixelShader: {
  96849. name: string;
  96850. shader: string;
  96851. };
  96852. }
  96853. declare module BABYLON {
  96854. /** @hidden */
  96855. export var lineVertexShader: {
  96856. name: string;
  96857. shader: string;
  96858. };
  96859. }
  96860. declare module BABYLON {
  96861. interface Scene {
  96862. /** @hidden */
  96863. _edgeRenderLineShader: Nullable<ShaderMaterial>;
  96864. }
  96865. interface AbstractMesh {
  96866. /**
  96867. * Gets the edgesRenderer associated with the mesh
  96868. */
  96869. edgesRenderer: Nullable<EdgesRenderer>;
  96870. }
  96871. interface LinesMesh {
  96872. /**
  96873. * Enables the edge rendering mode on the mesh.
  96874. * This mode makes the mesh edges visible
  96875. * @param epsilon defines the maximal distance between two angles to detect a face
  96876. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  96877. * @returns the currentAbstractMesh
  96878. * @see https://www.babylonjs-playground.com/#19O9TU#0
  96879. */
  96880. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  96881. }
  96882. interface InstancedLinesMesh {
  96883. /**
  96884. * Enables the edge rendering mode on the mesh.
  96885. * This mode makes the mesh edges visible
  96886. * @param epsilon defines the maximal distance between two angles to detect a face
  96887. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  96888. * @returns the current InstancedLinesMesh
  96889. * @see https://www.babylonjs-playground.com/#19O9TU#0
  96890. */
  96891. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  96892. }
  96893. /**
  96894. * Defines the minimum contract an Edges renderer should follow.
  96895. */
  96896. export interface IEdgesRenderer extends IDisposable {
  96897. /**
  96898. * Gets or sets a boolean indicating if the edgesRenderer is active
  96899. */
  96900. isEnabled: boolean;
  96901. /**
  96902. * Renders the edges of the attached mesh,
  96903. */
  96904. render(): void;
  96905. /**
  96906. * Checks wether or not the edges renderer is ready to render.
  96907. * @return true if ready, otherwise false.
  96908. */
  96909. isReady(): boolean;
  96910. /**
  96911. * List of instances to render in case the source mesh has instances
  96912. */
  96913. customInstances: SmartArray<Matrix>;
  96914. }
  96915. /**
  96916. * Defines the additional options of the edges renderer
  96917. */
  96918. export interface IEdgesRendererOptions {
  96919. /**
  96920. * Gets or sets a boolean indicating that the alternate edge finder algorithm must be used
  96921. * If not defined, the default value is true
  96922. */
  96923. useAlternateEdgeFinder?: boolean;
  96924. /**
  96925. * Gets or sets a boolean indicating that the vertex merger fast processing must be used.
  96926. * If not defined, the default value is true.
  96927. * 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)
  96928. * This option is used only if useAlternateEdgeFinder = true
  96929. */
  96930. useFastVertexMerger?: boolean;
  96931. /**
  96932. * During edges processing, the vertices are merged if they are close enough: epsilonVertexMerge is the limit whithin which vertices are considered to be equal.
  96933. * The default value is 1e-6
  96934. * This option is used only if useAlternateEdgeFinder = true
  96935. */
  96936. epsilonVertexMerge?: number;
  96937. /**
  96938. * 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
  96939. * 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.
  96940. * This option is used only if useAlternateEdgeFinder = true
  96941. */
  96942. applyTessellation?: boolean;
  96943. /**
  96944. * 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
  96945. * The default value is 1e-6
  96946. * This option is used only if useAlternateEdgeFinder = true
  96947. */
  96948. epsilonVertexAligned?: number;
  96949. }
  96950. /**
  96951. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  96952. */
  96953. export class EdgesRenderer implements IEdgesRenderer {
  96954. /**
  96955. * Define the size of the edges with an orthographic camera
  96956. */
  96957. edgesWidthScalerForOrthographic: number;
  96958. /**
  96959. * Define the size of the edges with a perspective camera
  96960. */
  96961. edgesWidthScalerForPerspective: number;
  96962. protected _source: AbstractMesh;
  96963. protected _linesPositions: number[];
  96964. protected _linesNormals: number[];
  96965. protected _linesIndices: number[];
  96966. protected _epsilon: number;
  96967. protected _indicesCount: number;
  96968. protected _lineShader: ShaderMaterial;
  96969. protected _ib: DataBuffer;
  96970. protected _buffers: {
  96971. [key: string]: Nullable<VertexBuffer>;
  96972. };
  96973. protected _buffersForInstances: {
  96974. [key: string]: Nullable<VertexBuffer>;
  96975. };
  96976. protected _checkVerticesInsteadOfIndices: boolean;
  96977. protected _options: Nullable<IEdgesRendererOptions>;
  96978. private _meshRebuildObserver;
  96979. private _meshDisposeObserver;
  96980. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  96981. isEnabled: boolean;
  96982. /**
  96983. * List of instances to render in case the source mesh has instances
  96984. */
  96985. customInstances: SmartArray<Matrix>;
  96986. private static GetShader;
  96987. /**
  96988. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  96989. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  96990. * @param source Mesh used to create edges
  96991. * @param epsilon sum of angles in adjacency to check for edge
  96992. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices. Note that this parameter is not used if options.useAlternateEdgeFinder = true
  96993. * @param generateEdgesLines - should generate Lines or only prepare resources.
  96994. * @param options The options to apply when generating the edges
  96995. */
  96996. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean, options?: IEdgesRendererOptions);
  96997. protected _prepareRessources(): void;
  96998. /** @hidden */
  96999. _rebuild(): void;
  97000. /**
  97001. * Releases the required resources for the edges renderer
  97002. */
  97003. dispose(): void;
  97004. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  97005. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  97006. /**
  97007. * Checks if the pair of p0 and p1 is en edge
  97008. * @param faceIndex
  97009. * @param edge
  97010. * @param faceNormals
  97011. * @param p0
  97012. * @param p1
  97013. * @private
  97014. */
  97015. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  97016. /**
  97017. * push line into the position, normal and index buffer
  97018. * @protected
  97019. */
  97020. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  97021. /**
  97022. * See https://playground.babylonjs.com/#R3JR6V#1 for a visual display of the algorithm
  97023. */
  97024. private _tessellateTriangle;
  97025. private _generateEdgesLinesAlternate;
  97026. /**
  97027. * Generates lines edges from adjacencjes
  97028. * @private
  97029. */
  97030. _generateEdgesLines(): void;
  97031. /**
  97032. * Checks wether or not the edges renderer is ready to render.
  97033. * @return true if ready, otherwise false.
  97034. */
  97035. isReady(): boolean;
  97036. /**
  97037. * Renders the edges of the attached mesh,
  97038. */
  97039. render(): void;
  97040. }
  97041. /**
  97042. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  97043. */
  97044. export class LineEdgesRenderer extends EdgesRenderer {
  97045. /**
  97046. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  97047. * @param source LineMesh used to generate edges
  97048. * @param epsilon not important (specified angle for edge detection)
  97049. * @param checkVerticesInsteadOfIndices not important for LineMesh
  97050. */
  97051. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  97052. /**
  97053. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  97054. */
  97055. _generateEdgesLines(): void;
  97056. }
  97057. }
  97058. declare module BABYLON {
  97059. /**
  97060. * This represents the object necessary to create a rendering group.
  97061. * This is exclusively used and created by the rendering manager.
  97062. * To modify the behavior, you use the available helpers in your scene or meshes.
  97063. * @hidden
  97064. */
  97065. export class RenderingGroup {
  97066. index: number;
  97067. private static _zeroVector;
  97068. private _scene;
  97069. private _opaqueSubMeshes;
  97070. private _transparentSubMeshes;
  97071. private _alphaTestSubMeshes;
  97072. private _depthOnlySubMeshes;
  97073. private _particleSystems;
  97074. private _spriteManagers;
  97075. private _opaqueSortCompareFn;
  97076. private _alphaTestSortCompareFn;
  97077. private _transparentSortCompareFn;
  97078. private _renderOpaque;
  97079. private _renderAlphaTest;
  97080. private _renderTransparent;
  97081. /** @hidden */
  97082. _edgesRenderers: SmartArrayNoDuplicate<IEdgesRenderer>;
  97083. onBeforeTransparentRendering: () => void;
  97084. /**
  97085. * Set the opaque sort comparison function.
  97086. * If null the sub meshes will be render in the order they were created
  97087. */
  97088. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  97089. /**
  97090. * Set the alpha test sort comparison function.
  97091. * If null the sub meshes will be render in the order they were created
  97092. */
  97093. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  97094. /**
  97095. * Set the transparent sort comparison function.
  97096. * If null the sub meshes will be render in the order they were created
  97097. */
  97098. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  97099. /**
  97100. * Creates a new rendering group.
  97101. * @param index The rendering group index
  97102. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  97103. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  97104. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  97105. */
  97106. 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>);
  97107. /**
  97108. * Render all the sub meshes contained in the group.
  97109. * @param customRenderFunction Used to override the default render behaviour of the group.
  97110. * @returns true if rendered some submeshes.
  97111. */
  97112. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  97113. /**
  97114. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  97115. * @param subMeshes The submeshes to render
  97116. */
  97117. private renderOpaqueSorted;
  97118. /**
  97119. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  97120. * @param subMeshes The submeshes to render
  97121. */
  97122. private renderAlphaTestSorted;
  97123. /**
  97124. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  97125. * @param subMeshes The submeshes to render
  97126. */
  97127. private renderTransparentSorted;
  97128. /**
  97129. * Renders the submeshes in a specified order.
  97130. * @param subMeshes The submeshes to sort before render
  97131. * @param sortCompareFn The comparison function use to sort
  97132. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  97133. * @param transparent Specifies to activate blending if true
  97134. */
  97135. private static renderSorted;
  97136. /**
  97137. * Renders the submeshes in the order they were dispatched (no sort applied).
  97138. * @param subMeshes The submeshes to render
  97139. */
  97140. private static renderUnsorted;
  97141. /**
  97142. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  97143. * are rendered back to front if in the same alpha index.
  97144. *
  97145. * @param a The first submesh
  97146. * @param b The second submesh
  97147. * @returns The result of the comparison
  97148. */
  97149. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  97150. /**
  97151. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  97152. * are rendered back to front.
  97153. *
  97154. * @param a The first submesh
  97155. * @param b The second submesh
  97156. * @returns The result of the comparison
  97157. */
  97158. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  97159. /**
  97160. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  97161. * are rendered front to back (prevent overdraw).
  97162. *
  97163. * @param a The first submesh
  97164. * @param b The second submesh
  97165. * @returns The result of the comparison
  97166. */
  97167. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  97168. /**
  97169. * Resets the different lists of submeshes to prepare a new frame.
  97170. */
  97171. prepare(): void;
  97172. dispose(): void;
  97173. /**
  97174. * Inserts the submesh in its correct queue depending on its material.
  97175. * @param subMesh The submesh to dispatch
  97176. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  97177. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  97178. */
  97179. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  97180. dispatchSprites(spriteManager: ISpriteManager): void;
  97181. dispatchParticles(particleSystem: IParticleSystem): void;
  97182. private _renderParticles;
  97183. private _renderSprites;
  97184. }
  97185. }
  97186. declare module BABYLON {
  97187. /**
  97188. * Interface describing the different options available in the rendering manager
  97189. * regarding Auto Clear between groups.
  97190. */
  97191. export interface IRenderingManagerAutoClearSetup {
  97192. /**
  97193. * Defines whether or not autoclear is enable.
  97194. */
  97195. autoClear: boolean;
  97196. /**
  97197. * Defines whether or not to autoclear the depth buffer.
  97198. */
  97199. depth: boolean;
  97200. /**
  97201. * Defines whether or not to autoclear the stencil buffer.
  97202. */
  97203. stencil: boolean;
  97204. }
  97205. /**
  97206. * This class is used by the onRenderingGroupObservable
  97207. */
  97208. export class RenderingGroupInfo {
  97209. /**
  97210. * The Scene that being rendered
  97211. */
  97212. scene: Scene;
  97213. /**
  97214. * The camera currently used for the rendering pass
  97215. */
  97216. camera: Nullable<Camera>;
  97217. /**
  97218. * The ID of the renderingGroup being processed
  97219. */
  97220. renderingGroupId: number;
  97221. }
  97222. /**
  97223. * This is the manager responsible of all the rendering for meshes sprites and particles.
  97224. * It is enable to manage the different groups as well as the different necessary sort functions.
  97225. * This should not be used directly aside of the few static configurations
  97226. */
  97227. export class RenderingManager {
  97228. /**
  97229. * The max id used for rendering groups (not included)
  97230. */
  97231. static MAX_RENDERINGGROUPS: number;
  97232. /**
  97233. * The min id used for rendering groups (included)
  97234. */
  97235. static MIN_RENDERINGGROUPS: number;
  97236. /**
  97237. * Used to globally prevent autoclearing scenes.
  97238. */
  97239. static AUTOCLEAR: boolean;
  97240. /**
  97241. * @hidden
  97242. */
  97243. _useSceneAutoClearSetup: boolean;
  97244. private _scene;
  97245. private _renderingGroups;
  97246. private _depthStencilBufferAlreadyCleaned;
  97247. private _autoClearDepthStencil;
  97248. private _customOpaqueSortCompareFn;
  97249. private _customAlphaTestSortCompareFn;
  97250. private _customTransparentSortCompareFn;
  97251. private _renderingGroupInfo;
  97252. /**
  97253. * Instantiates a new rendering group for a particular scene
  97254. * @param scene Defines the scene the groups belongs to
  97255. */
  97256. constructor(scene: Scene);
  97257. private _clearDepthStencilBuffer;
  97258. /**
  97259. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  97260. * @hidden
  97261. */
  97262. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  97263. /**
  97264. * Resets the different information of the group to prepare a new frame
  97265. * @hidden
  97266. */
  97267. reset(): void;
  97268. /**
  97269. * Dispose and release the group and its associated resources.
  97270. * @hidden
  97271. */
  97272. dispose(): void;
  97273. /**
  97274. * Clear the info related to rendering groups preventing retention points during dispose.
  97275. */
  97276. freeRenderingGroups(): void;
  97277. private _prepareRenderingGroup;
  97278. /**
  97279. * Add a sprite manager to the rendering manager in order to render it this frame.
  97280. * @param spriteManager Define the sprite manager to render
  97281. */
  97282. dispatchSprites(spriteManager: ISpriteManager): void;
  97283. /**
  97284. * Add a particle system to the rendering manager in order to render it this frame.
  97285. * @param particleSystem Define the particle system to render
  97286. */
  97287. dispatchParticles(particleSystem: IParticleSystem): void;
  97288. /**
  97289. * Add a submesh to the manager in order to render it this frame
  97290. * @param subMesh The submesh to dispatch
  97291. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  97292. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  97293. */
  97294. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  97295. /**
  97296. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  97297. * This allowed control for front to back rendering or reversly depending of the special needs.
  97298. *
  97299. * @param renderingGroupId The rendering group id corresponding to its index
  97300. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  97301. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  97302. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  97303. */
  97304. 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;
  97305. /**
  97306. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  97307. *
  97308. * @param renderingGroupId The rendering group id corresponding to its index
  97309. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  97310. * @param depth Automatically clears depth between groups if true and autoClear is true.
  97311. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  97312. */
  97313. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  97314. /**
  97315. * Gets the current auto clear configuration for one rendering group of the rendering
  97316. * manager.
  97317. * @param index the rendering group index to get the information for
  97318. * @returns The auto clear setup for the requested rendering group
  97319. */
  97320. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  97321. }
  97322. }
  97323. declare module BABYLON {
  97324. /**
  97325. * Defines the options associated with the creation of a custom shader for a shadow generator.
  97326. */
  97327. export interface ICustomShaderOptions {
  97328. /**
  97329. * Gets or sets the custom shader name to use
  97330. */
  97331. shaderName: string;
  97332. /**
  97333. * The list of attribute names used in the shader
  97334. */
  97335. attributes?: string[];
  97336. /**
  97337. * The list of unifrom names used in the shader
  97338. */
  97339. uniforms?: string[];
  97340. /**
  97341. * The list of sampler names used in the shader
  97342. */
  97343. samplers?: string[];
  97344. /**
  97345. * The list of defines used in the shader
  97346. */
  97347. defines?: string[];
  97348. }
  97349. /**
  97350. * Interface to implement to create a shadow generator compatible with BJS.
  97351. */
  97352. export interface IShadowGenerator {
  97353. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  97354. id: string;
  97355. /**
  97356. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  97357. * @returns The render target texture if present otherwise, null
  97358. */
  97359. getShadowMap(): Nullable<RenderTargetTexture>;
  97360. /**
  97361. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  97362. * @param subMesh The submesh we want to render in the shadow map
  97363. * @param useInstances Defines wether will draw in the map using instances
  97364. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  97365. * @returns true if ready otherwise, false
  97366. */
  97367. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  97368. /**
  97369. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  97370. * @param defines Defines of the material we want to update
  97371. * @param lightIndex Index of the light in the enabled light list of the material
  97372. */
  97373. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  97374. /**
  97375. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  97376. * defined in the generator but impacting the effect).
  97377. * It implies the unifroms available on the materials are the standard BJS ones.
  97378. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  97379. * @param effect The effect we are binfing the information for
  97380. */
  97381. bindShadowLight(lightIndex: string, effect: Effect): void;
  97382. /**
  97383. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  97384. * (eq to shadow prjection matrix * light transform matrix)
  97385. * @returns The transform matrix used to create the shadow map
  97386. */
  97387. getTransformMatrix(): Matrix;
  97388. /**
  97389. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  97390. * Cube and 2D textures for instance.
  97391. */
  97392. recreateShadowMap(): void;
  97393. /**
  97394. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  97395. * @param onCompiled Callback triggered at the and of the effects compilation
  97396. * @param options Sets of optional options forcing the compilation with different modes
  97397. */
  97398. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  97399. useInstances: boolean;
  97400. }>): void;
  97401. /**
  97402. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  97403. * @param options Sets of optional options forcing the compilation with different modes
  97404. * @returns A promise that resolves when the compilation completes
  97405. */
  97406. forceCompilationAsync(options?: Partial<{
  97407. useInstances: boolean;
  97408. }>): Promise<void>;
  97409. /**
  97410. * Serializes the shadow generator setup to a json object.
  97411. * @returns The serialized JSON object
  97412. */
  97413. serialize(): any;
  97414. /**
  97415. * Disposes the Shadow map and related Textures and effects.
  97416. */
  97417. dispose(): void;
  97418. }
  97419. /**
  97420. * Default implementation IShadowGenerator.
  97421. * This is the main object responsible of generating shadows in the framework.
  97422. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  97423. */
  97424. export class ShadowGenerator implements IShadowGenerator {
  97425. /**
  97426. * Name of the shadow generator class
  97427. */
  97428. static CLASSNAME: string;
  97429. /**
  97430. * Shadow generator mode None: no filtering applied.
  97431. */
  97432. static readonly FILTER_NONE: number;
  97433. /**
  97434. * Shadow generator mode ESM: Exponential Shadow Mapping.
  97435. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  97436. */
  97437. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  97438. /**
  97439. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  97440. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  97441. */
  97442. static readonly FILTER_POISSONSAMPLING: number;
  97443. /**
  97444. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  97445. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  97446. */
  97447. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  97448. /**
  97449. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  97450. * edge artifacts on steep falloff.
  97451. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  97452. */
  97453. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  97454. /**
  97455. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  97456. * edge artifacts on steep falloff.
  97457. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  97458. */
  97459. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  97460. /**
  97461. * Shadow generator mode PCF: Percentage Closer Filtering
  97462. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  97463. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  97464. */
  97465. static readonly FILTER_PCF: number;
  97466. /**
  97467. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  97468. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  97469. * Contact Hardening
  97470. */
  97471. static readonly FILTER_PCSS: number;
  97472. /**
  97473. * Reserved for PCF and PCSS
  97474. * Highest Quality.
  97475. *
  97476. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  97477. *
  97478. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  97479. */
  97480. static readonly QUALITY_HIGH: number;
  97481. /**
  97482. * Reserved for PCF and PCSS
  97483. * Good tradeoff for quality/perf cross devices
  97484. *
  97485. * Execute PCF on a 3*3 kernel.
  97486. *
  97487. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  97488. */
  97489. static readonly QUALITY_MEDIUM: number;
  97490. /**
  97491. * Reserved for PCF and PCSS
  97492. * The lowest quality but the fastest.
  97493. *
  97494. * Execute PCF on a 1*1 kernel.
  97495. *
  97496. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  97497. */
  97498. static readonly QUALITY_LOW: number;
  97499. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  97500. id: string;
  97501. /** Gets or sets the custom shader name to use */
  97502. customShaderOptions: ICustomShaderOptions;
  97503. /**
  97504. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  97505. */
  97506. onBeforeShadowMapRenderObservable: Observable<Effect>;
  97507. /**
  97508. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  97509. */
  97510. onAfterShadowMapRenderObservable: Observable<Effect>;
  97511. /**
  97512. * Observable triggered before a mesh is rendered in the shadow map.
  97513. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  97514. */
  97515. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  97516. /**
  97517. * Observable triggered after a mesh is rendered in the shadow map.
  97518. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  97519. */
  97520. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  97521. protected _bias: number;
  97522. /**
  97523. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  97524. */
  97525. get bias(): number;
  97526. /**
  97527. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  97528. */
  97529. set bias(bias: number);
  97530. protected _normalBias: number;
  97531. /**
  97532. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  97533. */
  97534. get normalBias(): number;
  97535. /**
  97536. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  97537. */
  97538. set normalBias(normalBias: number);
  97539. protected _blurBoxOffset: number;
  97540. /**
  97541. * Gets the blur box offset: offset applied during the blur pass.
  97542. * Only useful if useKernelBlur = false
  97543. */
  97544. get blurBoxOffset(): number;
  97545. /**
  97546. * Sets the blur box offset: offset applied during the blur pass.
  97547. * Only useful if useKernelBlur = false
  97548. */
  97549. set blurBoxOffset(value: number);
  97550. protected _blurScale: number;
  97551. /**
  97552. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  97553. * 2 means half of the size.
  97554. */
  97555. get blurScale(): number;
  97556. /**
  97557. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  97558. * 2 means half of the size.
  97559. */
  97560. set blurScale(value: number);
  97561. protected _blurKernel: number;
  97562. /**
  97563. * Gets the blur kernel: kernel size of the blur pass.
  97564. * Only useful if useKernelBlur = true
  97565. */
  97566. get blurKernel(): number;
  97567. /**
  97568. * Sets the blur kernel: kernel size of the blur pass.
  97569. * Only useful if useKernelBlur = true
  97570. */
  97571. set blurKernel(value: number);
  97572. protected _useKernelBlur: boolean;
  97573. /**
  97574. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  97575. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  97576. */
  97577. get useKernelBlur(): boolean;
  97578. /**
  97579. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  97580. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  97581. */
  97582. set useKernelBlur(value: boolean);
  97583. protected _depthScale: number;
  97584. /**
  97585. * Gets the depth scale used in ESM mode.
  97586. */
  97587. get depthScale(): number;
  97588. /**
  97589. * Sets the depth scale used in ESM mode.
  97590. * This can override the scale stored on the light.
  97591. */
  97592. set depthScale(value: number);
  97593. protected _validateFilter(filter: number): number;
  97594. protected _filter: number;
  97595. /**
  97596. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  97597. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  97598. */
  97599. get filter(): number;
  97600. /**
  97601. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  97602. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  97603. */
  97604. set filter(value: number);
  97605. /**
  97606. * Gets if the current filter is set to Poisson Sampling.
  97607. */
  97608. get usePoissonSampling(): boolean;
  97609. /**
  97610. * Sets the current filter to Poisson Sampling.
  97611. */
  97612. set usePoissonSampling(value: boolean);
  97613. /**
  97614. * Gets if the current filter is set to ESM.
  97615. */
  97616. get useExponentialShadowMap(): boolean;
  97617. /**
  97618. * Sets the current filter is to ESM.
  97619. */
  97620. set useExponentialShadowMap(value: boolean);
  97621. /**
  97622. * Gets if the current filter is set to filtered ESM.
  97623. */
  97624. get useBlurExponentialShadowMap(): boolean;
  97625. /**
  97626. * Gets if the current filter is set to filtered ESM.
  97627. */
  97628. set useBlurExponentialShadowMap(value: boolean);
  97629. /**
  97630. * Gets if the current filter is set to "close ESM" (using the inverse of the
  97631. * exponential to prevent steep falloff artifacts).
  97632. */
  97633. get useCloseExponentialShadowMap(): boolean;
  97634. /**
  97635. * Sets the current filter to "close ESM" (using the inverse of the
  97636. * exponential to prevent steep falloff artifacts).
  97637. */
  97638. set useCloseExponentialShadowMap(value: boolean);
  97639. /**
  97640. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  97641. * exponential to prevent steep falloff artifacts).
  97642. */
  97643. get useBlurCloseExponentialShadowMap(): boolean;
  97644. /**
  97645. * Sets the current filter to filtered "close ESM" (using the inverse of the
  97646. * exponential to prevent steep falloff artifacts).
  97647. */
  97648. set useBlurCloseExponentialShadowMap(value: boolean);
  97649. /**
  97650. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  97651. */
  97652. get usePercentageCloserFiltering(): boolean;
  97653. /**
  97654. * Sets the current filter to "PCF" (percentage closer filtering).
  97655. */
  97656. set usePercentageCloserFiltering(value: boolean);
  97657. protected _filteringQuality: number;
  97658. /**
  97659. * Gets the PCF or PCSS Quality.
  97660. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  97661. */
  97662. get filteringQuality(): number;
  97663. /**
  97664. * Sets the PCF or PCSS Quality.
  97665. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  97666. */
  97667. set filteringQuality(filteringQuality: number);
  97668. /**
  97669. * Gets if the current filter is set to "PCSS" (contact hardening).
  97670. */
  97671. get useContactHardeningShadow(): boolean;
  97672. /**
  97673. * Sets the current filter to "PCSS" (contact hardening).
  97674. */
  97675. set useContactHardeningShadow(value: boolean);
  97676. protected _contactHardeningLightSizeUVRatio: number;
  97677. /**
  97678. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  97679. * Using a ratio helps keeping shape stability independently of the map size.
  97680. *
  97681. * It does not account for the light projection as it was having too much
  97682. * instability during the light setup or during light position changes.
  97683. *
  97684. * Only valid if useContactHardeningShadow is true.
  97685. */
  97686. get contactHardeningLightSizeUVRatio(): number;
  97687. /**
  97688. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  97689. * Using a ratio helps keeping shape stability independently of the map size.
  97690. *
  97691. * It does not account for the light projection as it was having too much
  97692. * instability during the light setup or during light position changes.
  97693. *
  97694. * Only valid if useContactHardeningShadow is true.
  97695. */
  97696. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  97697. protected _darkness: number;
  97698. /** Gets or sets the actual darkness of a shadow */
  97699. get darkness(): number;
  97700. set darkness(value: number);
  97701. /**
  97702. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  97703. * 0 means strongest and 1 would means no shadow.
  97704. * @returns the darkness.
  97705. */
  97706. getDarkness(): number;
  97707. /**
  97708. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  97709. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  97710. * @returns the shadow generator allowing fluent coding.
  97711. */
  97712. setDarkness(darkness: number): ShadowGenerator;
  97713. protected _transparencyShadow: boolean;
  97714. /** Gets or sets the ability to have transparent shadow */
  97715. get transparencyShadow(): boolean;
  97716. set transparencyShadow(value: boolean);
  97717. /**
  97718. * Sets the ability to have transparent shadow (boolean).
  97719. * @param transparent True if transparent else False
  97720. * @returns the shadow generator allowing fluent coding
  97721. */
  97722. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  97723. /**
  97724. * Enables or disables shadows with varying strength based on the transparency
  97725. * When it is enabled, the strength of the shadow is taken equal to mesh.visibility
  97726. * If you enabled an alpha texture on your material, the alpha value red from the texture is also combined to compute the strength:
  97727. * mesh.visibility * alphaTexture.a
  97728. * Note that by definition transparencyShadow must be set to true for enableSoftTransparentShadow to work!
  97729. */
  97730. enableSoftTransparentShadow: boolean;
  97731. protected _shadowMap: Nullable<RenderTargetTexture>;
  97732. protected _shadowMap2: Nullable<RenderTargetTexture>;
  97733. /**
  97734. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  97735. * @returns The render target texture if present otherwise, null
  97736. */
  97737. getShadowMap(): Nullable<RenderTargetTexture>;
  97738. /**
  97739. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  97740. * @returns The render target texture if the shadow map is present otherwise, null
  97741. */
  97742. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  97743. /**
  97744. * Gets the class name of that object
  97745. * @returns "ShadowGenerator"
  97746. */
  97747. getClassName(): string;
  97748. /**
  97749. * Helper function to add a mesh and its descendants to the list of shadow casters.
  97750. * @param mesh Mesh to add
  97751. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  97752. * @returns the Shadow Generator itself
  97753. */
  97754. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  97755. /**
  97756. * Helper function to remove a mesh and its descendants from the list of shadow casters
  97757. * @param mesh Mesh to remove
  97758. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  97759. * @returns the Shadow Generator itself
  97760. */
  97761. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  97762. /**
  97763. * Controls the extent to which the shadows fade out at the edge of the frustum
  97764. */
  97765. frustumEdgeFalloff: number;
  97766. protected _light: IShadowLight;
  97767. /**
  97768. * Returns the associated light object.
  97769. * @returns the light generating the shadow
  97770. */
  97771. getLight(): IShadowLight;
  97772. /**
  97773. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  97774. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  97775. * It might on the other hand introduce peter panning.
  97776. */
  97777. forceBackFacesOnly: boolean;
  97778. protected _scene: Scene;
  97779. protected _lightDirection: Vector3;
  97780. protected _effect: Effect;
  97781. protected _viewMatrix: Matrix;
  97782. protected _projectionMatrix: Matrix;
  97783. protected _transformMatrix: Matrix;
  97784. protected _cachedPosition: Vector3;
  97785. protected _cachedDirection: Vector3;
  97786. protected _cachedDefines: string;
  97787. protected _currentRenderID: number;
  97788. protected _boxBlurPostprocess: Nullable<PostProcess>;
  97789. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  97790. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  97791. protected _blurPostProcesses: PostProcess[];
  97792. protected _mapSize: number;
  97793. protected _currentFaceIndex: number;
  97794. protected _currentFaceIndexCache: number;
  97795. protected _textureType: number;
  97796. protected _defaultTextureMatrix: Matrix;
  97797. protected _storedUniqueId: Nullable<number>;
  97798. /** @hidden */
  97799. static _SceneComponentInitialization: (scene: Scene) => void;
  97800. /**
  97801. * Creates a ShadowGenerator object.
  97802. * A ShadowGenerator is the required tool to use the shadows.
  97803. * Each light casting shadows needs to use its own ShadowGenerator.
  97804. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  97805. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  97806. * @param light The light object generating the shadows.
  97807. * @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.
  97808. */
  97809. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  97810. protected _initializeGenerator(): void;
  97811. protected _createTargetRenderTexture(): void;
  97812. protected _initializeShadowMap(): void;
  97813. protected _initializeBlurRTTAndPostProcesses(): void;
  97814. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  97815. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  97816. protected _renderSubMeshForShadowMap(subMesh: SubMesh, isTransparent?: boolean): void;
  97817. protected _applyFilterValues(): void;
  97818. /**
  97819. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  97820. * @param onCompiled Callback triggered at the and of the effects compilation
  97821. * @param options Sets of optional options forcing the compilation with different modes
  97822. */
  97823. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  97824. useInstances: boolean;
  97825. }>): void;
  97826. /**
  97827. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  97828. * @param options Sets of optional options forcing the compilation with different modes
  97829. * @returns A promise that resolves when the compilation completes
  97830. */
  97831. forceCompilationAsync(options?: Partial<{
  97832. useInstances: boolean;
  97833. }>): Promise<void>;
  97834. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  97835. private _prepareShadowDefines;
  97836. /**
  97837. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  97838. * @param subMesh The submesh we want to render in the shadow map
  97839. * @param useInstances Defines wether will draw in the map using instances
  97840. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  97841. * @returns true if ready otherwise, false
  97842. */
  97843. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  97844. /**
  97845. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  97846. * @param defines Defines of the material we want to update
  97847. * @param lightIndex Index of the light in the enabled light list of the material
  97848. */
  97849. prepareDefines(defines: any, lightIndex: number): void;
  97850. /**
  97851. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  97852. * defined in the generator but impacting the effect).
  97853. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  97854. * @param effect The effect we are binfing the information for
  97855. */
  97856. bindShadowLight(lightIndex: string, effect: Effect): void;
  97857. /**
  97858. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  97859. * (eq to shadow prjection matrix * light transform matrix)
  97860. * @returns The transform matrix used to create the shadow map
  97861. */
  97862. getTransformMatrix(): Matrix;
  97863. /**
  97864. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  97865. * Cube and 2D textures for instance.
  97866. */
  97867. recreateShadowMap(): void;
  97868. protected _disposeBlurPostProcesses(): void;
  97869. protected _disposeRTTandPostProcesses(): void;
  97870. /**
  97871. * Disposes the ShadowGenerator.
  97872. * Returns nothing.
  97873. */
  97874. dispose(): void;
  97875. /**
  97876. * Serializes the shadow generator setup to a json object.
  97877. * @returns The serialized JSON object
  97878. */
  97879. serialize(): any;
  97880. /**
  97881. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  97882. * @param parsedShadowGenerator The JSON object to parse
  97883. * @param scene The scene to create the shadow map for
  97884. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  97885. * @returns The parsed shadow generator
  97886. */
  97887. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  97888. }
  97889. }
  97890. declare module BABYLON {
  97891. /**
  97892. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  97893. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  97894. * 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.
  97895. */
  97896. export abstract class Light extends Node {
  97897. /**
  97898. * Falloff Default: light is falling off following the material specification:
  97899. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  97900. */
  97901. static readonly FALLOFF_DEFAULT: number;
  97902. /**
  97903. * Falloff Physical: light is falling off following the inverse squared distance law.
  97904. */
  97905. static readonly FALLOFF_PHYSICAL: number;
  97906. /**
  97907. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  97908. * to enhance interoperability with other engines.
  97909. */
  97910. static readonly FALLOFF_GLTF: number;
  97911. /**
  97912. * Falloff Standard: light is falling off like in the standard material
  97913. * to enhance interoperability with other materials.
  97914. */
  97915. static readonly FALLOFF_STANDARD: number;
  97916. /**
  97917. * If every light affecting the material is in this lightmapMode,
  97918. * material.lightmapTexture adds or multiplies
  97919. * (depends on material.useLightmapAsShadowmap)
  97920. * after every other light calculations.
  97921. */
  97922. static readonly LIGHTMAP_DEFAULT: number;
  97923. /**
  97924. * material.lightmapTexture as only diffuse lighting from this light
  97925. * adds only specular lighting from this light
  97926. * adds dynamic shadows
  97927. */
  97928. static readonly LIGHTMAP_SPECULAR: number;
  97929. /**
  97930. * material.lightmapTexture as only lighting
  97931. * no light calculation from this light
  97932. * only adds dynamic shadows from this light
  97933. */
  97934. static readonly LIGHTMAP_SHADOWSONLY: number;
  97935. /**
  97936. * Each light type uses the default quantity according to its type:
  97937. * point/spot lights use luminous intensity
  97938. * directional lights use illuminance
  97939. */
  97940. static readonly INTENSITYMODE_AUTOMATIC: number;
  97941. /**
  97942. * lumen (lm)
  97943. */
  97944. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  97945. /**
  97946. * candela (lm/sr)
  97947. */
  97948. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  97949. /**
  97950. * lux (lm/m^2)
  97951. */
  97952. static readonly INTENSITYMODE_ILLUMINANCE: number;
  97953. /**
  97954. * nit (cd/m^2)
  97955. */
  97956. static readonly INTENSITYMODE_LUMINANCE: number;
  97957. /**
  97958. * Light type const id of the point light.
  97959. */
  97960. static readonly LIGHTTYPEID_POINTLIGHT: number;
  97961. /**
  97962. * Light type const id of the directional light.
  97963. */
  97964. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  97965. /**
  97966. * Light type const id of the spot light.
  97967. */
  97968. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  97969. /**
  97970. * Light type const id of the hemispheric light.
  97971. */
  97972. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  97973. /**
  97974. * Diffuse gives the basic color to an object.
  97975. */
  97976. diffuse: Color3;
  97977. /**
  97978. * Specular produces a highlight color on an object.
  97979. * Note: This is note affecting PBR materials.
  97980. */
  97981. specular: Color3;
  97982. /**
  97983. * Defines the falloff type for this light. This lets overrriding how punctual light are
  97984. * falling off base on range or angle.
  97985. * This can be set to any values in Light.FALLOFF_x.
  97986. *
  97987. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  97988. * other types of materials.
  97989. */
  97990. falloffType: number;
  97991. /**
  97992. * Strength of the light.
  97993. * Note: By default it is define in the framework own unit.
  97994. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  97995. */
  97996. intensity: number;
  97997. private _range;
  97998. protected _inverseSquaredRange: number;
  97999. /**
  98000. * Defines how far from the source the light is impacting in scene units.
  98001. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  98002. */
  98003. get range(): number;
  98004. /**
  98005. * Defines how far from the source the light is impacting in scene units.
  98006. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  98007. */
  98008. set range(value: number);
  98009. /**
  98010. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  98011. * of light.
  98012. */
  98013. private _photometricScale;
  98014. private _intensityMode;
  98015. /**
  98016. * Gets the photometric scale used to interpret the intensity.
  98017. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  98018. */
  98019. get intensityMode(): number;
  98020. /**
  98021. * Sets the photometric scale used to interpret the intensity.
  98022. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  98023. */
  98024. set intensityMode(value: number);
  98025. private _radius;
  98026. /**
  98027. * Gets the light radius used by PBR Materials to simulate soft area lights.
  98028. */
  98029. get radius(): number;
  98030. /**
  98031. * sets the light radius used by PBR Materials to simulate soft area lights.
  98032. */
  98033. set radius(value: number);
  98034. private _renderPriority;
  98035. /**
  98036. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  98037. * exceeding the number allowed of the materials.
  98038. */
  98039. renderPriority: number;
  98040. private _shadowEnabled;
  98041. /**
  98042. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  98043. * the current shadow generator.
  98044. */
  98045. get shadowEnabled(): boolean;
  98046. /**
  98047. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  98048. * the current shadow generator.
  98049. */
  98050. set shadowEnabled(value: boolean);
  98051. private _includedOnlyMeshes;
  98052. /**
  98053. * Gets the only meshes impacted by this light.
  98054. */
  98055. get includedOnlyMeshes(): AbstractMesh[];
  98056. /**
  98057. * Sets the only meshes impacted by this light.
  98058. */
  98059. set includedOnlyMeshes(value: AbstractMesh[]);
  98060. private _excludedMeshes;
  98061. /**
  98062. * Gets the meshes not impacted by this light.
  98063. */
  98064. get excludedMeshes(): AbstractMesh[];
  98065. /**
  98066. * Sets the meshes not impacted by this light.
  98067. */
  98068. set excludedMeshes(value: AbstractMesh[]);
  98069. private _excludeWithLayerMask;
  98070. /**
  98071. * Gets the layer id use to find what meshes are not impacted by the light.
  98072. * Inactive if 0
  98073. */
  98074. get excludeWithLayerMask(): number;
  98075. /**
  98076. * Sets the layer id use to find what meshes are not impacted by the light.
  98077. * Inactive if 0
  98078. */
  98079. set excludeWithLayerMask(value: number);
  98080. private _includeOnlyWithLayerMask;
  98081. /**
  98082. * Gets the layer id use to find what meshes are impacted by the light.
  98083. * Inactive if 0
  98084. */
  98085. get includeOnlyWithLayerMask(): number;
  98086. /**
  98087. * Sets the layer id use to find what meshes are impacted by the light.
  98088. * Inactive if 0
  98089. */
  98090. set includeOnlyWithLayerMask(value: number);
  98091. private _lightmapMode;
  98092. /**
  98093. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  98094. */
  98095. get lightmapMode(): number;
  98096. /**
  98097. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  98098. */
  98099. set lightmapMode(value: number);
  98100. /**
  98101. * Shadow generator associted to the light.
  98102. * @hidden Internal use only.
  98103. */
  98104. _shadowGenerator: Nullable<IShadowGenerator>;
  98105. /**
  98106. * @hidden Internal use only.
  98107. */
  98108. _excludedMeshesIds: string[];
  98109. /**
  98110. * @hidden Internal use only.
  98111. */
  98112. _includedOnlyMeshesIds: string[];
  98113. /**
  98114. * The current light unifom buffer.
  98115. * @hidden Internal use only.
  98116. */
  98117. _uniformBuffer: UniformBuffer;
  98118. /** @hidden */
  98119. _renderId: number;
  98120. /**
  98121. * Creates a Light object in the scene.
  98122. * Documentation : https://doc.babylonjs.com/babylon101/lights
  98123. * @param name The firendly name of the light
  98124. * @param scene The scene the light belongs too
  98125. */
  98126. constructor(name: string, scene: Scene);
  98127. protected abstract _buildUniformLayout(): void;
  98128. /**
  98129. * Sets the passed Effect "effect" with the Light information.
  98130. * @param effect The effect to update
  98131. * @param lightIndex The index of the light in the effect to update
  98132. * @returns The light
  98133. */
  98134. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  98135. /**
  98136. * Sets the passed Effect "effect" with the Light textures.
  98137. * @param effect The effect to update
  98138. * @param lightIndex The index of the light in the effect to update
  98139. * @returns The light
  98140. */
  98141. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  98142. /**
  98143. * Binds the lights information from the scene to the effect for the given mesh.
  98144. * @param lightIndex Light index
  98145. * @param scene The scene where the light belongs to
  98146. * @param effect The effect we are binding the data to
  98147. * @param useSpecular Defines if specular is supported
  98148. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  98149. */
  98150. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  98151. /**
  98152. * Sets the passed Effect "effect" with the Light information.
  98153. * @param effect The effect to update
  98154. * @param lightDataUniformName The uniform used to store light data (position or direction)
  98155. * @returns The light
  98156. */
  98157. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  98158. /**
  98159. * Returns the string "Light".
  98160. * @returns the class name
  98161. */
  98162. getClassName(): string;
  98163. /** @hidden */
  98164. readonly _isLight: boolean;
  98165. /**
  98166. * Converts the light information to a readable string for debug purpose.
  98167. * @param fullDetails Supports for multiple levels of logging within scene loading
  98168. * @returns the human readable light info
  98169. */
  98170. toString(fullDetails?: boolean): string;
  98171. /** @hidden */
  98172. protected _syncParentEnabledState(): void;
  98173. /**
  98174. * Set the enabled state of this node.
  98175. * @param value - the new enabled state
  98176. */
  98177. setEnabled(value: boolean): void;
  98178. /**
  98179. * Returns the Light associated shadow generator if any.
  98180. * @return the associated shadow generator.
  98181. */
  98182. getShadowGenerator(): Nullable<IShadowGenerator>;
  98183. /**
  98184. * Returns a Vector3, the absolute light position in the World.
  98185. * @returns the world space position of the light
  98186. */
  98187. getAbsolutePosition(): Vector3;
  98188. /**
  98189. * Specifies if the light will affect the passed mesh.
  98190. * @param mesh The mesh to test against the light
  98191. * @return true the mesh is affected otherwise, false.
  98192. */
  98193. canAffectMesh(mesh: AbstractMesh): boolean;
  98194. /**
  98195. * Sort function to order lights for rendering.
  98196. * @param a First Light object to compare to second.
  98197. * @param b Second Light object to compare first.
  98198. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  98199. */
  98200. static CompareLightsPriority(a: Light, b: Light): number;
  98201. /**
  98202. * Releases resources associated with this node.
  98203. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  98204. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  98205. */
  98206. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  98207. /**
  98208. * Returns the light type ID (integer).
  98209. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  98210. */
  98211. getTypeID(): number;
  98212. /**
  98213. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  98214. * @returns the scaled intensity in intensity mode unit
  98215. */
  98216. getScaledIntensity(): number;
  98217. /**
  98218. * Returns a new Light object, named "name", from the current one.
  98219. * @param name The name of the cloned light
  98220. * @param newParent The parent of this light, if it has one
  98221. * @returns the new created light
  98222. */
  98223. clone(name: string, newParent?: Nullable<Node>): Nullable<Light>;
  98224. /**
  98225. * Serializes the current light into a Serialization object.
  98226. * @returns the serialized object.
  98227. */
  98228. serialize(): any;
  98229. /**
  98230. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  98231. * This new light is named "name" and added to the passed scene.
  98232. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  98233. * @param name The friendly name of the light
  98234. * @param scene The scene the new light will belong to
  98235. * @returns the constructor function
  98236. */
  98237. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  98238. /**
  98239. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  98240. * @param parsedLight The JSON representation of the light
  98241. * @param scene The scene to create the parsed light in
  98242. * @returns the created light after parsing
  98243. */
  98244. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  98245. private _hookArrayForExcluded;
  98246. private _hookArrayForIncludedOnly;
  98247. private _resyncMeshes;
  98248. /**
  98249. * Forces the meshes to update their light related information in their rendering used effects
  98250. * @hidden Internal Use Only
  98251. */
  98252. _markMeshesAsLightDirty(): void;
  98253. /**
  98254. * Recomputes the cached photometric scale if needed.
  98255. */
  98256. private _computePhotometricScale;
  98257. /**
  98258. * Returns the Photometric Scale according to the light type and intensity mode.
  98259. */
  98260. private _getPhotometricScale;
  98261. /**
  98262. * Reorder the light in the scene according to their defined priority.
  98263. * @hidden Internal Use Only
  98264. */
  98265. _reorderLightsInScene(): void;
  98266. /**
  98267. * Prepares the list of defines specific to the light type.
  98268. * @param defines the list of defines
  98269. * @param lightIndex defines the index of the light for the effect
  98270. */
  98271. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  98272. }
  98273. }
  98274. declare module BABYLON {
  98275. /**
  98276. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  98277. * This is the base of the follow, arc rotate cameras and Free camera
  98278. * @see https://doc.babylonjs.com/features/cameras
  98279. */
  98280. export class TargetCamera extends Camera {
  98281. private static _RigCamTransformMatrix;
  98282. private static _TargetTransformMatrix;
  98283. private static _TargetFocalPoint;
  98284. private _tmpUpVector;
  98285. private _tmpTargetVector;
  98286. /**
  98287. * Define the current direction the camera is moving to
  98288. */
  98289. cameraDirection: Vector3;
  98290. /**
  98291. * Define the current rotation the camera is rotating to
  98292. */
  98293. cameraRotation: Vector2;
  98294. /** Gets or sets a boolean indicating that the scaling of the parent hierarchy will not be taken in account by the camera */
  98295. ignoreParentScaling: boolean;
  98296. /**
  98297. * When set, the up vector of the camera will be updated by the rotation of the camera
  98298. */
  98299. updateUpVectorFromRotation: boolean;
  98300. private _tmpQuaternion;
  98301. /**
  98302. * Define the current rotation of the camera
  98303. */
  98304. rotation: Vector3;
  98305. /**
  98306. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  98307. */
  98308. rotationQuaternion: Quaternion;
  98309. /**
  98310. * Define the current speed of the camera
  98311. */
  98312. speed: number;
  98313. /**
  98314. * Add constraint to the camera to prevent it to move freely in all directions and
  98315. * around all axis.
  98316. */
  98317. noRotationConstraint: boolean;
  98318. /**
  98319. * Reverses mouselook direction to 'natural' panning as opposed to traditional direct
  98320. * panning
  98321. */
  98322. invertRotation: boolean;
  98323. /**
  98324. * Speed multiplier for inverse camera panning
  98325. */
  98326. inverseRotationSpeed: number;
  98327. /**
  98328. * Define the current target of the camera as an object or a position.
  98329. */
  98330. lockedTarget: any;
  98331. /** @hidden */
  98332. _currentTarget: Vector3;
  98333. /** @hidden */
  98334. _initialFocalDistance: number;
  98335. /** @hidden */
  98336. _viewMatrix: Matrix;
  98337. /** @hidden */
  98338. _camMatrix: Matrix;
  98339. /** @hidden */
  98340. _cameraTransformMatrix: Matrix;
  98341. /** @hidden */
  98342. _cameraRotationMatrix: Matrix;
  98343. /** @hidden */
  98344. _referencePoint: Vector3;
  98345. /** @hidden */
  98346. _transformedReferencePoint: Vector3;
  98347. /** @hidden */
  98348. _reset: () => void;
  98349. private _defaultUp;
  98350. /**
  98351. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  98352. * This is the base of the follow, arc rotate cameras and Free camera
  98353. * @see https://doc.babylonjs.com/features/cameras
  98354. * @param name Defines the name of the camera in the scene
  98355. * @param position Defines the start position of the camera in the scene
  98356. * @param scene Defines the scene the camera belongs to
  98357. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  98358. */
  98359. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  98360. /**
  98361. * Gets the position in front of the camera at a given distance.
  98362. * @param distance The distance from the camera we want the position to be
  98363. * @returns the position
  98364. */
  98365. getFrontPosition(distance: number): Vector3;
  98366. /** @hidden */
  98367. _getLockedTargetPosition(): Nullable<Vector3>;
  98368. private _storedPosition;
  98369. private _storedRotation;
  98370. private _storedRotationQuaternion;
  98371. /**
  98372. * Store current camera state of the camera (fov, position, rotation, etc..)
  98373. * @returns the camera
  98374. */
  98375. storeState(): Camera;
  98376. /**
  98377. * Restored camera state. You must call storeState() first
  98378. * @returns whether it was successful or not
  98379. * @hidden
  98380. */
  98381. _restoreStateValues(): boolean;
  98382. /** @hidden */
  98383. _initCache(): void;
  98384. /** @hidden */
  98385. _updateCache(ignoreParentClass?: boolean): void;
  98386. /** @hidden */
  98387. _isSynchronizedViewMatrix(): boolean;
  98388. /** @hidden */
  98389. _computeLocalCameraSpeed(): number;
  98390. /**
  98391. * Defines the target the camera should look at.
  98392. * @param target Defines the new target as a Vector or a mesh
  98393. */
  98394. setTarget(target: Vector3): void;
  98395. /**
  98396. * Defines the target point of the camera.
  98397. * The camera looks towards it form the radius distance.
  98398. */
  98399. get target(): Vector3;
  98400. set target(value: Vector3);
  98401. /**
  98402. * Return the current target position of the camera. This value is expressed in local space.
  98403. * @returns the target position
  98404. */
  98405. getTarget(): Vector3;
  98406. /** @hidden */
  98407. _decideIfNeedsToMove(): boolean;
  98408. /** @hidden */
  98409. _updatePosition(): void;
  98410. /** @hidden */
  98411. _checkInputs(): void;
  98412. protected _updateCameraRotationMatrix(): void;
  98413. /**
  98414. * 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)
  98415. * @returns the current camera
  98416. */
  98417. private _rotateUpVectorWithCameraRotationMatrix;
  98418. private _cachedRotationZ;
  98419. private _cachedQuaternionRotationZ;
  98420. /** @hidden */
  98421. _getViewMatrix(): Matrix;
  98422. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  98423. /**
  98424. * @hidden
  98425. */
  98426. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  98427. /**
  98428. * @hidden
  98429. */
  98430. _updateRigCameras(): void;
  98431. private _getRigCamPositionAndTarget;
  98432. /**
  98433. * Gets the current object class name.
  98434. * @return the class name
  98435. */
  98436. getClassName(): string;
  98437. }
  98438. }
  98439. declare module BABYLON {
  98440. /**
  98441. * Gather the list of keyboard event types as constants.
  98442. */
  98443. export class KeyboardEventTypes {
  98444. /**
  98445. * The keydown event is fired when a key becomes active (pressed).
  98446. */
  98447. static readonly KEYDOWN: number;
  98448. /**
  98449. * The keyup event is fired when a key has been released.
  98450. */
  98451. static readonly KEYUP: number;
  98452. }
  98453. /**
  98454. * This class is used to store keyboard related info for the onKeyboardObservable event.
  98455. */
  98456. export class KeyboardInfo {
  98457. /**
  98458. * Defines the type of event (KeyboardEventTypes)
  98459. */
  98460. type: number;
  98461. /**
  98462. * Defines the related dom event
  98463. */
  98464. event: KeyboardEvent;
  98465. /**
  98466. * Instantiates a new keyboard info.
  98467. * This class is used to store keyboard related info for the onKeyboardObservable event.
  98468. * @param type Defines the type of event (KeyboardEventTypes)
  98469. * @param event Defines the related dom event
  98470. */
  98471. constructor(
  98472. /**
  98473. * Defines the type of event (KeyboardEventTypes)
  98474. */
  98475. type: number,
  98476. /**
  98477. * Defines the related dom event
  98478. */
  98479. event: KeyboardEvent);
  98480. }
  98481. /**
  98482. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  98483. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  98484. */
  98485. export class KeyboardInfoPre extends KeyboardInfo {
  98486. /**
  98487. * Defines the type of event (KeyboardEventTypes)
  98488. */
  98489. type: number;
  98490. /**
  98491. * Defines the related dom event
  98492. */
  98493. event: KeyboardEvent;
  98494. /**
  98495. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  98496. */
  98497. skipOnPointerObservable: boolean;
  98498. /**
  98499. * Instantiates a new keyboard pre info.
  98500. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  98501. * @param type Defines the type of event (KeyboardEventTypes)
  98502. * @param event Defines the related dom event
  98503. */
  98504. constructor(
  98505. /**
  98506. * Defines the type of event (KeyboardEventTypes)
  98507. */
  98508. type: number,
  98509. /**
  98510. * Defines the related dom event
  98511. */
  98512. event: KeyboardEvent);
  98513. }
  98514. }
  98515. declare module BABYLON {
  98516. /**
  98517. * Manage the keyboard inputs to control the movement of a free camera.
  98518. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  98519. */
  98520. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  98521. /**
  98522. * Defines the camera the input is attached to.
  98523. */
  98524. camera: FreeCamera;
  98525. /**
  98526. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  98527. */
  98528. keysUp: number[];
  98529. /**
  98530. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  98531. */
  98532. keysUpward: number[];
  98533. /**
  98534. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  98535. */
  98536. keysDown: number[];
  98537. /**
  98538. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  98539. */
  98540. keysDownward: number[];
  98541. /**
  98542. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  98543. */
  98544. keysLeft: number[];
  98545. /**
  98546. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  98547. */
  98548. keysRight: number[];
  98549. private _keys;
  98550. private _onCanvasBlurObserver;
  98551. private _onKeyboardObserver;
  98552. private _engine;
  98553. private _scene;
  98554. /**
  98555. * Attach the input controls to a specific dom element to get the input from.
  98556. * @param element Defines the element the controls should be listened from
  98557. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  98558. */
  98559. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  98560. /**
  98561. * Detach the current controls from the specified dom element.
  98562. * @param element Defines the element to stop listening the inputs from
  98563. */
  98564. detachControl(element: Nullable<HTMLElement>): void;
  98565. /**
  98566. * Update the current camera state depending on the inputs that have been used this frame.
  98567. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  98568. */
  98569. checkInputs(): void;
  98570. /**
  98571. * Gets the class name of the current intput.
  98572. * @returns the class name
  98573. */
  98574. getClassName(): string;
  98575. /** @hidden */
  98576. _onLostFocus(): void;
  98577. /**
  98578. * Get the friendly name associated with the input class.
  98579. * @returns the input friendly name
  98580. */
  98581. getSimpleName(): string;
  98582. }
  98583. }
  98584. declare module BABYLON {
  98585. /**
  98586. * Gather the list of pointer event types as constants.
  98587. */
  98588. export class PointerEventTypes {
  98589. /**
  98590. * 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.
  98591. */
  98592. static readonly POINTERDOWN: number;
  98593. /**
  98594. * The pointerup event is fired when a pointer is no longer active.
  98595. */
  98596. static readonly POINTERUP: number;
  98597. /**
  98598. * The pointermove event is fired when a pointer changes coordinates.
  98599. */
  98600. static readonly POINTERMOVE: number;
  98601. /**
  98602. * The pointerwheel event is fired when a mouse wheel has been rotated.
  98603. */
  98604. static readonly POINTERWHEEL: number;
  98605. /**
  98606. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  98607. */
  98608. static readonly POINTERPICK: number;
  98609. /**
  98610. * The pointertap event is fired when a the object has been touched and released without drag.
  98611. */
  98612. static readonly POINTERTAP: number;
  98613. /**
  98614. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  98615. */
  98616. static readonly POINTERDOUBLETAP: number;
  98617. }
  98618. /**
  98619. * Base class of pointer info types.
  98620. */
  98621. export class PointerInfoBase {
  98622. /**
  98623. * Defines the type of event (PointerEventTypes)
  98624. */
  98625. type: number;
  98626. /**
  98627. * Defines the related dom event
  98628. */
  98629. event: PointerEvent | MouseWheelEvent;
  98630. /**
  98631. * Instantiates the base class of pointers info.
  98632. * @param type Defines the type of event (PointerEventTypes)
  98633. * @param event Defines the related dom event
  98634. */
  98635. constructor(
  98636. /**
  98637. * Defines the type of event (PointerEventTypes)
  98638. */
  98639. type: number,
  98640. /**
  98641. * Defines the related dom event
  98642. */
  98643. event: PointerEvent | MouseWheelEvent);
  98644. }
  98645. /**
  98646. * This class is used to store pointer related info for the onPrePointerObservable event.
  98647. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  98648. */
  98649. export class PointerInfoPre extends PointerInfoBase {
  98650. /**
  98651. * Ray from a pointer if availible (eg. 6dof controller)
  98652. */
  98653. ray: Nullable<Ray>;
  98654. /**
  98655. * Defines the local position of the pointer on the canvas.
  98656. */
  98657. localPosition: Vector2;
  98658. /**
  98659. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  98660. */
  98661. skipOnPointerObservable: boolean;
  98662. /**
  98663. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  98664. * @param type Defines the type of event (PointerEventTypes)
  98665. * @param event Defines the related dom event
  98666. * @param localX Defines the local x coordinates of the pointer when the event occured
  98667. * @param localY Defines the local y coordinates of the pointer when the event occured
  98668. */
  98669. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  98670. }
  98671. /**
  98672. * This type contains all the data related to a pointer event in Babylon.js.
  98673. * 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.
  98674. */
  98675. export class PointerInfo extends PointerInfoBase {
  98676. /**
  98677. * Defines the picking info associated to the info (if any)\
  98678. */
  98679. pickInfo: Nullable<PickingInfo>;
  98680. /**
  98681. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  98682. * @param type Defines the type of event (PointerEventTypes)
  98683. * @param event Defines the related dom event
  98684. * @param pickInfo Defines the picking info associated to the info (if any)\
  98685. */
  98686. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  98687. /**
  98688. * Defines the picking info associated to the info (if any)\
  98689. */
  98690. pickInfo: Nullable<PickingInfo>);
  98691. }
  98692. /**
  98693. * Data relating to a touch event on the screen.
  98694. */
  98695. export interface PointerTouch {
  98696. /**
  98697. * X coordinate of touch.
  98698. */
  98699. x: number;
  98700. /**
  98701. * Y coordinate of touch.
  98702. */
  98703. y: number;
  98704. /**
  98705. * Id of touch. Unique for each finger.
  98706. */
  98707. pointerId: number;
  98708. /**
  98709. * Event type passed from DOM.
  98710. */
  98711. type: any;
  98712. }
  98713. }
  98714. declare module BABYLON {
  98715. /**
  98716. * Manage the mouse inputs to control the movement of a free camera.
  98717. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  98718. */
  98719. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  98720. /**
  98721. * Define if touch is enabled in the mouse input
  98722. */
  98723. touchEnabled: boolean;
  98724. /**
  98725. * Defines the camera the input is attached to.
  98726. */
  98727. camera: FreeCamera;
  98728. /**
  98729. * Defines the buttons associated with the input to handle camera move.
  98730. */
  98731. buttons: number[];
  98732. /**
  98733. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  98734. */
  98735. angularSensibility: number;
  98736. private _pointerInput;
  98737. private _onMouseMove;
  98738. private _observer;
  98739. private previousPosition;
  98740. /**
  98741. * Observable for when a pointer move event occurs containing the move offset
  98742. */
  98743. onPointerMovedObservable: Observable<{
  98744. offsetX: number;
  98745. offsetY: number;
  98746. }>;
  98747. /**
  98748. * @hidden
  98749. * If the camera should be rotated automatically based on pointer movement
  98750. */
  98751. _allowCameraRotation: boolean;
  98752. /**
  98753. * Manage the mouse inputs to control the movement of a free camera.
  98754. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  98755. * @param touchEnabled Defines if touch is enabled or not
  98756. */
  98757. constructor(
  98758. /**
  98759. * Define if touch is enabled in the mouse input
  98760. */
  98761. touchEnabled?: boolean);
  98762. /**
  98763. * Attach the input controls to a specific dom element to get the input from.
  98764. * @param element Defines the element the controls should be listened from
  98765. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  98766. */
  98767. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  98768. /**
  98769. * Called on JS contextmenu event.
  98770. * Override this method to provide functionality.
  98771. */
  98772. protected onContextMenu(evt: PointerEvent): void;
  98773. /**
  98774. * Detach the current controls from the specified dom element.
  98775. * @param element Defines the element to stop listening the inputs from
  98776. */
  98777. detachControl(element: Nullable<HTMLElement>): void;
  98778. /**
  98779. * Gets the class name of the current intput.
  98780. * @returns the class name
  98781. */
  98782. getClassName(): string;
  98783. /**
  98784. * Get the friendly name associated with the input class.
  98785. * @returns the input friendly name
  98786. */
  98787. getSimpleName(): string;
  98788. }
  98789. }
  98790. declare module BABYLON {
  98791. /**
  98792. * Manage the touch inputs to control the movement of a free camera.
  98793. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  98794. */
  98795. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  98796. /**
  98797. * Define if mouse events can be treated as touch events
  98798. */
  98799. allowMouse: boolean;
  98800. /**
  98801. * Defines the camera the input is attached to.
  98802. */
  98803. camera: FreeCamera;
  98804. /**
  98805. * Defines the touch sensibility for rotation.
  98806. * The higher the faster.
  98807. */
  98808. touchAngularSensibility: number;
  98809. /**
  98810. * Defines the touch sensibility for move.
  98811. * The higher the faster.
  98812. */
  98813. touchMoveSensibility: number;
  98814. private _offsetX;
  98815. private _offsetY;
  98816. private _pointerPressed;
  98817. private _pointerInput;
  98818. private _observer;
  98819. private _onLostFocus;
  98820. /**
  98821. * Manage the touch inputs to control the movement of a free camera.
  98822. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  98823. * @param allowMouse Defines if mouse events can be treated as touch events
  98824. */
  98825. constructor(
  98826. /**
  98827. * Define if mouse events can be treated as touch events
  98828. */
  98829. allowMouse?: boolean);
  98830. /**
  98831. * Attach the input controls to a specific dom element to get the input from.
  98832. * @param element Defines the element the controls should be listened from
  98833. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  98834. */
  98835. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  98836. /**
  98837. * Detach the current controls from the specified dom element.
  98838. * @param element Defines the element to stop listening the inputs from
  98839. */
  98840. detachControl(element: Nullable<HTMLElement>): void;
  98841. /**
  98842. * Update the current camera state depending on the inputs that have been used this frame.
  98843. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  98844. */
  98845. checkInputs(): void;
  98846. /**
  98847. * Gets the class name of the current intput.
  98848. * @returns the class name
  98849. */
  98850. getClassName(): string;
  98851. /**
  98852. * Get the friendly name associated with the input class.
  98853. * @returns the input friendly name
  98854. */
  98855. getSimpleName(): string;
  98856. }
  98857. }
  98858. declare module BABYLON {
  98859. /**
  98860. * Default Inputs manager for the FreeCamera.
  98861. * It groups all the default supported inputs for ease of use.
  98862. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  98863. */
  98864. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  98865. /**
  98866. * @hidden
  98867. */
  98868. _mouseInput: Nullable<FreeCameraMouseInput>;
  98869. /**
  98870. * Instantiates a new FreeCameraInputsManager.
  98871. * @param camera Defines the camera the inputs belong to
  98872. */
  98873. constructor(camera: FreeCamera);
  98874. /**
  98875. * Add keyboard input support to the input manager.
  98876. * @returns the current input manager
  98877. */
  98878. addKeyboard(): FreeCameraInputsManager;
  98879. /**
  98880. * Add mouse input support to the input manager.
  98881. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  98882. * @returns the current input manager
  98883. */
  98884. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  98885. /**
  98886. * Removes the mouse input support from the manager
  98887. * @returns the current input manager
  98888. */
  98889. removeMouse(): FreeCameraInputsManager;
  98890. /**
  98891. * Add touch input support to the input manager.
  98892. * @returns the current input manager
  98893. */
  98894. addTouch(): FreeCameraInputsManager;
  98895. /**
  98896. * Remove all attached input methods from a camera
  98897. */
  98898. clear(): void;
  98899. }
  98900. }
  98901. declare module BABYLON {
  98902. /**
  98903. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  98904. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  98905. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  98906. */
  98907. export class FreeCamera extends TargetCamera {
  98908. /**
  98909. * Define the collision ellipsoid of the camera.
  98910. * This is helpful to simulate a camera body like the player body around the camera
  98911. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  98912. */
  98913. ellipsoid: Vector3;
  98914. /**
  98915. * Define an offset for the position of the ellipsoid around the camera.
  98916. * This can be helpful to determine the center of the body near the gravity center of the body
  98917. * instead of its head.
  98918. */
  98919. ellipsoidOffset: Vector3;
  98920. /**
  98921. * Enable or disable collisions of the camera with the rest of the scene objects.
  98922. */
  98923. checkCollisions: boolean;
  98924. /**
  98925. * Enable or disable gravity on the camera.
  98926. */
  98927. applyGravity: boolean;
  98928. /**
  98929. * Define the input manager associated to the camera.
  98930. */
  98931. inputs: FreeCameraInputsManager;
  98932. /**
  98933. * Gets the input sensibility for a mouse input. (default is 2000.0)
  98934. * Higher values reduce sensitivity.
  98935. */
  98936. get angularSensibility(): number;
  98937. /**
  98938. * Sets the input sensibility for a mouse input. (default is 2000.0)
  98939. * Higher values reduce sensitivity.
  98940. */
  98941. set angularSensibility(value: number);
  98942. /**
  98943. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  98944. */
  98945. get keysUp(): number[];
  98946. set keysUp(value: number[]);
  98947. /**
  98948. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  98949. */
  98950. get keysUpward(): number[];
  98951. set keysUpward(value: number[]);
  98952. /**
  98953. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  98954. */
  98955. get keysDown(): number[];
  98956. set keysDown(value: number[]);
  98957. /**
  98958. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  98959. */
  98960. get keysDownward(): number[];
  98961. set keysDownward(value: number[]);
  98962. /**
  98963. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  98964. */
  98965. get keysLeft(): number[];
  98966. set keysLeft(value: number[]);
  98967. /**
  98968. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  98969. */
  98970. get keysRight(): number[];
  98971. set keysRight(value: number[]);
  98972. /**
  98973. * Event raised when the camera collide with a mesh in the scene.
  98974. */
  98975. onCollide: (collidedMesh: AbstractMesh) => void;
  98976. private _collider;
  98977. private _needMoveForGravity;
  98978. private _oldPosition;
  98979. private _diffPosition;
  98980. private _newPosition;
  98981. /** @hidden */
  98982. _localDirection: Vector3;
  98983. /** @hidden */
  98984. _transformedDirection: Vector3;
  98985. /**
  98986. * Instantiates a Free Camera.
  98987. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  98988. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  98989. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  98990. * @param name Define the name of the camera in the scene
  98991. * @param position Define the start position of the camera in the scene
  98992. * @param scene Define the scene the camera belongs to
  98993. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  98994. */
  98995. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  98996. /**
  98997. * Attached controls to the current camera.
  98998. * @param element Defines the element the controls should be listened from
  98999. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  99000. */
  99001. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  99002. /**
  99003. * Detach the current controls from the camera.
  99004. * The camera will stop reacting to inputs.
  99005. * @param element Defines the element to stop listening the inputs from
  99006. */
  99007. detachControl(element: HTMLElement): void;
  99008. private _collisionMask;
  99009. /**
  99010. * Define a collision mask to limit the list of object the camera can collide with
  99011. */
  99012. get collisionMask(): number;
  99013. set collisionMask(mask: number);
  99014. /** @hidden */
  99015. _collideWithWorld(displacement: Vector3): void;
  99016. private _onCollisionPositionChange;
  99017. /** @hidden */
  99018. _checkInputs(): void;
  99019. /** @hidden */
  99020. _decideIfNeedsToMove(): boolean;
  99021. /** @hidden */
  99022. _updatePosition(): void;
  99023. /**
  99024. * Destroy the camera and release the current resources hold by it.
  99025. */
  99026. dispose(): void;
  99027. /**
  99028. * Gets the current object class name.
  99029. * @return the class name
  99030. */
  99031. getClassName(): string;
  99032. }
  99033. }
  99034. declare module BABYLON {
  99035. /**
  99036. * Represents a gamepad control stick position
  99037. */
  99038. export class StickValues {
  99039. /**
  99040. * The x component of the control stick
  99041. */
  99042. x: number;
  99043. /**
  99044. * The y component of the control stick
  99045. */
  99046. y: number;
  99047. /**
  99048. * Initializes the gamepad x and y control stick values
  99049. * @param x The x component of the gamepad control stick value
  99050. * @param y The y component of the gamepad control stick value
  99051. */
  99052. constructor(
  99053. /**
  99054. * The x component of the control stick
  99055. */
  99056. x: number,
  99057. /**
  99058. * The y component of the control stick
  99059. */
  99060. y: number);
  99061. }
  99062. /**
  99063. * An interface which manages callbacks for gamepad button changes
  99064. */
  99065. export interface GamepadButtonChanges {
  99066. /**
  99067. * Called when a gamepad has been changed
  99068. */
  99069. changed: boolean;
  99070. /**
  99071. * Called when a gamepad press event has been triggered
  99072. */
  99073. pressChanged: boolean;
  99074. /**
  99075. * Called when a touch event has been triggered
  99076. */
  99077. touchChanged: boolean;
  99078. /**
  99079. * Called when a value has changed
  99080. */
  99081. valueChanged: boolean;
  99082. }
  99083. /**
  99084. * Represents a gamepad
  99085. */
  99086. export class Gamepad {
  99087. /**
  99088. * The id of the gamepad
  99089. */
  99090. id: string;
  99091. /**
  99092. * The index of the gamepad
  99093. */
  99094. index: number;
  99095. /**
  99096. * The browser gamepad
  99097. */
  99098. browserGamepad: any;
  99099. /**
  99100. * Specifies what type of gamepad this represents
  99101. */
  99102. type: number;
  99103. private _leftStick;
  99104. private _rightStick;
  99105. /** @hidden */
  99106. _isConnected: boolean;
  99107. private _leftStickAxisX;
  99108. private _leftStickAxisY;
  99109. private _rightStickAxisX;
  99110. private _rightStickAxisY;
  99111. /**
  99112. * Triggered when the left control stick has been changed
  99113. */
  99114. private _onleftstickchanged;
  99115. /**
  99116. * Triggered when the right control stick has been changed
  99117. */
  99118. private _onrightstickchanged;
  99119. /**
  99120. * Represents a gamepad controller
  99121. */
  99122. static GAMEPAD: number;
  99123. /**
  99124. * Represents a generic controller
  99125. */
  99126. static GENERIC: number;
  99127. /**
  99128. * Represents an XBox controller
  99129. */
  99130. static XBOX: number;
  99131. /**
  99132. * Represents a pose-enabled controller
  99133. */
  99134. static POSE_ENABLED: number;
  99135. /**
  99136. * Represents an Dual Shock controller
  99137. */
  99138. static DUALSHOCK: number;
  99139. /**
  99140. * Specifies whether the left control stick should be Y-inverted
  99141. */
  99142. protected _invertLeftStickY: boolean;
  99143. /**
  99144. * Specifies if the gamepad has been connected
  99145. */
  99146. get isConnected(): boolean;
  99147. /**
  99148. * Initializes the gamepad
  99149. * @param id The id of the gamepad
  99150. * @param index The index of the gamepad
  99151. * @param browserGamepad The browser gamepad
  99152. * @param leftStickX The x component of the left joystick
  99153. * @param leftStickY The y component of the left joystick
  99154. * @param rightStickX The x component of the right joystick
  99155. * @param rightStickY The y component of the right joystick
  99156. */
  99157. constructor(
  99158. /**
  99159. * The id of the gamepad
  99160. */
  99161. id: string,
  99162. /**
  99163. * The index of the gamepad
  99164. */
  99165. index: number,
  99166. /**
  99167. * The browser gamepad
  99168. */
  99169. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  99170. /**
  99171. * Callback triggered when the left joystick has changed
  99172. * @param callback
  99173. */
  99174. onleftstickchanged(callback: (values: StickValues) => void): void;
  99175. /**
  99176. * Callback triggered when the right joystick has changed
  99177. * @param callback
  99178. */
  99179. onrightstickchanged(callback: (values: StickValues) => void): void;
  99180. /**
  99181. * Gets the left joystick
  99182. */
  99183. get leftStick(): StickValues;
  99184. /**
  99185. * Sets the left joystick values
  99186. */
  99187. set leftStick(newValues: StickValues);
  99188. /**
  99189. * Gets the right joystick
  99190. */
  99191. get rightStick(): StickValues;
  99192. /**
  99193. * Sets the right joystick value
  99194. */
  99195. set rightStick(newValues: StickValues);
  99196. /**
  99197. * Updates the gamepad joystick positions
  99198. */
  99199. update(): void;
  99200. /**
  99201. * Disposes the gamepad
  99202. */
  99203. dispose(): void;
  99204. }
  99205. /**
  99206. * Represents a generic gamepad
  99207. */
  99208. export class GenericPad extends Gamepad {
  99209. private _buttons;
  99210. private _onbuttondown;
  99211. private _onbuttonup;
  99212. /**
  99213. * Observable triggered when a button has been pressed
  99214. */
  99215. onButtonDownObservable: Observable<number>;
  99216. /**
  99217. * Observable triggered when a button has been released
  99218. */
  99219. onButtonUpObservable: Observable<number>;
  99220. /**
  99221. * Callback triggered when a button has been pressed
  99222. * @param callback Called when a button has been pressed
  99223. */
  99224. onbuttondown(callback: (buttonPressed: number) => void): void;
  99225. /**
  99226. * Callback triggered when a button has been released
  99227. * @param callback Called when a button has been released
  99228. */
  99229. onbuttonup(callback: (buttonReleased: number) => void): void;
  99230. /**
  99231. * Initializes the generic gamepad
  99232. * @param id The id of the generic gamepad
  99233. * @param index The index of the generic gamepad
  99234. * @param browserGamepad The browser gamepad
  99235. */
  99236. constructor(id: string, index: number, browserGamepad: any);
  99237. private _setButtonValue;
  99238. /**
  99239. * Updates the generic gamepad
  99240. */
  99241. update(): void;
  99242. /**
  99243. * Disposes the generic gamepad
  99244. */
  99245. dispose(): void;
  99246. }
  99247. }
  99248. declare module BABYLON {
  99249. /**
  99250. * Defines the types of pose enabled controllers that are supported
  99251. */
  99252. export enum PoseEnabledControllerType {
  99253. /**
  99254. * HTC Vive
  99255. */
  99256. VIVE = 0,
  99257. /**
  99258. * Oculus Rift
  99259. */
  99260. OCULUS = 1,
  99261. /**
  99262. * Windows mixed reality
  99263. */
  99264. WINDOWS = 2,
  99265. /**
  99266. * Samsung gear VR
  99267. */
  99268. GEAR_VR = 3,
  99269. /**
  99270. * Google Daydream
  99271. */
  99272. DAYDREAM = 4,
  99273. /**
  99274. * Generic
  99275. */
  99276. GENERIC = 5
  99277. }
  99278. /**
  99279. * Defines the MutableGamepadButton interface for the state of a gamepad button
  99280. */
  99281. export interface MutableGamepadButton {
  99282. /**
  99283. * Value of the button/trigger
  99284. */
  99285. value: number;
  99286. /**
  99287. * If the button/trigger is currently touched
  99288. */
  99289. touched: boolean;
  99290. /**
  99291. * If the button/trigger is currently pressed
  99292. */
  99293. pressed: boolean;
  99294. }
  99295. /**
  99296. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  99297. * @hidden
  99298. */
  99299. export interface ExtendedGamepadButton extends GamepadButton {
  99300. /**
  99301. * If the button/trigger is currently pressed
  99302. */
  99303. readonly pressed: boolean;
  99304. /**
  99305. * If the button/trigger is currently touched
  99306. */
  99307. readonly touched: boolean;
  99308. /**
  99309. * Value of the button/trigger
  99310. */
  99311. readonly value: number;
  99312. }
  99313. /** @hidden */
  99314. export interface _GamePadFactory {
  99315. /**
  99316. * Returns whether or not the current gamepad can be created for this type of controller.
  99317. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  99318. * @returns true if it can be created, otherwise false
  99319. */
  99320. canCreate(gamepadInfo: any): boolean;
  99321. /**
  99322. * Creates a new instance of the Gamepad.
  99323. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  99324. * @returns the new gamepad instance
  99325. */
  99326. create(gamepadInfo: any): Gamepad;
  99327. }
  99328. /**
  99329. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  99330. */
  99331. export class PoseEnabledControllerHelper {
  99332. /** @hidden */
  99333. static _ControllerFactories: _GamePadFactory[];
  99334. /** @hidden */
  99335. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  99336. /**
  99337. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  99338. * @param vrGamepad the gamepad to initialized
  99339. * @returns a vr controller of the type the gamepad identified as
  99340. */
  99341. static InitiateController(vrGamepad: any): Gamepad;
  99342. }
  99343. /**
  99344. * Defines the PoseEnabledController object that contains state of a vr capable controller
  99345. */
  99346. export class PoseEnabledController extends Gamepad implements PoseControlled {
  99347. /**
  99348. * If the controller is used in a webXR session
  99349. */
  99350. isXR: boolean;
  99351. private _deviceRoomPosition;
  99352. private _deviceRoomRotationQuaternion;
  99353. /**
  99354. * The device position in babylon space
  99355. */
  99356. devicePosition: Vector3;
  99357. /**
  99358. * The device rotation in babylon space
  99359. */
  99360. deviceRotationQuaternion: Quaternion;
  99361. /**
  99362. * The scale factor of the device in babylon space
  99363. */
  99364. deviceScaleFactor: number;
  99365. /**
  99366. * (Likely devicePosition should be used instead) The device position in its room space
  99367. */
  99368. position: Vector3;
  99369. /**
  99370. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  99371. */
  99372. rotationQuaternion: Quaternion;
  99373. /**
  99374. * The type of controller (Eg. Windows mixed reality)
  99375. */
  99376. controllerType: PoseEnabledControllerType;
  99377. protected _calculatedPosition: Vector3;
  99378. private _calculatedRotation;
  99379. /**
  99380. * The raw pose from the device
  99381. */
  99382. rawPose: DevicePose;
  99383. private _trackPosition;
  99384. private _maxRotationDistFromHeadset;
  99385. private _draggedRoomRotation;
  99386. /**
  99387. * @hidden
  99388. */
  99389. _disableTrackPosition(fixedPosition: Vector3): void;
  99390. /**
  99391. * Internal, the mesh attached to the controller
  99392. * @hidden
  99393. */
  99394. _mesh: Nullable<AbstractMesh>;
  99395. private _poseControlledCamera;
  99396. private _leftHandSystemQuaternion;
  99397. /**
  99398. * Internal, matrix used to convert room space to babylon space
  99399. * @hidden
  99400. */
  99401. _deviceToWorld: Matrix;
  99402. /**
  99403. * Node to be used when casting a ray from the controller
  99404. * @hidden
  99405. */
  99406. _pointingPoseNode: Nullable<TransformNode>;
  99407. /**
  99408. * Name of the child mesh that can be used to cast a ray from the controller
  99409. */
  99410. static readonly POINTING_POSE: string;
  99411. /**
  99412. * Creates a new PoseEnabledController from a gamepad
  99413. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  99414. */
  99415. constructor(browserGamepad: any);
  99416. private _workingMatrix;
  99417. /**
  99418. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  99419. */
  99420. update(): void;
  99421. /**
  99422. * Updates only the pose device and mesh without doing any button event checking
  99423. */
  99424. protected _updatePoseAndMesh(): void;
  99425. /**
  99426. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  99427. * @param poseData raw pose fromthe device
  99428. */
  99429. updateFromDevice(poseData: DevicePose): void;
  99430. /**
  99431. * @hidden
  99432. */
  99433. _meshAttachedObservable: Observable<AbstractMesh>;
  99434. /**
  99435. * Attaches a mesh to the controller
  99436. * @param mesh the mesh to be attached
  99437. */
  99438. attachToMesh(mesh: AbstractMesh): void;
  99439. /**
  99440. * Attaches the controllers mesh to a camera
  99441. * @param camera the camera the mesh should be attached to
  99442. */
  99443. attachToPoseControlledCamera(camera: TargetCamera): void;
  99444. /**
  99445. * Disposes of the controller
  99446. */
  99447. dispose(): void;
  99448. /**
  99449. * The mesh that is attached to the controller
  99450. */
  99451. get mesh(): Nullable<AbstractMesh>;
  99452. /**
  99453. * Gets the ray of the controller in the direction the controller is pointing
  99454. * @param length the length the resulting ray should be
  99455. * @returns a ray in the direction the controller is pointing
  99456. */
  99457. getForwardRay(length?: number): Ray;
  99458. }
  99459. }
  99460. declare module BABYLON {
  99461. /**
  99462. * Defines the WebVRController object that represents controllers tracked in 3D space
  99463. */
  99464. export abstract class WebVRController extends PoseEnabledController {
  99465. /**
  99466. * Internal, the default controller model for the controller
  99467. */
  99468. protected _defaultModel: Nullable<AbstractMesh>;
  99469. /**
  99470. * Fired when the trigger state has changed
  99471. */
  99472. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  99473. /**
  99474. * Fired when the main button state has changed
  99475. */
  99476. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  99477. /**
  99478. * Fired when the secondary button state has changed
  99479. */
  99480. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  99481. /**
  99482. * Fired when the pad state has changed
  99483. */
  99484. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  99485. /**
  99486. * Fired when controllers stick values have changed
  99487. */
  99488. onPadValuesChangedObservable: Observable<StickValues>;
  99489. /**
  99490. * Array of button availible on the controller
  99491. */
  99492. protected _buttons: Array<MutableGamepadButton>;
  99493. private _onButtonStateChange;
  99494. /**
  99495. * Fired when a controller button's state has changed
  99496. * @param callback the callback containing the button that was modified
  99497. */
  99498. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  99499. /**
  99500. * X and Y axis corresponding to the controllers joystick
  99501. */
  99502. pad: StickValues;
  99503. /**
  99504. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  99505. */
  99506. hand: string;
  99507. /**
  99508. * The default controller model for the controller
  99509. */
  99510. get defaultModel(): Nullable<AbstractMesh>;
  99511. /**
  99512. * Creates a new WebVRController from a gamepad
  99513. * @param vrGamepad the gamepad that the WebVRController should be created from
  99514. */
  99515. constructor(vrGamepad: any);
  99516. /**
  99517. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  99518. */
  99519. update(): void;
  99520. /**
  99521. * Function to be called when a button is modified
  99522. */
  99523. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  99524. /**
  99525. * Loads a mesh and attaches it to the controller
  99526. * @param scene the scene the mesh should be added to
  99527. * @param meshLoaded callback for when the mesh has been loaded
  99528. */
  99529. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  99530. private _setButtonValue;
  99531. private _changes;
  99532. private _checkChanges;
  99533. /**
  99534. * Disposes of th webVRCOntroller
  99535. */
  99536. dispose(): void;
  99537. }
  99538. }
  99539. declare module BABYLON {
  99540. /**
  99541. * The HemisphericLight simulates the ambient environment light,
  99542. * so the passed direction is the light reflection direction, not the incoming direction.
  99543. */
  99544. export class HemisphericLight extends Light {
  99545. /**
  99546. * The groundColor is the light in the opposite direction to the one specified during creation.
  99547. * 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.
  99548. */
  99549. groundColor: Color3;
  99550. /**
  99551. * The light reflection direction, not the incoming direction.
  99552. */
  99553. direction: Vector3;
  99554. /**
  99555. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  99556. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  99557. * The HemisphericLight can't cast shadows.
  99558. * Documentation : https://doc.babylonjs.com/babylon101/lights
  99559. * @param name The friendly name of the light
  99560. * @param direction The direction of the light reflection
  99561. * @param scene The scene the light belongs to
  99562. */
  99563. constructor(name: string, direction: Vector3, scene: Scene);
  99564. protected _buildUniformLayout(): void;
  99565. /**
  99566. * Returns the string "HemisphericLight".
  99567. * @return The class name
  99568. */
  99569. getClassName(): string;
  99570. /**
  99571. * Sets the HemisphericLight direction towards the passed target (Vector3).
  99572. * Returns the updated direction.
  99573. * @param target The target the direction should point to
  99574. * @return The computed direction
  99575. */
  99576. setDirectionToTarget(target: Vector3): Vector3;
  99577. /**
  99578. * Returns the shadow generator associated to the light.
  99579. * @returns Always null for hemispheric lights because it does not support shadows.
  99580. */
  99581. getShadowGenerator(): Nullable<IShadowGenerator>;
  99582. /**
  99583. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  99584. * @param effect The effect to update
  99585. * @param lightIndex The index of the light in the effect to update
  99586. * @returns The hemispheric light
  99587. */
  99588. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  99589. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  99590. /**
  99591. * Computes the world matrix of the node
  99592. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  99593. * @param useWasUpdatedFlag defines a reserved property
  99594. * @returns the world matrix
  99595. */
  99596. computeWorldMatrix(): Matrix;
  99597. /**
  99598. * Returns the integer 3.
  99599. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  99600. */
  99601. getTypeID(): number;
  99602. /**
  99603. * Prepares the list of defines specific to the light type.
  99604. * @param defines the list of defines
  99605. * @param lightIndex defines the index of the light for the effect
  99606. */
  99607. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  99608. }
  99609. }
  99610. declare module BABYLON {
  99611. /** @hidden */
  99612. export var vrMultiviewToSingleviewPixelShader: {
  99613. name: string;
  99614. shader: string;
  99615. };
  99616. }
  99617. declare module BABYLON {
  99618. /**
  99619. * Renders to multiple views with a single draw call
  99620. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  99621. */
  99622. export class MultiviewRenderTarget extends RenderTargetTexture {
  99623. /**
  99624. * Creates a multiview render target
  99625. * @param scene scene used with the render target
  99626. * @param size the size of the render target (used for each view)
  99627. */
  99628. constructor(scene: Scene, size?: number | {
  99629. width: number;
  99630. height: number;
  99631. } | {
  99632. ratio: number;
  99633. });
  99634. /**
  99635. * @hidden
  99636. * @param faceIndex the face index, if its a cube texture
  99637. */
  99638. _bindFrameBuffer(faceIndex?: number): void;
  99639. /**
  99640. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  99641. * @returns the view count
  99642. */
  99643. getViewCount(): number;
  99644. }
  99645. }
  99646. declare module BABYLON {
  99647. interface Engine {
  99648. /**
  99649. * Creates a new multiview render target
  99650. * @param width defines the width of the texture
  99651. * @param height defines the height of the texture
  99652. * @returns the created multiview texture
  99653. */
  99654. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  99655. /**
  99656. * Binds a multiview framebuffer to be drawn to
  99657. * @param multiviewTexture texture to bind
  99658. */
  99659. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  99660. }
  99661. interface Camera {
  99662. /**
  99663. * @hidden
  99664. * 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)
  99665. */
  99666. _useMultiviewToSingleView: boolean;
  99667. /**
  99668. * @hidden
  99669. * 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)
  99670. */
  99671. _multiviewTexture: Nullable<RenderTargetTexture>;
  99672. /**
  99673. * @hidden
  99674. * ensures the multiview texture of the camera exists and has the specified width/height
  99675. * @param width height to set on the multiview texture
  99676. * @param height width to set on the multiview texture
  99677. */
  99678. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  99679. }
  99680. interface Scene {
  99681. /** @hidden */
  99682. _transformMatrixR: Matrix;
  99683. /** @hidden */
  99684. _multiviewSceneUbo: Nullable<UniformBuffer>;
  99685. /** @hidden */
  99686. _createMultiviewUbo(): void;
  99687. /** @hidden */
  99688. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  99689. /** @hidden */
  99690. _renderMultiviewToSingleView(camera: Camera): void;
  99691. }
  99692. }
  99693. declare module BABYLON {
  99694. /**
  99695. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  99696. * This will not be used for webXR as it supports displaying texture arrays directly
  99697. */
  99698. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  99699. /**
  99700. * Gets a string identifying the name of the class
  99701. * @returns "VRMultiviewToSingleviewPostProcess" string
  99702. */
  99703. getClassName(): string;
  99704. /**
  99705. * Initializes a VRMultiviewToSingleview
  99706. * @param name name of the post process
  99707. * @param camera camera to be applied to
  99708. * @param scaleFactor scaling factor to the size of the output texture
  99709. */
  99710. constructor(name: string, camera: Camera, scaleFactor: number);
  99711. }
  99712. }
  99713. declare module BABYLON {
  99714. /**
  99715. * Interface used to define additional presentation attributes
  99716. */
  99717. export interface IVRPresentationAttributes {
  99718. /**
  99719. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  99720. */
  99721. highRefreshRate: boolean;
  99722. /**
  99723. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  99724. */
  99725. foveationLevel: number;
  99726. }
  99727. interface Engine {
  99728. /** @hidden */
  99729. _vrDisplay: any;
  99730. /** @hidden */
  99731. _vrSupported: boolean;
  99732. /** @hidden */
  99733. _oldSize: Size;
  99734. /** @hidden */
  99735. _oldHardwareScaleFactor: number;
  99736. /** @hidden */
  99737. _vrExclusivePointerMode: boolean;
  99738. /** @hidden */
  99739. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  99740. /** @hidden */
  99741. _onVRDisplayPointerRestricted: () => void;
  99742. /** @hidden */
  99743. _onVRDisplayPointerUnrestricted: () => void;
  99744. /** @hidden */
  99745. _onVrDisplayConnect: Nullable<(display: any) => void>;
  99746. /** @hidden */
  99747. _onVrDisplayDisconnect: Nullable<() => void>;
  99748. /** @hidden */
  99749. _onVrDisplayPresentChange: Nullable<() => void>;
  99750. /**
  99751. * Observable signaled when VR display mode changes
  99752. */
  99753. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  99754. /**
  99755. * Observable signaled when VR request present is complete
  99756. */
  99757. onVRRequestPresentComplete: Observable<boolean>;
  99758. /**
  99759. * Observable signaled when VR request present starts
  99760. */
  99761. onVRRequestPresentStart: Observable<Engine>;
  99762. /**
  99763. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  99764. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  99765. */
  99766. isInVRExclusivePointerMode: boolean;
  99767. /**
  99768. * Gets a boolean indicating if a webVR device was detected
  99769. * @returns true if a webVR device was detected
  99770. */
  99771. isVRDevicePresent(): boolean;
  99772. /**
  99773. * Gets the current webVR device
  99774. * @returns the current webVR device (or null)
  99775. */
  99776. getVRDevice(): any;
  99777. /**
  99778. * Initializes a webVR display and starts listening to display change events
  99779. * The onVRDisplayChangedObservable will be notified upon these changes
  99780. * @returns A promise containing a VRDisplay and if vr is supported
  99781. */
  99782. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  99783. /** @hidden */
  99784. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  99785. /**
  99786. * Gets or sets the presentation attributes used to configure VR rendering
  99787. */
  99788. vrPresentationAttributes?: IVRPresentationAttributes;
  99789. /**
  99790. * Call this function to switch to webVR mode
  99791. * Will do nothing if webVR is not supported or if there is no webVR device
  99792. * @param options the webvr options provided to the camera. mainly used for multiview
  99793. * @see https://doc.babylonjs.com/how_to/webvr_camera
  99794. */
  99795. enableVR(options: WebVROptions): void;
  99796. /** @hidden */
  99797. _onVRFullScreenTriggered(): void;
  99798. }
  99799. }
  99800. declare module BABYLON {
  99801. /**
  99802. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  99803. * IMPORTANT!! The data is right-hand data.
  99804. * @export
  99805. * @interface DevicePose
  99806. */
  99807. export interface DevicePose {
  99808. /**
  99809. * The position of the device, values in array are [x,y,z].
  99810. */
  99811. readonly position: Nullable<Float32Array>;
  99812. /**
  99813. * The linearVelocity of the device, values in array are [x,y,z].
  99814. */
  99815. readonly linearVelocity: Nullable<Float32Array>;
  99816. /**
  99817. * The linearAcceleration of the device, values in array are [x,y,z].
  99818. */
  99819. readonly linearAcceleration: Nullable<Float32Array>;
  99820. /**
  99821. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  99822. */
  99823. readonly orientation: Nullable<Float32Array>;
  99824. /**
  99825. * The angularVelocity of the device, values in array are [x,y,z].
  99826. */
  99827. readonly angularVelocity: Nullable<Float32Array>;
  99828. /**
  99829. * The angularAcceleration of the device, values in array are [x,y,z].
  99830. */
  99831. readonly angularAcceleration: Nullable<Float32Array>;
  99832. }
  99833. /**
  99834. * Interface representing a pose controlled object in Babylon.
  99835. * A pose controlled object has both regular pose values as well as pose values
  99836. * from an external device such as a VR head mounted display
  99837. */
  99838. export interface PoseControlled {
  99839. /**
  99840. * The position of the object in babylon space.
  99841. */
  99842. position: Vector3;
  99843. /**
  99844. * The rotation quaternion of the object in babylon space.
  99845. */
  99846. rotationQuaternion: Quaternion;
  99847. /**
  99848. * The position of the device in babylon space.
  99849. */
  99850. devicePosition?: Vector3;
  99851. /**
  99852. * The rotation quaternion of the device in babylon space.
  99853. */
  99854. deviceRotationQuaternion: Quaternion;
  99855. /**
  99856. * The raw pose coming from the device.
  99857. */
  99858. rawPose: Nullable<DevicePose>;
  99859. /**
  99860. * The scale of the device to be used when translating from device space to babylon space.
  99861. */
  99862. deviceScaleFactor: number;
  99863. /**
  99864. * Updates the poseControlled values based on the input device pose.
  99865. * @param poseData the pose data to update the object with
  99866. */
  99867. updateFromDevice(poseData: DevicePose): void;
  99868. }
  99869. /**
  99870. * Set of options to customize the webVRCamera
  99871. */
  99872. export interface WebVROptions {
  99873. /**
  99874. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  99875. */
  99876. trackPosition?: boolean;
  99877. /**
  99878. * Sets the scale of the vrDevice in babylon space. (default: 1)
  99879. */
  99880. positionScale?: number;
  99881. /**
  99882. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  99883. */
  99884. displayName?: string;
  99885. /**
  99886. * Should the native controller meshes be initialized. (default: true)
  99887. */
  99888. controllerMeshes?: boolean;
  99889. /**
  99890. * Creating a default HemiLight only on controllers. (default: true)
  99891. */
  99892. defaultLightingOnControllers?: boolean;
  99893. /**
  99894. * If you don't want to use the default VR button of the helper. (default: false)
  99895. */
  99896. useCustomVRButton?: boolean;
  99897. /**
  99898. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  99899. */
  99900. customVRButton?: HTMLButtonElement;
  99901. /**
  99902. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  99903. */
  99904. rayLength?: number;
  99905. /**
  99906. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  99907. */
  99908. defaultHeight?: number;
  99909. /**
  99910. * If multiview should be used if availible (default: false)
  99911. */
  99912. useMultiview?: boolean;
  99913. }
  99914. /**
  99915. * This represents a WebVR camera.
  99916. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  99917. * @example https://doc.babylonjs.com/how_to/webvr_camera
  99918. */
  99919. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  99920. private webVROptions;
  99921. /**
  99922. * @hidden
  99923. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  99924. */
  99925. _vrDevice: any;
  99926. /**
  99927. * The rawPose of the vrDevice.
  99928. */
  99929. rawPose: Nullable<DevicePose>;
  99930. private _onVREnabled;
  99931. private _specsVersion;
  99932. private _attached;
  99933. private _frameData;
  99934. protected _descendants: Array<Node>;
  99935. private _deviceRoomPosition;
  99936. /** @hidden */
  99937. _deviceRoomRotationQuaternion: Quaternion;
  99938. private _standingMatrix;
  99939. /**
  99940. * Represents device position in babylon space.
  99941. */
  99942. devicePosition: Vector3;
  99943. /**
  99944. * Represents device rotation in babylon space.
  99945. */
  99946. deviceRotationQuaternion: Quaternion;
  99947. /**
  99948. * The scale of the device to be used when translating from device space to babylon space.
  99949. */
  99950. deviceScaleFactor: number;
  99951. private _deviceToWorld;
  99952. private _worldToDevice;
  99953. /**
  99954. * References to the webVR controllers for the vrDevice.
  99955. */
  99956. controllers: Array<WebVRController>;
  99957. /**
  99958. * Emits an event when a controller is attached.
  99959. */
  99960. onControllersAttachedObservable: Observable<WebVRController[]>;
  99961. /**
  99962. * Emits an event when a controller's mesh has been loaded;
  99963. */
  99964. onControllerMeshLoadedObservable: Observable<WebVRController>;
  99965. /**
  99966. * Emits an event when the HMD's pose has been updated.
  99967. */
  99968. onPoseUpdatedFromDeviceObservable: Observable<any>;
  99969. private _poseSet;
  99970. /**
  99971. * If the rig cameras be used as parent instead of this camera.
  99972. */
  99973. rigParenting: boolean;
  99974. private _lightOnControllers;
  99975. private _defaultHeight?;
  99976. /**
  99977. * Instantiates a WebVRFreeCamera.
  99978. * @param name The name of the WebVRFreeCamera
  99979. * @param position The starting anchor position for the camera
  99980. * @param scene The scene the camera belongs to
  99981. * @param webVROptions a set of customizable options for the webVRCamera
  99982. */
  99983. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  99984. /**
  99985. * Gets the device distance from the ground in meters.
  99986. * @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.
  99987. */
  99988. deviceDistanceToRoomGround(): number;
  99989. /**
  99990. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  99991. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  99992. */
  99993. useStandingMatrix(callback?: (bool: boolean) => void): void;
  99994. /**
  99995. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  99996. * @returns A promise with a boolean set to if the standing matrix is supported.
  99997. */
  99998. useStandingMatrixAsync(): Promise<boolean>;
  99999. /**
  100000. * Disposes the camera
  100001. */
  100002. dispose(): void;
  100003. /**
  100004. * Gets a vrController by name.
  100005. * @param name The name of the controller to retreive
  100006. * @returns the controller matching the name specified or null if not found
  100007. */
  100008. getControllerByName(name: string): Nullable<WebVRController>;
  100009. private _leftController;
  100010. /**
  100011. * The controller corresponding to the users left hand.
  100012. */
  100013. get leftController(): Nullable<WebVRController>;
  100014. private _rightController;
  100015. /**
  100016. * The controller corresponding to the users right hand.
  100017. */
  100018. get rightController(): Nullable<WebVRController>;
  100019. /**
  100020. * Casts a ray forward from the vrCamera's gaze.
  100021. * @param length Length of the ray (default: 100)
  100022. * @returns the ray corresponding to the gaze
  100023. */
  100024. getForwardRay(length?: number): Ray;
  100025. /**
  100026. * @hidden
  100027. * Updates the camera based on device's frame data
  100028. */
  100029. _checkInputs(): void;
  100030. /**
  100031. * Updates the poseControlled values based on the input device pose.
  100032. * @param poseData Pose coming from the device
  100033. */
  100034. updateFromDevice(poseData: DevicePose): void;
  100035. private _htmlElementAttached;
  100036. private _detachIfAttached;
  100037. /**
  100038. * WebVR's attach control will start broadcasting frames to the device.
  100039. * Note that in certain browsers (chrome for example) this function must be called
  100040. * within a user-interaction callback. Example:
  100041. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  100042. *
  100043. * @param element html element to attach the vrDevice to
  100044. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  100045. */
  100046. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  100047. /**
  100048. * Detaches the camera from the html element and disables VR
  100049. *
  100050. * @param element html element to detach from
  100051. */
  100052. detachControl(element: HTMLElement): void;
  100053. /**
  100054. * @returns the name of this class
  100055. */
  100056. getClassName(): string;
  100057. /**
  100058. * Calls resetPose on the vrDisplay
  100059. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  100060. */
  100061. resetToCurrentRotation(): void;
  100062. /**
  100063. * @hidden
  100064. * Updates the rig cameras (left and right eye)
  100065. */
  100066. _updateRigCameras(): void;
  100067. private _workingVector;
  100068. private _oneVector;
  100069. private _workingMatrix;
  100070. private updateCacheCalled;
  100071. private _correctPositionIfNotTrackPosition;
  100072. /**
  100073. * @hidden
  100074. * Updates the cached values of the camera
  100075. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  100076. */
  100077. _updateCache(ignoreParentClass?: boolean): void;
  100078. /**
  100079. * @hidden
  100080. * Get current device position in babylon world
  100081. */
  100082. _computeDevicePosition(): void;
  100083. /**
  100084. * Updates the current device position and rotation in the babylon world
  100085. */
  100086. update(): void;
  100087. /**
  100088. * @hidden
  100089. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  100090. * @returns an identity matrix
  100091. */
  100092. _getViewMatrix(): Matrix;
  100093. private _tmpMatrix;
  100094. /**
  100095. * This function is called by the two RIG cameras.
  100096. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  100097. * @hidden
  100098. */
  100099. _getWebVRViewMatrix(): Matrix;
  100100. /** @hidden */
  100101. _getWebVRProjectionMatrix(): Matrix;
  100102. private _onGamepadConnectedObserver;
  100103. private _onGamepadDisconnectedObserver;
  100104. private _updateCacheWhenTrackingDisabledObserver;
  100105. /**
  100106. * Initializes the controllers and their meshes
  100107. */
  100108. initControllers(): void;
  100109. }
  100110. }
  100111. declare module BABYLON {
  100112. /**
  100113. * "Static Class" containing the most commonly used helper while dealing with material for rendering purpose.
  100114. *
  100115. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  100116. *
  100117. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  100118. */
  100119. export class MaterialHelper {
  100120. /**
  100121. * Bind the current view position to an effect.
  100122. * @param effect The effect to be bound
  100123. * @param scene The scene the eyes position is used from
  100124. * @param variableName name of the shader variable that will hold the eye position
  100125. */
  100126. static BindEyePosition(effect: Effect, scene: Scene, variableName?: string): void;
  100127. /**
  100128. * Helps preparing the defines values about the UVs in used in the effect.
  100129. * UVs are shared as much as we can accross channels in the shaders.
  100130. * @param texture The texture we are preparing the UVs for
  100131. * @param defines The defines to update
  100132. * @param key The channel key "diffuse", "specular"... used in the shader
  100133. */
  100134. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  100135. /**
  100136. * Binds a texture matrix value to its corrsponding uniform
  100137. * @param texture The texture to bind the matrix for
  100138. * @param uniformBuffer The uniform buffer receivin the data
  100139. * @param key The channel key "diffuse", "specular"... used in the shader
  100140. */
  100141. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  100142. /**
  100143. * Gets the current status of the fog (should it be enabled?)
  100144. * @param mesh defines the mesh to evaluate for fog support
  100145. * @param scene defines the hosting scene
  100146. * @returns true if fog must be enabled
  100147. */
  100148. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  100149. /**
  100150. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  100151. * @param mesh defines the current mesh
  100152. * @param scene defines the current scene
  100153. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  100154. * @param pointsCloud defines if point cloud rendering has to be turned on
  100155. * @param fogEnabled defines if fog has to be turned on
  100156. * @param alphaTest defines if alpha testing has to be turned on
  100157. * @param defines defines the current list of defines
  100158. */
  100159. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  100160. /**
  100161. * Helper used to prepare the list of defines associated with frame values for shader compilation
  100162. * @param scene defines the current scene
  100163. * @param engine defines the current engine
  100164. * @param defines specifies the list of active defines
  100165. * @param useInstances defines if instances have to be turned on
  100166. * @param useClipPlane defines if clip plane have to be turned on
  100167. * @param useInstances defines if instances have to be turned on
  100168. * @param useThinInstances defines if thin instances have to be turned on
  100169. */
  100170. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>, useThinInstances?: boolean): void;
  100171. /**
  100172. * Prepares the defines for bones
  100173. * @param mesh The mesh containing the geometry data we will draw
  100174. * @param defines The defines to update
  100175. */
  100176. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  100177. /**
  100178. * Prepares the defines for morph targets
  100179. * @param mesh The mesh containing the geometry data we will draw
  100180. * @param defines The defines to update
  100181. */
  100182. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  100183. /**
  100184. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  100185. * @param mesh The mesh containing the geometry data we will draw
  100186. * @param defines The defines to update
  100187. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  100188. * @param useBones Precise whether bones should be used or not (override mesh info)
  100189. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  100190. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  100191. * @returns false if defines are considered not dirty and have not been checked
  100192. */
  100193. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  100194. /**
  100195. * Prepares the defines related to multiview
  100196. * @param scene The scene we are intending to draw
  100197. * @param defines The defines to update
  100198. */
  100199. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  100200. /**
  100201. * Prepares the defines related to the prepass
  100202. * @param scene The scene we are intending to draw
  100203. * @param defines The defines to update
  100204. * @param canRenderToMRT Indicates if this material renders to several textures in the prepass
  100205. */
  100206. static PrepareDefinesForPrePass(scene: Scene, defines: any, canRenderToMRT: boolean): void;
  100207. /**
  100208. * Prepares the defines related to the light information passed in parameter
  100209. * @param scene The scene we are intending to draw
  100210. * @param mesh The mesh the effect is compiling for
  100211. * @param light The light the effect is compiling for
  100212. * @param lightIndex The index of the light
  100213. * @param defines The defines to update
  100214. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  100215. * @param state Defines the current state regarding what is needed (normals, etc...)
  100216. */
  100217. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  100218. needNormals: boolean;
  100219. needRebuild: boolean;
  100220. shadowEnabled: boolean;
  100221. specularEnabled: boolean;
  100222. lightmapMode: boolean;
  100223. }): void;
  100224. /**
  100225. * Prepares the defines related to the light information passed in parameter
  100226. * @param scene The scene we are intending to draw
  100227. * @param mesh The mesh the effect is compiling for
  100228. * @param defines The defines to update
  100229. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  100230. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  100231. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  100232. * @returns true if normals will be required for the rest of the effect
  100233. */
  100234. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  100235. /**
  100236. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  100237. * @param lightIndex defines the light index
  100238. * @param uniformsList The uniform list
  100239. * @param samplersList The sampler list
  100240. * @param projectedLightTexture defines if projected texture must be used
  100241. * @param uniformBuffersList defines an optional list of uniform buffers
  100242. */
  100243. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  100244. /**
  100245. * Prepares the uniforms and samplers list to be used in the effect
  100246. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  100247. * @param samplersList The sampler list
  100248. * @param defines The defines helping in the list generation
  100249. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  100250. */
  100251. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  100252. /**
  100253. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  100254. * @param defines The defines to update while falling back
  100255. * @param fallbacks The authorized effect fallbacks
  100256. * @param maxSimultaneousLights The maximum number of lights allowed
  100257. * @param rank the current rank of the Effect
  100258. * @returns The newly affected rank
  100259. */
  100260. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  100261. private static _TmpMorphInfluencers;
  100262. /**
  100263. * Prepares the list of attributes required for morph targets according to the effect defines.
  100264. * @param attribs The current list of supported attribs
  100265. * @param mesh The mesh to prepare the morph targets attributes for
  100266. * @param influencers The number of influencers
  100267. */
  100268. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  100269. /**
  100270. * Prepares the list of attributes required for morph targets according to the effect defines.
  100271. * @param attribs The current list of supported attribs
  100272. * @param mesh The mesh to prepare the morph targets attributes for
  100273. * @param defines The current Defines of the effect
  100274. */
  100275. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  100276. /**
  100277. * Prepares the list of attributes required for bones according to the effect defines.
  100278. * @param attribs The current list of supported attribs
  100279. * @param mesh The mesh to prepare the bones attributes for
  100280. * @param defines The current Defines of the effect
  100281. * @param fallbacks The current efffect fallback strategy
  100282. */
  100283. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  100284. /**
  100285. * Check and prepare the list of attributes required for instances according to the effect defines.
  100286. * @param attribs The current list of supported attribs
  100287. * @param defines The current MaterialDefines of the effect
  100288. */
  100289. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  100290. /**
  100291. * Add the list of attributes required for instances to the attribs array.
  100292. * @param attribs The current list of supported attribs
  100293. */
  100294. static PushAttributesForInstances(attribs: string[]): void;
  100295. /**
  100296. * Binds the light information to the effect.
  100297. * @param light The light containing the generator
  100298. * @param effect The effect we are binding the data to
  100299. * @param lightIndex The light index in the effect used to render
  100300. */
  100301. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  100302. /**
  100303. * Binds the lights information from the scene to the effect for the given mesh.
  100304. * @param light Light to bind
  100305. * @param lightIndex Light index
  100306. * @param scene The scene where the light belongs to
  100307. * @param effect The effect we are binding the data to
  100308. * @param useSpecular Defines if specular is supported
  100309. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  100310. */
  100311. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  100312. /**
  100313. * Binds the lights information from the scene to the effect for the given mesh.
  100314. * @param scene The scene the lights belongs to
  100315. * @param mesh The mesh we are binding the information to render
  100316. * @param effect The effect we are binding the data to
  100317. * @param defines The generated defines for the effect
  100318. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  100319. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  100320. */
  100321. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  100322. private static _tempFogColor;
  100323. /**
  100324. * Binds the fog information from the scene to the effect for the given mesh.
  100325. * @param scene The scene the lights belongs to
  100326. * @param mesh The mesh we are binding the information to render
  100327. * @param effect The effect we are binding the data to
  100328. * @param linearSpace Defines if the fog effect is applied in linear space
  100329. */
  100330. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  100331. /**
  100332. * Binds the bones information from the mesh to the effect.
  100333. * @param mesh The mesh we are binding the information to render
  100334. * @param effect The effect we are binding the data to
  100335. */
  100336. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  100337. /**
  100338. * Binds the morph targets information from the mesh to the effect.
  100339. * @param abstractMesh The mesh we are binding the information to render
  100340. * @param effect The effect we are binding the data to
  100341. */
  100342. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  100343. /**
  100344. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  100345. * @param defines The generated defines used in the effect
  100346. * @param effect The effect we are binding the data to
  100347. * @param scene The scene we are willing to render with logarithmic scale for
  100348. */
  100349. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  100350. /**
  100351. * Binds the clip plane information from the scene to the effect.
  100352. * @param scene The scene the clip plane information are extracted from
  100353. * @param effect The effect we are binding the data to
  100354. */
  100355. static BindClipPlane(effect: Effect, scene: Scene): void;
  100356. }
  100357. }
  100358. declare module BABYLON {
  100359. /**
  100360. * Block used to expose an input value
  100361. */
  100362. export class InputBlock extends NodeMaterialBlock {
  100363. private _mode;
  100364. private _associatedVariableName;
  100365. private _storedValue;
  100366. private _valueCallback;
  100367. private _type;
  100368. private _animationType;
  100369. /** Gets or set a value used to limit the range of float values */
  100370. min: number;
  100371. /** Gets or set a value used to limit the range of float values */
  100372. max: number;
  100373. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  100374. isBoolean: boolean;
  100375. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  100376. matrixMode: number;
  100377. /** @hidden */
  100378. _systemValue: Nullable<NodeMaterialSystemValues>;
  100379. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  100380. isConstant: boolean;
  100381. /** Gets or sets the group to use to display this block in the Inspector */
  100382. groupInInspector: string;
  100383. /** Gets an observable raised when the value is changed */
  100384. onValueChangedObservable: Observable<InputBlock>;
  100385. /**
  100386. * Gets or sets the connection point type (default is float)
  100387. */
  100388. get type(): NodeMaterialBlockConnectionPointTypes;
  100389. /**
  100390. * Creates a new InputBlock
  100391. * @param name defines the block name
  100392. * @param target defines the target of that block (Vertex by default)
  100393. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  100394. */
  100395. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  100396. /**
  100397. * Validates if a name is a reserve word.
  100398. * @param newName the new name to be given to the node.
  100399. * @returns false if the name is a reserve word, else true.
  100400. */
  100401. validateBlockName(newName: string): boolean;
  100402. /**
  100403. * Gets the output component
  100404. */
  100405. get output(): NodeMaterialConnectionPoint;
  100406. /**
  100407. * Set the source of this connection point to a vertex attribute
  100408. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  100409. * @returns the current connection point
  100410. */
  100411. setAsAttribute(attributeName?: string): InputBlock;
  100412. /**
  100413. * Set the source of this connection point to a system value
  100414. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  100415. * @returns the current connection point
  100416. */
  100417. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  100418. /**
  100419. * Gets or sets the value of that point.
  100420. * Please note that this value will be ignored if valueCallback is defined
  100421. */
  100422. get value(): any;
  100423. set value(value: any);
  100424. /**
  100425. * Gets or sets a callback used to get the value of that point.
  100426. * Please note that setting this value will force the connection point to ignore the value property
  100427. */
  100428. get valueCallback(): () => any;
  100429. set valueCallback(value: () => any);
  100430. /**
  100431. * Gets or sets the associated variable name in the shader
  100432. */
  100433. get associatedVariableName(): string;
  100434. set associatedVariableName(value: string);
  100435. /** Gets or sets the type of animation applied to the input */
  100436. get animationType(): AnimatedInputBlockTypes;
  100437. set animationType(value: AnimatedInputBlockTypes);
  100438. /**
  100439. * Gets a boolean indicating that this connection point not defined yet
  100440. */
  100441. get isUndefined(): boolean;
  100442. /**
  100443. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  100444. * In this case the connection point name must be the name of the uniform to use.
  100445. * Can only be set on inputs
  100446. */
  100447. get isUniform(): boolean;
  100448. set isUniform(value: boolean);
  100449. /**
  100450. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  100451. * In this case the connection point name must be the name of the attribute to use
  100452. * Can only be set on inputs
  100453. */
  100454. get isAttribute(): boolean;
  100455. set isAttribute(value: boolean);
  100456. /**
  100457. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  100458. * Can only be set on exit points
  100459. */
  100460. get isVarying(): boolean;
  100461. set isVarying(value: boolean);
  100462. /**
  100463. * Gets a boolean indicating that the current connection point is a system value
  100464. */
  100465. get isSystemValue(): boolean;
  100466. /**
  100467. * Gets or sets the current well known value or null if not defined as a system value
  100468. */
  100469. get systemValue(): Nullable<NodeMaterialSystemValues>;
  100470. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  100471. /**
  100472. * Gets the current class name
  100473. * @returns the class name
  100474. */
  100475. getClassName(): string;
  100476. /**
  100477. * Animate the input if animationType !== None
  100478. * @param scene defines the rendering scene
  100479. */
  100480. animate(scene: Scene): void;
  100481. private _emitDefine;
  100482. initialize(state: NodeMaterialBuildState): void;
  100483. /**
  100484. * Set the input block to its default value (based on its type)
  100485. */
  100486. setDefaultValue(): void;
  100487. private _emitConstant;
  100488. /** @hidden */
  100489. get _noContextSwitch(): boolean;
  100490. private _emit;
  100491. /** @hidden */
  100492. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  100493. /** @hidden */
  100494. _transmit(effect: Effect, scene: Scene): void;
  100495. protected _buildBlock(state: NodeMaterialBuildState): void;
  100496. protected _dumpPropertiesCode(): string;
  100497. dispose(): void;
  100498. serialize(): any;
  100499. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  100500. }
  100501. }
  100502. declare module BABYLON {
  100503. /**
  100504. * Enum used to define the compatibility state between two connection points
  100505. */
  100506. export enum NodeMaterialConnectionPointCompatibilityStates {
  100507. /** Points are compatibles */
  100508. Compatible = 0,
  100509. /** Points are incompatible because of their types */
  100510. TypeIncompatible = 1,
  100511. /** Points are incompatible because of their targets (vertex vs fragment) */
  100512. TargetIncompatible = 2
  100513. }
  100514. /**
  100515. * Defines the direction of a connection point
  100516. */
  100517. export enum NodeMaterialConnectionPointDirection {
  100518. /** Input */
  100519. Input = 0,
  100520. /** Output */
  100521. Output = 1
  100522. }
  100523. /**
  100524. * Defines a connection point for a block
  100525. */
  100526. export class NodeMaterialConnectionPoint {
  100527. /** @hidden */
  100528. _ownerBlock: NodeMaterialBlock;
  100529. /** @hidden */
  100530. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  100531. private _endpoints;
  100532. private _associatedVariableName;
  100533. private _direction;
  100534. /** @hidden */
  100535. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  100536. /** @hidden */
  100537. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  100538. private _type;
  100539. /** @hidden */
  100540. _enforceAssociatedVariableName: boolean;
  100541. /** Gets the direction of the point */
  100542. get direction(): NodeMaterialConnectionPointDirection;
  100543. /** Indicates that this connection point needs dual validation before being connected to another point */
  100544. needDualDirectionValidation: boolean;
  100545. /**
  100546. * Gets or sets the additional types supported by this connection point
  100547. */
  100548. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  100549. /**
  100550. * Gets or sets the additional types excluded by this connection point
  100551. */
  100552. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  100553. /**
  100554. * Observable triggered when this point is connected
  100555. */
  100556. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  100557. /**
  100558. * Gets or sets the associated variable name in the shader
  100559. */
  100560. get associatedVariableName(): string;
  100561. set associatedVariableName(value: string);
  100562. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  100563. get innerType(): NodeMaterialBlockConnectionPointTypes;
  100564. /**
  100565. * Gets or sets the connection point type (default is float)
  100566. */
  100567. get type(): NodeMaterialBlockConnectionPointTypes;
  100568. set type(value: NodeMaterialBlockConnectionPointTypes);
  100569. /**
  100570. * Gets or sets the connection point name
  100571. */
  100572. name: string;
  100573. /**
  100574. * Gets or sets the connection point name
  100575. */
  100576. displayName: string;
  100577. /**
  100578. * Gets or sets a boolean indicating that this connection point can be omitted
  100579. */
  100580. isOptional: boolean;
  100581. /**
  100582. * Gets or sets a boolean indicating that this connection point is exposed on a frame
  100583. */
  100584. isExposedOnFrame: boolean;
  100585. /**
  100586. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  100587. */
  100588. define: string;
  100589. /** @hidden */
  100590. _prioritizeVertex: boolean;
  100591. private _target;
  100592. /** Gets or sets the target of that connection point */
  100593. get target(): NodeMaterialBlockTargets;
  100594. set target(value: NodeMaterialBlockTargets);
  100595. /**
  100596. * Gets a boolean indicating that the current point is connected to another NodeMaterialBlock
  100597. */
  100598. get isConnected(): boolean;
  100599. /**
  100600. * Gets a boolean indicating that the current point is connected to an input block
  100601. */
  100602. get isConnectedToInputBlock(): boolean;
  100603. /**
  100604. * Gets a the connected input block (if any)
  100605. */
  100606. get connectInputBlock(): Nullable<InputBlock>;
  100607. /** Get the other side of the connection (if any) */
  100608. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  100609. /** Get the block that owns this connection point */
  100610. get ownerBlock(): NodeMaterialBlock;
  100611. /** Get the block connected on the other side of this connection (if any) */
  100612. get sourceBlock(): Nullable<NodeMaterialBlock>;
  100613. /** Get the block connected on the endpoints of this connection (if any) */
  100614. get connectedBlocks(): Array<NodeMaterialBlock>;
  100615. /** Gets the list of connected endpoints */
  100616. get endpoints(): NodeMaterialConnectionPoint[];
  100617. /** Gets a boolean indicating if that output point is connected to at least one input */
  100618. get hasEndpoints(): boolean;
  100619. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  100620. get isConnectedInVertexShader(): boolean;
  100621. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  100622. get isConnectedInFragmentShader(): boolean;
  100623. /**
  100624. * Creates a block suitable to be used as an input for this input point.
  100625. * If null is returned, a block based on the point type will be created.
  100626. * @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
  100627. */
  100628. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  100629. /**
  100630. * Creates a new connection point
  100631. * @param name defines the connection point name
  100632. * @param ownerBlock defines the block hosting this connection point
  100633. * @param direction defines the direction of the connection point
  100634. */
  100635. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  100636. /**
  100637. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  100638. * @returns the class name
  100639. */
  100640. getClassName(): string;
  100641. /**
  100642. * Gets a boolean indicating if the current point can be connected to another point
  100643. * @param connectionPoint defines the other connection point
  100644. * @returns a boolean
  100645. */
  100646. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  100647. /**
  100648. * Gets a number indicating if the current point can be connected to another point
  100649. * @param connectionPoint defines the other connection point
  100650. * @returns a number defining the compatibility state
  100651. */
  100652. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  100653. /**
  100654. * Connect this point to another connection point
  100655. * @param connectionPoint defines the other connection point
  100656. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  100657. * @returns the current connection point
  100658. */
  100659. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  100660. /**
  100661. * Disconnect this point from one of his endpoint
  100662. * @param endpoint defines the other connection point
  100663. * @returns the current connection point
  100664. */
  100665. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  100666. /**
  100667. * Serializes this point in a JSON representation
  100668. * @param isInput defines if the connection point is an input (default is true)
  100669. * @returns the serialized point object
  100670. */
  100671. serialize(isInput?: boolean): any;
  100672. /**
  100673. * Release resources
  100674. */
  100675. dispose(): void;
  100676. }
  100677. }
  100678. declare module BABYLON {
  100679. /**
  100680. * Enum used to define the material modes
  100681. */
  100682. export enum NodeMaterialModes {
  100683. /** Regular material */
  100684. Material = 0,
  100685. /** For post process */
  100686. PostProcess = 1,
  100687. /** For particle system */
  100688. Particle = 2,
  100689. /** For procedural texture */
  100690. ProceduralTexture = 3
  100691. }
  100692. }
  100693. declare module BABYLON {
  100694. /**
  100695. * Block used to read a texture from a sampler
  100696. */
  100697. export class TextureBlock extends NodeMaterialBlock {
  100698. private _defineName;
  100699. private _linearDefineName;
  100700. private _gammaDefineName;
  100701. private _tempTextureRead;
  100702. private _samplerName;
  100703. private _transformedUVName;
  100704. private _textureTransformName;
  100705. private _textureInfoName;
  100706. private _mainUVName;
  100707. private _mainUVDefineName;
  100708. private _fragmentOnly;
  100709. /**
  100710. * Gets or sets the texture associated with the node
  100711. */
  100712. texture: Nullable<Texture>;
  100713. /**
  100714. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  100715. */
  100716. convertToGammaSpace: boolean;
  100717. /**
  100718. * Gets or sets a boolean indicating if content needs to be converted to linear space
  100719. */
  100720. convertToLinearSpace: boolean;
  100721. /**
  100722. * Create a new TextureBlock
  100723. * @param name defines the block name
  100724. */
  100725. constructor(name: string, fragmentOnly?: boolean);
  100726. /**
  100727. * Gets the current class name
  100728. * @returns the class name
  100729. */
  100730. getClassName(): string;
  100731. /**
  100732. * Gets the uv input component
  100733. */
  100734. get uv(): NodeMaterialConnectionPoint;
  100735. /**
  100736. * Gets the rgba output component
  100737. */
  100738. get rgba(): NodeMaterialConnectionPoint;
  100739. /**
  100740. * Gets the rgb output component
  100741. */
  100742. get rgb(): NodeMaterialConnectionPoint;
  100743. /**
  100744. * Gets the r output component
  100745. */
  100746. get r(): NodeMaterialConnectionPoint;
  100747. /**
  100748. * Gets the g output component
  100749. */
  100750. get g(): NodeMaterialConnectionPoint;
  100751. /**
  100752. * Gets the b output component
  100753. */
  100754. get b(): NodeMaterialConnectionPoint;
  100755. /**
  100756. * Gets the a output component
  100757. */
  100758. get a(): NodeMaterialConnectionPoint;
  100759. get target(): NodeMaterialBlockTargets;
  100760. autoConfigure(material: NodeMaterial): void;
  100761. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  100762. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  100763. isReady(): boolean;
  100764. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  100765. private get _isMixed();
  100766. private _injectVertexCode;
  100767. private _writeTextureRead;
  100768. private _writeOutput;
  100769. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  100770. protected _dumpPropertiesCode(): string;
  100771. serialize(): any;
  100772. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  100773. }
  100774. }
  100775. declare module BABYLON {
  100776. /** @hidden */
  100777. export var reflectionFunction: {
  100778. name: string;
  100779. shader: string;
  100780. };
  100781. }
  100782. declare module BABYLON {
  100783. /**
  100784. * Base block used to read a reflection texture from a sampler
  100785. */
  100786. export abstract class ReflectionTextureBaseBlock extends NodeMaterialBlock {
  100787. /** @hidden */
  100788. _define3DName: string;
  100789. /** @hidden */
  100790. _defineCubicName: string;
  100791. /** @hidden */
  100792. _defineExplicitName: string;
  100793. /** @hidden */
  100794. _defineProjectionName: string;
  100795. /** @hidden */
  100796. _defineLocalCubicName: string;
  100797. /** @hidden */
  100798. _defineSphericalName: string;
  100799. /** @hidden */
  100800. _definePlanarName: string;
  100801. /** @hidden */
  100802. _defineEquirectangularName: string;
  100803. /** @hidden */
  100804. _defineMirroredEquirectangularFixedName: string;
  100805. /** @hidden */
  100806. _defineEquirectangularFixedName: string;
  100807. /** @hidden */
  100808. _defineSkyboxName: string;
  100809. /** @hidden */
  100810. _defineOppositeZ: string;
  100811. /** @hidden */
  100812. _cubeSamplerName: string;
  100813. /** @hidden */
  100814. _2DSamplerName: string;
  100815. protected _positionUVWName: string;
  100816. protected _directionWName: string;
  100817. protected _reflectionVectorName: string;
  100818. /** @hidden */
  100819. _reflectionCoordsName: string;
  100820. /** @hidden */
  100821. _reflectionMatrixName: string;
  100822. protected _reflectionColorName: string;
  100823. /**
  100824. * Gets or sets the texture associated with the node
  100825. */
  100826. texture: Nullable<BaseTexture>;
  100827. /**
  100828. * Create a new ReflectionTextureBaseBlock
  100829. * @param name defines the block name
  100830. */
  100831. constructor(name: string);
  100832. /**
  100833. * Gets the current class name
  100834. * @returns the class name
  100835. */
  100836. getClassName(): string;
  100837. /**
  100838. * Gets the world position input component
  100839. */
  100840. abstract get position(): NodeMaterialConnectionPoint;
  100841. /**
  100842. * Gets the world position input component
  100843. */
  100844. abstract get worldPosition(): NodeMaterialConnectionPoint;
  100845. /**
  100846. * Gets the world normal input component
  100847. */
  100848. abstract get worldNormal(): NodeMaterialConnectionPoint;
  100849. /**
  100850. * Gets the world input component
  100851. */
  100852. abstract get world(): NodeMaterialConnectionPoint;
  100853. /**
  100854. * Gets the camera (or eye) position component
  100855. */
  100856. abstract get cameraPosition(): NodeMaterialConnectionPoint;
  100857. /**
  100858. * Gets the view input component
  100859. */
  100860. abstract get view(): NodeMaterialConnectionPoint;
  100861. protected _getTexture(): Nullable<BaseTexture>;
  100862. autoConfigure(material: NodeMaterial): void;
  100863. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  100864. isReady(): boolean;
  100865. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  100866. /**
  100867. * Gets the code to inject in the vertex shader
  100868. * @param state current state of the node material building
  100869. * @returns the shader code
  100870. */
  100871. handleVertexSide(state: NodeMaterialBuildState): string;
  100872. /**
  100873. * Handles the inits for the fragment code path
  100874. * @param state node material build state
  100875. */
  100876. handleFragmentSideInits(state: NodeMaterialBuildState): void;
  100877. /**
  100878. * Generates the reflection coords code for the fragment code path
  100879. * @param worldNormalVarName name of the world normal variable
  100880. * @param worldPos name of the world position variable. If not provided, will use the world position connected to this block
  100881. * @param onlyReflectionVector if true, generates code only for the reflection vector computation, not for the reflection coordinates
  100882. * @returns the shader code
  100883. */
  100884. handleFragmentSideCodeReflectionCoords(worldNormalVarName: string, worldPos?: string, onlyReflectionVector?: boolean): string;
  100885. /**
  100886. * Generates the reflection color code for the fragment code path
  100887. * @param lodVarName name of the lod variable
  100888. * @param swizzleLookupTexture swizzle to use for the final color variable
  100889. * @returns the shader code
  100890. */
  100891. handleFragmentSideCodeReflectionColor(lodVarName?: string, swizzleLookupTexture?: string): string;
  100892. /**
  100893. * Generates the code corresponding to the connected output points
  100894. * @param state node material build state
  100895. * @param varName name of the variable to output
  100896. * @returns the shader code
  100897. */
  100898. writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  100899. protected _buildBlock(state: NodeMaterialBuildState): this;
  100900. protected _dumpPropertiesCode(): string;
  100901. serialize(): any;
  100902. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  100903. }
  100904. }
  100905. declare module BABYLON {
  100906. /**
  100907. * Defines a connection point to be used for points with a custom object type
  100908. */
  100909. export class NodeMaterialConnectionPointCustomObject<T extends NodeMaterialBlock> extends NodeMaterialConnectionPoint {
  100910. private _blockType;
  100911. private _blockName;
  100912. private _nameForCheking?;
  100913. /**
  100914. * Creates a new connection point
  100915. * @param name defines the connection point name
  100916. * @param ownerBlock defines the block hosting this connection point
  100917. * @param direction defines the direction of the connection point
  100918. */
  100919. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection, _blockType: new (...args: any[]) => T, _blockName: string, _nameForCheking?: string | undefined);
  100920. /**
  100921. * Gets a number indicating if the current point can be connected to another point
  100922. * @param connectionPoint defines the other connection point
  100923. * @returns a number defining the compatibility state
  100924. */
  100925. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  100926. /**
  100927. * Creates a block suitable to be used as an input for this input point.
  100928. * If null is returned, a block based on the point type will be created.
  100929. * @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
  100930. */
  100931. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  100932. }
  100933. }
  100934. declare module BABYLON {
  100935. /**
  100936. * Enum defining the type of properties that can be edited in the property pages in the NME
  100937. */
  100938. export enum PropertyTypeForEdition {
  100939. /** property is a boolean */
  100940. Boolean = 0,
  100941. /** property is a float */
  100942. Float = 1,
  100943. /** property is a Vector2 */
  100944. Vector2 = 2,
  100945. /** property is a list of values */
  100946. List = 3
  100947. }
  100948. /**
  100949. * Interface that defines an option in a variable of type list
  100950. */
  100951. export interface IEditablePropertyListOption {
  100952. /** label of the option */
  100953. "label": string;
  100954. /** value of the option */
  100955. "value": number;
  100956. }
  100957. /**
  100958. * Interface that defines the options available for an editable property
  100959. */
  100960. export interface IEditablePropertyOption {
  100961. /** min value */
  100962. "min"?: number;
  100963. /** max value */
  100964. "max"?: number;
  100965. /** notifiers: indicates which actions to take when the property is changed */
  100966. "notifiers"?: {
  100967. /** the material should be rebuilt */
  100968. "rebuild"?: boolean;
  100969. /** the preview should be updated */
  100970. "update"?: boolean;
  100971. };
  100972. /** list of the options for a variable of type list */
  100973. "options"?: IEditablePropertyListOption[];
  100974. }
  100975. /**
  100976. * Interface that describes an editable property
  100977. */
  100978. export interface IPropertyDescriptionForEdition {
  100979. /** name of the property */
  100980. "propertyName": string;
  100981. /** display name of the property */
  100982. "displayName": string;
  100983. /** type of the property */
  100984. "type": PropertyTypeForEdition;
  100985. /** group of the property - all properties with the same group value will be displayed in a specific section */
  100986. "groupName": string;
  100987. /** options for the property */
  100988. "options": IEditablePropertyOption;
  100989. }
  100990. /**
  100991. * Decorator that flags a property in a node material block as being editable
  100992. */
  100993. export function editableInPropertyPage(displayName: string, propertyType?: PropertyTypeForEdition, groupName?: string, options?: IEditablePropertyOption): (target: any, propertyKey: string) => void;
  100994. }
  100995. declare module BABYLON {
  100996. /**
  100997. * Block used to implement the refraction part of the sub surface module of the PBR material
  100998. */
  100999. export class RefractionBlock extends NodeMaterialBlock {
  101000. /** @hidden */
  101001. _define3DName: string;
  101002. /** @hidden */
  101003. _refractionMatrixName: string;
  101004. /** @hidden */
  101005. _defineLODRefractionAlpha: string;
  101006. /** @hidden */
  101007. _defineLinearSpecularRefraction: string;
  101008. /** @hidden */
  101009. _defineOppositeZ: string;
  101010. /** @hidden */
  101011. _cubeSamplerName: string;
  101012. /** @hidden */
  101013. _2DSamplerName: string;
  101014. /** @hidden */
  101015. _vRefractionMicrosurfaceInfosName: string;
  101016. /** @hidden */
  101017. _vRefractionInfosName: string;
  101018. private _scene;
  101019. /**
  101020. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  101021. * Materials half opaque for instance using refraction could benefit from this control.
  101022. */
  101023. linkRefractionWithTransparency: boolean;
  101024. /**
  101025. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  101026. */
  101027. invertRefractionY: boolean;
  101028. /**
  101029. * Gets or sets the texture associated with the node
  101030. */
  101031. texture: Nullable<BaseTexture>;
  101032. /**
  101033. * Create a new RefractionBlock
  101034. * @param name defines the block name
  101035. */
  101036. constructor(name: string);
  101037. /**
  101038. * Gets the current class name
  101039. * @returns the class name
  101040. */
  101041. getClassName(): string;
  101042. /**
  101043. * Gets the intensity input component
  101044. */
  101045. get intensity(): NodeMaterialConnectionPoint;
  101046. /**
  101047. * Gets the index of refraction input component
  101048. */
  101049. get indexOfRefraction(): NodeMaterialConnectionPoint;
  101050. /**
  101051. * Gets the tint at distance input component
  101052. */
  101053. get tintAtDistance(): NodeMaterialConnectionPoint;
  101054. /**
  101055. * Gets the view input component
  101056. */
  101057. get view(): NodeMaterialConnectionPoint;
  101058. /**
  101059. * Gets the refraction object output component
  101060. */
  101061. get refraction(): NodeMaterialConnectionPoint;
  101062. /**
  101063. * Returns true if the block has a texture
  101064. */
  101065. get hasTexture(): boolean;
  101066. protected _getTexture(): Nullable<BaseTexture>;
  101067. autoConfigure(material: NodeMaterial): void;
  101068. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  101069. isReady(): boolean;
  101070. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  101071. /**
  101072. * Gets the main code of the block (fragment side)
  101073. * @param state current state of the node material building
  101074. * @returns the shader code
  101075. */
  101076. getCode(state: NodeMaterialBuildState): string;
  101077. protected _buildBlock(state: NodeMaterialBuildState): this;
  101078. protected _dumpPropertiesCode(): string;
  101079. serialize(): any;
  101080. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  101081. }
  101082. }
  101083. declare module BABYLON {
  101084. /**
  101085. * Base block used as input for post process
  101086. */
  101087. export class CurrentScreenBlock extends NodeMaterialBlock {
  101088. private _samplerName;
  101089. private _linearDefineName;
  101090. private _gammaDefineName;
  101091. private _mainUVName;
  101092. private _tempTextureRead;
  101093. /**
  101094. * Gets or sets the texture associated with the node
  101095. */
  101096. texture: Nullable<BaseTexture>;
  101097. /**
  101098. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  101099. */
  101100. convertToGammaSpace: boolean;
  101101. /**
  101102. * Gets or sets a boolean indicating if content needs to be converted to linear space
  101103. */
  101104. convertToLinearSpace: boolean;
  101105. /**
  101106. * Create a new CurrentScreenBlock
  101107. * @param name defines the block name
  101108. */
  101109. constructor(name: string);
  101110. /**
  101111. * Gets the current class name
  101112. * @returns the class name
  101113. */
  101114. getClassName(): string;
  101115. /**
  101116. * Gets the uv input component
  101117. */
  101118. get uv(): NodeMaterialConnectionPoint;
  101119. /**
  101120. * Gets the rgba output component
  101121. */
  101122. get rgba(): NodeMaterialConnectionPoint;
  101123. /**
  101124. * Gets the rgb output component
  101125. */
  101126. get rgb(): NodeMaterialConnectionPoint;
  101127. /**
  101128. * Gets the r output component
  101129. */
  101130. get r(): NodeMaterialConnectionPoint;
  101131. /**
  101132. * Gets the g output component
  101133. */
  101134. get g(): NodeMaterialConnectionPoint;
  101135. /**
  101136. * Gets the b output component
  101137. */
  101138. get b(): NodeMaterialConnectionPoint;
  101139. /**
  101140. * Gets the a output component
  101141. */
  101142. get a(): NodeMaterialConnectionPoint;
  101143. /**
  101144. * Initialize the block and prepare the context for build
  101145. * @param state defines the state that will be used for the build
  101146. */
  101147. initialize(state: NodeMaterialBuildState): void;
  101148. get target(): NodeMaterialBlockTargets;
  101149. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  101150. isReady(): boolean;
  101151. private _injectVertexCode;
  101152. private _writeTextureRead;
  101153. private _writeOutput;
  101154. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  101155. serialize(): any;
  101156. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  101157. }
  101158. }
  101159. declare module BABYLON {
  101160. /**
  101161. * Base block used for the particle texture
  101162. */
  101163. export class ParticleTextureBlock extends NodeMaterialBlock {
  101164. private _samplerName;
  101165. private _linearDefineName;
  101166. private _gammaDefineName;
  101167. private _tempTextureRead;
  101168. /**
  101169. * Gets or sets the texture associated with the node
  101170. */
  101171. texture: Nullable<BaseTexture>;
  101172. /**
  101173. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  101174. */
  101175. convertToGammaSpace: boolean;
  101176. /**
  101177. * Gets or sets a boolean indicating if content needs to be converted to linear space
  101178. */
  101179. convertToLinearSpace: boolean;
  101180. /**
  101181. * Create a new ParticleTextureBlock
  101182. * @param name defines the block name
  101183. */
  101184. constructor(name: string);
  101185. /**
  101186. * Gets the current class name
  101187. * @returns the class name
  101188. */
  101189. getClassName(): string;
  101190. /**
  101191. * Gets the uv input component
  101192. */
  101193. get uv(): NodeMaterialConnectionPoint;
  101194. /**
  101195. * Gets the rgba output component
  101196. */
  101197. get rgba(): NodeMaterialConnectionPoint;
  101198. /**
  101199. * Gets the rgb output component
  101200. */
  101201. get rgb(): NodeMaterialConnectionPoint;
  101202. /**
  101203. * Gets the r output component
  101204. */
  101205. get r(): NodeMaterialConnectionPoint;
  101206. /**
  101207. * Gets the g output component
  101208. */
  101209. get g(): NodeMaterialConnectionPoint;
  101210. /**
  101211. * Gets the b output component
  101212. */
  101213. get b(): NodeMaterialConnectionPoint;
  101214. /**
  101215. * Gets the a output component
  101216. */
  101217. get a(): NodeMaterialConnectionPoint;
  101218. /**
  101219. * Initialize the block and prepare the context for build
  101220. * @param state defines the state that will be used for the build
  101221. */
  101222. initialize(state: NodeMaterialBuildState): void;
  101223. autoConfigure(material: NodeMaterial): void;
  101224. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  101225. isReady(): boolean;
  101226. private _writeOutput;
  101227. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  101228. serialize(): any;
  101229. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  101230. }
  101231. }
  101232. declare module BABYLON {
  101233. /**
  101234. * Class used to store shared data between 2 NodeMaterialBuildState
  101235. */
  101236. export class NodeMaterialBuildStateSharedData {
  101237. /**
  101238. * Gets the list of emitted varyings
  101239. */
  101240. temps: string[];
  101241. /**
  101242. * Gets the list of emitted varyings
  101243. */
  101244. varyings: string[];
  101245. /**
  101246. * Gets the varying declaration string
  101247. */
  101248. varyingDeclaration: string;
  101249. /**
  101250. * Input blocks
  101251. */
  101252. inputBlocks: InputBlock[];
  101253. /**
  101254. * Input blocks
  101255. */
  101256. textureBlocks: (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  101257. /**
  101258. * Bindable blocks (Blocks that need to set data to the effect)
  101259. */
  101260. bindableBlocks: NodeMaterialBlock[];
  101261. /**
  101262. * List of blocks that can provide a compilation fallback
  101263. */
  101264. blocksWithFallbacks: NodeMaterialBlock[];
  101265. /**
  101266. * List of blocks that can provide a define update
  101267. */
  101268. blocksWithDefines: NodeMaterialBlock[];
  101269. /**
  101270. * List of blocks that can provide a repeatable content
  101271. */
  101272. repeatableContentBlocks: NodeMaterialBlock[];
  101273. /**
  101274. * List of blocks that can provide a dynamic list of uniforms
  101275. */
  101276. dynamicUniformBlocks: NodeMaterialBlock[];
  101277. /**
  101278. * List of blocks that can block the isReady function for the material
  101279. */
  101280. blockingBlocks: NodeMaterialBlock[];
  101281. /**
  101282. * Gets the list of animated inputs
  101283. */
  101284. animatedInputs: InputBlock[];
  101285. /**
  101286. * Build Id used to avoid multiple recompilations
  101287. */
  101288. buildId: number;
  101289. /** List of emitted variables */
  101290. variableNames: {
  101291. [key: string]: number;
  101292. };
  101293. /** List of emitted defines */
  101294. defineNames: {
  101295. [key: string]: number;
  101296. };
  101297. /** Should emit comments? */
  101298. emitComments: boolean;
  101299. /** Emit build activity */
  101300. verbose: boolean;
  101301. /** Gets or sets the hosting scene */
  101302. scene: Scene;
  101303. /**
  101304. * Gets the compilation hints emitted at compilation time
  101305. */
  101306. hints: {
  101307. needWorldViewMatrix: boolean;
  101308. needWorldViewProjectionMatrix: boolean;
  101309. needAlphaBlending: boolean;
  101310. needAlphaTesting: boolean;
  101311. };
  101312. /**
  101313. * List of compilation checks
  101314. */
  101315. checks: {
  101316. emitVertex: boolean;
  101317. emitFragment: boolean;
  101318. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  101319. };
  101320. /**
  101321. * Is vertex program allowed to be empty?
  101322. */
  101323. allowEmptyVertexProgram: boolean;
  101324. /** Creates a new shared data */
  101325. constructor();
  101326. /**
  101327. * Emits console errors and exceptions if there is a failing check
  101328. */
  101329. emitErrors(): void;
  101330. }
  101331. }
  101332. declare module BABYLON {
  101333. /**
  101334. * Class used to store node based material build state
  101335. */
  101336. export class NodeMaterialBuildState {
  101337. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  101338. supportUniformBuffers: boolean;
  101339. /**
  101340. * Gets the list of emitted attributes
  101341. */
  101342. attributes: string[];
  101343. /**
  101344. * Gets the list of emitted uniforms
  101345. */
  101346. uniforms: string[];
  101347. /**
  101348. * Gets the list of emitted constants
  101349. */
  101350. constants: string[];
  101351. /**
  101352. * Gets the list of emitted samplers
  101353. */
  101354. samplers: string[];
  101355. /**
  101356. * Gets the list of emitted functions
  101357. */
  101358. functions: {
  101359. [key: string]: string;
  101360. };
  101361. /**
  101362. * Gets the list of emitted extensions
  101363. */
  101364. extensions: {
  101365. [key: string]: string;
  101366. };
  101367. /**
  101368. * Gets the target of the compilation state
  101369. */
  101370. target: NodeMaterialBlockTargets;
  101371. /**
  101372. * Gets the list of emitted counters
  101373. */
  101374. counters: {
  101375. [key: string]: number;
  101376. };
  101377. /**
  101378. * Shared data between multiple NodeMaterialBuildState instances
  101379. */
  101380. sharedData: NodeMaterialBuildStateSharedData;
  101381. /** @hidden */
  101382. _vertexState: NodeMaterialBuildState;
  101383. /** @hidden */
  101384. _attributeDeclaration: string;
  101385. /** @hidden */
  101386. _uniformDeclaration: string;
  101387. /** @hidden */
  101388. _constantDeclaration: string;
  101389. /** @hidden */
  101390. _samplerDeclaration: string;
  101391. /** @hidden */
  101392. _varyingTransfer: string;
  101393. /** @hidden */
  101394. _injectAtEnd: string;
  101395. private _repeatableContentAnchorIndex;
  101396. /** @hidden */
  101397. _builtCompilationString: string;
  101398. /**
  101399. * Gets the emitted compilation strings
  101400. */
  101401. compilationString: string;
  101402. /**
  101403. * Finalize the compilation strings
  101404. * @param state defines the current compilation state
  101405. */
  101406. finalize(state: NodeMaterialBuildState): void;
  101407. /** @hidden */
  101408. get _repeatableContentAnchor(): string;
  101409. /** @hidden */
  101410. _getFreeVariableName(prefix: string): string;
  101411. /** @hidden */
  101412. _getFreeDefineName(prefix: string): string;
  101413. /** @hidden */
  101414. _excludeVariableName(name: string): void;
  101415. /** @hidden */
  101416. _emit2DSampler(name: string): void;
  101417. /** @hidden */
  101418. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  101419. /** @hidden */
  101420. _emitExtension(name: string, extension: string, define?: string): void;
  101421. /** @hidden */
  101422. _emitFunction(name: string, code: string, comments: string): void;
  101423. /** @hidden */
  101424. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  101425. replaceStrings?: {
  101426. search: RegExp;
  101427. replace: string;
  101428. }[];
  101429. repeatKey?: string;
  101430. }): string;
  101431. /** @hidden */
  101432. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  101433. repeatKey?: string;
  101434. removeAttributes?: boolean;
  101435. removeUniforms?: boolean;
  101436. removeVaryings?: boolean;
  101437. removeIfDef?: boolean;
  101438. replaceStrings?: {
  101439. search: RegExp;
  101440. replace: string;
  101441. }[];
  101442. }, storeKey?: string): void;
  101443. /** @hidden */
  101444. _registerTempVariable(name: string): boolean;
  101445. /** @hidden */
  101446. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  101447. /** @hidden */
  101448. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  101449. /** @hidden */
  101450. _emitFloat(value: number): string;
  101451. }
  101452. }
  101453. declare module BABYLON {
  101454. /**
  101455. * Helper class used to generate session unique ID
  101456. */
  101457. export class UniqueIdGenerator {
  101458. private static _UniqueIdCounter;
  101459. /**
  101460. * Gets an unique (relatively to the current scene) Id
  101461. */
  101462. static get UniqueId(): number;
  101463. }
  101464. }
  101465. declare module BABYLON {
  101466. /**
  101467. * Defines a block that can be used inside a node based material
  101468. */
  101469. export class NodeMaterialBlock {
  101470. private _buildId;
  101471. private _buildTarget;
  101472. private _target;
  101473. private _isFinalMerger;
  101474. private _isInput;
  101475. private _name;
  101476. protected _isUnique: boolean;
  101477. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  101478. inputsAreExclusive: boolean;
  101479. /** @hidden */
  101480. _codeVariableName: string;
  101481. /** @hidden */
  101482. _inputs: NodeMaterialConnectionPoint[];
  101483. /** @hidden */
  101484. _outputs: NodeMaterialConnectionPoint[];
  101485. /** @hidden */
  101486. _preparationId: number;
  101487. /**
  101488. * Gets the name of the block
  101489. */
  101490. get name(): string;
  101491. /**
  101492. * Sets the name of the block. Will check if the name is valid.
  101493. */
  101494. set name(newName: string);
  101495. /**
  101496. * Gets or sets the unique id of the node
  101497. */
  101498. uniqueId: number;
  101499. /**
  101500. * Gets or sets the comments associated with this block
  101501. */
  101502. comments: string;
  101503. /**
  101504. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  101505. */
  101506. get isUnique(): boolean;
  101507. /**
  101508. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  101509. */
  101510. get isFinalMerger(): boolean;
  101511. /**
  101512. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  101513. */
  101514. get isInput(): boolean;
  101515. /**
  101516. * Gets or sets the build Id
  101517. */
  101518. get buildId(): number;
  101519. set buildId(value: number);
  101520. /**
  101521. * Gets or sets the target of the block
  101522. */
  101523. get target(): NodeMaterialBlockTargets;
  101524. set target(value: NodeMaterialBlockTargets);
  101525. /**
  101526. * Gets the list of input points
  101527. */
  101528. get inputs(): NodeMaterialConnectionPoint[];
  101529. /** Gets the list of output points */
  101530. get outputs(): NodeMaterialConnectionPoint[];
  101531. /**
  101532. * Find an input by its name
  101533. * @param name defines the name of the input to look for
  101534. * @returns the input or null if not found
  101535. */
  101536. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  101537. /**
  101538. * Find an output by its name
  101539. * @param name defines the name of the outputto look for
  101540. * @returns the output or null if not found
  101541. */
  101542. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  101543. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  101544. visibleInInspector: boolean;
  101545. /**
  101546. * Creates a new NodeMaterialBlock
  101547. * @param name defines the block name
  101548. * @param target defines the target of that block (Vertex by default)
  101549. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  101550. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  101551. */
  101552. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  101553. /**
  101554. * Initialize the block and prepare the context for build
  101555. * @param state defines the state that will be used for the build
  101556. */
  101557. initialize(state: NodeMaterialBuildState): void;
  101558. /**
  101559. * Bind data to effect. Will only be called for blocks with isBindable === true
  101560. * @param effect defines the effect to bind data to
  101561. * @param nodeMaterial defines the hosting NodeMaterial
  101562. * @param mesh defines the mesh that will be rendered
  101563. * @param subMesh defines the submesh that will be rendered
  101564. */
  101565. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  101566. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  101567. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  101568. protected _writeFloat(value: number): string;
  101569. /**
  101570. * Gets the current class name e.g. "NodeMaterialBlock"
  101571. * @returns the class name
  101572. */
  101573. getClassName(): string;
  101574. /**
  101575. * Register a new input. Must be called inside a block constructor
  101576. * @param name defines the connection point name
  101577. * @param type defines the connection point type
  101578. * @param isOptional defines a boolean indicating that this input can be omitted
  101579. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  101580. * @param point an already created connection point. If not provided, create a new one
  101581. * @returns the current block
  101582. */
  101583. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  101584. /**
  101585. * Register a new output. Must be called inside a block constructor
  101586. * @param name defines the connection point name
  101587. * @param type defines the connection point type
  101588. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  101589. * @param point an already created connection point. If not provided, create a new one
  101590. * @returns the current block
  101591. */
  101592. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  101593. /**
  101594. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  101595. * @param forOutput defines an optional connection point to check compatibility with
  101596. * @returns the first available input or null
  101597. */
  101598. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  101599. /**
  101600. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  101601. * @param forBlock defines an optional block to check compatibility with
  101602. * @returns the first available input or null
  101603. */
  101604. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  101605. /**
  101606. * Gets the sibling of the given output
  101607. * @param current defines the current output
  101608. * @returns the next output in the list or null
  101609. */
  101610. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  101611. /**
  101612. * Connect current block with another block
  101613. * @param other defines the block to connect with
  101614. * @param options define the various options to help pick the right connections
  101615. * @returns the current block
  101616. */
  101617. connectTo(other: NodeMaterialBlock, options?: {
  101618. input?: string;
  101619. output?: string;
  101620. outputSwizzle?: string;
  101621. }): this | undefined;
  101622. protected _buildBlock(state: NodeMaterialBuildState): void;
  101623. /**
  101624. * Add uniforms, samplers and uniform buffers at compilation time
  101625. * @param state defines the state to update
  101626. * @param nodeMaterial defines the node material requesting the update
  101627. * @param defines defines the material defines to update
  101628. * @param uniformBuffers defines the list of uniform buffer names
  101629. */
  101630. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  101631. /**
  101632. * Add potential fallbacks if shader compilation fails
  101633. * @param mesh defines the mesh to be rendered
  101634. * @param fallbacks defines the current prioritized list of fallbacks
  101635. */
  101636. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  101637. /**
  101638. * Initialize defines for shader compilation
  101639. * @param mesh defines the mesh to be rendered
  101640. * @param nodeMaterial defines the node material requesting the update
  101641. * @param defines defines the material defines to update
  101642. * @param useInstances specifies that instances should be used
  101643. */
  101644. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  101645. /**
  101646. * Update defines for shader compilation
  101647. * @param mesh defines the mesh to be rendered
  101648. * @param nodeMaterial defines the node material requesting the update
  101649. * @param defines defines the material defines to update
  101650. * @param useInstances specifies that instances should be used
  101651. * @param subMesh defines which submesh to render
  101652. */
  101653. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  101654. /**
  101655. * Lets the block try to connect some inputs automatically
  101656. * @param material defines the hosting NodeMaterial
  101657. */
  101658. autoConfigure(material: NodeMaterial): void;
  101659. /**
  101660. * Function called when a block is declared as repeatable content generator
  101661. * @param vertexShaderState defines the current compilation state for the vertex shader
  101662. * @param fragmentShaderState defines the current compilation state for the fragment shader
  101663. * @param mesh defines the mesh to be rendered
  101664. * @param defines defines the material defines to update
  101665. */
  101666. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  101667. /**
  101668. * Checks if the block is ready
  101669. * @param mesh defines the mesh to be rendered
  101670. * @param nodeMaterial defines the node material requesting the update
  101671. * @param defines defines the material defines to update
  101672. * @param useInstances specifies that instances should be used
  101673. * @returns true if the block is ready
  101674. */
  101675. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  101676. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  101677. private _processBuild;
  101678. /**
  101679. * Validates the new name for the block node.
  101680. * @param newName the new name to be given to the node.
  101681. * @returns false if the name is a reserve word, else true.
  101682. */
  101683. validateBlockName(newName: string): boolean;
  101684. /**
  101685. * Compile the current node and generate the shader code
  101686. * @param state defines the current compilation state (uniforms, samplers, current string)
  101687. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  101688. * @returns true if already built
  101689. */
  101690. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  101691. protected _inputRename(name: string): string;
  101692. protected _outputRename(name: string): string;
  101693. protected _dumpPropertiesCode(): string;
  101694. /** @hidden */
  101695. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  101696. /** @hidden */
  101697. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  101698. /**
  101699. * Clone the current block to a new identical block
  101700. * @param scene defines the hosting scene
  101701. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  101702. * @returns a copy of the current block
  101703. */
  101704. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  101705. /**
  101706. * Serializes this block in a JSON representation
  101707. * @returns the serialized block object
  101708. */
  101709. serialize(): any;
  101710. /** @hidden */
  101711. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  101712. private _deserializePortDisplayNamesAndExposedOnFrame;
  101713. /**
  101714. * Release resources
  101715. */
  101716. dispose(): void;
  101717. }
  101718. }
  101719. declare module BABYLON {
  101720. /**
  101721. * Base class of materials working in push mode in babylon JS
  101722. * @hidden
  101723. */
  101724. export class PushMaterial extends Material {
  101725. protected _activeEffect: Effect;
  101726. protected _normalMatrix: Matrix;
  101727. constructor(name: string, scene: Scene);
  101728. getEffect(): Effect;
  101729. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  101730. protected _isReadyForSubMesh(subMesh: SubMesh): boolean;
  101731. /**
  101732. * Binds the given world matrix to the active effect
  101733. *
  101734. * @param world the matrix to bind
  101735. */
  101736. bindOnlyWorldMatrix(world: Matrix): void;
  101737. /**
  101738. * Binds the given normal matrix to the active effect
  101739. *
  101740. * @param normalMatrix the matrix to bind
  101741. */
  101742. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  101743. bind(world: Matrix, mesh?: Mesh): void;
  101744. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  101745. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  101746. }
  101747. }
  101748. declare module BABYLON {
  101749. /**
  101750. * Root class for all node material optimizers
  101751. */
  101752. export class NodeMaterialOptimizer {
  101753. /**
  101754. * Function used to optimize a NodeMaterial graph
  101755. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  101756. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  101757. */
  101758. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  101759. }
  101760. }
  101761. declare module BABYLON {
  101762. /**
  101763. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  101764. */
  101765. export class TransformBlock extends NodeMaterialBlock {
  101766. /**
  101767. * Defines the value to use to complement W value to transform it to a Vector4
  101768. */
  101769. complementW: number;
  101770. /**
  101771. * Defines the value to use to complement z value to transform it to a Vector4
  101772. */
  101773. complementZ: number;
  101774. /**
  101775. * Creates a new TransformBlock
  101776. * @param name defines the block name
  101777. */
  101778. constructor(name: string);
  101779. /**
  101780. * Gets the current class name
  101781. * @returns the class name
  101782. */
  101783. getClassName(): string;
  101784. /**
  101785. * Gets the vector input
  101786. */
  101787. get vector(): NodeMaterialConnectionPoint;
  101788. /**
  101789. * Gets the output component
  101790. */
  101791. get output(): NodeMaterialConnectionPoint;
  101792. /**
  101793. * Gets the xyz output component
  101794. */
  101795. get xyz(): NodeMaterialConnectionPoint;
  101796. /**
  101797. * Gets the matrix transform input
  101798. */
  101799. get transform(): NodeMaterialConnectionPoint;
  101800. protected _buildBlock(state: NodeMaterialBuildState): this;
  101801. /**
  101802. * Update defines for shader compilation
  101803. * @param mesh defines the mesh to be rendered
  101804. * @param nodeMaterial defines the node material requesting the update
  101805. * @param defines defines the material defines to update
  101806. * @param useInstances specifies that instances should be used
  101807. * @param subMesh defines which submesh to render
  101808. */
  101809. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  101810. serialize(): any;
  101811. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  101812. protected _dumpPropertiesCode(): string;
  101813. }
  101814. }
  101815. declare module BABYLON {
  101816. /**
  101817. * Block used to output the vertex position
  101818. */
  101819. export class VertexOutputBlock extends NodeMaterialBlock {
  101820. /**
  101821. * Creates a new VertexOutputBlock
  101822. * @param name defines the block name
  101823. */
  101824. constructor(name: string);
  101825. /**
  101826. * Gets the current class name
  101827. * @returns the class name
  101828. */
  101829. getClassName(): string;
  101830. /**
  101831. * Gets the vector input component
  101832. */
  101833. get vector(): NodeMaterialConnectionPoint;
  101834. protected _buildBlock(state: NodeMaterialBuildState): this;
  101835. }
  101836. }
  101837. declare module BABYLON {
  101838. /**
  101839. * Block used to output the final color
  101840. */
  101841. export class FragmentOutputBlock extends NodeMaterialBlock {
  101842. /**
  101843. * Create a new FragmentOutputBlock
  101844. * @param name defines the block name
  101845. */
  101846. constructor(name: string);
  101847. /**
  101848. * Gets the current class name
  101849. * @returns the class name
  101850. */
  101851. getClassName(): string;
  101852. /**
  101853. * Gets the rgba input component
  101854. */
  101855. get rgba(): NodeMaterialConnectionPoint;
  101856. /**
  101857. * Gets the rgb input component
  101858. */
  101859. get rgb(): NodeMaterialConnectionPoint;
  101860. /**
  101861. * Gets the a input component
  101862. */
  101863. get a(): NodeMaterialConnectionPoint;
  101864. protected _buildBlock(state: NodeMaterialBuildState): this;
  101865. }
  101866. }
  101867. declare module BABYLON {
  101868. /**
  101869. * Block used for the particle ramp gradient section
  101870. */
  101871. export class ParticleRampGradientBlock extends NodeMaterialBlock {
  101872. /**
  101873. * Create a new ParticleRampGradientBlock
  101874. * @param name defines the block name
  101875. */
  101876. constructor(name: string);
  101877. /**
  101878. * Gets the current class name
  101879. * @returns the class name
  101880. */
  101881. getClassName(): string;
  101882. /**
  101883. * Gets the color input component
  101884. */
  101885. get color(): NodeMaterialConnectionPoint;
  101886. /**
  101887. * Gets the rampColor output component
  101888. */
  101889. get rampColor(): NodeMaterialConnectionPoint;
  101890. /**
  101891. * Initialize the block and prepare the context for build
  101892. * @param state defines the state that will be used for the build
  101893. */
  101894. initialize(state: NodeMaterialBuildState): void;
  101895. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  101896. }
  101897. }
  101898. declare module BABYLON {
  101899. /**
  101900. * Block used for the particle blend multiply section
  101901. */
  101902. export class ParticleBlendMultiplyBlock extends NodeMaterialBlock {
  101903. /**
  101904. * Create a new ParticleBlendMultiplyBlock
  101905. * @param name defines the block name
  101906. */
  101907. constructor(name: string);
  101908. /**
  101909. * Gets the current class name
  101910. * @returns the class name
  101911. */
  101912. getClassName(): string;
  101913. /**
  101914. * Gets the color input component
  101915. */
  101916. get color(): NodeMaterialConnectionPoint;
  101917. /**
  101918. * Gets the alphaTexture input component
  101919. */
  101920. get alphaTexture(): NodeMaterialConnectionPoint;
  101921. /**
  101922. * Gets the alphaColor input component
  101923. */
  101924. get alphaColor(): NodeMaterialConnectionPoint;
  101925. /**
  101926. * Gets the blendColor output component
  101927. */
  101928. get blendColor(): NodeMaterialConnectionPoint;
  101929. /**
  101930. * Initialize the block and prepare the context for build
  101931. * @param state defines the state that will be used for the build
  101932. */
  101933. initialize(state: NodeMaterialBuildState): void;
  101934. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  101935. }
  101936. }
  101937. declare module BABYLON {
  101938. /**
  101939. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  101940. */
  101941. export class VectorMergerBlock extends NodeMaterialBlock {
  101942. /**
  101943. * Create a new VectorMergerBlock
  101944. * @param name defines the block name
  101945. */
  101946. constructor(name: string);
  101947. /**
  101948. * Gets the current class name
  101949. * @returns the class name
  101950. */
  101951. getClassName(): string;
  101952. /**
  101953. * Gets the xyz component (input)
  101954. */
  101955. get xyzIn(): NodeMaterialConnectionPoint;
  101956. /**
  101957. * Gets the xy component (input)
  101958. */
  101959. get xyIn(): NodeMaterialConnectionPoint;
  101960. /**
  101961. * Gets the x component (input)
  101962. */
  101963. get x(): NodeMaterialConnectionPoint;
  101964. /**
  101965. * Gets the y component (input)
  101966. */
  101967. get y(): NodeMaterialConnectionPoint;
  101968. /**
  101969. * Gets the z component (input)
  101970. */
  101971. get z(): NodeMaterialConnectionPoint;
  101972. /**
  101973. * Gets the w component (input)
  101974. */
  101975. get w(): NodeMaterialConnectionPoint;
  101976. /**
  101977. * Gets the xyzw component (output)
  101978. */
  101979. get xyzw(): NodeMaterialConnectionPoint;
  101980. /**
  101981. * Gets the xyz component (output)
  101982. */
  101983. get xyzOut(): NodeMaterialConnectionPoint;
  101984. /**
  101985. * Gets the xy component (output)
  101986. */
  101987. get xyOut(): NodeMaterialConnectionPoint;
  101988. /**
  101989. * Gets the xy component (output)
  101990. * @deprecated Please use xyOut instead.
  101991. */
  101992. get xy(): NodeMaterialConnectionPoint;
  101993. /**
  101994. * Gets the xyz component (output)
  101995. * @deprecated Please use xyzOut instead.
  101996. */
  101997. get xyz(): NodeMaterialConnectionPoint;
  101998. protected _buildBlock(state: NodeMaterialBuildState): this;
  101999. }
  102000. }
  102001. declare module BABYLON {
  102002. /**
  102003. * Block used to remap a float from a range to a new one
  102004. */
  102005. export class RemapBlock extends NodeMaterialBlock {
  102006. /**
  102007. * Gets or sets the source range
  102008. */
  102009. sourceRange: Vector2;
  102010. /**
  102011. * Gets or sets the target range
  102012. */
  102013. targetRange: Vector2;
  102014. /**
  102015. * Creates a new RemapBlock
  102016. * @param name defines the block name
  102017. */
  102018. constructor(name: string);
  102019. /**
  102020. * Gets the current class name
  102021. * @returns the class name
  102022. */
  102023. getClassName(): string;
  102024. /**
  102025. * Gets the input component
  102026. */
  102027. get input(): NodeMaterialConnectionPoint;
  102028. /**
  102029. * Gets the source min input component
  102030. */
  102031. get sourceMin(): NodeMaterialConnectionPoint;
  102032. /**
  102033. * Gets the source max input component
  102034. */
  102035. get sourceMax(): NodeMaterialConnectionPoint;
  102036. /**
  102037. * Gets the target min input component
  102038. */
  102039. get targetMin(): NodeMaterialConnectionPoint;
  102040. /**
  102041. * Gets the target max input component
  102042. */
  102043. get targetMax(): NodeMaterialConnectionPoint;
  102044. /**
  102045. * Gets the output component
  102046. */
  102047. get output(): NodeMaterialConnectionPoint;
  102048. protected _buildBlock(state: NodeMaterialBuildState): this;
  102049. protected _dumpPropertiesCode(): string;
  102050. serialize(): any;
  102051. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  102052. }
  102053. }
  102054. declare module BABYLON {
  102055. /**
  102056. * Block used to multiply 2 values
  102057. */
  102058. export class MultiplyBlock extends NodeMaterialBlock {
  102059. /**
  102060. * Creates a new MultiplyBlock
  102061. * @param name defines the block name
  102062. */
  102063. constructor(name: string);
  102064. /**
  102065. * Gets the current class name
  102066. * @returns the class name
  102067. */
  102068. getClassName(): string;
  102069. /**
  102070. * Gets the left operand input component
  102071. */
  102072. get left(): NodeMaterialConnectionPoint;
  102073. /**
  102074. * Gets the right operand input component
  102075. */
  102076. get right(): NodeMaterialConnectionPoint;
  102077. /**
  102078. * Gets the output component
  102079. */
  102080. get output(): NodeMaterialConnectionPoint;
  102081. protected _buildBlock(state: NodeMaterialBuildState): this;
  102082. }
  102083. }
  102084. declare module BABYLON {
  102085. /**
  102086. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  102087. */
  102088. export class ColorSplitterBlock extends NodeMaterialBlock {
  102089. /**
  102090. * Create a new ColorSplitterBlock
  102091. * @param name defines the block name
  102092. */
  102093. constructor(name: string);
  102094. /**
  102095. * Gets the current class name
  102096. * @returns the class name
  102097. */
  102098. getClassName(): string;
  102099. /**
  102100. * Gets the rgba component (input)
  102101. */
  102102. get rgba(): NodeMaterialConnectionPoint;
  102103. /**
  102104. * Gets the rgb component (input)
  102105. */
  102106. get rgbIn(): NodeMaterialConnectionPoint;
  102107. /**
  102108. * Gets the rgb component (output)
  102109. */
  102110. get rgbOut(): NodeMaterialConnectionPoint;
  102111. /**
  102112. * Gets the r component (output)
  102113. */
  102114. get r(): NodeMaterialConnectionPoint;
  102115. /**
  102116. * Gets the g component (output)
  102117. */
  102118. get g(): NodeMaterialConnectionPoint;
  102119. /**
  102120. * Gets the b component (output)
  102121. */
  102122. get b(): NodeMaterialConnectionPoint;
  102123. /**
  102124. * Gets the a component (output)
  102125. */
  102126. get a(): NodeMaterialConnectionPoint;
  102127. protected _inputRename(name: string): string;
  102128. protected _outputRename(name: string): string;
  102129. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  102130. }
  102131. }
  102132. declare module BABYLON {
  102133. /**
  102134. * Operations supported by the Trigonometry block
  102135. */
  102136. export enum TrigonometryBlockOperations {
  102137. /** Cos */
  102138. Cos = 0,
  102139. /** Sin */
  102140. Sin = 1,
  102141. /** Abs */
  102142. Abs = 2,
  102143. /** Exp */
  102144. Exp = 3,
  102145. /** Exp2 */
  102146. Exp2 = 4,
  102147. /** Round */
  102148. Round = 5,
  102149. /** Floor */
  102150. Floor = 6,
  102151. /** Ceiling */
  102152. Ceiling = 7,
  102153. /** Square root */
  102154. Sqrt = 8,
  102155. /** Log */
  102156. Log = 9,
  102157. /** Tangent */
  102158. Tan = 10,
  102159. /** Arc tangent */
  102160. ArcTan = 11,
  102161. /** Arc cosinus */
  102162. ArcCos = 12,
  102163. /** Arc sinus */
  102164. ArcSin = 13,
  102165. /** Fraction */
  102166. Fract = 14,
  102167. /** Sign */
  102168. Sign = 15,
  102169. /** To radians (from degrees) */
  102170. Radians = 16,
  102171. /** To degrees (from radians) */
  102172. Degrees = 17
  102173. }
  102174. /**
  102175. * Block used to apply trigonometry operation to floats
  102176. */
  102177. export class TrigonometryBlock extends NodeMaterialBlock {
  102178. /**
  102179. * Gets or sets the operation applied by the block
  102180. */
  102181. operation: TrigonometryBlockOperations;
  102182. /**
  102183. * Creates a new TrigonometryBlock
  102184. * @param name defines the block name
  102185. */
  102186. constructor(name: string);
  102187. /**
  102188. * Gets the current class name
  102189. * @returns the class name
  102190. */
  102191. getClassName(): string;
  102192. /**
  102193. * Gets the input component
  102194. */
  102195. get input(): NodeMaterialConnectionPoint;
  102196. /**
  102197. * Gets the output component
  102198. */
  102199. get output(): NodeMaterialConnectionPoint;
  102200. protected _buildBlock(state: NodeMaterialBuildState): this;
  102201. serialize(): any;
  102202. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  102203. protected _dumpPropertiesCode(): string;
  102204. }
  102205. }
  102206. declare module BABYLON {
  102207. /**
  102208. * Interface used to configure the node material editor
  102209. */
  102210. export interface INodeMaterialEditorOptions {
  102211. /** Define the URl to load node editor script */
  102212. editorURL?: string;
  102213. }
  102214. /** @hidden */
  102215. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  102216. NORMAL: boolean;
  102217. TANGENT: boolean;
  102218. UV1: boolean;
  102219. /** BONES */
  102220. NUM_BONE_INFLUENCERS: number;
  102221. BonesPerMesh: number;
  102222. BONETEXTURE: boolean;
  102223. /** MORPH TARGETS */
  102224. MORPHTARGETS: boolean;
  102225. MORPHTARGETS_NORMAL: boolean;
  102226. MORPHTARGETS_TANGENT: boolean;
  102227. MORPHTARGETS_UV: boolean;
  102228. NUM_MORPH_INFLUENCERS: number;
  102229. /** IMAGE PROCESSING */
  102230. IMAGEPROCESSING: boolean;
  102231. VIGNETTE: boolean;
  102232. VIGNETTEBLENDMODEMULTIPLY: boolean;
  102233. VIGNETTEBLENDMODEOPAQUE: boolean;
  102234. TONEMAPPING: boolean;
  102235. TONEMAPPING_ACES: boolean;
  102236. CONTRAST: boolean;
  102237. EXPOSURE: boolean;
  102238. COLORCURVES: boolean;
  102239. COLORGRADING: boolean;
  102240. COLORGRADING3D: boolean;
  102241. SAMPLER3DGREENDEPTH: boolean;
  102242. SAMPLER3DBGRMAP: boolean;
  102243. IMAGEPROCESSINGPOSTPROCESS: boolean;
  102244. /** MISC. */
  102245. BUMPDIRECTUV: number;
  102246. constructor();
  102247. setValue(name: string, value: any, markAsUnprocessedIfDirty?: boolean): void;
  102248. }
  102249. /**
  102250. * Class used to configure NodeMaterial
  102251. */
  102252. export interface INodeMaterialOptions {
  102253. /**
  102254. * Defines if blocks should emit comments
  102255. */
  102256. emitComments: boolean;
  102257. }
  102258. /**
  102259. * Class used to create a node based material built by assembling shader blocks
  102260. */
  102261. export class NodeMaterial extends PushMaterial {
  102262. private static _BuildIdGenerator;
  102263. private _options;
  102264. private _vertexCompilationState;
  102265. private _fragmentCompilationState;
  102266. private _sharedData;
  102267. private _buildId;
  102268. private _buildWasSuccessful;
  102269. private _cachedWorldViewMatrix;
  102270. private _cachedWorldViewProjectionMatrix;
  102271. private _optimizers;
  102272. private _animationFrame;
  102273. /** Define the Url to load node editor script */
  102274. static EditorURL: string;
  102275. /** Define the Url to load snippets */
  102276. static SnippetUrl: string;
  102277. /** Gets or sets a boolean indicating that node materials should not deserialize textures from json / snippet content */
  102278. static IgnoreTexturesAtLoadTime: boolean;
  102279. private BJSNODEMATERIALEDITOR;
  102280. /** Get the inspector from bundle or global */
  102281. private _getGlobalNodeMaterialEditor;
  102282. /**
  102283. * Snippet ID if the material was created from the snippet server
  102284. */
  102285. snippetId: string;
  102286. /**
  102287. * Gets or sets data used by visual editor
  102288. * @see https://nme.babylonjs.com
  102289. */
  102290. editorData: any;
  102291. /**
  102292. * 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)
  102293. */
  102294. ignoreAlpha: boolean;
  102295. /**
  102296. * Defines the maximum number of lights that can be used in the material
  102297. */
  102298. maxSimultaneousLights: number;
  102299. /**
  102300. * Observable raised when the material is built
  102301. */
  102302. onBuildObservable: Observable<NodeMaterial>;
  102303. /**
  102304. * Gets or sets the root nodes of the material vertex shader
  102305. */
  102306. _vertexOutputNodes: NodeMaterialBlock[];
  102307. /**
  102308. * Gets or sets the root nodes of the material fragment (pixel) shader
  102309. */
  102310. _fragmentOutputNodes: NodeMaterialBlock[];
  102311. /** Gets or sets options to control the node material overall behavior */
  102312. get options(): INodeMaterialOptions;
  102313. set options(options: INodeMaterialOptions);
  102314. /**
  102315. * Default configuration related to image processing available in the standard Material.
  102316. */
  102317. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  102318. /**
  102319. * Gets the image processing configuration used either in this material.
  102320. */
  102321. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  102322. /**
  102323. * Sets the Default image processing configuration used either in the this material.
  102324. *
  102325. * If sets to null, the scene one is in use.
  102326. */
  102327. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  102328. /**
  102329. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  102330. */
  102331. attachedBlocks: NodeMaterialBlock[];
  102332. /**
  102333. * Specifies the mode of the node material
  102334. * @hidden
  102335. */
  102336. _mode: NodeMaterialModes;
  102337. /**
  102338. * Gets the mode property
  102339. */
  102340. get mode(): NodeMaterialModes;
  102341. /**
  102342. * Create a new node based material
  102343. * @param name defines the material name
  102344. * @param scene defines the hosting scene
  102345. * @param options defines creation option
  102346. */
  102347. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  102348. /**
  102349. * Gets the current class name of the material e.g. "NodeMaterial"
  102350. * @returns the class name
  102351. */
  102352. getClassName(): string;
  102353. /**
  102354. * Keep track of the image processing observer to allow dispose and replace.
  102355. */
  102356. private _imageProcessingObserver;
  102357. /**
  102358. * Attaches a new image processing configuration to the Standard Material.
  102359. * @param configuration
  102360. */
  102361. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  102362. /**
  102363. * Get a block by its name
  102364. * @param name defines the name of the block to retrieve
  102365. * @returns the required block or null if not found
  102366. */
  102367. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  102368. /**
  102369. * Get a block by its name
  102370. * @param predicate defines the predicate used to find the good candidate
  102371. * @returns the required block or null if not found
  102372. */
  102373. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  102374. /**
  102375. * Get an input block by its name
  102376. * @param predicate defines the predicate used to find the good candidate
  102377. * @returns the required input block or null if not found
  102378. */
  102379. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  102380. /**
  102381. * Gets the list of input blocks attached to this material
  102382. * @returns an array of InputBlocks
  102383. */
  102384. getInputBlocks(): InputBlock[];
  102385. /**
  102386. * Adds a new optimizer to the list of optimizers
  102387. * @param optimizer defines the optimizers to add
  102388. * @returns the current material
  102389. */
  102390. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  102391. /**
  102392. * Remove an optimizer from the list of optimizers
  102393. * @param optimizer defines the optimizers to remove
  102394. * @returns the current material
  102395. */
  102396. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  102397. /**
  102398. * Add a new block to the list of output nodes
  102399. * @param node defines the node to add
  102400. * @returns the current material
  102401. */
  102402. addOutputNode(node: NodeMaterialBlock): this;
  102403. /**
  102404. * Remove a block from the list of root nodes
  102405. * @param node defines the node to remove
  102406. * @returns the current material
  102407. */
  102408. removeOutputNode(node: NodeMaterialBlock): this;
  102409. private _addVertexOutputNode;
  102410. private _removeVertexOutputNode;
  102411. private _addFragmentOutputNode;
  102412. private _removeFragmentOutputNode;
  102413. /**
  102414. * Specifies if the material will require alpha blending
  102415. * @returns a boolean specifying if alpha blending is needed
  102416. */
  102417. needAlphaBlending(): boolean;
  102418. /**
  102419. * Specifies if this material should be rendered in alpha test mode
  102420. * @returns a boolean specifying if an alpha test is needed.
  102421. */
  102422. needAlphaTesting(): boolean;
  102423. private _initializeBlock;
  102424. private _resetDualBlocks;
  102425. /**
  102426. * Remove a block from the current node material
  102427. * @param block defines the block to remove
  102428. */
  102429. removeBlock(block: NodeMaterialBlock): void;
  102430. /**
  102431. * Build the material and generates the inner effect
  102432. * @param verbose defines if the build should log activity
  102433. */
  102434. build(verbose?: boolean): void;
  102435. /**
  102436. * Runs an otpimization phase to try to improve the shader code
  102437. */
  102438. optimize(): void;
  102439. private _prepareDefinesForAttributes;
  102440. /**
  102441. * Create a post process from the material
  102442. * @param camera The camera to apply the render pass to.
  102443. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  102444. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  102445. * @param engine The engine which the post process will be applied. (default: current engine)
  102446. * @param reusable If the post process can be reused on the same frame. (default: false)
  102447. * @param textureType Type of textures used when performing the post process. (default: 0)
  102448. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  102449. * @returns the post process created
  102450. */
  102451. createPostProcess(camera: Nullable<Camera>, options?: number | PostProcessOptions, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, textureFormat?: number): PostProcess;
  102452. /**
  102453. * Create the post process effect from the material
  102454. * @param postProcess The post process to create the effect for
  102455. */
  102456. createEffectForPostProcess(postProcess: PostProcess): void;
  102457. private _createEffectForPostProcess;
  102458. /**
  102459. * Create a new procedural texture based on this node material
  102460. * @param size defines the size of the texture
  102461. * @param scene defines the hosting scene
  102462. * @returns the new procedural texture attached to this node material
  102463. */
  102464. createProceduralTexture(size: number | {
  102465. width: number;
  102466. height: number;
  102467. layers?: number;
  102468. }, scene: Scene): ProceduralTexture;
  102469. private _createEffectForParticles;
  102470. private _checkInternals;
  102471. /**
  102472. * Create the effect to be used as the custom effect for a particle system
  102473. * @param particleSystem Particle system to create the effect for
  102474. * @param onCompiled defines a function to call when the effect creation is successful
  102475. * @param onError defines a function to call when the effect creation has failed
  102476. */
  102477. createEffectForParticles(particleSystem: IParticleSystem, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  102478. private _processDefines;
  102479. /**
  102480. * Get if the submesh is ready to be used and all its information available.
  102481. * Child classes can use it to update shaders
  102482. * @param mesh defines the mesh to check
  102483. * @param subMesh defines which submesh to check
  102484. * @param useInstances specifies that instances should be used
  102485. * @returns a boolean indicating that the submesh is ready or not
  102486. */
  102487. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  102488. /**
  102489. * Get a string representing the shaders built by the current node graph
  102490. */
  102491. get compiledShaders(): string;
  102492. /**
  102493. * Binds the world matrix to the material
  102494. * @param world defines the world transformation matrix
  102495. */
  102496. bindOnlyWorldMatrix(world: Matrix): void;
  102497. /**
  102498. * Binds the submesh to this material by preparing the effect and shader to draw
  102499. * @param world defines the world transformation matrix
  102500. * @param mesh defines the mesh containing the submesh
  102501. * @param subMesh defines the submesh to bind the material to
  102502. */
  102503. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  102504. /**
  102505. * Gets the active textures from the material
  102506. * @returns an array of textures
  102507. */
  102508. getActiveTextures(): BaseTexture[];
  102509. /**
  102510. * Gets the list of texture blocks
  102511. * @returns an array of texture blocks
  102512. */
  102513. getTextureBlocks(): (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  102514. /**
  102515. * Specifies if the material uses a texture
  102516. * @param texture defines the texture to check against the material
  102517. * @returns a boolean specifying if the material uses the texture
  102518. */
  102519. hasTexture(texture: BaseTexture): boolean;
  102520. /**
  102521. * Disposes the material
  102522. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  102523. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  102524. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  102525. */
  102526. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  102527. /** Creates the node editor window. */
  102528. private _createNodeEditor;
  102529. /**
  102530. * Launch the node material editor
  102531. * @param config Define the configuration of the editor
  102532. * @return a promise fulfilled when the node editor is visible
  102533. */
  102534. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  102535. /**
  102536. * Clear the current material
  102537. */
  102538. clear(): void;
  102539. /**
  102540. * Clear the current material and set it to a default state
  102541. */
  102542. setToDefault(): void;
  102543. /**
  102544. * Clear the current material and set it to a default state for post process
  102545. */
  102546. setToDefaultPostProcess(): void;
  102547. /**
  102548. * Clear the current material and set it to a default state for procedural texture
  102549. */
  102550. setToDefaultProceduralTexture(): void;
  102551. /**
  102552. * Clear the current material and set it to a default state for particle
  102553. */
  102554. setToDefaultParticle(): void;
  102555. /**
  102556. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  102557. * @param url defines the url to load from
  102558. * @returns a promise that will fullfil when the material is fully loaded
  102559. */
  102560. loadAsync(url: string): Promise<void>;
  102561. private _gatherBlocks;
  102562. /**
  102563. * Generate a string containing the code declaration required to create an equivalent of this material
  102564. * @returns a string
  102565. */
  102566. generateCode(): string;
  102567. /**
  102568. * Serializes this material in a JSON representation
  102569. * @returns the serialized material object
  102570. */
  102571. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  102572. private _restoreConnections;
  102573. /**
  102574. * Clear the current graph and load a new one from a serialization object
  102575. * @param source defines the JSON representation of the material
  102576. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  102577. * @param merge defines whether or not the source must be merged or replace the current content
  102578. */
  102579. loadFromSerialization(source: any, rootUrl?: string, merge?: boolean): void;
  102580. /**
  102581. * Makes a duplicate of the current material.
  102582. * @param name - name to use for the new material.
  102583. */
  102584. clone(name: string): NodeMaterial;
  102585. /**
  102586. * Creates a node material from parsed material data
  102587. * @param source defines the JSON representation of the material
  102588. * @param scene defines the hosting scene
  102589. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  102590. * @returns a new node material
  102591. */
  102592. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  102593. /**
  102594. * Creates a node material from a snippet saved in a remote file
  102595. * @param name defines the name of the material to create
  102596. * @param url defines the url to load from
  102597. * @param scene defines the hosting scene
  102598. * @returns a promise that will resolve to the new node material
  102599. */
  102600. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  102601. /**
  102602. * Creates a node material from a snippet saved by the node material editor
  102603. * @param snippetId defines the snippet to load
  102604. * @param scene defines the hosting scene
  102605. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  102606. * @param nodeMaterial defines a node material to update (instead of creating a new one)
  102607. * @returns a promise that will resolve to the new node material
  102608. */
  102609. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string, nodeMaterial?: NodeMaterial): Promise<NodeMaterial>;
  102610. /**
  102611. * Creates a new node material set to default basic configuration
  102612. * @param name defines the name of the material
  102613. * @param scene defines the hosting scene
  102614. * @returns a new NodeMaterial
  102615. */
  102616. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  102617. }
  102618. }
  102619. declare module BABYLON {
  102620. /**
  102621. * Size options for a post process
  102622. */
  102623. export type PostProcessOptions = {
  102624. width: number;
  102625. height: number;
  102626. };
  102627. /**
  102628. * PostProcess can be used to apply a shader to a texture after it has been rendered
  102629. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  102630. */
  102631. export class PostProcess {
  102632. /**
  102633. * Gets or sets the unique id of the post process
  102634. */
  102635. uniqueId: number;
  102636. /** Name of the PostProcess. */
  102637. name: string;
  102638. /**
  102639. * Width of the texture to apply the post process on
  102640. */
  102641. width: number;
  102642. /**
  102643. * Height of the texture to apply the post process on
  102644. */
  102645. height: number;
  102646. /**
  102647. * Gets the node material used to create this postprocess (null if the postprocess was manually created)
  102648. */
  102649. nodeMaterialSource: Nullable<NodeMaterial>;
  102650. /**
  102651. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  102652. * @hidden
  102653. */
  102654. _outputTexture: Nullable<InternalTexture>;
  102655. /**
  102656. * Sampling mode used by the shader
  102657. * See https://doc.babylonjs.com/classes/3.1/texture
  102658. */
  102659. renderTargetSamplingMode: number;
  102660. /**
  102661. * Clear color to use when screen clearing
  102662. */
  102663. clearColor: Color4;
  102664. /**
  102665. * If the buffer needs to be cleared before applying the post process. (default: true)
  102666. * Should be set to false if shader will overwrite all previous pixels.
  102667. */
  102668. autoClear: boolean;
  102669. /**
  102670. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  102671. */
  102672. alphaMode: number;
  102673. /**
  102674. * Sets the setAlphaBlendConstants of the babylon engine
  102675. */
  102676. alphaConstants: Color4;
  102677. /**
  102678. * Animations to be used for the post processing
  102679. */
  102680. animations: Animation[];
  102681. /**
  102682. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  102683. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  102684. */
  102685. enablePixelPerfectMode: boolean;
  102686. /**
  102687. * Force the postprocess to be applied without taking in account viewport
  102688. */
  102689. forceFullscreenViewport: boolean;
  102690. /**
  102691. * List of inspectable custom properties (used by the Inspector)
  102692. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  102693. */
  102694. inspectableCustomProperties: IInspectable[];
  102695. /**
  102696. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  102697. *
  102698. * | Value | Type | Description |
  102699. * | ----- | ----------------------------------- | ----------- |
  102700. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  102701. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  102702. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  102703. *
  102704. */
  102705. scaleMode: number;
  102706. /**
  102707. * Force textures to be a power of two (default: false)
  102708. */
  102709. alwaysForcePOT: boolean;
  102710. private _samples;
  102711. /**
  102712. * Number of sample textures (default: 1)
  102713. */
  102714. get samples(): number;
  102715. set samples(n: number);
  102716. /**
  102717. * Modify the scale of the post process to be the same as the viewport (default: false)
  102718. */
  102719. adaptScaleToCurrentViewport: boolean;
  102720. private _camera;
  102721. protected _scene: Scene;
  102722. private _engine;
  102723. private _options;
  102724. private _reusable;
  102725. private _textureType;
  102726. private _textureFormat;
  102727. /**
  102728. * Smart array of input and output textures for the post process.
  102729. * @hidden
  102730. */
  102731. _textures: SmartArray<InternalTexture>;
  102732. /**
  102733. * The index in _textures that corresponds to the output texture.
  102734. * @hidden
  102735. */
  102736. _currentRenderTextureInd: number;
  102737. private _effect;
  102738. private _samplers;
  102739. private _fragmentUrl;
  102740. private _vertexUrl;
  102741. private _parameters;
  102742. private _scaleRatio;
  102743. protected _indexParameters: any;
  102744. private _shareOutputWithPostProcess;
  102745. private _texelSize;
  102746. private _forcedOutputTexture;
  102747. /**
  102748. * Returns the fragment url or shader name used in the post process.
  102749. * @returns the fragment url or name in the shader store.
  102750. */
  102751. getEffectName(): string;
  102752. /**
  102753. * An event triggered when the postprocess is activated.
  102754. */
  102755. onActivateObservable: Observable<Camera>;
  102756. private _onActivateObserver;
  102757. /**
  102758. * A function that is added to the onActivateObservable
  102759. */
  102760. set onActivate(callback: Nullable<(camera: Camera) => void>);
  102761. /**
  102762. * An event triggered when the postprocess changes its size.
  102763. */
  102764. onSizeChangedObservable: Observable<PostProcess>;
  102765. private _onSizeChangedObserver;
  102766. /**
  102767. * A function that is added to the onSizeChangedObservable
  102768. */
  102769. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  102770. /**
  102771. * An event triggered when the postprocess applies its effect.
  102772. */
  102773. onApplyObservable: Observable<Effect>;
  102774. private _onApplyObserver;
  102775. /**
  102776. * A function that is added to the onApplyObservable
  102777. */
  102778. set onApply(callback: (effect: Effect) => void);
  102779. /**
  102780. * An event triggered before rendering the postprocess
  102781. */
  102782. onBeforeRenderObservable: Observable<Effect>;
  102783. private _onBeforeRenderObserver;
  102784. /**
  102785. * A function that is added to the onBeforeRenderObservable
  102786. */
  102787. set onBeforeRender(callback: (effect: Effect) => void);
  102788. /**
  102789. * An event triggered after rendering the postprocess
  102790. */
  102791. onAfterRenderObservable: Observable<Effect>;
  102792. private _onAfterRenderObserver;
  102793. /**
  102794. * A function that is added to the onAfterRenderObservable
  102795. */
  102796. set onAfterRender(callback: (efect: Effect) => void);
  102797. /**
  102798. * 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
  102799. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  102800. */
  102801. get inputTexture(): InternalTexture;
  102802. set inputTexture(value: InternalTexture);
  102803. /**
  102804. * Since inputTexture should always be defined, if we previously manually set `inputTexture`,
  102805. * the only way to unset it is to use this function to restore its internal state
  102806. */
  102807. restoreDefaultInputTexture(): void;
  102808. /**
  102809. * Gets the camera which post process is applied to.
  102810. * @returns The camera the post process is applied to.
  102811. */
  102812. getCamera(): Camera;
  102813. /**
  102814. * Gets the texel size of the postprocess.
  102815. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  102816. */
  102817. get texelSize(): Vector2;
  102818. /**
  102819. * Creates a new instance PostProcess
  102820. * @param name The name of the PostProcess.
  102821. * @param fragmentUrl The url of the fragment shader to be used.
  102822. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  102823. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  102824. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  102825. * @param camera The camera to apply the render pass to.
  102826. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  102827. * @param engine The engine which the post process will be applied. (default: current engine)
  102828. * @param reusable If the post process can be reused on the same frame. (default: false)
  102829. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  102830. * @param textureType Type of textures used when performing the post process. (default: 0)
  102831. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  102832. * @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
  102833. * @param blockCompilation If the shader should not be compiled immediatly. (default: false)
  102834. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  102835. */
  102836. constructor(name: string, fragmentUrl: string, parameters: Nullable<string[]>, samplers: Nullable<string[]>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, defines?: Nullable<string>, textureType?: number, vertexUrl?: string, indexParameters?: any, blockCompilation?: boolean, textureFormat?: number);
  102837. /**
  102838. * Gets a string identifying the name of the class
  102839. * @returns "PostProcess" string
  102840. */
  102841. getClassName(): string;
  102842. /**
  102843. * Gets the engine which this post process belongs to.
  102844. * @returns The engine the post process was enabled with.
  102845. */
  102846. getEngine(): Engine;
  102847. /**
  102848. * The effect that is created when initializing the post process.
  102849. * @returns The created effect corresponding the the postprocess.
  102850. */
  102851. getEffect(): Effect;
  102852. /**
  102853. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  102854. * @param postProcess The post process to share the output with.
  102855. * @returns This post process.
  102856. */
  102857. shareOutputWith(postProcess: PostProcess): PostProcess;
  102858. /**
  102859. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  102860. * This should be called if the post process that shares output with this post process is disabled/disposed.
  102861. */
  102862. useOwnOutput(): void;
  102863. /**
  102864. * Updates the effect with the current post process compile time values and recompiles the shader.
  102865. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  102866. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  102867. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  102868. * @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
  102869. * @param onCompiled Called when the shader has been compiled.
  102870. * @param onError Called if there is an error when compiling a shader.
  102871. * @param vertexUrl The url of the vertex shader to be used (default: the one given at construction time)
  102872. * @param fragmentUrl The url of the fragment shader to be used (default: the one given at construction time)
  102873. */
  102874. 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;
  102875. /**
  102876. * The post process is reusable if it can be used multiple times within one frame.
  102877. * @returns If the post process is reusable
  102878. */
  102879. isReusable(): boolean;
  102880. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  102881. markTextureDirty(): void;
  102882. /**
  102883. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  102884. * 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.
  102885. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  102886. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  102887. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  102888. * @returns The target texture that was bound to be written to.
  102889. */
  102890. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  102891. /**
  102892. * If the post process is supported.
  102893. */
  102894. get isSupported(): boolean;
  102895. /**
  102896. * The aspect ratio of the output texture.
  102897. */
  102898. get aspectRatio(): number;
  102899. /**
  102900. * Get a value indicating if the post-process is ready to be used
  102901. * @returns true if the post-process is ready (shader is compiled)
  102902. */
  102903. isReady(): boolean;
  102904. /**
  102905. * Binds all textures and uniforms to the shader, this will be run on every pass.
  102906. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  102907. */
  102908. apply(): Nullable<Effect>;
  102909. private _disposeTextures;
  102910. /**
  102911. * Disposes the post process.
  102912. * @param camera The camera to dispose the post process on.
  102913. */
  102914. dispose(camera?: Camera): void;
  102915. /**
  102916. * Serializes the particle system to a JSON object
  102917. * @returns the JSON object
  102918. */
  102919. serialize(): any;
  102920. /**
  102921. * Creates a material from parsed material data
  102922. * @param parsedPostProcess defines parsed post process data
  102923. * @param scene defines the hosting scene
  102924. * @param rootUrl defines the root URL to use to load textures
  102925. * @returns a new post process
  102926. */
  102927. static Parse(parsedPostProcess: any, scene: Scene, rootUrl: string): Nullable<PostProcess>;
  102928. }
  102929. }
  102930. declare module BABYLON {
  102931. /** @hidden */
  102932. export var kernelBlurVaryingDeclaration: {
  102933. name: string;
  102934. shader: string;
  102935. };
  102936. }
  102937. declare module BABYLON {
  102938. /** @hidden */
  102939. export var kernelBlurFragment: {
  102940. name: string;
  102941. shader: string;
  102942. };
  102943. }
  102944. declare module BABYLON {
  102945. /** @hidden */
  102946. export var kernelBlurFragment2: {
  102947. name: string;
  102948. shader: string;
  102949. };
  102950. }
  102951. declare module BABYLON {
  102952. /** @hidden */
  102953. export var kernelBlurPixelShader: {
  102954. name: string;
  102955. shader: string;
  102956. };
  102957. }
  102958. declare module BABYLON {
  102959. /** @hidden */
  102960. export var kernelBlurVertex: {
  102961. name: string;
  102962. shader: string;
  102963. };
  102964. }
  102965. declare module BABYLON {
  102966. /** @hidden */
  102967. export var kernelBlurVertexShader: {
  102968. name: string;
  102969. shader: string;
  102970. };
  102971. }
  102972. declare module BABYLON {
  102973. /**
  102974. * The Blur Post Process which blurs an image based on a kernel and direction.
  102975. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  102976. */
  102977. export class BlurPostProcess extends PostProcess {
  102978. private blockCompilation;
  102979. protected _kernel: number;
  102980. protected _idealKernel: number;
  102981. protected _packedFloat: boolean;
  102982. private _staticDefines;
  102983. /** The direction in which to blur the image. */
  102984. direction: Vector2;
  102985. /**
  102986. * Sets the length in pixels of the blur sample region
  102987. */
  102988. set kernel(v: number);
  102989. /**
  102990. * Gets the length in pixels of the blur sample region
  102991. */
  102992. get kernel(): number;
  102993. /**
  102994. * Sets wether or not the blur needs to unpack/repack floats
  102995. */
  102996. set packedFloat(v: boolean);
  102997. /**
  102998. * Gets wether or not the blur is unpacking/repacking floats
  102999. */
  103000. get packedFloat(): boolean;
  103001. /**
  103002. * Gets a string identifying the name of the class
  103003. * @returns "BlurPostProcess" string
  103004. */
  103005. getClassName(): string;
  103006. /**
  103007. * Creates a new instance BlurPostProcess
  103008. * @param name The name of the effect.
  103009. * @param direction The direction in which to blur the image.
  103010. * @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.
  103011. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  103012. * @param camera The camera to apply the render pass to.
  103013. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  103014. * @param engine The engine which the post process will be applied. (default: current engine)
  103015. * @param reusable If the post process can be reused on the same frame. (default: false)
  103016. * @param textureType Type of textures used when performing the post process. (default: 0)
  103017. * @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)
  103018. */
  103019. constructor(name: string, direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  103020. /**
  103021. * Updates the effect with the current post process compile time values and recompiles the shader.
  103022. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  103023. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  103024. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  103025. * @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
  103026. * @param onCompiled Called when the shader has been compiled.
  103027. * @param onError Called if there is an error when compiling a shader.
  103028. */
  103029. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  103030. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  103031. /**
  103032. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  103033. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  103034. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  103035. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  103036. * The gaps between physical kernels are compensated for in the weighting of the samples
  103037. * @param idealKernel Ideal blur kernel.
  103038. * @return Nearest best kernel.
  103039. */
  103040. protected _nearestBestKernel(idealKernel: number): number;
  103041. /**
  103042. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  103043. * @param x The point on the Gaussian distribution to sample.
  103044. * @return the value of the Gaussian function at x.
  103045. */
  103046. protected _gaussianWeight(x: number): number;
  103047. /**
  103048. * Generates a string that can be used as a floating point number in GLSL.
  103049. * @param x Value to print.
  103050. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  103051. * @return GLSL float string.
  103052. */
  103053. protected _glslFloat(x: number, decimalFigures?: number): string;
  103054. /** @hidden */
  103055. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlurPostProcess>;
  103056. }
  103057. }
  103058. declare module BABYLON {
  103059. /**
  103060. * Mirror texture can be used to simulate the view from a mirror in a scene.
  103061. * It will dynamically be rendered every frame to adapt to the camera point of view.
  103062. * You can then easily use it as a reflectionTexture on a flat surface.
  103063. * In case the surface is not a plane, please consider relying on reflection probes.
  103064. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  103065. */
  103066. export class MirrorTexture extends RenderTargetTexture {
  103067. private scene;
  103068. /**
  103069. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  103070. * 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.
  103071. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  103072. */
  103073. mirrorPlane: Plane;
  103074. /**
  103075. * Define the blur ratio used to blur the reflection if needed.
  103076. */
  103077. set blurRatio(value: number);
  103078. get blurRatio(): number;
  103079. /**
  103080. * Define the adaptive blur kernel used to blur the reflection if needed.
  103081. * This will autocompute the closest best match for the `blurKernel`
  103082. */
  103083. set adaptiveBlurKernel(value: number);
  103084. /**
  103085. * Define the blur kernel used to blur the reflection if needed.
  103086. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  103087. */
  103088. set blurKernel(value: number);
  103089. /**
  103090. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  103091. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  103092. */
  103093. set blurKernelX(value: number);
  103094. get blurKernelX(): number;
  103095. /**
  103096. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  103097. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  103098. */
  103099. set blurKernelY(value: number);
  103100. get blurKernelY(): number;
  103101. private _autoComputeBlurKernel;
  103102. protected _onRatioRescale(): void;
  103103. private _updateGammaSpace;
  103104. private _imageProcessingConfigChangeObserver;
  103105. private _transformMatrix;
  103106. private _mirrorMatrix;
  103107. private _savedViewMatrix;
  103108. private _blurX;
  103109. private _blurY;
  103110. private _adaptiveBlurKernel;
  103111. private _blurKernelX;
  103112. private _blurKernelY;
  103113. private _blurRatio;
  103114. /**
  103115. * Instantiates a Mirror Texture.
  103116. * Mirror texture can be used to simulate the view from a mirror in a scene.
  103117. * It will dynamically be rendered every frame to adapt to the camera point of view.
  103118. * You can then easily use it as a reflectionTexture on a flat surface.
  103119. * In case the surface is not a plane, please consider relying on reflection probes.
  103120. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  103121. * @param name
  103122. * @param size
  103123. * @param scene
  103124. * @param generateMipMaps
  103125. * @param type
  103126. * @param samplingMode
  103127. * @param generateDepthBuffer
  103128. */
  103129. constructor(name: string, size: number | {
  103130. width: number;
  103131. height: number;
  103132. } | {
  103133. ratio: number;
  103134. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  103135. private _preparePostProcesses;
  103136. /**
  103137. * Clone the mirror texture.
  103138. * @returns the cloned texture
  103139. */
  103140. clone(): MirrorTexture;
  103141. /**
  103142. * Serialize the texture to a JSON representation you could use in Parse later on
  103143. * @returns the serialized JSON representation
  103144. */
  103145. serialize(): any;
  103146. /**
  103147. * Dispose the texture and release its associated resources.
  103148. */
  103149. dispose(): void;
  103150. }
  103151. }
  103152. declare module BABYLON {
  103153. /**
  103154. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  103155. * @see https://doc.babylonjs.com/babylon101/materials#texture
  103156. */
  103157. export class Texture extends BaseTexture {
  103158. /**
  103159. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  103160. */
  103161. static SerializeBuffers: boolean;
  103162. /** @hidden */
  103163. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  103164. /** @hidden */
  103165. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  103166. /** @hidden */
  103167. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  103168. /** nearest is mag = nearest and min = nearest and mip = linear */
  103169. static readonly NEAREST_SAMPLINGMODE: number;
  103170. /** nearest is mag = nearest and min = nearest and mip = linear */
  103171. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  103172. /** Bilinear is mag = linear and min = linear and mip = nearest */
  103173. static readonly BILINEAR_SAMPLINGMODE: number;
  103174. /** Bilinear is mag = linear and min = linear and mip = nearest */
  103175. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  103176. /** Trilinear is mag = linear and min = linear and mip = linear */
  103177. static readonly TRILINEAR_SAMPLINGMODE: number;
  103178. /** Trilinear is mag = linear and min = linear and mip = linear */
  103179. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  103180. /** mag = nearest and min = nearest and mip = nearest */
  103181. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  103182. /** mag = nearest and min = linear and mip = nearest */
  103183. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  103184. /** mag = nearest and min = linear and mip = linear */
  103185. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  103186. /** mag = nearest and min = linear and mip = none */
  103187. static readonly NEAREST_LINEAR: number;
  103188. /** mag = nearest and min = nearest and mip = none */
  103189. static readonly NEAREST_NEAREST: number;
  103190. /** mag = linear and min = nearest and mip = nearest */
  103191. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  103192. /** mag = linear and min = nearest and mip = linear */
  103193. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  103194. /** mag = linear and min = linear and mip = none */
  103195. static readonly LINEAR_LINEAR: number;
  103196. /** mag = linear and min = nearest and mip = none */
  103197. static readonly LINEAR_NEAREST: number;
  103198. /** Explicit coordinates mode */
  103199. static readonly EXPLICIT_MODE: number;
  103200. /** Spherical coordinates mode */
  103201. static readonly SPHERICAL_MODE: number;
  103202. /** Planar coordinates mode */
  103203. static readonly PLANAR_MODE: number;
  103204. /** Cubic coordinates mode */
  103205. static readonly CUBIC_MODE: number;
  103206. /** Projection coordinates mode */
  103207. static readonly PROJECTION_MODE: number;
  103208. /** Inverse Cubic coordinates mode */
  103209. static readonly SKYBOX_MODE: number;
  103210. /** Inverse Cubic coordinates mode */
  103211. static readonly INVCUBIC_MODE: number;
  103212. /** Equirectangular coordinates mode */
  103213. static readonly EQUIRECTANGULAR_MODE: number;
  103214. /** Equirectangular Fixed coordinates mode */
  103215. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  103216. /** Equirectangular Fixed Mirrored coordinates mode */
  103217. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  103218. /** Texture is not repeating outside of 0..1 UVs */
  103219. static readonly CLAMP_ADDRESSMODE: number;
  103220. /** Texture is repeating outside of 0..1 UVs */
  103221. static readonly WRAP_ADDRESSMODE: number;
  103222. /** Texture is repeating and mirrored */
  103223. static readonly MIRROR_ADDRESSMODE: number;
  103224. /**
  103225. * 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
  103226. */
  103227. static UseSerializedUrlIfAny: boolean;
  103228. /**
  103229. * Define the url of the texture.
  103230. */
  103231. url: Nullable<string>;
  103232. /**
  103233. * Define an offset on the texture to offset the u coordinates of the UVs
  103234. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  103235. */
  103236. uOffset: number;
  103237. /**
  103238. * Define an offset on the texture to offset the v coordinates of the UVs
  103239. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  103240. */
  103241. vOffset: number;
  103242. /**
  103243. * Define an offset on the texture to scale the u coordinates of the UVs
  103244. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  103245. */
  103246. uScale: number;
  103247. /**
  103248. * Define an offset on the texture to scale the v coordinates of the UVs
  103249. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  103250. */
  103251. vScale: number;
  103252. /**
  103253. * Define an offset on the texture to rotate around the u coordinates of the UVs
  103254. * @see https://doc.babylonjs.com/how_to/more_materials
  103255. */
  103256. uAng: number;
  103257. /**
  103258. * Define an offset on the texture to rotate around the v coordinates of the UVs
  103259. * @see https://doc.babylonjs.com/how_to/more_materials
  103260. */
  103261. vAng: number;
  103262. /**
  103263. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  103264. * @see https://doc.babylonjs.com/how_to/more_materials
  103265. */
  103266. wAng: number;
  103267. /**
  103268. * Defines the center of rotation (U)
  103269. */
  103270. uRotationCenter: number;
  103271. /**
  103272. * Defines the center of rotation (V)
  103273. */
  103274. vRotationCenter: number;
  103275. /**
  103276. * Defines the center of rotation (W)
  103277. */
  103278. wRotationCenter: number;
  103279. /**
  103280. * Are mip maps generated for this texture or not.
  103281. */
  103282. get noMipmap(): boolean;
  103283. /**
  103284. * List of inspectable custom properties (used by the Inspector)
  103285. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  103286. */
  103287. inspectableCustomProperties: Nullable<IInspectable[]>;
  103288. private _noMipmap;
  103289. /** @hidden */
  103290. _invertY: boolean;
  103291. private _rowGenerationMatrix;
  103292. private _cachedTextureMatrix;
  103293. private _projectionModeMatrix;
  103294. private _t0;
  103295. private _t1;
  103296. private _t2;
  103297. private _cachedUOffset;
  103298. private _cachedVOffset;
  103299. private _cachedUScale;
  103300. private _cachedVScale;
  103301. private _cachedUAng;
  103302. private _cachedVAng;
  103303. private _cachedWAng;
  103304. private _cachedProjectionMatrixId;
  103305. private _cachedCoordinatesMode;
  103306. /** @hidden */
  103307. protected _initialSamplingMode: number;
  103308. /** @hidden */
  103309. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  103310. private _deleteBuffer;
  103311. protected _format: Nullable<number>;
  103312. private _delayedOnLoad;
  103313. private _delayedOnError;
  103314. private _mimeType?;
  103315. /** Returns the texture mime type if it was defined by a loader (undefined else) */
  103316. get mimeType(): string | undefined;
  103317. /**
  103318. * Observable triggered once the texture has been loaded.
  103319. */
  103320. onLoadObservable: Observable<Texture>;
  103321. protected _isBlocking: boolean;
  103322. /**
  103323. * Is the texture preventing material to render while loading.
  103324. * If false, a default texture will be used instead of the loading one during the preparation step.
  103325. */
  103326. set isBlocking(value: boolean);
  103327. get isBlocking(): boolean;
  103328. /**
  103329. * Get the current sampling mode associated with the texture.
  103330. */
  103331. get samplingMode(): number;
  103332. /**
  103333. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  103334. */
  103335. get invertY(): boolean;
  103336. /**
  103337. * Instantiates a new texture.
  103338. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  103339. * @see https://doc.babylonjs.com/babylon101/materials#texture
  103340. * @param url defines the url of the picture to load as a texture
  103341. * @param sceneOrEngine defines the scene or engine the texture will belong to
  103342. * @param noMipmap defines if the texture will require mip maps or not
  103343. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  103344. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  103345. * @param onLoad defines a callback triggered when the texture has been loaded
  103346. * @param onError defines a callback triggered when an error occurred during the loading session
  103347. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  103348. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  103349. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  103350. * @param mimeType defines an optional mime type information
  103351. */
  103352. 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);
  103353. /**
  103354. * Update the url (and optional buffer) of this texture if url was null during construction.
  103355. * @param url the url of the texture
  103356. * @param buffer the buffer of the texture (defaults to null)
  103357. * @param onLoad callback called when the texture is loaded (defaults to null)
  103358. */
  103359. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  103360. /**
  103361. * Finish the loading sequence of a texture flagged as delayed load.
  103362. * @hidden
  103363. */
  103364. delayLoad(): void;
  103365. private _prepareRowForTextureGeneration;
  103366. /**
  103367. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  103368. * @returns the transform matrix of the texture.
  103369. */
  103370. getTextureMatrix(uBase?: number): Matrix;
  103371. /**
  103372. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  103373. * @returns The reflection texture transform
  103374. */
  103375. getReflectionTextureMatrix(): Matrix;
  103376. /**
  103377. * Clones the texture.
  103378. * @returns the cloned texture
  103379. */
  103380. clone(): Texture;
  103381. /**
  103382. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  103383. * @returns The JSON representation of the texture
  103384. */
  103385. serialize(): any;
  103386. /**
  103387. * Get the current class name of the texture useful for serialization or dynamic coding.
  103388. * @returns "Texture"
  103389. */
  103390. getClassName(): string;
  103391. /**
  103392. * Dispose the texture and release its associated resources.
  103393. */
  103394. dispose(): void;
  103395. /**
  103396. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  103397. * @param parsedTexture Define the JSON representation of the texture
  103398. * @param scene Define the scene the parsed texture should be instantiated in
  103399. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  103400. * @returns The parsed texture if successful
  103401. */
  103402. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  103403. /**
  103404. * Creates a texture from its base 64 representation.
  103405. * @param data Define the base64 payload without the data: prefix
  103406. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  103407. * @param scene Define the scene the texture should belong to
  103408. * @param noMipmap Forces the texture to not create mip map information if true
  103409. * @param invertY define if the texture needs to be inverted on the y axis during loading
  103410. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  103411. * @param onLoad define a callback triggered when the texture has been loaded
  103412. * @param onError define a callback triggered when an error occurred during the loading session
  103413. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  103414. * @returns the created texture
  103415. */
  103416. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  103417. /**
  103418. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  103419. * @param data Define the base64 payload without the data: prefix
  103420. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  103421. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  103422. * @param scene Define the scene the texture should belong to
  103423. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  103424. * @param noMipmap Forces the texture to not create mip map information if true
  103425. * @param invertY define if the texture needs to be inverted on the y axis during loading
  103426. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  103427. * @param onLoad define a callback triggered when the texture has been loaded
  103428. * @param onError define a callback triggered when an error occurred during the loading session
  103429. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  103430. * @returns the created texture
  103431. */
  103432. 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;
  103433. }
  103434. }
  103435. declare module BABYLON {
  103436. /**
  103437. * PostProcessManager is used to manage one or more post processes or post process pipelines
  103438. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  103439. */
  103440. export class PostProcessManager {
  103441. private _scene;
  103442. private _indexBuffer;
  103443. private _vertexBuffers;
  103444. /**
  103445. * Creates a new instance PostProcess
  103446. * @param scene The scene that the post process is associated with.
  103447. */
  103448. constructor(scene: Scene);
  103449. private _prepareBuffers;
  103450. private _buildIndexBuffer;
  103451. /**
  103452. * Rebuilds the vertex buffers of the manager.
  103453. * @hidden
  103454. */
  103455. _rebuild(): void;
  103456. /**
  103457. * Prepares a frame to be run through a post process.
  103458. * @param sourceTexture The input texture to the post procesess. (default: null)
  103459. * @param postProcesses An array of post processes to be run. (default: null)
  103460. * @returns True if the post processes were able to be run.
  103461. * @hidden
  103462. */
  103463. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  103464. /**
  103465. * Manually render a set of post processes to a texture.
  103466. * Please note, the frame buffer won't be unbound after the call in case you have more render to do.
  103467. * @param postProcesses An array of post processes to be run.
  103468. * @param targetTexture The target texture to render to.
  103469. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  103470. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  103471. * @param lodLevel defines which lod of the texture to render to
  103472. * @param doNotBindFrambuffer If set to true, assumes that the framebuffer has been bound previously
  103473. */
  103474. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number, doNotBindFrambuffer?: boolean): void;
  103475. /**
  103476. * Finalize the result of the output of the postprocesses.
  103477. * @param doNotPresent If true the result will not be displayed to the screen.
  103478. * @param targetTexture The target texture to render to.
  103479. * @param faceIndex The index of the face to bind the target texture to.
  103480. * @param postProcesses The array of post processes to render.
  103481. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  103482. * @hidden
  103483. */
  103484. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  103485. /**
  103486. * Disposes of the post process manager.
  103487. */
  103488. dispose(): void;
  103489. }
  103490. }
  103491. declare module BABYLON {
  103492. /**
  103493. * This Helps creating a texture that will be created from a camera in your scene.
  103494. * It is basically a dynamic texture that could be used to create special effects for instance.
  103495. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  103496. */
  103497. export class RenderTargetTexture extends Texture {
  103498. /**
  103499. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  103500. */
  103501. static readonly REFRESHRATE_RENDER_ONCE: number;
  103502. /**
  103503. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  103504. */
  103505. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  103506. /**
  103507. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  103508. * the central point of your effect and can save a lot of performances.
  103509. */
  103510. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  103511. /**
  103512. * Use this predicate to dynamically define the list of mesh you want to render.
  103513. * If set, the renderList property will be overwritten.
  103514. */
  103515. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  103516. private _renderList;
  103517. /**
  103518. * Use this list to define the list of mesh you want to render.
  103519. */
  103520. get renderList(): Nullable<Array<AbstractMesh>>;
  103521. set renderList(value: Nullable<Array<AbstractMesh>>);
  103522. /**
  103523. * Use this function to overload the renderList array at rendering time.
  103524. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  103525. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  103526. * the cube (if the RTT is a cube, else layerOrFace=0).
  103527. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  103528. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  103529. * hold dummy elements!
  103530. */
  103531. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  103532. private _hookArray;
  103533. /**
  103534. * Define if particles should be rendered in your texture.
  103535. */
  103536. renderParticles: boolean;
  103537. /**
  103538. * Define if sprites should be rendered in your texture.
  103539. */
  103540. renderSprites: boolean;
  103541. /**
  103542. * Define the camera used to render the texture.
  103543. */
  103544. activeCamera: Nullable<Camera>;
  103545. /**
  103546. * Override the mesh isReady function with your own one.
  103547. */
  103548. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  103549. /**
  103550. * Override the render function of the texture with your own one.
  103551. */
  103552. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  103553. /**
  103554. * Define if camera post processes should be use while rendering the texture.
  103555. */
  103556. useCameraPostProcesses: boolean;
  103557. /**
  103558. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  103559. */
  103560. ignoreCameraViewport: boolean;
  103561. private _postProcessManager;
  103562. private _postProcesses;
  103563. private _resizeObserver;
  103564. /**
  103565. * An event triggered when the texture is unbind.
  103566. */
  103567. onBeforeBindObservable: Observable<RenderTargetTexture>;
  103568. /**
  103569. * An event triggered when the texture is unbind.
  103570. */
  103571. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  103572. private _onAfterUnbindObserver;
  103573. /**
  103574. * Set a after unbind callback in the texture.
  103575. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  103576. */
  103577. set onAfterUnbind(callback: () => void);
  103578. /**
  103579. * An event triggered before rendering the texture
  103580. */
  103581. onBeforeRenderObservable: Observable<number>;
  103582. private _onBeforeRenderObserver;
  103583. /**
  103584. * Set a before render callback in the texture.
  103585. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  103586. */
  103587. set onBeforeRender(callback: (faceIndex: number) => void);
  103588. /**
  103589. * An event triggered after rendering the texture
  103590. */
  103591. onAfterRenderObservable: Observable<number>;
  103592. private _onAfterRenderObserver;
  103593. /**
  103594. * Set a after render callback in the texture.
  103595. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  103596. */
  103597. set onAfterRender(callback: (faceIndex: number) => void);
  103598. /**
  103599. * An event triggered after the texture clear
  103600. */
  103601. onClearObservable: Observable<Engine>;
  103602. private _onClearObserver;
  103603. /**
  103604. * Set a clear callback in the texture.
  103605. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  103606. */
  103607. set onClear(callback: (Engine: Engine) => void);
  103608. /**
  103609. * An event triggered when the texture is resized.
  103610. */
  103611. onResizeObservable: Observable<RenderTargetTexture>;
  103612. /**
  103613. * Define the clear color of the Render Target if it should be different from the scene.
  103614. */
  103615. clearColor: Color4;
  103616. protected _size: number | {
  103617. width: number;
  103618. height: number;
  103619. layers?: number;
  103620. };
  103621. protected _initialSizeParameter: number | {
  103622. width: number;
  103623. height: number;
  103624. } | {
  103625. ratio: number;
  103626. };
  103627. protected _sizeRatio: Nullable<number>;
  103628. /** @hidden */
  103629. _generateMipMaps: boolean;
  103630. protected _renderingManager: RenderingManager;
  103631. /** @hidden */
  103632. _waitingRenderList?: string[];
  103633. protected _doNotChangeAspectRatio: boolean;
  103634. protected _currentRefreshId: number;
  103635. protected _refreshRate: number;
  103636. protected _textureMatrix: Matrix;
  103637. protected _samples: number;
  103638. protected _renderTargetOptions: RenderTargetCreationOptions;
  103639. /**
  103640. * Gets render target creation options that were used.
  103641. */
  103642. get renderTargetOptions(): RenderTargetCreationOptions;
  103643. protected _onRatioRescale(): void;
  103644. /**
  103645. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  103646. * It must define where the camera used to render the texture is set
  103647. */
  103648. boundingBoxPosition: Vector3;
  103649. private _boundingBoxSize;
  103650. /**
  103651. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  103652. * When defined, the cubemap will switch to local mode
  103653. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  103654. * @example https://www.babylonjs-playground.com/#RNASML
  103655. */
  103656. set boundingBoxSize(value: Vector3);
  103657. get boundingBoxSize(): Vector3;
  103658. /**
  103659. * In case the RTT has been created with a depth texture, get the associated
  103660. * depth texture.
  103661. * Otherwise, return null.
  103662. */
  103663. get depthStencilTexture(): Nullable<InternalTexture>;
  103664. /**
  103665. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  103666. * or used a shadow, depth texture...
  103667. * @param name The friendly name of the texture
  103668. * @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)
  103669. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  103670. * @param generateMipMaps True if mip maps need to be generated after render.
  103671. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  103672. * @param type The type of the buffer in the RTT (int, half float, float...)
  103673. * @param isCube True if a cube texture needs to be created
  103674. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  103675. * @param generateDepthBuffer True to generate a depth buffer
  103676. * @param generateStencilBuffer True to generate a stencil buffer
  103677. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  103678. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  103679. * @param delayAllocation if the texture allocation should be delayed (default: false)
  103680. */
  103681. constructor(name: string, size: number | {
  103682. width: number;
  103683. height: number;
  103684. layers?: number;
  103685. } | {
  103686. ratio: number;
  103687. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  103688. /**
  103689. * Creates a depth stencil texture.
  103690. * This is only available in WebGL 2 or with the depth texture extension available.
  103691. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  103692. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  103693. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  103694. */
  103695. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  103696. private _processSizeParameter;
  103697. /**
  103698. * Define the number of samples to use in case of MSAA.
  103699. * It defaults to one meaning no MSAA has been enabled.
  103700. */
  103701. get samples(): number;
  103702. set samples(value: number);
  103703. /**
  103704. * Resets the refresh counter of the texture and start bak from scratch.
  103705. * Could be useful to regenerate the texture if it is setup to render only once.
  103706. */
  103707. resetRefreshCounter(): void;
  103708. /**
  103709. * Define the refresh rate of the texture or the rendering frequency.
  103710. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  103711. */
  103712. get refreshRate(): number;
  103713. set refreshRate(value: number);
  103714. /**
  103715. * Adds a post process to the render target rendering passes.
  103716. * @param postProcess define the post process to add
  103717. */
  103718. addPostProcess(postProcess: PostProcess): void;
  103719. /**
  103720. * Clear all the post processes attached to the render target
  103721. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  103722. */
  103723. clearPostProcesses(dispose?: boolean): void;
  103724. /**
  103725. * Remove one of the post process from the list of attached post processes to the texture
  103726. * @param postProcess define the post process to remove from the list
  103727. */
  103728. removePostProcess(postProcess: PostProcess): void;
  103729. /** @hidden */
  103730. _shouldRender(): boolean;
  103731. /**
  103732. * Gets the actual render size of the texture.
  103733. * @returns the width of the render size
  103734. */
  103735. getRenderSize(): number;
  103736. /**
  103737. * Gets the actual render width of the texture.
  103738. * @returns the width of the render size
  103739. */
  103740. getRenderWidth(): number;
  103741. /**
  103742. * Gets the actual render height of the texture.
  103743. * @returns the height of the render size
  103744. */
  103745. getRenderHeight(): number;
  103746. /**
  103747. * Gets the actual number of layers of the texture.
  103748. * @returns the number of layers
  103749. */
  103750. getRenderLayers(): number;
  103751. /**
  103752. * Get if the texture can be rescaled or not.
  103753. */
  103754. get canRescale(): boolean;
  103755. /**
  103756. * Resize the texture using a ratio.
  103757. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  103758. */
  103759. scale(ratio: number): void;
  103760. /**
  103761. * Get the texture reflection matrix used to rotate/transform the reflection.
  103762. * @returns the reflection matrix
  103763. */
  103764. getReflectionTextureMatrix(): Matrix;
  103765. /**
  103766. * Resize the texture to a new desired size.
  103767. * Be carrefull as it will recreate all the data in the new texture.
  103768. * @param size Define the new size. It can be:
  103769. * - a number for squared texture,
  103770. * - an object containing { width: number, height: number }
  103771. * - or an object containing a ratio { ratio: number }
  103772. */
  103773. resize(size: number | {
  103774. width: number;
  103775. height: number;
  103776. } | {
  103777. ratio: number;
  103778. }): void;
  103779. private _defaultRenderListPrepared;
  103780. /**
  103781. * Renders all the objects from the render list into the texture.
  103782. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  103783. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  103784. */
  103785. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  103786. private _bestReflectionRenderTargetDimension;
  103787. private _prepareRenderingManager;
  103788. /**
  103789. * @hidden
  103790. * @param faceIndex face index to bind to if this is a cubetexture
  103791. * @param layer defines the index of the texture to bind in the array
  103792. */
  103793. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  103794. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  103795. private renderToTarget;
  103796. /**
  103797. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  103798. * This allowed control for front to back rendering or reversly depending of the special needs.
  103799. *
  103800. * @param renderingGroupId The rendering group id corresponding to its index
  103801. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  103802. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  103803. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  103804. */
  103805. 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;
  103806. /**
  103807. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  103808. *
  103809. * @param renderingGroupId The rendering group id corresponding to its index
  103810. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  103811. */
  103812. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  103813. /**
  103814. * Clones the texture.
  103815. * @returns the cloned texture
  103816. */
  103817. clone(): RenderTargetTexture;
  103818. /**
  103819. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  103820. * @returns The JSON representation of the texture
  103821. */
  103822. serialize(): any;
  103823. /**
  103824. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  103825. */
  103826. disposeFramebufferObjects(): void;
  103827. /**
  103828. * Dispose the texture and release its associated resources.
  103829. */
  103830. dispose(): void;
  103831. /** @hidden */
  103832. _rebuild(): void;
  103833. /**
  103834. * Clear the info related to rendering groups preventing retention point in material dispose.
  103835. */
  103836. freeRenderingGroups(): void;
  103837. /**
  103838. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  103839. * @returns the view count
  103840. */
  103841. getViewCount(): number;
  103842. }
  103843. }
  103844. declare module BABYLON {
  103845. /**
  103846. * Class used to manipulate GUIDs
  103847. */
  103848. export class GUID {
  103849. /**
  103850. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  103851. * Be aware Math.random() could cause collisions, but:
  103852. * "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"
  103853. * @returns a pseudo random id
  103854. */
  103855. static RandomId(): string;
  103856. }
  103857. }
  103858. declare module BABYLON {
  103859. /**
  103860. * Options to be used when creating a shadow depth material
  103861. */
  103862. export interface IIOptionShadowDepthMaterial {
  103863. /** Variables in the vertex shader code that need to have their names remapped.
  103864. * The format is: ["var_name", "var_remapped_name", "var_name", "var_remapped_name", ...]
  103865. * "var_name" should be either: worldPos or vNormalW
  103866. * So, if the variable holding the world position in your vertex shader is not named worldPos, you must tell the system
  103867. * the name to use instead by using: ["worldPos", "myWorldPosVar"] assuming the variable is named myWorldPosVar in your code.
  103868. * If the normal must also be remapped: ["worldPos", "myWorldPosVar", "vNormalW", "myWorldNormal"]
  103869. */
  103870. remappedVariables?: string[];
  103871. /** Set standalone to true if the base material wrapped by ShadowDepthMaterial is not used for a regular object but for depth shadow generation only */
  103872. standalone?: boolean;
  103873. }
  103874. /**
  103875. * Class that can be used to wrap a base material to generate accurate shadows when using custom vertex/fragment code in the base material
  103876. */
  103877. export class ShadowDepthWrapper {
  103878. private _scene;
  103879. private _options?;
  103880. private _baseMaterial;
  103881. private _onEffectCreatedObserver;
  103882. private _subMeshToEffect;
  103883. private _subMeshToDepthEffect;
  103884. private _meshes;
  103885. /** @hidden */
  103886. _matriceNames: any;
  103887. /** Gets the standalone status of the wrapper */
  103888. get standalone(): boolean;
  103889. /** Gets the base material the wrapper is built upon */
  103890. get baseMaterial(): Material;
  103891. /**
  103892. * Instantiate a new shadow depth wrapper.
  103893. * It works by injecting some specific code in the vertex/fragment shaders of the base material and is used by a shadow generator to
  103894. * generate the shadow depth map. For more information, please refer to the documentation:
  103895. * https://doc.babylonjs.com/babylon101/shadows
  103896. * @param baseMaterial Material to wrap
  103897. * @param scene Define the scene the material belongs to
  103898. * @param options Options used to create the wrapper
  103899. */
  103900. constructor(baseMaterial: Material, scene: Scene, options?: IIOptionShadowDepthMaterial);
  103901. /**
  103902. * Gets the effect to use to generate the depth map
  103903. * @param subMesh subMesh to get the effect for
  103904. * @param shadowGenerator shadow generator to get the effect for
  103905. * @returns the effect to use to generate the depth map for the subMesh + shadow generator specified
  103906. */
  103907. getEffect(subMesh: Nullable<SubMesh>, shadowGenerator: ShadowGenerator): Nullable<Effect>;
  103908. /**
  103909. * Specifies that the submesh is ready to be used for depth rendering
  103910. * @param subMesh submesh to check
  103911. * @param defines the list of defines to take into account when checking the effect
  103912. * @param shadowGenerator combined with subMesh, it defines the effect to check
  103913. * @param useInstances specifies that instances should be used
  103914. * @returns a boolean indicating that the submesh is ready or not
  103915. */
  103916. isReadyForSubMesh(subMesh: SubMesh, defines: string[], shadowGenerator: ShadowGenerator, useInstances: boolean): boolean;
  103917. /**
  103918. * Disposes the resources
  103919. */
  103920. dispose(): void;
  103921. private _makeEffect;
  103922. }
  103923. }
  103924. declare module BABYLON {
  103925. interface ThinEngine {
  103926. /**
  103927. * Unbind a list of render target textures from the webGL context
  103928. * This is used only when drawBuffer extension or webGL2 are active
  103929. * @param textures defines the render target textures to unbind
  103930. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  103931. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  103932. */
  103933. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  103934. /**
  103935. * Create a multi render target texture
  103936. * @see https://doc.babylonjs.com/features/webgl2#multiple-render-target
  103937. * @param size defines the size of the texture
  103938. * @param options defines the creation options
  103939. * @returns the cube texture as an InternalTexture
  103940. */
  103941. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  103942. /**
  103943. * Update the sample count for a given multiple render target texture
  103944. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  103945. * @param textures defines the textures to update
  103946. * @param samples defines the sample count to set
  103947. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  103948. */
  103949. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  103950. /**
  103951. * Select a subsets of attachments to draw to.
  103952. * @param attachments gl attachments
  103953. */
  103954. bindAttachments(attachments: number[]): void;
  103955. }
  103956. }
  103957. declare module BABYLON {
  103958. /**
  103959. * Creation options of the multi render target texture.
  103960. */
  103961. export interface IMultiRenderTargetOptions {
  103962. /**
  103963. * Define if the texture needs to create mip maps after render.
  103964. */
  103965. generateMipMaps?: boolean;
  103966. /**
  103967. * Define the types of all the draw buffers we want to create
  103968. */
  103969. types?: number[];
  103970. /**
  103971. * Define the sampling modes of all the draw buffers we want to create
  103972. */
  103973. samplingModes?: number[];
  103974. /**
  103975. * Define if a depth buffer is required
  103976. */
  103977. generateDepthBuffer?: boolean;
  103978. /**
  103979. * Define if a stencil buffer is required
  103980. */
  103981. generateStencilBuffer?: boolean;
  103982. /**
  103983. * Define if a depth texture is required instead of a depth buffer
  103984. */
  103985. generateDepthTexture?: boolean;
  103986. /**
  103987. * Define the number of desired draw buffers
  103988. */
  103989. textureCount?: number;
  103990. /**
  103991. * Define if aspect ratio should be adapted to the texture or stay the scene one
  103992. */
  103993. doNotChangeAspectRatio?: boolean;
  103994. /**
  103995. * Define the default type of the buffers we are creating
  103996. */
  103997. defaultType?: number;
  103998. }
  103999. /**
  104000. * A multi render target, like a render target provides the ability to render to a texture.
  104001. * Unlike the render target, it can render to several draw buffers in one draw.
  104002. * This is specially interesting in deferred rendering or for any effects requiring more than
  104003. * just one color from a single pass.
  104004. */
  104005. export class MultiRenderTarget extends RenderTargetTexture {
  104006. private _internalTextures;
  104007. private _textures;
  104008. private _multiRenderTargetOptions;
  104009. private _count;
  104010. /**
  104011. * Get if draw buffers are currently supported by the used hardware and browser.
  104012. */
  104013. get isSupported(): boolean;
  104014. /**
  104015. * Get the list of textures generated by the multi render target.
  104016. */
  104017. get textures(): Texture[];
  104018. /**
  104019. * Gets the number of textures in this MRT. This number can be different from `_textures.length` in case a depth texture is generated.
  104020. */
  104021. get count(): number;
  104022. /**
  104023. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  104024. */
  104025. get depthTexture(): Texture;
  104026. /**
  104027. * Set the wrapping mode on U of all the textures we are rendering to.
  104028. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  104029. */
  104030. set wrapU(wrap: number);
  104031. /**
  104032. * Set the wrapping mode on V of all the textures we are rendering to.
  104033. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  104034. */
  104035. set wrapV(wrap: number);
  104036. /**
  104037. * Instantiate a new multi render target texture.
  104038. * A multi render target, like a render target provides the ability to render to a texture.
  104039. * Unlike the render target, it can render to several draw buffers in one draw.
  104040. * This is specially interesting in deferred rendering or for any effects requiring more than
  104041. * just one color from a single pass.
  104042. * @param name Define the name of the texture
  104043. * @param size Define the size of the buffers to render to
  104044. * @param count Define the number of target we are rendering into
  104045. * @param scene Define the scene the texture belongs to
  104046. * @param options Define the options used to create the multi render target
  104047. */
  104048. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  104049. /** @hidden */
  104050. _rebuild(): void;
  104051. private _createInternalTextures;
  104052. private _createTextures;
  104053. /**
  104054. * Define the number of samples used if MSAA is enabled.
  104055. */
  104056. get samples(): number;
  104057. set samples(value: number);
  104058. /**
  104059. * Resize all the textures in the multi render target.
  104060. * Be carrefull as it will recreate all the data in the new texture.
  104061. * @param size Define the new size
  104062. */
  104063. resize(size: any): void;
  104064. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  104065. /**
  104066. * Dispose the render targets and their associated resources
  104067. */
  104068. dispose(): void;
  104069. /**
  104070. * Release all the underlying texture used as draw buffers.
  104071. */
  104072. releaseInternalTextures(): void;
  104073. }
  104074. }
  104075. declare module BABYLON {
  104076. /** @hidden */
  104077. export var imageProcessingPixelShader: {
  104078. name: string;
  104079. shader: string;
  104080. };
  104081. }
  104082. declare module BABYLON {
  104083. /**
  104084. * ImageProcessingPostProcess
  104085. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  104086. */
  104087. export class ImageProcessingPostProcess extends PostProcess {
  104088. /**
  104089. * Default configuration related to image processing available in the PBR Material.
  104090. */
  104091. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  104092. /**
  104093. * Gets the image processing configuration used either in this material.
  104094. */
  104095. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  104096. /**
  104097. * Sets the Default image processing configuration used either in the this material.
  104098. *
  104099. * If sets to null, the scene one is in use.
  104100. */
  104101. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  104102. /**
  104103. * Keep track of the image processing observer to allow dispose and replace.
  104104. */
  104105. private _imageProcessingObserver;
  104106. /**
  104107. * Attaches a new image processing configuration to the PBR Material.
  104108. * @param configuration
  104109. */
  104110. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  104111. /**
  104112. * If the post process is supported.
  104113. */
  104114. get isSupported(): boolean;
  104115. /**
  104116. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  104117. */
  104118. get colorCurves(): Nullable<ColorCurves>;
  104119. /**
  104120. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  104121. */
  104122. set colorCurves(value: Nullable<ColorCurves>);
  104123. /**
  104124. * Gets wether the color curves effect is enabled.
  104125. */
  104126. get colorCurvesEnabled(): boolean;
  104127. /**
  104128. * Sets wether the color curves effect is enabled.
  104129. */
  104130. set colorCurvesEnabled(value: boolean);
  104131. /**
  104132. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  104133. */
  104134. get colorGradingTexture(): Nullable<BaseTexture>;
  104135. /**
  104136. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  104137. */
  104138. set colorGradingTexture(value: Nullable<BaseTexture>);
  104139. /**
  104140. * Gets wether the color grading effect is enabled.
  104141. */
  104142. get colorGradingEnabled(): boolean;
  104143. /**
  104144. * Gets wether the color grading effect is enabled.
  104145. */
  104146. set colorGradingEnabled(value: boolean);
  104147. /**
  104148. * Gets exposure used in the effect.
  104149. */
  104150. get exposure(): number;
  104151. /**
  104152. * Sets exposure used in the effect.
  104153. */
  104154. set exposure(value: number);
  104155. /**
  104156. * Gets wether tonemapping is enabled or not.
  104157. */
  104158. get toneMappingEnabled(): boolean;
  104159. /**
  104160. * Sets wether tonemapping is enabled or not
  104161. */
  104162. set toneMappingEnabled(value: boolean);
  104163. /**
  104164. * Gets the type of tone mapping effect.
  104165. */
  104166. get toneMappingType(): number;
  104167. /**
  104168. * Sets the type of tone mapping effect.
  104169. */
  104170. set toneMappingType(value: number);
  104171. /**
  104172. * Gets contrast used in the effect.
  104173. */
  104174. get contrast(): number;
  104175. /**
  104176. * Sets contrast used in the effect.
  104177. */
  104178. set contrast(value: number);
  104179. /**
  104180. * Gets Vignette stretch size.
  104181. */
  104182. get vignetteStretch(): number;
  104183. /**
  104184. * Sets Vignette stretch size.
  104185. */
  104186. set vignetteStretch(value: number);
  104187. /**
  104188. * Gets Vignette centre X Offset.
  104189. */
  104190. get vignetteCentreX(): number;
  104191. /**
  104192. * Sets Vignette centre X Offset.
  104193. */
  104194. set vignetteCentreX(value: number);
  104195. /**
  104196. * Gets Vignette centre Y Offset.
  104197. */
  104198. get vignetteCentreY(): number;
  104199. /**
  104200. * Sets Vignette centre Y Offset.
  104201. */
  104202. set vignetteCentreY(value: number);
  104203. /**
  104204. * Gets Vignette weight or intensity of the vignette effect.
  104205. */
  104206. get vignetteWeight(): number;
  104207. /**
  104208. * Sets Vignette weight or intensity of the vignette effect.
  104209. */
  104210. set vignetteWeight(value: number);
  104211. /**
  104212. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  104213. * if vignetteEnabled is set to true.
  104214. */
  104215. get vignetteColor(): Color4;
  104216. /**
  104217. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  104218. * if vignetteEnabled is set to true.
  104219. */
  104220. set vignetteColor(value: Color4);
  104221. /**
  104222. * Gets Camera field of view used by the Vignette effect.
  104223. */
  104224. get vignetteCameraFov(): number;
  104225. /**
  104226. * Sets Camera field of view used by the Vignette effect.
  104227. */
  104228. set vignetteCameraFov(value: number);
  104229. /**
  104230. * Gets the vignette blend mode allowing different kind of effect.
  104231. */
  104232. get vignetteBlendMode(): number;
  104233. /**
  104234. * Sets the vignette blend mode allowing different kind of effect.
  104235. */
  104236. set vignetteBlendMode(value: number);
  104237. /**
  104238. * Gets wether the vignette effect is enabled.
  104239. */
  104240. get vignetteEnabled(): boolean;
  104241. /**
  104242. * Sets wether the vignette effect is enabled.
  104243. */
  104244. set vignetteEnabled(value: boolean);
  104245. private _fromLinearSpace;
  104246. /**
  104247. * Gets wether the input of the processing is in Gamma or Linear Space.
  104248. */
  104249. get fromLinearSpace(): boolean;
  104250. /**
  104251. * Sets wether the input of the processing is in Gamma or Linear Space.
  104252. */
  104253. set fromLinearSpace(value: boolean);
  104254. /**
  104255. * Defines cache preventing GC.
  104256. */
  104257. private _defines;
  104258. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  104259. /**
  104260. * "ImageProcessingPostProcess"
  104261. * @returns "ImageProcessingPostProcess"
  104262. */
  104263. getClassName(): string;
  104264. /**
  104265. * @hidden
  104266. */
  104267. _updateParameters(): void;
  104268. dispose(camera?: Camera): void;
  104269. }
  104270. }
  104271. declare module BABYLON {
  104272. /** @hidden */
  104273. export var fibonacci: {
  104274. name: string;
  104275. shader: string;
  104276. };
  104277. }
  104278. declare module BABYLON {
  104279. /** @hidden */
  104280. export var subSurfaceScatteringFunctions: {
  104281. name: string;
  104282. shader: string;
  104283. };
  104284. }
  104285. declare module BABYLON {
  104286. /** @hidden */
  104287. export var diffusionProfile: {
  104288. name: string;
  104289. shader: string;
  104290. };
  104291. }
  104292. declare module BABYLON {
  104293. /** @hidden */
  104294. export var subSurfaceScatteringPixelShader: {
  104295. name: string;
  104296. shader: string;
  104297. };
  104298. }
  104299. declare module BABYLON {
  104300. /**
  104301. * Sub surface scattering post process
  104302. */
  104303. export class SubSurfaceScatteringPostProcess extends PostProcess {
  104304. /**
  104305. * Gets a string identifying the name of the class
  104306. * @returns "SubSurfaceScatteringPostProcess" string
  104307. */
  104308. getClassName(): string;
  104309. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  104310. }
  104311. }
  104312. declare module BABYLON {
  104313. /**
  104314. * Interface for defining prepass effects in the prepass post-process pipeline
  104315. */
  104316. export interface PrePassEffectConfiguration {
  104317. /**
  104318. * Post process to attach for this effect
  104319. */
  104320. postProcess: PostProcess;
  104321. /**
  104322. * Is the effect enabled
  104323. */
  104324. enabled: boolean;
  104325. /**
  104326. * Disposes the effect configuration
  104327. */
  104328. dispose(): void;
  104329. /**
  104330. * Disposes the effect configuration
  104331. */
  104332. createPostProcess: () => PostProcess;
  104333. }
  104334. }
  104335. declare module BABYLON {
  104336. /**
  104337. * Contains all parameters needed for the prepass to perform
  104338. * screen space subsurface scattering
  104339. */
  104340. export class SubSurfaceConfiguration implements PrePassEffectConfiguration {
  104341. private _ssDiffusionS;
  104342. private _ssFilterRadii;
  104343. private _ssDiffusionD;
  104344. /**
  104345. * Post process to attach for screen space subsurface scattering
  104346. */
  104347. postProcess: SubSurfaceScatteringPostProcess;
  104348. /**
  104349. * Diffusion profile color for subsurface scattering
  104350. */
  104351. get ssDiffusionS(): number[];
  104352. /**
  104353. * Diffusion profile max color channel value for subsurface scattering
  104354. */
  104355. get ssDiffusionD(): number[];
  104356. /**
  104357. * Diffusion profile filter radius for subsurface scattering
  104358. */
  104359. get ssFilterRadii(): number[];
  104360. /**
  104361. * Is subsurface enabled
  104362. */
  104363. enabled: boolean;
  104364. /**
  104365. * Diffusion profile colors for subsurface scattering
  104366. * You can add one diffusion color using `addDiffusionProfile` on `scene.prePassRenderer`
  104367. * See ...
  104368. * Note that you can only store up to 5 of them
  104369. */
  104370. ssDiffusionProfileColors: Color3[];
  104371. /**
  104372. * Defines the ratio real world => scene units.
  104373. * Used for subsurface scattering
  104374. */
  104375. metersPerUnit: number;
  104376. private _scene;
  104377. /**
  104378. * Builds a subsurface configuration object
  104379. * @param scene The scene
  104380. */
  104381. constructor(scene: Scene);
  104382. /**
  104383. * Adds a new diffusion profile.
  104384. * Useful for more realistic subsurface scattering on diverse materials.
  104385. * @param color The color of the diffusion profile. Should be the average color of the material.
  104386. * @return The index of the diffusion profile for the material subsurface configuration
  104387. */
  104388. addDiffusionProfile(color: Color3): number;
  104389. /**
  104390. * Creates the sss post process
  104391. * @return The created post process
  104392. */
  104393. createPostProcess(): SubSurfaceScatteringPostProcess;
  104394. /**
  104395. * Deletes all diffusion profiles.
  104396. * Note that in order to render subsurface scattering, you should have at least 1 diffusion profile.
  104397. */
  104398. clearAllDiffusionProfiles(): void;
  104399. /**
  104400. * Disposes this object
  104401. */
  104402. dispose(): void;
  104403. /**
  104404. * @hidden
  104405. * https://zero-radiance.github.io/post/sampling-diffusion/
  104406. *
  104407. * Importance sample the normalized diffuse reflectance profile for the computed value of 's'.
  104408. * ------------------------------------------------------------------------------------
  104409. * R[r, phi, s] = s * (Exp[-r * s] + Exp[-r * s / 3]) / (8 * Pi * r)
  104410. * PDF[r, phi, s] = r * R[r, phi, s]
  104411. * CDF[r, s] = 1 - 1/4 * Exp[-r * s] - 3/4 * Exp[-r * s / 3]
  104412. * ------------------------------------------------------------------------------------
  104413. * We importance sample the color channel with the widest scattering distance.
  104414. */
  104415. getDiffusionProfileParameters(color: Color3): number;
  104416. /**
  104417. * Performs sampling of a Normalized Burley diffusion profile in polar coordinates.
  104418. * 'u' is the random number (the value of the CDF): [0, 1).
  104419. * rcp(s) = 1 / ShapeParam = ScatteringDistance.
  104420. * Returns the sampled radial distance, s.t. (u = 0 -> r = 0) and (u = 1 -> r = Inf).
  104421. */
  104422. private _sampleBurleyDiffusionProfile;
  104423. }
  104424. }
  104425. declare module BABYLON {
  104426. /**
  104427. * Renders a pre pass of the scene
  104428. * This means every mesh in the scene will be rendered to a render target texture
  104429. * And then this texture will be composited to the rendering canvas with post processes
  104430. * It is necessary for effects like subsurface scattering or deferred shading
  104431. */
  104432. export class PrePassRenderer {
  104433. /** @hidden */
  104434. static _SceneComponentInitialization: (scene: Scene) => void;
  104435. private _scene;
  104436. private _engine;
  104437. private _isDirty;
  104438. /**
  104439. * Number of textures in the multi render target texture where the scene is directly rendered
  104440. */
  104441. readonly mrtCount: number;
  104442. /**
  104443. * The render target where the scene is directly rendered
  104444. */
  104445. prePassRT: MultiRenderTarget;
  104446. private _mrtTypes;
  104447. private _multiRenderAttachments;
  104448. private _defaultAttachments;
  104449. private _clearAttachments;
  104450. private _postProcesses;
  104451. private readonly _clearColor;
  104452. /**
  104453. * Image processing post process for composition
  104454. */
  104455. imageProcessingPostProcess: ImageProcessingPostProcess;
  104456. /**
  104457. * Configuration for sub surface scattering post process
  104458. */
  104459. subSurfaceConfiguration: SubSurfaceConfiguration;
  104460. /**
  104461. * Should materials render their geometry on the MRT
  104462. */
  104463. materialsShouldRenderGeometry: boolean;
  104464. /**
  104465. * Should materials render the irradiance information on the MRT
  104466. */
  104467. materialsShouldRenderIrradiance: boolean;
  104468. private _enabled;
  104469. /**
  104470. * Indicates if the prepass is enabled
  104471. */
  104472. get enabled(): boolean;
  104473. /**
  104474. * How many samples are used for MSAA of the scene render target
  104475. */
  104476. get samples(): number;
  104477. set samples(n: number);
  104478. /**
  104479. * Instanciates a prepass renderer
  104480. * @param scene The scene
  104481. */
  104482. constructor(scene: Scene);
  104483. private _initializeAttachments;
  104484. private _createCompositionEffect;
  104485. /**
  104486. * Indicates if rendering a prepass is supported
  104487. */
  104488. get isSupported(): boolean;
  104489. /**
  104490. * Sets the proper output textures to draw in the engine.
  104491. * @param effect The effect that is drawn. It can be or not be compatible with drawing to several output textures.
  104492. */
  104493. bindAttachmentsForEffect(effect: Effect): void;
  104494. /**
  104495. * @hidden
  104496. */
  104497. _beforeCameraDraw(): void;
  104498. /**
  104499. * @hidden
  104500. */
  104501. _afterCameraDraw(): void;
  104502. private _checkRTSize;
  104503. private _bindFrameBuffer;
  104504. /**
  104505. * Clears the scene render target (in the sense of settings pixels to the scene clear color value)
  104506. */
  104507. clear(): void;
  104508. private _setState;
  104509. private _enable;
  104510. private _disable;
  104511. private _resetPostProcessChain;
  104512. private _bindPostProcessChain;
  104513. /**
  104514. * Marks the prepass renderer as dirty, triggering a check if the prepass is necessary for the next rendering.
  104515. */
  104516. markAsDirty(): void;
  104517. private _update;
  104518. /**
  104519. * Disposes the prepass renderer.
  104520. */
  104521. dispose(): void;
  104522. }
  104523. }
  104524. declare module BABYLON {
  104525. /**
  104526. * Options for compiling materials.
  104527. */
  104528. export interface IMaterialCompilationOptions {
  104529. /**
  104530. * Defines whether clip planes are enabled.
  104531. */
  104532. clipPlane: boolean;
  104533. /**
  104534. * Defines whether instances are enabled.
  104535. */
  104536. useInstances: boolean;
  104537. }
  104538. /**
  104539. * Options passed when calling customShaderNameResolve
  104540. */
  104541. export interface ICustomShaderNameResolveOptions {
  104542. /**
  104543. * 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
  104544. */
  104545. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  104546. }
  104547. /**
  104548. * Base class for the main features of a material in Babylon.js
  104549. */
  104550. export class Material implements IAnimatable {
  104551. /**
  104552. * Returns the triangle fill mode
  104553. */
  104554. static readonly TriangleFillMode: number;
  104555. /**
  104556. * Returns the wireframe mode
  104557. */
  104558. static readonly WireFrameFillMode: number;
  104559. /**
  104560. * Returns the point fill mode
  104561. */
  104562. static readonly PointFillMode: number;
  104563. /**
  104564. * Returns the point list draw mode
  104565. */
  104566. static readonly PointListDrawMode: number;
  104567. /**
  104568. * Returns the line list draw mode
  104569. */
  104570. static readonly LineListDrawMode: number;
  104571. /**
  104572. * Returns the line loop draw mode
  104573. */
  104574. static readonly LineLoopDrawMode: number;
  104575. /**
  104576. * Returns the line strip draw mode
  104577. */
  104578. static readonly LineStripDrawMode: number;
  104579. /**
  104580. * Returns the triangle strip draw mode
  104581. */
  104582. static readonly TriangleStripDrawMode: number;
  104583. /**
  104584. * Returns the triangle fan draw mode
  104585. */
  104586. static readonly TriangleFanDrawMode: number;
  104587. /**
  104588. * Stores the clock-wise side orientation
  104589. */
  104590. static readonly ClockWiseSideOrientation: number;
  104591. /**
  104592. * Stores the counter clock-wise side orientation
  104593. */
  104594. static readonly CounterClockWiseSideOrientation: number;
  104595. /**
  104596. * The dirty texture flag value
  104597. */
  104598. static readonly TextureDirtyFlag: number;
  104599. /**
  104600. * The dirty light flag value
  104601. */
  104602. static readonly LightDirtyFlag: number;
  104603. /**
  104604. * The dirty fresnel flag value
  104605. */
  104606. static readonly FresnelDirtyFlag: number;
  104607. /**
  104608. * The dirty attribute flag value
  104609. */
  104610. static readonly AttributesDirtyFlag: number;
  104611. /**
  104612. * The dirty misc flag value
  104613. */
  104614. static readonly MiscDirtyFlag: number;
  104615. /**
  104616. * The all dirty flag value
  104617. */
  104618. static readonly AllDirtyFlag: number;
  104619. /**
  104620. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  104621. */
  104622. static readonly MATERIAL_OPAQUE: number;
  104623. /**
  104624. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  104625. */
  104626. static readonly MATERIAL_ALPHATEST: number;
  104627. /**
  104628. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  104629. */
  104630. static readonly MATERIAL_ALPHABLEND: number;
  104631. /**
  104632. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  104633. * They are also discarded below the alpha cutoff threshold to improve performances.
  104634. */
  104635. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  104636. /**
  104637. * The Whiteout method is used to blend normals.
  104638. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  104639. */
  104640. static readonly MATERIAL_NORMALBLENDMETHOD_WHITEOUT: number;
  104641. /**
  104642. * The Reoriented Normal Mapping method is used to blend normals.
  104643. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  104644. */
  104645. static readonly MATERIAL_NORMALBLENDMETHOD_RNM: number;
  104646. /**
  104647. * Custom callback helping to override the default shader used in the material.
  104648. */
  104649. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: MaterialDefines | string[], attributes?: string[], options?: ICustomShaderNameResolveOptions) => string;
  104650. /**
  104651. * Custom shadow depth material to use for shadow rendering instead of the in-built one
  104652. */
  104653. shadowDepthWrapper: Nullable<ShadowDepthWrapper>;
  104654. /**
  104655. * Gets or sets a boolean indicating that the material is allowed (if supported) to do shader hot swapping.
  104656. * This means that the material can keep using a previous shader while a new one is being compiled.
  104657. * This is mostly used when shader parallel compilation is supported (true by default)
  104658. */
  104659. allowShaderHotSwapping: boolean;
  104660. /**
  104661. * The ID of the material
  104662. */
  104663. id: string;
  104664. /**
  104665. * Gets or sets the unique id of the material
  104666. */
  104667. uniqueId: number;
  104668. /**
  104669. * The name of the material
  104670. */
  104671. name: string;
  104672. /**
  104673. * Gets or sets user defined metadata
  104674. */
  104675. metadata: any;
  104676. /**
  104677. * For internal use only. Please do not use.
  104678. */
  104679. reservedDataStore: any;
  104680. /**
  104681. * Specifies if the ready state should be checked on each call
  104682. */
  104683. checkReadyOnEveryCall: boolean;
  104684. /**
  104685. * Specifies if the ready state should be checked once
  104686. */
  104687. checkReadyOnlyOnce: boolean;
  104688. /**
  104689. * The state of the material
  104690. */
  104691. state: string;
  104692. /**
  104693. * If the material can be rendered to several textures with MRT extension
  104694. */
  104695. get canRenderToMRT(): boolean;
  104696. /**
  104697. * The alpha value of the material
  104698. */
  104699. protected _alpha: number;
  104700. /**
  104701. * List of inspectable custom properties (used by the Inspector)
  104702. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  104703. */
  104704. inspectableCustomProperties: IInspectable[];
  104705. /**
  104706. * Sets the alpha value of the material
  104707. */
  104708. set alpha(value: number);
  104709. /**
  104710. * Gets the alpha value of the material
  104711. */
  104712. get alpha(): number;
  104713. /**
  104714. * Specifies if back face culling is enabled
  104715. */
  104716. protected _backFaceCulling: boolean;
  104717. /**
  104718. * Sets the back-face culling state
  104719. */
  104720. set backFaceCulling(value: boolean);
  104721. /**
  104722. * Gets the back-face culling state
  104723. */
  104724. get backFaceCulling(): boolean;
  104725. /**
  104726. * Stores the value for side orientation
  104727. */
  104728. sideOrientation: number;
  104729. /**
  104730. * Callback triggered when the material is compiled
  104731. */
  104732. onCompiled: Nullable<(effect: Effect) => void>;
  104733. /**
  104734. * Callback triggered when an error occurs
  104735. */
  104736. onError: Nullable<(effect: Effect, errors: string) => void>;
  104737. /**
  104738. * Callback triggered to get the render target textures
  104739. */
  104740. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  104741. /**
  104742. * Gets a boolean indicating that current material needs to register RTT
  104743. */
  104744. get hasRenderTargetTextures(): boolean;
  104745. /**
  104746. * Specifies if the material should be serialized
  104747. */
  104748. doNotSerialize: boolean;
  104749. /**
  104750. * @hidden
  104751. */
  104752. _storeEffectOnSubMeshes: boolean;
  104753. /**
  104754. * Stores the animations for the material
  104755. */
  104756. animations: Nullable<Array<Animation>>;
  104757. /**
  104758. * An event triggered when the material is disposed
  104759. */
  104760. onDisposeObservable: Observable<Material>;
  104761. /**
  104762. * An observer which watches for dispose events
  104763. */
  104764. private _onDisposeObserver;
  104765. private _onUnBindObservable;
  104766. /**
  104767. * Called during a dispose event
  104768. */
  104769. set onDispose(callback: () => void);
  104770. private _onBindObservable;
  104771. /**
  104772. * An event triggered when the material is bound
  104773. */
  104774. get onBindObservable(): Observable<AbstractMesh>;
  104775. /**
  104776. * An observer which watches for bind events
  104777. */
  104778. private _onBindObserver;
  104779. /**
  104780. * Called during a bind event
  104781. */
  104782. set onBind(callback: (Mesh: AbstractMesh) => void);
  104783. /**
  104784. * An event triggered when the material is unbound
  104785. */
  104786. get onUnBindObservable(): Observable<Material>;
  104787. protected _onEffectCreatedObservable: Nullable<Observable<{
  104788. effect: Effect;
  104789. subMesh: Nullable<SubMesh>;
  104790. }>>;
  104791. /**
  104792. * An event triggered when the effect is (re)created
  104793. */
  104794. get onEffectCreatedObservable(): Observable<{
  104795. effect: Effect;
  104796. subMesh: Nullable<SubMesh>;
  104797. }>;
  104798. /**
  104799. * Stores the value of the alpha mode
  104800. */
  104801. private _alphaMode;
  104802. /**
  104803. * Sets the value of the alpha mode.
  104804. *
  104805. * | Value | Type | Description |
  104806. * | --- | --- | --- |
  104807. * | 0 | ALPHA_DISABLE | |
  104808. * | 1 | ALPHA_ADD | |
  104809. * | 2 | ALPHA_COMBINE | |
  104810. * | 3 | ALPHA_SUBTRACT | |
  104811. * | 4 | ALPHA_MULTIPLY | |
  104812. * | 5 | ALPHA_MAXIMIZED | |
  104813. * | 6 | ALPHA_ONEONE | |
  104814. * | 7 | ALPHA_PREMULTIPLIED | |
  104815. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  104816. * | 9 | ALPHA_INTERPOLATE | |
  104817. * | 10 | ALPHA_SCREENMODE | |
  104818. *
  104819. */
  104820. set alphaMode(value: number);
  104821. /**
  104822. * Gets the value of the alpha mode
  104823. */
  104824. get alphaMode(): number;
  104825. /**
  104826. * Stores the state of the need depth pre-pass value
  104827. */
  104828. private _needDepthPrePass;
  104829. /**
  104830. * Sets the need depth pre-pass value
  104831. */
  104832. set needDepthPrePass(value: boolean);
  104833. /**
  104834. * Gets the depth pre-pass value
  104835. */
  104836. get needDepthPrePass(): boolean;
  104837. /**
  104838. * Specifies if depth writing should be disabled
  104839. */
  104840. disableDepthWrite: boolean;
  104841. /**
  104842. * Specifies if color writing should be disabled
  104843. */
  104844. disableColorWrite: boolean;
  104845. /**
  104846. * Specifies if depth writing should be forced
  104847. */
  104848. forceDepthWrite: boolean;
  104849. /**
  104850. * Specifies the depth function that should be used. 0 means the default engine function
  104851. */
  104852. depthFunction: number;
  104853. /**
  104854. * Specifies if there should be a separate pass for culling
  104855. */
  104856. separateCullingPass: boolean;
  104857. /**
  104858. * Stores the state specifing if fog should be enabled
  104859. */
  104860. private _fogEnabled;
  104861. /**
  104862. * Sets the state for enabling fog
  104863. */
  104864. set fogEnabled(value: boolean);
  104865. /**
  104866. * Gets the value of the fog enabled state
  104867. */
  104868. get fogEnabled(): boolean;
  104869. /**
  104870. * Stores the size of points
  104871. */
  104872. pointSize: number;
  104873. /**
  104874. * Stores the z offset value
  104875. */
  104876. zOffset: number;
  104877. get wireframe(): boolean;
  104878. /**
  104879. * Sets the state of wireframe mode
  104880. */
  104881. set wireframe(value: boolean);
  104882. /**
  104883. * Gets the value specifying if point clouds are enabled
  104884. */
  104885. get pointsCloud(): boolean;
  104886. /**
  104887. * Sets the state of point cloud mode
  104888. */
  104889. set pointsCloud(value: boolean);
  104890. /**
  104891. * Gets the material fill mode
  104892. */
  104893. get fillMode(): number;
  104894. /**
  104895. * Sets the material fill mode
  104896. */
  104897. set fillMode(value: number);
  104898. /**
  104899. * @hidden
  104900. * Stores the effects for the material
  104901. */
  104902. _effect: Nullable<Effect>;
  104903. /**
  104904. * Specifies if uniform buffers should be used
  104905. */
  104906. private _useUBO;
  104907. /**
  104908. * Stores a reference to the scene
  104909. */
  104910. private _scene;
  104911. /**
  104912. * Stores the fill mode state
  104913. */
  104914. private _fillMode;
  104915. /**
  104916. * Specifies if the depth write state should be cached
  104917. */
  104918. private _cachedDepthWriteState;
  104919. /**
  104920. * Specifies if the color write state should be cached
  104921. */
  104922. private _cachedColorWriteState;
  104923. /**
  104924. * Specifies if the depth function state should be cached
  104925. */
  104926. private _cachedDepthFunctionState;
  104927. /**
  104928. * Stores the uniform buffer
  104929. */
  104930. protected _uniformBuffer: UniformBuffer;
  104931. /** @hidden */
  104932. _indexInSceneMaterialArray: number;
  104933. /** @hidden */
  104934. meshMap: Nullable<{
  104935. [id: string]: AbstractMesh | undefined;
  104936. }>;
  104937. /**
  104938. * Creates a material instance
  104939. * @param name defines the name of the material
  104940. * @param scene defines the scene to reference
  104941. * @param doNotAdd specifies if the material should be added to the scene
  104942. */
  104943. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  104944. /**
  104945. * Returns a string representation of the current material
  104946. * @param fullDetails defines a boolean indicating which levels of logging is desired
  104947. * @returns a string with material information
  104948. */
  104949. toString(fullDetails?: boolean): string;
  104950. /**
  104951. * Gets the class name of the material
  104952. * @returns a string with the class name of the material
  104953. */
  104954. getClassName(): string;
  104955. /**
  104956. * Specifies if updates for the material been locked
  104957. */
  104958. get isFrozen(): boolean;
  104959. /**
  104960. * Locks updates for the material
  104961. */
  104962. freeze(): void;
  104963. /**
  104964. * Unlocks updates for the material
  104965. */
  104966. unfreeze(): void;
  104967. /**
  104968. * Specifies if the material is ready to be used
  104969. * @param mesh defines the mesh to check
  104970. * @param useInstances specifies if instances should be used
  104971. * @returns a boolean indicating if the material is ready to be used
  104972. */
  104973. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  104974. /**
  104975. * Specifies that the submesh is ready to be used
  104976. * @param mesh defines the mesh to check
  104977. * @param subMesh defines which submesh to check
  104978. * @param useInstances specifies that instances should be used
  104979. * @returns a boolean indicating that the submesh is ready or not
  104980. */
  104981. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  104982. /**
  104983. * Returns the material effect
  104984. * @returns the effect associated with the material
  104985. */
  104986. getEffect(): Nullable<Effect>;
  104987. /**
  104988. * Returns the current scene
  104989. * @returns a Scene
  104990. */
  104991. getScene(): Scene;
  104992. /**
  104993. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  104994. */
  104995. protected _forceAlphaTest: boolean;
  104996. /**
  104997. * The transparency mode of the material.
  104998. */
  104999. protected _transparencyMode: Nullable<number>;
  105000. /**
  105001. * Gets the current transparency mode.
  105002. */
  105003. get transparencyMode(): Nullable<number>;
  105004. /**
  105005. * Sets the transparency mode of the material.
  105006. *
  105007. * | Value | Type | Description |
  105008. * | ----- | ----------------------------------- | ----------- |
  105009. * | 0 | OPAQUE | |
  105010. * | 1 | ALPHATEST | |
  105011. * | 2 | ALPHABLEND | |
  105012. * | 3 | ALPHATESTANDBLEND | |
  105013. *
  105014. */
  105015. set transparencyMode(value: Nullable<number>);
  105016. /**
  105017. * Returns true if alpha blending should be disabled.
  105018. */
  105019. protected get _disableAlphaBlending(): boolean;
  105020. /**
  105021. * Specifies whether or not this material should be rendered in alpha blend mode.
  105022. * @returns a boolean specifying if alpha blending is needed
  105023. */
  105024. needAlphaBlending(): boolean;
  105025. /**
  105026. * Specifies if the mesh will require alpha blending
  105027. * @param mesh defines the mesh to check
  105028. * @returns a boolean specifying if alpha blending is needed for the mesh
  105029. */
  105030. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  105031. /**
  105032. * Specifies whether or not this material should be rendered in alpha test mode.
  105033. * @returns a boolean specifying if an alpha test is needed.
  105034. */
  105035. needAlphaTesting(): boolean;
  105036. /**
  105037. * Specifies if material alpha testing should be turned on for the mesh
  105038. * @param mesh defines the mesh to check
  105039. */
  105040. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  105041. /**
  105042. * Gets the texture used for the alpha test
  105043. * @returns the texture to use for alpha testing
  105044. */
  105045. getAlphaTestTexture(): Nullable<BaseTexture>;
  105046. /**
  105047. * Marks the material to indicate that it needs to be re-calculated
  105048. */
  105049. markDirty(): void;
  105050. /** @hidden */
  105051. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  105052. /**
  105053. * Binds the material to the mesh
  105054. * @param world defines the world transformation matrix
  105055. * @param mesh defines the mesh to bind the material to
  105056. */
  105057. bind(world: Matrix, mesh?: Mesh): void;
  105058. /**
  105059. * Binds the submesh to the material
  105060. * @param world defines the world transformation matrix
  105061. * @param mesh defines the mesh containing the submesh
  105062. * @param subMesh defines the submesh to bind the material to
  105063. */
  105064. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  105065. /**
  105066. * Binds the world matrix to the material
  105067. * @param world defines the world transformation matrix
  105068. */
  105069. bindOnlyWorldMatrix(world: Matrix): void;
  105070. /**
  105071. * Binds the scene's uniform buffer to the effect.
  105072. * @param effect defines the effect to bind to the scene uniform buffer
  105073. * @param sceneUbo defines the uniform buffer storing scene data
  105074. */
  105075. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  105076. /**
  105077. * Binds the view matrix to the effect
  105078. * @param effect defines the effect to bind the view matrix to
  105079. */
  105080. bindView(effect: Effect): void;
  105081. /**
  105082. * Binds the view projection matrix to the effect
  105083. * @param effect defines the effect to bind the view projection matrix to
  105084. */
  105085. bindViewProjection(effect: Effect): void;
  105086. /**
  105087. * Processes to execute after binding the material to a mesh
  105088. * @param mesh defines the rendered mesh
  105089. */
  105090. protected _afterBind(mesh?: Mesh): void;
  105091. /**
  105092. * Unbinds the material from the mesh
  105093. */
  105094. unbind(): void;
  105095. /**
  105096. * Gets the active textures from the material
  105097. * @returns an array of textures
  105098. */
  105099. getActiveTextures(): BaseTexture[];
  105100. /**
  105101. * Specifies if the material uses a texture
  105102. * @param texture defines the texture to check against the material
  105103. * @returns a boolean specifying if the material uses the texture
  105104. */
  105105. hasTexture(texture: BaseTexture): boolean;
  105106. /**
  105107. * Makes a duplicate of the material, and gives it a new name
  105108. * @param name defines the new name for the duplicated material
  105109. * @returns the cloned material
  105110. */
  105111. clone(name: string): Nullable<Material>;
  105112. /**
  105113. * Gets the meshes bound to the material
  105114. * @returns an array of meshes bound to the material
  105115. */
  105116. getBindedMeshes(): AbstractMesh[];
  105117. /**
  105118. * Force shader compilation
  105119. * @param mesh defines the mesh associated with this material
  105120. * @param onCompiled defines a function to execute once the material is compiled
  105121. * @param options defines the options to configure the compilation
  105122. * @param onError defines a function to execute if the material fails compiling
  105123. */
  105124. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  105125. /**
  105126. * Force shader compilation
  105127. * @param mesh defines the mesh that will use this material
  105128. * @param options defines additional options for compiling the shaders
  105129. * @returns a promise that resolves when the compilation completes
  105130. */
  105131. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  105132. private static readonly _AllDirtyCallBack;
  105133. private static readonly _ImageProcessingDirtyCallBack;
  105134. private static readonly _TextureDirtyCallBack;
  105135. private static readonly _FresnelDirtyCallBack;
  105136. private static readonly _MiscDirtyCallBack;
  105137. private static readonly _LightsDirtyCallBack;
  105138. private static readonly _AttributeDirtyCallBack;
  105139. private static _FresnelAndMiscDirtyCallBack;
  105140. private static _TextureAndMiscDirtyCallBack;
  105141. private static readonly _DirtyCallbackArray;
  105142. private static readonly _RunDirtyCallBacks;
  105143. /**
  105144. * Marks a define in the material to indicate that it needs to be re-computed
  105145. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  105146. */
  105147. markAsDirty(flag: number): void;
  105148. /**
  105149. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  105150. * @param func defines a function which checks material defines against the submeshes
  105151. */
  105152. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  105153. /**
  105154. * Indicates that the scene should check if the rendering now needs a prepass
  105155. */
  105156. protected _markScenePrePassDirty(): void;
  105157. /**
  105158. * Indicates that we need to re-calculated for all submeshes
  105159. */
  105160. protected _markAllSubMeshesAsAllDirty(): void;
  105161. /**
  105162. * Indicates that image processing needs to be re-calculated for all submeshes
  105163. */
  105164. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  105165. /**
  105166. * Indicates that textures need to be re-calculated for all submeshes
  105167. */
  105168. protected _markAllSubMeshesAsTexturesDirty(): void;
  105169. /**
  105170. * Indicates that fresnel needs to be re-calculated for all submeshes
  105171. */
  105172. protected _markAllSubMeshesAsFresnelDirty(): void;
  105173. /**
  105174. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  105175. */
  105176. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  105177. /**
  105178. * Indicates that lights need to be re-calculated for all submeshes
  105179. */
  105180. protected _markAllSubMeshesAsLightsDirty(): void;
  105181. /**
  105182. * Indicates that attributes need to be re-calculated for all submeshes
  105183. */
  105184. protected _markAllSubMeshesAsAttributesDirty(): void;
  105185. /**
  105186. * Indicates that misc needs to be re-calculated for all submeshes
  105187. */
  105188. protected _markAllSubMeshesAsMiscDirty(): void;
  105189. /**
  105190. * Indicates that textures and misc need to be re-calculated for all submeshes
  105191. */
  105192. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  105193. /**
  105194. * Sets the required values to the prepass renderer.
  105195. * @param prePassRenderer defines the prepass renderer to setup.
  105196. * @returns true if the pre pass is needed.
  105197. */
  105198. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  105199. /**
  105200. * Disposes the material
  105201. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  105202. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  105203. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  105204. */
  105205. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  105206. /** @hidden */
  105207. private releaseVertexArrayObject;
  105208. /**
  105209. * Serializes this material
  105210. * @returns the serialized material object
  105211. */
  105212. serialize(): any;
  105213. /**
  105214. * Creates a material from parsed material data
  105215. * @param parsedMaterial defines parsed material data
  105216. * @param scene defines the hosting scene
  105217. * @param rootUrl defines the root URL to use to load textures
  105218. * @returns a new material
  105219. */
  105220. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  105221. }
  105222. }
  105223. declare module BABYLON {
  105224. /**
  105225. * A multi-material is used to apply different materials to different parts of the same object without the need of
  105226. * separate meshes. This can be use to improve performances.
  105227. * @see https://doc.babylonjs.com/how_to/multi_materials
  105228. */
  105229. export class MultiMaterial extends Material {
  105230. private _subMaterials;
  105231. /**
  105232. * Gets or Sets the list of Materials used within the multi material.
  105233. * They need to be ordered according to the submeshes order in the associated mesh
  105234. */
  105235. get subMaterials(): Nullable<Material>[];
  105236. set subMaterials(value: Nullable<Material>[]);
  105237. /**
  105238. * Function used to align with Node.getChildren()
  105239. * @returns the list of Materials used within the multi material
  105240. */
  105241. getChildren(): Nullable<Material>[];
  105242. /**
  105243. * Instantiates a new Multi Material
  105244. * A multi-material is used to apply different materials to different parts of the same object without the need of
  105245. * separate meshes. This can be use to improve performances.
  105246. * @see https://doc.babylonjs.com/how_to/multi_materials
  105247. * @param name Define the name in the scene
  105248. * @param scene Define the scene the material belongs to
  105249. */
  105250. constructor(name: string, scene: Scene);
  105251. private _hookArray;
  105252. /**
  105253. * Get one of the submaterial by its index in the submaterials array
  105254. * @param index The index to look the sub material at
  105255. * @returns The Material if the index has been defined
  105256. */
  105257. getSubMaterial(index: number): Nullable<Material>;
  105258. /**
  105259. * Get the list of active textures for the whole sub materials list.
  105260. * @returns All the textures that will be used during the rendering
  105261. */
  105262. getActiveTextures(): BaseTexture[];
  105263. /**
  105264. * Gets the current class name of the material e.g. "MultiMaterial"
  105265. * Mainly use in serialization.
  105266. * @returns the class name
  105267. */
  105268. getClassName(): string;
  105269. /**
  105270. * Checks if the material is ready to render the requested sub mesh
  105271. * @param mesh Define the mesh the submesh belongs to
  105272. * @param subMesh Define the sub mesh to look readyness for
  105273. * @param useInstances Define whether or not the material is used with instances
  105274. * @returns true if ready, otherwise false
  105275. */
  105276. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  105277. /**
  105278. * Clones the current material and its related sub materials
  105279. * @param name Define the name of the newly cloned material
  105280. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  105281. * @returns the cloned material
  105282. */
  105283. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  105284. /**
  105285. * Serializes the materials into a JSON representation.
  105286. * @returns the JSON representation
  105287. */
  105288. serialize(): any;
  105289. /**
  105290. * Dispose the material and release its associated resources
  105291. * @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)
  105292. * @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)
  105293. * @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)
  105294. */
  105295. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  105296. /**
  105297. * Creates a MultiMaterial from parsed MultiMaterial data.
  105298. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  105299. * @param scene defines the hosting scene
  105300. * @returns a new MultiMaterial
  105301. */
  105302. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  105303. }
  105304. }
  105305. declare module BABYLON {
  105306. /**
  105307. * Defines a subdivision inside a mesh
  105308. */
  105309. export class SubMesh implements ICullable {
  105310. /** the material index to use */
  105311. materialIndex: number;
  105312. /** vertex index start */
  105313. verticesStart: number;
  105314. /** vertices count */
  105315. verticesCount: number;
  105316. /** index start */
  105317. indexStart: number;
  105318. /** indices count */
  105319. indexCount: number;
  105320. /** @hidden */
  105321. _materialDefines: Nullable<MaterialDefines>;
  105322. /** @hidden */
  105323. _materialEffect: Nullable<Effect>;
  105324. /** @hidden */
  105325. _effectOverride: Nullable<Effect>;
  105326. /**
  105327. * Gets material defines used by the effect associated to the sub mesh
  105328. */
  105329. get materialDefines(): Nullable<MaterialDefines>;
  105330. /**
  105331. * Sets material defines used by the effect associated to the sub mesh
  105332. */
  105333. set materialDefines(defines: Nullable<MaterialDefines>);
  105334. /**
  105335. * Gets associated effect
  105336. */
  105337. get effect(): Nullable<Effect>;
  105338. /**
  105339. * Sets associated effect (effect used to render this submesh)
  105340. * @param effect defines the effect to associate with
  105341. * @param defines defines the set of defines used to compile this effect
  105342. */
  105343. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  105344. /** @hidden */
  105345. _linesIndexCount: number;
  105346. private _mesh;
  105347. private _renderingMesh;
  105348. private _boundingInfo;
  105349. private _linesIndexBuffer;
  105350. /** @hidden */
  105351. _lastColliderWorldVertices: Nullable<Vector3[]>;
  105352. /** @hidden */
  105353. _trianglePlanes: Plane[];
  105354. /** @hidden */
  105355. _lastColliderTransformMatrix: Nullable<Matrix>;
  105356. /** @hidden */
  105357. _renderId: number;
  105358. /** @hidden */
  105359. _alphaIndex: number;
  105360. /** @hidden */
  105361. _distanceToCamera: number;
  105362. /** @hidden */
  105363. _id: number;
  105364. private _currentMaterial;
  105365. /**
  105366. * Add a new submesh to a mesh
  105367. * @param materialIndex defines the material index to use
  105368. * @param verticesStart defines vertex index start
  105369. * @param verticesCount defines vertices count
  105370. * @param indexStart defines index start
  105371. * @param indexCount defines indices count
  105372. * @param mesh defines the parent mesh
  105373. * @param renderingMesh defines an optional rendering mesh
  105374. * @param createBoundingBox defines if bounding box should be created for this submesh
  105375. * @returns the new submesh
  105376. */
  105377. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  105378. /**
  105379. * Creates a new submesh
  105380. * @param materialIndex defines the material index to use
  105381. * @param verticesStart defines vertex index start
  105382. * @param verticesCount defines vertices count
  105383. * @param indexStart defines index start
  105384. * @param indexCount defines indices count
  105385. * @param mesh defines the parent mesh
  105386. * @param renderingMesh defines an optional rendering mesh
  105387. * @param createBoundingBox defines if bounding box should be created for this submesh
  105388. * @param addToMesh defines a boolean indicating that the submesh must be added to the mesh.subMeshes array (true by default)
  105389. */
  105390. constructor(
  105391. /** the material index to use */
  105392. materialIndex: number,
  105393. /** vertex index start */
  105394. verticesStart: number,
  105395. /** vertices count */
  105396. verticesCount: number,
  105397. /** index start */
  105398. indexStart: number,
  105399. /** indices count */
  105400. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean, addToMesh?: boolean);
  105401. /**
  105402. * Returns true if this submesh covers the entire parent mesh
  105403. * @ignorenaming
  105404. */
  105405. get IsGlobal(): boolean;
  105406. /**
  105407. * Returns the submesh BoudingInfo object
  105408. * @returns current bounding info (or mesh's one if the submesh is global)
  105409. */
  105410. getBoundingInfo(): BoundingInfo;
  105411. /**
  105412. * Sets the submesh BoundingInfo
  105413. * @param boundingInfo defines the new bounding info to use
  105414. * @returns the SubMesh
  105415. */
  105416. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  105417. /**
  105418. * Returns the mesh of the current submesh
  105419. * @return the parent mesh
  105420. */
  105421. getMesh(): AbstractMesh;
  105422. /**
  105423. * Returns the rendering mesh of the submesh
  105424. * @returns the rendering mesh (could be different from parent mesh)
  105425. */
  105426. getRenderingMesh(): Mesh;
  105427. /**
  105428. * Returns the replacement mesh of the submesh
  105429. * @returns the replacement mesh (could be different from parent mesh)
  105430. */
  105431. getReplacementMesh(): Nullable<AbstractMesh>;
  105432. /**
  105433. * Returns the effective mesh of the submesh
  105434. * @returns the effective mesh (could be different from parent mesh)
  105435. */
  105436. getEffectiveMesh(): AbstractMesh;
  105437. /**
  105438. * Returns the submesh material
  105439. * @returns null or the current material
  105440. */
  105441. getMaterial(): Nullable<Material>;
  105442. private _IsMultiMaterial;
  105443. /**
  105444. * Sets a new updated BoundingInfo object to the submesh
  105445. * @param data defines an optional position array to use to determine the bounding info
  105446. * @returns the SubMesh
  105447. */
  105448. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  105449. /** @hidden */
  105450. _checkCollision(collider: Collider): boolean;
  105451. /**
  105452. * Updates the submesh BoundingInfo
  105453. * @param world defines the world matrix to use to update the bounding info
  105454. * @returns the submesh
  105455. */
  105456. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  105457. /**
  105458. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  105459. * @param frustumPlanes defines the frustum planes
  105460. * @returns true if the submesh is intersecting with the frustum
  105461. */
  105462. isInFrustum(frustumPlanes: Plane[]): boolean;
  105463. /**
  105464. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  105465. * @param frustumPlanes defines the frustum planes
  105466. * @returns true if the submesh is inside the frustum
  105467. */
  105468. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  105469. /**
  105470. * Renders the submesh
  105471. * @param enableAlphaMode defines if alpha needs to be used
  105472. * @returns the submesh
  105473. */
  105474. render(enableAlphaMode: boolean): SubMesh;
  105475. /**
  105476. * @hidden
  105477. */
  105478. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  105479. /**
  105480. * Checks if the submesh intersects with a ray
  105481. * @param ray defines the ray to test
  105482. * @returns true is the passed ray intersects the submesh bounding box
  105483. */
  105484. canIntersects(ray: Ray): boolean;
  105485. /**
  105486. * Intersects current submesh with a ray
  105487. * @param ray defines the ray to test
  105488. * @param positions defines mesh's positions array
  105489. * @param indices defines mesh's indices array
  105490. * @param fastCheck defines if the first intersection will be used (and not the closest)
  105491. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  105492. * @returns intersection info or null if no intersection
  105493. */
  105494. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  105495. /** @hidden */
  105496. private _intersectLines;
  105497. /** @hidden */
  105498. private _intersectUnIndexedLines;
  105499. /** @hidden */
  105500. private _intersectTriangles;
  105501. /** @hidden */
  105502. private _intersectUnIndexedTriangles;
  105503. /** @hidden */
  105504. _rebuild(): void;
  105505. /**
  105506. * Creates a new submesh from the passed mesh
  105507. * @param newMesh defines the new hosting mesh
  105508. * @param newRenderingMesh defines an optional rendering mesh
  105509. * @returns the new submesh
  105510. */
  105511. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  105512. /**
  105513. * Release associated resources
  105514. */
  105515. dispose(): void;
  105516. /**
  105517. * Gets the class name
  105518. * @returns the string "SubMesh".
  105519. */
  105520. getClassName(): string;
  105521. /**
  105522. * Creates a new submesh from indices data
  105523. * @param materialIndex the index of the main mesh material
  105524. * @param startIndex the index where to start the copy in the mesh indices array
  105525. * @param indexCount the number of indices to copy then from the startIndex
  105526. * @param mesh the main mesh to create the submesh from
  105527. * @param renderingMesh the optional rendering mesh
  105528. * @returns a new submesh
  105529. */
  105530. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  105531. }
  105532. }
  105533. declare module BABYLON {
  105534. /**
  105535. * Class used to represent data loading progression
  105536. */
  105537. export class SceneLoaderFlags {
  105538. private static _ForceFullSceneLoadingForIncremental;
  105539. private static _ShowLoadingScreen;
  105540. private static _CleanBoneMatrixWeights;
  105541. private static _loggingLevel;
  105542. /**
  105543. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  105544. */
  105545. static get ForceFullSceneLoadingForIncremental(): boolean;
  105546. static set ForceFullSceneLoadingForIncremental(value: boolean);
  105547. /**
  105548. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  105549. */
  105550. static get ShowLoadingScreen(): boolean;
  105551. static set ShowLoadingScreen(value: boolean);
  105552. /**
  105553. * Defines the current logging level (while loading the scene)
  105554. * @ignorenaming
  105555. */
  105556. static get loggingLevel(): number;
  105557. static set loggingLevel(value: number);
  105558. /**
  105559. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  105560. */
  105561. static get CleanBoneMatrixWeights(): boolean;
  105562. static set CleanBoneMatrixWeights(value: boolean);
  105563. }
  105564. }
  105565. declare module BABYLON {
  105566. /**
  105567. * Class used to store geometry data (vertex buffers + index buffer)
  105568. */
  105569. export class Geometry implements IGetSetVerticesData {
  105570. /**
  105571. * Gets or sets the ID of the geometry
  105572. */
  105573. id: string;
  105574. /**
  105575. * Gets or sets the unique ID of the geometry
  105576. */
  105577. uniqueId: number;
  105578. /**
  105579. * Gets the delay loading state of the geometry (none by default which means not delayed)
  105580. */
  105581. delayLoadState: number;
  105582. /**
  105583. * Gets the file containing the data to load when running in delay load state
  105584. */
  105585. delayLoadingFile: Nullable<string>;
  105586. /**
  105587. * Callback called when the geometry is updated
  105588. */
  105589. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  105590. private _scene;
  105591. private _engine;
  105592. private _meshes;
  105593. private _totalVertices;
  105594. /** @hidden */
  105595. _indices: IndicesArray;
  105596. /** @hidden */
  105597. _vertexBuffers: {
  105598. [key: string]: VertexBuffer;
  105599. };
  105600. private _isDisposed;
  105601. private _extend;
  105602. private _boundingBias;
  105603. /** @hidden */
  105604. _delayInfo: Array<string>;
  105605. private _indexBuffer;
  105606. private _indexBufferIsUpdatable;
  105607. /** @hidden */
  105608. _boundingInfo: Nullable<BoundingInfo>;
  105609. /** @hidden */
  105610. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  105611. /** @hidden */
  105612. _softwareSkinningFrameId: number;
  105613. private _vertexArrayObjects;
  105614. private _updatable;
  105615. /** @hidden */
  105616. _positions: Nullable<Vector3[]>;
  105617. /**
  105618. * 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
  105619. */
  105620. get boundingBias(): Vector2;
  105621. /**
  105622. * 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
  105623. */
  105624. set boundingBias(value: Vector2);
  105625. /**
  105626. * Static function used to attach a new empty geometry to a mesh
  105627. * @param mesh defines the mesh to attach the geometry to
  105628. * @returns the new Geometry
  105629. */
  105630. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  105631. /** Get the list of meshes using this geometry */
  105632. get meshes(): Mesh[];
  105633. /**
  105634. * 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
  105635. * and won't be computed based on the vertex positions (which is what we get when useBoundingInfoFromGeometry = false)
  105636. */
  105637. useBoundingInfoFromGeometry: boolean;
  105638. /**
  105639. * Creates a new geometry
  105640. * @param id defines the unique ID
  105641. * @param scene defines the hosting scene
  105642. * @param vertexData defines the VertexData used to get geometry data
  105643. * @param updatable defines if geometry must be updatable (false by default)
  105644. * @param mesh defines the mesh that will be associated with the geometry
  105645. */
  105646. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  105647. /**
  105648. * Gets the current extend of the geometry
  105649. */
  105650. get extend(): {
  105651. minimum: Vector3;
  105652. maximum: Vector3;
  105653. };
  105654. /**
  105655. * Gets the hosting scene
  105656. * @returns the hosting Scene
  105657. */
  105658. getScene(): Scene;
  105659. /**
  105660. * Gets the hosting engine
  105661. * @returns the hosting Engine
  105662. */
  105663. getEngine(): Engine;
  105664. /**
  105665. * Defines if the geometry is ready to use
  105666. * @returns true if the geometry is ready to be used
  105667. */
  105668. isReady(): boolean;
  105669. /**
  105670. * Gets a value indicating that the geometry should not be serialized
  105671. */
  105672. get doNotSerialize(): boolean;
  105673. /** @hidden */
  105674. _rebuild(): void;
  105675. /**
  105676. * Affects all geometry data in one call
  105677. * @param vertexData defines the geometry data
  105678. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  105679. */
  105680. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  105681. /**
  105682. * Set specific vertex data
  105683. * @param kind defines the data kind (Position, normal, etc...)
  105684. * @param data defines the vertex data to use
  105685. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  105686. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  105687. */
  105688. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  105689. /**
  105690. * Removes a specific vertex data
  105691. * @param kind defines the data kind (Position, normal, etc...)
  105692. */
  105693. removeVerticesData(kind: string): void;
  105694. /**
  105695. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  105696. * @param buffer defines the vertex buffer to use
  105697. * @param totalVertices defines the total number of vertices for position kind (could be null)
  105698. */
  105699. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  105700. /**
  105701. * Update a specific vertex buffer
  105702. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  105703. * It will do nothing if the buffer is not updatable
  105704. * @param kind defines the data kind (Position, normal, etc...)
  105705. * @param data defines the data to use
  105706. * @param offset defines the offset in the target buffer where to store the data
  105707. * @param useBytes set to true if the offset is in bytes
  105708. */
  105709. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  105710. /**
  105711. * Update a specific vertex buffer
  105712. * This function will create a new buffer if the current one is not updatable
  105713. * @param kind defines the data kind (Position, normal, etc...)
  105714. * @param data defines the data to use
  105715. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  105716. */
  105717. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  105718. private _updateBoundingInfo;
  105719. /** @hidden */
  105720. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  105721. /**
  105722. * Gets total number of vertices
  105723. * @returns the total number of vertices
  105724. */
  105725. getTotalVertices(): number;
  105726. /**
  105727. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  105728. * @param kind defines the data kind (Position, normal, etc...)
  105729. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  105730. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  105731. * @returns a float array containing vertex data
  105732. */
  105733. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  105734. /**
  105735. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  105736. * @param kind defines the data kind (Position, normal, etc...)
  105737. * @returns true if the vertex buffer with the specified kind is updatable
  105738. */
  105739. isVertexBufferUpdatable(kind: string): boolean;
  105740. /**
  105741. * Gets a specific vertex buffer
  105742. * @param kind defines the data kind (Position, normal, etc...)
  105743. * @returns a VertexBuffer
  105744. */
  105745. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  105746. /**
  105747. * Returns all vertex buffers
  105748. * @return an object holding all vertex buffers indexed by kind
  105749. */
  105750. getVertexBuffers(): Nullable<{
  105751. [key: string]: VertexBuffer;
  105752. }>;
  105753. /**
  105754. * Gets a boolean indicating if specific vertex buffer is present
  105755. * @param kind defines the data kind (Position, normal, etc...)
  105756. * @returns true if data is present
  105757. */
  105758. isVerticesDataPresent(kind: string): boolean;
  105759. /**
  105760. * Gets a list of all attached data kinds (Position, normal, etc...)
  105761. * @returns a list of string containing all kinds
  105762. */
  105763. getVerticesDataKinds(): string[];
  105764. /**
  105765. * Update index buffer
  105766. * @param indices defines the indices to store in the index buffer
  105767. * @param offset defines the offset in the target buffer where to store the data
  105768. * @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)
  105769. */
  105770. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  105771. /**
  105772. * Creates a new index buffer
  105773. * @param indices defines the indices to store in the index buffer
  105774. * @param totalVertices defines the total number of vertices (could be null)
  105775. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  105776. */
  105777. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  105778. /**
  105779. * Return the total number of indices
  105780. * @returns the total number of indices
  105781. */
  105782. getTotalIndices(): number;
  105783. /**
  105784. * Gets the index buffer array
  105785. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  105786. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  105787. * @returns the index buffer array
  105788. */
  105789. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  105790. /**
  105791. * Gets the index buffer
  105792. * @return the index buffer
  105793. */
  105794. getIndexBuffer(): Nullable<DataBuffer>;
  105795. /** @hidden */
  105796. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  105797. /**
  105798. * Release the associated resources for a specific mesh
  105799. * @param mesh defines the source mesh
  105800. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  105801. */
  105802. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  105803. /**
  105804. * Apply current geometry to a given mesh
  105805. * @param mesh defines the mesh to apply geometry to
  105806. */
  105807. applyToMesh(mesh: Mesh): void;
  105808. private _updateExtend;
  105809. private _applyToMesh;
  105810. private notifyUpdate;
  105811. /**
  105812. * Load the geometry if it was flagged as delay loaded
  105813. * @param scene defines the hosting scene
  105814. * @param onLoaded defines a callback called when the geometry is loaded
  105815. */
  105816. load(scene: Scene, onLoaded?: () => void): void;
  105817. private _queueLoad;
  105818. /**
  105819. * Invert the geometry to move from a right handed system to a left handed one.
  105820. */
  105821. toLeftHanded(): void;
  105822. /** @hidden */
  105823. _resetPointsArrayCache(): void;
  105824. /** @hidden */
  105825. _generatePointsArray(): boolean;
  105826. /**
  105827. * Gets a value indicating if the geometry is disposed
  105828. * @returns true if the geometry was disposed
  105829. */
  105830. isDisposed(): boolean;
  105831. private _disposeVertexArrayObjects;
  105832. /**
  105833. * Free all associated resources
  105834. */
  105835. dispose(): void;
  105836. /**
  105837. * Clone the current geometry into a new geometry
  105838. * @param id defines the unique ID of the new geometry
  105839. * @returns a new geometry object
  105840. */
  105841. copy(id: string): Geometry;
  105842. /**
  105843. * Serialize the current geometry info (and not the vertices data) into a JSON object
  105844. * @return a JSON representation of the current geometry data (without the vertices data)
  105845. */
  105846. serialize(): any;
  105847. private toNumberArray;
  105848. /**
  105849. * Serialize all vertices data into a JSON oject
  105850. * @returns a JSON representation of the current geometry data
  105851. */
  105852. serializeVerticeData(): any;
  105853. /**
  105854. * Extracts a clone of a mesh geometry
  105855. * @param mesh defines the source mesh
  105856. * @param id defines the unique ID of the new geometry object
  105857. * @returns the new geometry object
  105858. */
  105859. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  105860. /**
  105861. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  105862. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  105863. * Be aware Math.random() could cause collisions, but:
  105864. * "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"
  105865. * @returns a string containing a new GUID
  105866. */
  105867. static RandomId(): string;
  105868. /** @hidden */
  105869. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  105870. private static _CleanMatricesWeights;
  105871. /**
  105872. * Create a new geometry from persisted data (Using .babylon file format)
  105873. * @param parsedVertexData defines the persisted data
  105874. * @param scene defines the hosting scene
  105875. * @param rootUrl defines the root url to use to load assets (like delayed data)
  105876. * @returns the new geometry object
  105877. */
  105878. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  105879. }
  105880. }
  105881. declare module BABYLON {
  105882. /**
  105883. * Define an interface for all classes that will get and set the data on vertices
  105884. */
  105885. export interface IGetSetVerticesData {
  105886. /**
  105887. * Gets a boolean indicating if specific vertex data is present
  105888. * @param kind defines the vertex data kind to use
  105889. * @returns true is data kind is present
  105890. */
  105891. isVerticesDataPresent(kind: string): boolean;
  105892. /**
  105893. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  105894. * @param kind defines the data kind (Position, normal, etc...)
  105895. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  105896. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  105897. * @returns a float array containing vertex data
  105898. */
  105899. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  105900. /**
  105901. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  105902. * @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.
  105903. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  105904. * @returns the indices array or an empty array if the mesh has no geometry
  105905. */
  105906. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  105907. /**
  105908. * Set specific vertex data
  105909. * @param kind defines the data kind (Position, normal, etc...)
  105910. * @param data defines the vertex data to use
  105911. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  105912. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  105913. */
  105914. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  105915. /**
  105916. * Update a specific associated vertex buffer
  105917. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  105918. * - VertexBuffer.PositionKind
  105919. * - VertexBuffer.UVKind
  105920. * - VertexBuffer.UV2Kind
  105921. * - VertexBuffer.UV3Kind
  105922. * - VertexBuffer.UV4Kind
  105923. * - VertexBuffer.UV5Kind
  105924. * - VertexBuffer.UV6Kind
  105925. * - VertexBuffer.ColorKind
  105926. * - VertexBuffer.MatricesIndicesKind
  105927. * - VertexBuffer.MatricesIndicesExtraKind
  105928. * - VertexBuffer.MatricesWeightsKind
  105929. * - VertexBuffer.MatricesWeightsExtraKind
  105930. * @param data defines the data source
  105931. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  105932. * @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)
  105933. */
  105934. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  105935. /**
  105936. * Creates a new index buffer
  105937. * @param indices defines the indices to store in the index buffer
  105938. * @param totalVertices defines the total number of vertices (could be null)
  105939. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  105940. */
  105941. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  105942. }
  105943. /**
  105944. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  105945. */
  105946. export class VertexData {
  105947. /**
  105948. * Mesh side orientation : usually the external or front surface
  105949. */
  105950. static readonly FRONTSIDE: number;
  105951. /**
  105952. * Mesh side orientation : usually the internal or back surface
  105953. */
  105954. static readonly BACKSIDE: number;
  105955. /**
  105956. * Mesh side orientation : both internal and external or front and back surfaces
  105957. */
  105958. static readonly DOUBLESIDE: number;
  105959. /**
  105960. * Mesh side orientation : by default, `FRONTSIDE`
  105961. */
  105962. static readonly DEFAULTSIDE: number;
  105963. /**
  105964. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  105965. */
  105966. positions: Nullable<FloatArray>;
  105967. /**
  105968. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  105969. */
  105970. normals: Nullable<FloatArray>;
  105971. /**
  105972. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  105973. */
  105974. tangents: Nullable<FloatArray>;
  105975. /**
  105976. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  105977. */
  105978. uvs: Nullable<FloatArray>;
  105979. /**
  105980. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  105981. */
  105982. uvs2: Nullable<FloatArray>;
  105983. /**
  105984. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  105985. */
  105986. uvs3: Nullable<FloatArray>;
  105987. /**
  105988. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  105989. */
  105990. uvs4: Nullable<FloatArray>;
  105991. /**
  105992. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  105993. */
  105994. uvs5: Nullable<FloatArray>;
  105995. /**
  105996. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  105997. */
  105998. uvs6: Nullable<FloatArray>;
  105999. /**
  106000. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  106001. */
  106002. colors: Nullable<FloatArray>;
  106003. /**
  106004. * 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).
  106005. */
  106006. matricesIndices: Nullable<FloatArray>;
  106007. /**
  106008. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  106009. */
  106010. matricesWeights: Nullable<FloatArray>;
  106011. /**
  106012. * An array extending the number of possible indices
  106013. */
  106014. matricesIndicesExtra: Nullable<FloatArray>;
  106015. /**
  106016. * An array extending the number of possible weights when the number of indices is extended
  106017. */
  106018. matricesWeightsExtra: Nullable<FloatArray>;
  106019. /**
  106020. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  106021. */
  106022. indices: Nullable<IndicesArray>;
  106023. /**
  106024. * Uses the passed data array to set the set the values for the specified kind of data
  106025. * @param data a linear array of floating numbers
  106026. * @param kind the type of data that is being set, eg positions, colors etc
  106027. */
  106028. set(data: FloatArray, kind: string): void;
  106029. /**
  106030. * Associates the vertexData to the passed Mesh.
  106031. * Sets it as updatable or not (default `false`)
  106032. * @param mesh the mesh the vertexData is applied to
  106033. * @param updatable when used and having the value true allows new data to update the vertexData
  106034. * @returns the VertexData
  106035. */
  106036. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  106037. /**
  106038. * Associates the vertexData to the passed Geometry.
  106039. * Sets it as updatable or not (default `false`)
  106040. * @param geometry the geometry the vertexData is applied to
  106041. * @param updatable when used and having the value true allows new data to update the vertexData
  106042. * @returns VertexData
  106043. */
  106044. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  106045. /**
  106046. * Updates the associated mesh
  106047. * @param mesh the mesh to be updated
  106048. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  106049. * @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
  106050. * @returns VertexData
  106051. */
  106052. updateMesh(mesh: Mesh): VertexData;
  106053. /**
  106054. * Updates the associated geometry
  106055. * @param geometry the geometry to be updated
  106056. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  106057. * @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
  106058. * @returns VertexData.
  106059. */
  106060. updateGeometry(geometry: Geometry): VertexData;
  106061. private _applyTo;
  106062. private _update;
  106063. /**
  106064. * Transforms each position and each normal of the vertexData according to the passed Matrix
  106065. * @param matrix the transforming matrix
  106066. * @returns the VertexData
  106067. */
  106068. transform(matrix: Matrix): VertexData;
  106069. /**
  106070. * Merges the passed VertexData into the current one
  106071. * @param other the VertexData to be merged into the current one
  106072. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  106073. * @returns the modified VertexData
  106074. */
  106075. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  106076. private _mergeElement;
  106077. private _validate;
  106078. /**
  106079. * Serializes the VertexData
  106080. * @returns a serialized object
  106081. */
  106082. serialize(): any;
  106083. /**
  106084. * Extracts the vertexData from a mesh
  106085. * @param mesh the mesh from which to extract the VertexData
  106086. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  106087. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  106088. * @returns the object VertexData associated to the passed mesh
  106089. */
  106090. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  106091. /**
  106092. * Extracts the vertexData from the geometry
  106093. * @param geometry the geometry from which to extract the VertexData
  106094. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  106095. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  106096. * @returns the object VertexData associated to the passed mesh
  106097. */
  106098. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  106099. private static _ExtractFrom;
  106100. /**
  106101. * Creates the VertexData for a Ribbon
  106102. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  106103. * * pathArray array of paths, each of which an array of successive Vector3
  106104. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  106105. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  106106. * * 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
  106107. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  106108. * * 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)
  106109. * * 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)
  106110. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  106111. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  106112. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  106113. * @returns the VertexData of the ribbon
  106114. */
  106115. static CreateRibbon(options: {
  106116. pathArray: Vector3[][];
  106117. closeArray?: boolean;
  106118. closePath?: boolean;
  106119. offset?: number;
  106120. sideOrientation?: number;
  106121. frontUVs?: Vector4;
  106122. backUVs?: Vector4;
  106123. invertUV?: boolean;
  106124. uvs?: Vector2[];
  106125. colors?: Color4[];
  106126. }): VertexData;
  106127. /**
  106128. * Creates the VertexData for a box
  106129. * @param options an object used to set the following optional parameters for the box, required but can be empty
  106130. * * size sets the width, height and depth of the box to the value of size, optional default 1
  106131. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  106132. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  106133. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  106134. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  106135. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  106136. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  106137. * * 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)
  106138. * * 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)
  106139. * @returns the VertexData of the box
  106140. */
  106141. static CreateBox(options: {
  106142. size?: number;
  106143. width?: number;
  106144. height?: number;
  106145. depth?: number;
  106146. faceUV?: Vector4[];
  106147. faceColors?: Color4[];
  106148. sideOrientation?: number;
  106149. frontUVs?: Vector4;
  106150. backUVs?: Vector4;
  106151. }): VertexData;
  106152. /**
  106153. * Creates the VertexData for a tiled box
  106154. * @param options an object used to set the following optional parameters for the box, required but can be empty
  106155. * * faceTiles sets the pattern, tile size and number of tiles for a face
  106156. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  106157. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  106158. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  106159. * @returns the VertexData of the box
  106160. */
  106161. static CreateTiledBox(options: {
  106162. pattern?: number;
  106163. width?: number;
  106164. height?: number;
  106165. depth?: number;
  106166. tileSize?: number;
  106167. tileWidth?: number;
  106168. tileHeight?: number;
  106169. alignHorizontal?: number;
  106170. alignVertical?: number;
  106171. faceUV?: Vector4[];
  106172. faceColors?: Color4[];
  106173. sideOrientation?: number;
  106174. }): VertexData;
  106175. /**
  106176. * Creates the VertexData for a tiled plane
  106177. * @param options an object used to set the following optional parameters for the box, required but can be empty
  106178. * * pattern a limited pattern arrangement depending on the number
  106179. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  106180. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  106181. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  106182. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  106183. * * 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)
  106184. * * 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)
  106185. * @returns the VertexData of the tiled plane
  106186. */
  106187. static CreateTiledPlane(options: {
  106188. pattern?: number;
  106189. tileSize?: number;
  106190. tileWidth?: number;
  106191. tileHeight?: number;
  106192. size?: number;
  106193. width?: number;
  106194. height?: number;
  106195. alignHorizontal?: number;
  106196. alignVertical?: number;
  106197. sideOrientation?: number;
  106198. frontUVs?: Vector4;
  106199. backUVs?: Vector4;
  106200. }): VertexData;
  106201. /**
  106202. * Creates the VertexData for an ellipsoid, defaults to a sphere
  106203. * @param options an object used to set the following optional parameters for the box, required but can be empty
  106204. * * segments sets the number of horizontal strips optional, default 32
  106205. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  106206. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  106207. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  106208. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  106209. * * 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
  106210. * * 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
  106211. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  106212. * * 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)
  106213. * * 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)
  106214. * @returns the VertexData of the ellipsoid
  106215. */
  106216. static CreateSphere(options: {
  106217. segments?: number;
  106218. diameter?: number;
  106219. diameterX?: number;
  106220. diameterY?: number;
  106221. diameterZ?: number;
  106222. arc?: number;
  106223. slice?: number;
  106224. sideOrientation?: number;
  106225. frontUVs?: Vector4;
  106226. backUVs?: Vector4;
  106227. }): VertexData;
  106228. /**
  106229. * Creates the VertexData for a cylinder, cone or prism
  106230. * @param options an object used to set the following optional parameters for the box, required but can be empty
  106231. * * height sets the height (y direction) of the cylinder, optional, default 2
  106232. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  106233. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  106234. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  106235. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  106236. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  106237. * * 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
  106238. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  106239. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  106240. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  106241. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  106242. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  106243. * * 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)
  106244. * * 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)
  106245. * @returns the VertexData of the cylinder, cone or prism
  106246. */
  106247. static CreateCylinder(options: {
  106248. height?: number;
  106249. diameterTop?: number;
  106250. diameterBottom?: number;
  106251. diameter?: number;
  106252. tessellation?: number;
  106253. subdivisions?: number;
  106254. arc?: number;
  106255. faceColors?: Color4[];
  106256. faceUV?: Vector4[];
  106257. hasRings?: boolean;
  106258. enclose?: boolean;
  106259. sideOrientation?: number;
  106260. frontUVs?: Vector4;
  106261. backUVs?: Vector4;
  106262. }): VertexData;
  106263. /**
  106264. * Creates the VertexData for a torus
  106265. * @param options an object used to set the following optional parameters for the box, required but can be empty
  106266. * * diameter the diameter of the torus, optional default 1
  106267. * * thickness the diameter of the tube forming the torus, optional default 0.5
  106268. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  106269. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  106270. * * 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)
  106271. * * 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)
  106272. * @returns the VertexData of the torus
  106273. */
  106274. static CreateTorus(options: {
  106275. diameter?: number;
  106276. thickness?: number;
  106277. tessellation?: number;
  106278. sideOrientation?: number;
  106279. frontUVs?: Vector4;
  106280. backUVs?: Vector4;
  106281. }): VertexData;
  106282. /**
  106283. * Creates the VertexData of the LineSystem
  106284. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  106285. * - lines an array of lines, each line being an array of successive Vector3
  106286. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  106287. * @returns the VertexData of the LineSystem
  106288. */
  106289. static CreateLineSystem(options: {
  106290. lines: Vector3[][];
  106291. colors?: Nullable<Color4[][]>;
  106292. }): VertexData;
  106293. /**
  106294. * Create the VertexData for a DashedLines
  106295. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  106296. * - points an array successive Vector3
  106297. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  106298. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  106299. * - dashNb the intended total number of dashes, optional, default 200
  106300. * @returns the VertexData for the DashedLines
  106301. */
  106302. static CreateDashedLines(options: {
  106303. points: Vector3[];
  106304. dashSize?: number;
  106305. gapSize?: number;
  106306. dashNb?: number;
  106307. }): VertexData;
  106308. /**
  106309. * Creates the VertexData for a Ground
  106310. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  106311. * - width the width (x direction) of the ground, optional, default 1
  106312. * - height the height (z direction) of the ground, optional, default 1
  106313. * - subdivisions the number of subdivisions per side, optional, default 1
  106314. * @returns the VertexData of the Ground
  106315. */
  106316. static CreateGround(options: {
  106317. width?: number;
  106318. height?: number;
  106319. subdivisions?: number;
  106320. subdivisionsX?: number;
  106321. subdivisionsY?: number;
  106322. }): VertexData;
  106323. /**
  106324. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  106325. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  106326. * * xmin the ground minimum X coordinate, optional, default -1
  106327. * * zmin the ground minimum Z coordinate, optional, default -1
  106328. * * xmax the ground maximum X coordinate, optional, default 1
  106329. * * zmax the ground maximum Z coordinate, optional, default 1
  106330. * * 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}
  106331. * * 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}
  106332. * @returns the VertexData of the TiledGround
  106333. */
  106334. static CreateTiledGround(options: {
  106335. xmin: number;
  106336. zmin: number;
  106337. xmax: number;
  106338. zmax: number;
  106339. subdivisions?: {
  106340. w: number;
  106341. h: number;
  106342. };
  106343. precision?: {
  106344. w: number;
  106345. h: number;
  106346. };
  106347. }): VertexData;
  106348. /**
  106349. * Creates the VertexData of the Ground designed from a heightmap
  106350. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  106351. * * width the width (x direction) of the ground
  106352. * * height the height (z direction) of the ground
  106353. * * subdivisions the number of subdivisions per side
  106354. * * minHeight the minimum altitude on the ground, optional, default 0
  106355. * * maxHeight the maximum altitude on the ground, optional default 1
  106356. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  106357. * * buffer the array holding the image color data
  106358. * * bufferWidth the width of image
  106359. * * bufferHeight the height of image
  106360. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  106361. * @returns the VertexData of the Ground designed from a heightmap
  106362. */
  106363. static CreateGroundFromHeightMap(options: {
  106364. width: number;
  106365. height: number;
  106366. subdivisions: number;
  106367. minHeight: number;
  106368. maxHeight: number;
  106369. colorFilter: Color3;
  106370. buffer: Uint8Array;
  106371. bufferWidth: number;
  106372. bufferHeight: number;
  106373. alphaFilter: number;
  106374. }): VertexData;
  106375. /**
  106376. * Creates the VertexData for a Plane
  106377. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  106378. * * size sets the width and height of the plane to the value of size, optional default 1
  106379. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  106380. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  106381. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  106382. * * 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)
  106383. * * 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)
  106384. * @returns the VertexData of the box
  106385. */
  106386. static CreatePlane(options: {
  106387. size?: number;
  106388. width?: number;
  106389. height?: number;
  106390. sideOrientation?: number;
  106391. frontUVs?: Vector4;
  106392. backUVs?: Vector4;
  106393. }): VertexData;
  106394. /**
  106395. * Creates the VertexData of the Disc or regular Polygon
  106396. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  106397. * * radius the radius of the disc, optional default 0.5
  106398. * * tessellation the number of polygon sides, optional, default 64
  106399. * * 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
  106400. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  106401. * * 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)
  106402. * * 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)
  106403. * @returns the VertexData of the box
  106404. */
  106405. static CreateDisc(options: {
  106406. radius?: number;
  106407. tessellation?: number;
  106408. arc?: number;
  106409. sideOrientation?: number;
  106410. frontUVs?: Vector4;
  106411. backUVs?: Vector4;
  106412. }): VertexData;
  106413. /**
  106414. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  106415. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  106416. * @param polygon a mesh built from polygonTriangulation.build()
  106417. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  106418. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  106419. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  106420. * @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)
  106421. * @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)
  106422. * @param wrap a boolean, default false, when true and fUVs used texture is wrapped around all sides, when false texture is applied side
  106423. * @returns the VertexData of the Polygon
  106424. */
  106425. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4, wrap?: boolean): VertexData;
  106426. /**
  106427. * Creates the VertexData of the IcoSphere
  106428. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  106429. * * radius the radius of the IcoSphere, optional default 1
  106430. * * radiusX allows stretching in the x direction, optional, default radius
  106431. * * radiusY allows stretching in the y direction, optional, default radius
  106432. * * radiusZ allows stretching in the z direction, optional, default radius
  106433. * * flat when true creates a flat shaded mesh, optional, default true
  106434. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  106435. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  106436. * * 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)
  106437. * * 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)
  106438. * @returns the VertexData of the IcoSphere
  106439. */
  106440. static CreateIcoSphere(options: {
  106441. radius?: number;
  106442. radiusX?: number;
  106443. radiusY?: number;
  106444. radiusZ?: number;
  106445. flat?: boolean;
  106446. subdivisions?: number;
  106447. sideOrientation?: number;
  106448. frontUVs?: Vector4;
  106449. backUVs?: Vector4;
  106450. }): VertexData;
  106451. /**
  106452. * Creates the VertexData for a Polyhedron
  106453. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  106454. * * type provided types are:
  106455. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  106456. * * 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)
  106457. * * size the size of the IcoSphere, optional default 1
  106458. * * sizeX allows stretching in the x direction, optional, default size
  106459. * * sizeY allows stretching in the y direction, optional, default size
  106460. * * sizeZ allows stretching in the z direction, optional, default size
  106461. * * 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
  106462. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  106463. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  106464. * * flat when true creates a flat shaded mesh, optional, default true
  106465. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  106466. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  106467. * * 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)
  106468. * * 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)
  106469. * @returns the VertexData of the Polyhedron
  106470. */
  106471. static CreatePolyhedron(options: {
  106472. type?: number;
  106473. size?: number;
  106474. sizeX?: number;
  106475. sizeY?: number;
  106476. sizeZ?: number;
  106477. custom?: any;
  106478. faceUV?: Vector4[];
  106479. faceColors?: Color4[];
  106480. flat?: boolean;
  106481. sideOrientation?: number;
  106482. frontUVs?: Vector4;
  106483. backUVs?: Vector4;
  106484. }): VertexData;
  106485. /**
  106486. * Creates the VertexData for a Capsule, inspired from https://github.com/maximeq/three-js-capsule-geometry/blob/master/src/CapsuleBufferGeometry.js
  106487. * @param options an object used to set the following optional parameters for the capsule, required but can be empty
  106488. * @returns the VertexData of the Capsule
  106489. */
  106490. static CreateCapsule(options?: ICreateCapsuleOptions): VertexData;
  106491. /**
  106492. * Creates the VertexData for a TorusKnot
  106493. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  106494. * * radius the radius of the torus knot, optional, default 2
  106495. * * tube the thickness of the tube, optional, default 0.5
  106496. * * radialSegments the number of sides on each tube segments, optional, default 32
  106497. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  106498. * * p the number of windings around the z axis, optional, default 2
  106499. * * q the number of windings around the x axis, optional, default 3
  106500. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  106501. * * 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)
  106502. * * 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)
  106503. * @returns the VertexData of the Torus Knot
  106504. */
  106505. static CreateTorusKnot(options: {
  106506. radius?: number;
  106507. tube?: number;
  106508. radialSegments?: number;
  106509. tubularSegments?: number;
  106510. p?: number;
  106511. q?: number;
  106512. sideOrientation?: number;
  106513. frontUVs?: Vector4;
  106514. backUVs?: Vector4;
  106515. }): VertexData;
  106516. /**
  106517. * Compute normals for given positions and indices
  106518. * @param positions an array of vertex positions, [...., x, y, z, ......]
  106519. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  106520. * @param normals an array of vertex normals, [...., x, y, z, ......]
  106521. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  106522. * * facetNormals : optional array of facet normals (vector3)
  106523. * * facetPositions : optional array of facet positions (vector3)
  106524. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  106525. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  106526. * * bInfo : optional bounding info, required for facetPartitioning computation
  106527. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  106528. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  106529. * * useRightHandedSystem: optional boolean to for right handed system computation
  106530. * * depthSort : optional boolean to enable the facet depth sort computation
  106531. * * distanceTo : optional Vector3 to compute the facet depth from this location
  106532. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  106533. */
  106534. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  106535. facetNormals?: any;
  106536. facetPositions?: any;
  106537. facetPartitioning?: any;
  106538. ratio?: number;
  106539. bInfo?: any;
  106540. bbSize?: Vector3;
  106541. subDiv?: any;
  106542. useRightHandedSystem?: boolean;
  106543. depthSort?: boolean;
  106544. distanceTo?: Vector3;
  106545. depthSortedFacets?: any;
  106546. }): void;
  106547. /** @hidden */
  106548. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  106549. /**
  106550. * Applies VertexData created from the imported parameters to the geometry
  106551. * @param parsedVertexData the parsed data from an imported file
  106552. * @param geometry the geometry to apply the VertexData to
  106553. */
  106554. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  106555. }
  106556. }
  106557. declare module BABYLON {
  106558. /**
  106559. * Defines a target to use with MorphTargetManager
  106560. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  106561. */
  106562. export class MorphTarget implements IAnimatable {
  106563. /** defines the name of the target */
  106564. name: string;
  106565. /**
  106566. * Gets or sets the list of animations
  106567. */
  106568. animations: Animation[];
  106569. private _scene;
  106570. private _positions;
  106571. private _normals;
  106572. private _tangents;
  106573. private _uvs;
  106574. private _influence;
  106575. private _uniqueId;
  106576. /**
  106577. * Observable raised when the influence changes
  106578. */
  106579. onInfluenceChanged: Observable<boolean>;
  106580. /** @hidden */
  106581. _onDataLayoutChanged: Observable<void>;
  106582. /**
  106583. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  106584. */
  106585. get influence(): number;
  106586. set influence(influence: number);
  106587. /**
  106588. * Gets or sets the id of the morph Target
  106589. */
  106590. id: string;
  106591. private _animationPropertiesOverride;
  106592. /**
  106593. * Gets or sets the animation properties override
  106594. */
  106595. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  106596. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  106597. /**
  106598. * Creates a new MorphTarget
  106599. * @param name defines the name of the target
  106600. * @param influence defines the influence to use
  106601. * @param scene defines the scene the morphtarget belongs to
  106602. */
  106603. constructor(
  106604. /** defines the name of the target */
  106605. name: string, influence?: number, scene?: Nullable<Scene>);
  106606. /**
  106607. * Gets the unique ID of this manager
  106608. */
  106609. get uniqueId(): number;
  106610. /**
  106611. * Gets a boolean defining if the target contains position data
  106612. */
  106613. get hasPositions(): boolean;
  106614. /**
  106615. * Gets a boolean defining if the target contains normal data
  106616. */
  106617. get hasNormals(): boolean;
  106618. /**
  106619. * Gets a boolean defining if the target contains tangent data
  106620. */
  106621. get hasTangents(): boolean;
  106622. /**
  106623. * Gets a boolean defining if the target contains texture coordinates data
  106624. */
  106625. get hasUVs(): boolean;
  106626. /**
  106627. * Affects position data to this target
  106628. * @param data defines the position data to use
  106629. */
  106630. setPositions(data: Nullable<FloatArray>): void;
  106631. /**
  106632. * Gets the position data stored in this target
  106633. * @returns a FloatArray containing the position data (or null if not present)
  106634. */
  106635. getPositions(): Nullable<FloatArray>;
  106636. /**
  106637. * Affects normal data to this target
  106638. * @param data defines the normal data to use
  106639. */
  106640. setNormals(data: Nullable<FloatArray>): void;
  106641. /**
  106642. * Gets the normal data stored in this target
  106643. * @returns a FloatArray containing the normal data (or null if not present)
  106644. */
  106645. getNormals(): Nullable<FloatArray>;
  106646. /**
  106647. * Affects tangent data to this target
  106648. * @param data defines the tangent data to use
  106649. */
  106650. setTangents(data: Nullable<FloatArray>): void;
  106651. /**
  106652. * Gets the tangent data stored in this target
  106653. * @returns a FloatArray containing the tangent data (or null if not present)
  106654. */
  106655. getTangents(): Nullable<FloatArray>;
  106656. /**
  106657. * Affects texture coordinates data to this target
  106658. * @param data defines the texture coordinates data to use
  106659. */
  106660. setUVs(data: Nullable<FloatArray>): void;
  106661. /**
  106662. * Gets the texture coordinates data stored in this target
  106663. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  106664. */
  106665. getUVs(): Nullable<FloatArray>;
  106666. /**
  106667. * Clone the current target
  106668. * @returns a new MorphTarget
  106669. */
  106670. clone(): MorphTarget;
  106671. /**
  106672. * Serializes the current target into a Serialization object
  106673. * @returns the serialized object
  106674. */
  106675. serialize(): any;
  106676. /**
  106677. * Returns the string "MorphTarget"
  106678. * @returns "MorphTarget"
  106679. */
  106680. getClassName(): string;
  106681. /**
  106682. * Creates a new target from serialized data
  106683. * @param serializationObject defines the serialized data to use
  106684. * @returns a new MorphTarget
  106685. */
  106686. static Parse(serializationObject: any): MorphTarget;
  106687. /**
  106688. * Creates a MorphTarget from mesh data
  106689. * @param mesh defines the source mesh
  106690. * @param name defines the name to use for the new target
  106691. * @param influence defines the influence to attach to the target
  106692. * @returns a new MorphTarget
  106693. */
  106694. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  106695. }
  106696. }
  106697. declare module BABYLON {
  106698. /**
  106699. * This class is used to deform meshes using morphing between different targets
  106700. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  106701. */
  106702. export class MorphTargetManager {
  106703. private _targets;
  106704. private _targetInfluenceChangedObservers;
  106705. private _targetDataLayoutChangedObservers;
  106706. private _activeTargets;
  106707. private _scene;
  106708. private _influences;
  106709. private _supportsNormals;
  106710. private _supportsTangents;
  106711. private _supportsUVs;
  106712. private _vertexCount;
  106713. private _uniqueId;
  106714. private _tempInfluences;
  106715. /**
  106716. * Gets or sets a boolean indicating if normals must be morphed
  106717. */
  106718. enableNormalMorphing: boolean;
  106719. /**
  106720. * Gets or sets a boolean indicating if tangents must be morphed
  106721. */
  106722. enableTangentMorphing: boolean;
  106723. /**
  106724. * Gets or sets a boolean indicating if UV must be morphed
  106725. */
  106726. enableUVMorphing: boolean;
  106727. /**
  106728. * Creates a new MorphTargetManager
  106729. * @param scene defines the current scene
  106730. */
  106731. constructor(scene?: Nullable<Scene>);
  106732. /**
  106733. * Gets the unique ID of this manager
  106734. */
  106735. get uniqueId(): number;
  106736. /**
  106737. * Gets the number of vertices handled by this manager
  106738. */
  106739. get vertexCount(): number;
  106740. /**
  106741. * Gets a boolean indicating if this manager supports morphing of normals
  106742. */
  106743. get supportsNormals(): boolean;
  106744. /**
  106745. * Gets a boolean indicating if this manager supports morphing of tangents
  106746. */
  106747. get supportsTangents(): boolean;
  106748. /**
  106749. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  106750. */
  106751. get supportsUVs(): boolean;
  106752. /**
  106753. * Gets the number of targets stored in this manager
  106754. */
  106755. get numTargets(): number;
  106756. /**
  106757. * Gets the number of influencers (ie. the number of targets with influences > 0)
  106758. */
  106759. get numInfluencers(): number;
  106760. /**
  106761. * Gets the list of influences (one per target)
  106762. */
  106763. get influences(): Float32Array;
  106764. /**
  106765. * Gets the active target at specified index. An active target is a target with an influence > 0
  106766. * @param index defines the index to check
  106767. * @returns the requested target
  106768. */
  106769. getActiveTarget(index: number): MorphTarget;
  106770. /**
  106771. * Gets the target at specified index
  106772. * @param index defines the index to check
  106773. * @returns the requested target
  106774. */
  106775. getTarget(index: number): MorphTarget;
  106776. /**
  106777. * Add a new target to this manager
  106778. * @param target defines the target to add
  106779. */
  106780. addTarget(target: MorphTarget): void;
  106781. /**
  106782. * Removes a target from the manager
  106783. * @param target defines the target to remove
  106784. */
  106785. removeTarget(target: MorphTarget): void;
  106786. /**
  106787. * Clone the current manager
  106788. * @returns a new MorphTargetManager
  106789. */
  106790. clone(): MorphTargetManager;
  106791. /**
  106792. * Serializes the current manager into a Serialization object
  106793. * @returns the serialized object
  106794. */
  106795. serialize(): any;
  106796. private _syncActiveTargets;
  106797. /**
  106798. * Syncrhonize the targets with all the meshes using this morph target manager
  106799. */
  106800. synchronize(): void;
  106801. /**
  106802. * Creates a new MorphTargetManager from serialized data
  106803. * @param serializationObject defines the serialized data
  106804. * @param scene defines the hosting scene
  106805. * @returns the new MorphTargetManager
  106806. */
  106807. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  106808. }
  106809. }
  106810. declare module BABYLON {
  106811. /**
  106812. * Class used to represent a specific level of detail of a mesh
  106813. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  106814. */
  106815. export class MeshLODLevel {
  106816. /** Defines the distance where this level should start being displayed */
  106817. distance: number;
  106818. /** Defines the mesh to use to render this level */
  106819. mesh: Nullable<Mesh>;
  106820. /**
  106821. * Creates a new LOD level
  106822. * @param distance defines the distance where this level should star being displayed
  106823. * @param mesh defines the mesh to use to render this level
  106824. */
  106825. constructor(
  106826. /** Defines the distance where this level should start being displayed */
  106827. distance: number,
  106828. /** Defines the mesh to use to render this level */
  106829. mesh: Nullable<Mesh>);
  106830. }
  106831. }
  106832. declare module BABYLON {
  106833. /**
  106834. * Helper class used to generate a canvas to manipulate images
  106835. */
  106836. export class CanvasGenerator {
  106837. /**
  106838. * Create a new canvas (or offscreen canvas depending on the context)
  106839. * @param width defines the expected width
  106840. * @param height defines the expected height
  106841. * @return a new canvas or offscreen canvas
  106842. */
  106843. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  106844. }
  106845. }
  106846. declare module BABYLON {
  106847. /**
  106848. * Mesh representing the gorund
  106849. */
  106850. export class GroundMesh extends Mesh {
  106851. /** If octree should be generated */
  106852. generateOctree: boolean;
  106853. private _heightQuads;
  106854. /** @hidden */
  106855. _subdivisionsX: number;
  106856. /** @hidden */
  106857. _subdivisionsY: number;
  106858. /** @hidden */
  106859. _width: number;
  106860. /** @hidden */
  106861. _height: number;
  106862. /** @hidden */
  106863. _minX: number;
  106864. /** @hidden */
  106865. _maxX: number;
  106866. /** @hidden */
  106867. _minZ: number;
  106868. /** @hidden */
  106869. _maxZ: number;
  106870. constructor(name: string, scene: Scene);
  106871. /**
  106872. * "GroundMesh"
  106873. * @returns "GroundMesh"
  106874. */
  106875. getClassName(): string;
  106876. /**
  106877. * The minimum of x and y subdivisions
  106878. */
  106879. get subdivisions(): number;
  106880. /**
  106881. * X subdivisions
  106882. */
  106883. get subdivisionsX(): number;
  106884. /**
  106885. * Y subdivisions
  106886. */
  106887. get subdivisionsY(): number;
  106888. /**
  106889. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  106890. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  106891. * @param chunksCount the number of subdivisions for x and y
  106892. * @param octreeBlocksSize (Default: 32)
  106893. */
  106894. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  106895. /**
  106896. * Returns a height (y) value in the Worl system :
  106897. * the ground altitude at the coordinates (x, z) expressed in the World system.
  106898. * @param x x coordinate
  106899. * @param z z coordinate
  106900. * @returns the ground y position if (x, z) are outside the ground surface.
  106901. */
  106902. getHeightAtCoordinates(x: number, z: number): number;
  106903. /**
  106904. * Returns a normalized vector (Vector3) orthogonal to the ground
  106905. * at the ground coordinates (x, z) expressed in the World system.
  106906. * @param x x coordinate
  106907. * @param z z coordinate
  106908. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  106909. */
  106910. getNormalAtCoordinates(x: number, z: number): Vector3;
  106911. /**
  106912. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  106913. * at the ground coordinates (x, z) expressed in the World system.
  106914. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  106915. * @param x x coordinate
  106916. * @param z z coordinate
  106917. * @param ref vector to store the result
  106918. * @returns the GroundMesh.
  106919. */
  106920. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  106921. /**
  106922. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  106923. * if the ground has been updated.
  106924. * This can be used in the render loop.
  106925. * @returns the GroundMesh.
  106926. */
  106927. updateCoordinateHeights(): GroundMesh;
  106928. private _getFacetAt;
  106929. private _initHeightQuads;
  106930. private _computeHeightQuads;
  106931. /**
  106932. * Serializes this ground mesh
  106933. * @param serializationObject object to write serialization to
  106934. */
  106935. serialize(serializationObject: any): void;
  106936. /**
  106937. * Parses a serialized ground mesh
  106938. * @param parsedMesh the serialized mesh
  106939. * @param scene the scene to create the ground mesh in
  106940. * @returns the created ground mesh
  106941. */
  106942. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  106943. }
  106944. }
  106945. declare module BABYLON {
  106946. /**
  106947. * Interface for Physics-Joint data
  106948. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  106949. */
  106950. export interface PhysicsJointData {
  106951. /**
  106952. * The main pivot of the joint
  106953. */
  106954. mainPivot?: Vector3;
  106955. /**
  106956. * The connected pivot of the joint
  106957. */
  106958. connectedPivot?: Vector3;
  106959. /**
  106960. * The main axis of the joint
  106961. */
  106962. mainAxis?: Vector3;
  106963. /**
  106964. * The connected axis of the joint
  106965. */
  106966. connectedAxis?: Vector3;
  106967. /**
  106968. * The collision of the joint
  106969. */
  106970. collision?: boolean;
  106971. /**
  106972. * Native Oimo/Cannon/Energy data
  106973. */
  106974. nativeParams?: any;
  106975. }
  106976. /**
  106977. * This is a holder class for the physics joint created by the physics plugin
  106978. * It holds a set of functions to control the underlying joint
  106979. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  106980. */
  106981. export class PhysicsJoint {
  106982. /**
  106983. * The type of the physics joint
  106984. */
  106985. type: number;
  106986. /**
  106987. * The data for the physics joint
  106988. */
  106989. jointData: PhysicsJointData;
  106990. private _physicsJoint;
  106991. protected _physicsPlugin: IPhysicsEnginePlugin;
  106992. /**
  106993. * Initializes the physics joint
  106994. * @param type The type of the physics joint
  106995. * @param jointData The data for the physics joint
  106996. */
  106997. constructor(
  106998. /**
  106999. * The type of the physics joint
  107000. */
  107001. type: number,
  107002. /**
  107003. * The data for the physics joint
  107004. */
  107005. jointData: PhysicsJointData);
  107006. /**
  107007. * Gets the physics joint
  107008. */
  107009. get physicsJoint(): any;
  107010. /**
  107011. * Sets the physics joint
  107012. */
  107013. set physicsJoint(newJoint: any);
  107014. /**
  107015. * Sets the physics plugin
  107016. */
  107017. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  107018. /**
  107019. * Execute a function that is physics-plugin specific.
  107020. * @param {Function} func the function that will be executed.
  107021. * It accepts two parameters: the physics world and the physics joint
  107022. */
  107023. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  107024. /**
  107025. * Distance-Joint type
  107026. */
  107027. static DistanceJoint: number;
  107028. /**
  107029. * Hinge-Joint type
  107030. */
  107031. static HingeJoint: number;
  107032. /**
  107033. * Ball-and-Socket joint type
  107034. */
  107035. static BallAndSocketJoint: number;
  107036. /**
  107037. * Wheel-Joint type
  107038. */
  107039. static WheelJoint: number;
  107040. /**
  107041. * Slider-Joint type
  107042. */
  107043. static SliderJoint: number;
  107044. /**
  107045. * Prismatic-Joint type
  107046. */
  107047. static PrismaticJoint: number;
  107048. /**
  107049. * Universal-Joint type
  107050. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  107051. */
  107052. static UniversalJoint: number;
  107053. /**
  107054. * Hinge-Joint 2 type
  107055. */
  107056. static Hinge2Joint: number;
  107057. /**
  107058. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  107059. */
  107060. static PointToPointJoint: number;
  107061. /**
  107062. * Spring-Joint type
  107063. */
  107064. static SpringJoint: number;
  107065. /**
  107066. * Lock-Joint type
  107067. */
  107068. static LockJoint: number;
  107069. }
  107070. /**
  107071. * A class representing a physics distance joint
  107072. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107073. */
  107074. export class DistanceJoint extends PhysicsJoint {
  107075. /**
  107076. *
  107077. * @param jointData The data for the Distance-Joint
  107078. */
  107079. constructor(jointData: DistanceJointData);
  107080. /**
  107081. * Update the predefined distance.
  107082. * @param maxDistance The maximum preferred distance
  107083. * @param minDistance The minimum preferred distance
  107084. */
  107085. updateDistance(maxDistance: number, minDistance?: number): void;
  107086. }
  107087. /**
  107088. * Represents a Motor-Enabled Joint
  107089. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107090. */
  107091. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  107092. /**
  107093. * Initializes the Motor-Enabled Joint
  107094. * @param type The type of the joint
  107095. * @param jointData The physica joint data for the joint
  107096. */
  107097. constructor(type: number, jointData: PhysicsJointData);
  107098. /**
  107099. * Set the motor values.
  107100. * Attention, this function is plugin specific. Engines won't react 100% the same.
  107101. * @param force the force to apply
  107102. * @param maxForce max force for this motor.
  107103. */
  107104. setMotor(force?: number, maxForce?: number): void;
  107105. /**
  107106. * Set the motor's limits.
  107107. * Attention, this function is plugin specific. Engines won't react 100% the same.
  107108. * @param upperLimit The upper limit of the motor
  107109. * @param lowerLimit The lower limit of the motor
  107110. */
  107111. setLimit(upperLimit: number, lowerLimit?: number): void;
  107112. }
  107113. /**
  107114. * This class represents a single physics Hinge-Joint
  107115. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107116. */
  107117. export class HingeJoint extends MotorEnabledJoint {
  107118. /**
  107119. * Initializes the Hinge-Joint
  107120. * @param jointData The joint data for the Hinge-Joint
  107121. */
  107122. constructor(jointData: PhysicsJointData);
  107123. /**
  107124. * Set the motor values.
  107125. * Attention, this function is plugin specific. Engines won't react 100% the same.
  107126. * @param {number} force the force to apply
  107127. * @param {number} maxForce max force for this motor.
  107128. */
  107129. setMotor(force?: number, maxForce?: number): void;
  107130. /**
  107131. * Set the motor's limits.
  107132. * Attention, this function is plugin specific. Engines won't react 100% the same.
  107133. * @param upperLimit The upper limit of the motor
  107134. * @param lowerLimit The lower limit of the motor
  107135. */
  107136. setLimit(upperLimit: number, lowerLimit?: number): void;
  107137. }
  107138. /**
  107139. * This class represents a dual hinge physics joint (same as wheel joint)
  107140. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107141. */
  107142. export class Hinge2Joint extends MotorEnabledJoint {
  107143. /**
  107144. * Initializes the Hinge2-Joint
  107145. * @param jointData The joint data for the Hinge2-Joint
  107146. */
  107147. constructor(jointData: PhysicsJointData);
  107148. /**
  107149. * Set the motor values.
  107150. * Attention, this function is plugin specific. Engines won't react 100% the same.
  107151. * @param {number} targetSpeed the speed the motor is to reach
  107152. * @param {number} maxForce max force for this motor.
  107153. * @param {motorIndex} the motor's index, 0 or 1.
  107154. */
  107155. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  107156. /**
  107157. * Set the motor limits.
  107158. * Attention, this function is plugin specific. Engines won't react 100% the same.
  107159. * @param {number} upperLimit the upper limit
  107160. * @param {number} lowerLimit lower limit
  107161. * @param {motorIndex} the motor's index, 0 or 1.
  107162. */
  107163. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  107164. }
  107165. /**
  107166. * Interface for a motor enabled joint
  107167. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107168. */
  107169. export interface IMotorEnabledJoint {
  107170. /**
  107171. * Physics joint
  107172. */
  107173. physicsJoint: any;
  107174. /**
  107175. * Sets the motor of the motor-enabled joint
  107176. * @param force The force of the motor
  107177. * @param maxForce The maximum force of the motor
  107178. * @param motorIndex The index of the motor
  107179. */
  107180. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  107181. /**
  107182. * Sets the limit of the motor
  107183. * @param upperLimit The upper limit of the motor
  107184. * @param lowerLimit The lower limit of the motor
  107185. * @param motorIndex The index of the motor
  107186. */
  107187. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  107188. }
  107189. /**
  107190. * Joint data for a Distance-Joint
  107191. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107192. */
  107193. export interface DistanceJointData extends PhysicsJointData {
  107194. /**
  107195. * Max distance the 2 joint objects can be apart
  107196. */
  107197. maxDistance: number;
  107198. }
  107199. /**
  107200. * Joint data from a spring joint
  107201. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107202. */
  107203. export interface SpringJointData extends PhysicsJointData {
  107204. /**
  107205. * Length of the spring
  107206. */
  107207. length: number;
  107208. /**
  107209. * Stiffness of the spring
  107210. */
  107211. stiffness: number;
  107212. /**
  107213. * Damping of the spring
  107214. */
  107215. damping: number;
  107216. /** this callback will be called when applying the force to the impostors. */
  107217. forceApplicationCallback: () => void;
  107218. }
  107219. }
  107220. declare module BABYLON {
  107221. /**
  107222. * Holds the data for the raycast result
  107223. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107224. */
  107225. export class PhysicsRaycastResult {
  107226. private _hasHit;
  107227. private _hitDistance;
  107228. private _hitNormalWorld;
  107229. private _hitPointWorld;
  107230. private _rayFromWorld;
  107231. private _rayToWorld;
  107232. /**
  107233. * Gets if there was a hit
  107234. */
  107235. get hasHit(): boolean;
  107236. /**
  107237. * Gets the distance from the hit
  107238. */
  107239. get hitDistance(): number;
  107240. /**
  107241. * Gets the hit normal/direction in the world
  107242. */
  107243. get hitNormalWorld(): Vector3;
  107244. /**
  107245. * Gets the hit point in the world
  107246. */
  107247. get hitPointWorld(): Vector3;
  107248. /**
  107249. * Gets the ray "start point" of the ray in the world
  107250. */
  107251. get rayFromWorld(): Vector3;
  107252. /**
  107253. * Gets the ray "end point" of the ray in the world
  107254. */
  107255. get rayToWorld(): Vector3;
  107256. /**
  107257. * Sets the hit data (normal & point in world space)
  107258. * @param hitNormalWorld defines the normal in world space
  107259. * @param hitPointWorld defines the point in world space
  107260. */
  107261. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  107262. /**
  107263. * Sets the distance from the start point to the hit point
  107264. * @param distance
  107265. */
  107266. setHitDistance(distance: number): void;
  107267. /**
  107268. * Calculates the distance manually
  107269. */
  107270. calculateHitDistance(): void;
  107271. /**
  107272. * Resets all the values to default
  107273. * @param from The from point on world space
  107274. * @param to The to point on world space
  107275. */
  107276. reset(from?: Vector3, to?: Vector3): void;
  107277. }
  107278. /**
  107279. * Interface for the size containing width and height
  107280. */
  107281. interface IXYZ {
  107282. /**
  107283. * X
  107284. */
  107285. x: number;
  107286. /**
  107287. * Y
  107288. */
  107289. y: number;
  107290. /**
  107291. * Z
  107292. */
  107293. z: number;
  107294. }
  107295. }
  107296. declare module BABYLON {
  107297. /**
  107298. * Interface used to describe a physics joint
  107299. */
  107300. export interface PhysicsImpostorJoint {
  107301. /** Defines the main impostor to which the joint is linked */
  107302. mainImpostor: PhysicsImpostor;
  107303. /** Defines the impostor that is connected to the main impostor using this joint */
  107304. connectedImpostor: PhysicsImpostor;
  107305. /** Defines the joint itself */
  107306. joint: PhysicsJoint;
  107307. }
  107308. /** @hidden */
  107309. export interface IPhysicsEnginePlugin {
  107310. world: any;
  107311. name: string;
  107312. setGravity(gravity: Vector3): void;
  107313. setTimeStep(timeStep: number): void;
  107314. getTimeStep(): number;
  107315. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  107316. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  107317. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  107318. generatePhysicsBody(impostor: PhysicsImpostor): void;
  107319. removePhysicsBody(impostor: PhysicsImpostor): void;
  107320. generateJoint(joint: PhysicsImpostorJoint): void;
  107321. removeJoint(joint: PhysicsImpostorJoint): void;
  107322. isSupported(): boolean;
  107323. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  107324. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  107325. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  107326. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  107327. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  107328. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  107329. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  107330. getBodyMass(impostor: PhysicsImpostor): number;
  107331. getBodyFriction(impostor: PhysicsImpostor): number;
  107332. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  107333. getBodyRestitution(impostor: PhysicsImpostor): number;
  107334. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  107335. getBodyPressure?(impostor: PhysicsImpostor): number;
  107336. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  107337. getBodyStiffness?(impostor: PhysicsImpostor): number;
  107338. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  107339. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  107340. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  107341. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  107342. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  107343. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  107344. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  107345. sleepBody(impostor: PhysicsImpostor): void;
  107346. wakeUpBody(impostor: PhysicsImpostor): void;
  107347. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  107348. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  107349. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  107350. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  107351. getRadius(impostor: PhysicsImpostor): number;
  107352. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  107353. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  107354. dispose(): void;
  107355. }
  107356. /**
  107357. * Interface used to define a physics engine
  107358. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107359. */
  107360. export interface IPhysicsEngine {
  107361. /**
  107362. * Gets the gravity vector used by the simulation
  107363. */
  107364. gravity: Vector3;
  107365. /**
  107366. * Sets the gravity vector used by the simulation
  107367. * @param gravity defines the gravity vector to use
  107368. */
  107369. setGravity(gravity: Vector3): void;
  107370. /**
  107371. * Set the time step of the physics engine.
  107372. * Default is 1/60.
  107373. * To slow it down, enter 1/600 for example.
  107374. * To speed it up, 1/30
  107375. * @param newTimeStep the new timestep to apply to this world.
  107376. */
  107377. setTimeStep(newTimeStep: number): void;
  107378. /**
  107379. * Get the time step of the physics engine.
  107380. * @returns the current time step
  107381. */
  107382. getTimeStep(): number;
  107383. /**
  107384. * Set the sub time step of the physics engine.
  107385. * Default is 0 meaning there is no sub steps
  107386. * To increase physics resolution precision, set a small value (like 1 ms)
  107387. * @param subTimeStep defines the new sub timestep used for physics resolution.
  107388. */
  107389. setSubTimeStep(subTimeStep: number): void;
  107390. /**
  107391. * Get the sub time step of the physics engine.
  107392. * @returns the current sub time step
  107393. */
  107394. getSubTimeStep(): number;
  107395. /**
  107396. * Release all resources
  107397. */
  107398. dispose(): void;
  107399. /**
  107400. * Gets the name of the current physics plugin
  107401. * @returns the name of the plugin
  107402. */
  107403. getPhysicsPluginName(): string;
  107404. /**
  107405. * Adding a new impostor for the impostor tracking.
  107406. * This will be done by the impostor itself.
  107407. * @param impostor the impostor to add
  107408. */
  107409. addImpostor(impostor: PhysicsImpostor): void;
  107410. /**
  107411. * Remove an impostor from the engine.
  107412. * This impostor and its mesh will not longer be updated by the physics engine.
  107413. * @param impostor the impostor to remove
  107414. */
  107415. removeImpostor(impostor: PhysicsImpostor): void;
  107416. /**
  107417. * Add a joint to the physics engine
  107418. * @param mainImpostor defines the main impostor to which the joint is added.
  107419. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  107420. * @param joint defines the joint that will connect both impostors.
  107421. */
  107422. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  107423. /**
  107424. * Removes a joint from the simulation
  107425. * @param mainImpostor defines the impostor used with the joint
  107426. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  107427. * @param joint defines the joint to remove
  107428. */
  107429. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  107430. /**
  107431. * Gets the current plugin used to run the simulation
  107432. * @returns current plugin
  107433. */
  107434. getPhysicsPlugin(): IPhysicsEnginePlugin;
  107435. /**
  107436. * Gets the list of physic impostors
  107437. * @returns an array of PhysicsImpostor
  107438. */
  107439. getImpostors(): Array<PhysicsImpostor>;
  107440. /**
  107441. * Gets the impostor for a physics enabled object
  107442. * @param object defines the object impersonated by the impostor
  107443. * @returns the PhysicsImpostor or null if not found
  107444. */
  107445. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  107446. /**
  107447. * Gets the impostor for a physics body object
  107448. * @param body defines physics body used by the impostor
  107449. * @returns the PhysicsImpostor or null if not found
  107450. */
  107451. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  107452. /**
  107453. * Does a raycast in the physics world
  107454. * @param from when should the ray start?
  107455. * @param to when should the ray end?
  107456. * @returns PhysicsRaycastResult
  107457. */
  107458. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  107459. /**
  107460. * Called by the scene. No need to call it.
  107461. * @param delta defines the timespam between frames
  107462. */
  107463. _step(delta: number): void;
  107464. }
  107465. }
  107466. declare module BABYLON {
  107467. /**
  107468. * The interface for the physics imposter parameters
  107469. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107470. */
  107471. export interface PhysicsImpostorParameters {
  107472. /**
  107473. * The mass of the physics imposter
  107474. */
  107475. mass: number;
  107476. /**
  107477. * The friction of the physics imposter
  107478. */
  107479. friction?: number;
  107480. /**
  107481. * The coefficient of restitution of the physics imposter
  107482. */
  107483. restitution?: number;
  107484. /**
  107485. * The native options of the physics imposter
  107486. */
  107487. nativeOptions?: any;
  107488. /**
  107489. * Specifies if the parent should be ignored
  107490. */
  107491. ignoreParent?: boolean;
  107492. /**
  107493. * Specifies if bi-directional transformations should be disabled
  107494. */
  107495. disableBidirectionalTransformation?: boolean;
  107496. /**
  107497. * The pressure inside the physics imposter, soft object only
  107498. */
  107499. pressure?: number;
  107500. /**
  107501. * The stiffness the physics imposter, soft object only
  107502. */
  107503. stiffness?: number;
  107504. /**
  107505. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  107506. */
  107507. velocityIterations?: number;
  107508. /**
  107509. * The number of iterations used in maintaining consistent vertex positions, soft object only
  107510. */
  107511. positionIterations?: number;
  107512. /**
  107513. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  107514. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  107515. * Add to fix multiple points
  107516. */
  107517. fixedPoints?: number;
  107518. /**
  107519. * The collision margin around a soft object
  107520. */
  107521. margin?: number;
  107522. /**
  107523. * The collision margin around a soft object
  107524. */
  107525. damping?: number;
  107526. /**
  107527. * The path for a rope based on an extrusion
  107528. */
  107529. path?: any;
  107530. /**
  107531. * The shape of an extrusion used for a rope based on an extrusion
  107532. */
  107533. shape?: any;
  107534. }
  107535. /**
  107536. * Interface for a physics-enabled object
  107537. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107538. */
  107539. export interface IPhysicsEnabledObject {
  107540. /**
  107541. * The position of the physics-enabled object
  107542. */
  107543. position: Vector3;
  107544. /**
  107545. * The rotation of the physics-enabled object
  107546. */
  107547. rotationQuaternion: Nullable<Quaternion>;
  107548. /**
  107549. * The scale of the physics-enabled object
  107550. */
  107551. scaling: Vector3;
  107552. /**
  107553. * The rotation of the physics-enabled object
  107554. */
  107555. rotation?: Vector3;
  107556. /**
  107557. * The parent of the physics-enabled object
  107558. */
  107559. parent?: any;
  107560. /**
  107561. * The bounding info of the physics-enabled object
  107562. * @returns The bounding info of the physics-enabled object
  107563. */
  107564. getBoundingInfo(): BoundingInfo;
  107565. /**
  107566. * Computes the world matrix
  107567. * @param force Specifies if the world matrix should be computed by force
  107568. * @returns A world matrix
  107569. */
  107570. computeWorldMatrix(force: boolean): Matrix;
  107571. /**
  107572. * Gets the world matrix
  107573. * @returns A world matrix
  107574. */
  107575. getWorldMatrix?(): Matrix;
  107576. /**
  107577. * Gets the child meshes
  107578. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  107579. * @returns An array of abstract meshes
  107580. */
  107581. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  107582. /**
  107583. * Gets the vertex data
  107584. * @param kind The type of vertex data
  107585. * @returns A nullable array of numbers, or a float32 array
  107586. */
  107587. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  107588. /**
  107589. * Gets the indices from the mesh
  107590. * @returns A nullable array of index arrays
  107591. */
  107592. getIndices?(): Nullable<IndicesArray>;
  107593. /**
  107594. * Gets the scene from the mesh
  107595. * @returns the indices array or null
  107596. */
  107597. getScene?(): Scene;
  107598. /**
  107599. * Gets the absolute position from the mesh
  107600. * @returns the absolute position
  107601. */
  107602. getAbsolutePosition(): Vector3;
  107603. /**
  107604. * Gets the absolute pivot point from the mesh
  107605. * @returns the absolute pivot point
  107606. */
  107607. getAbsolutePivotPoint(): Vector3;
  107608. /**
  107609. * Rotates the mesh
  107610. * @param axis The axis of rotation
  107611. * @param amount The amount of rotation
  107612. * @param space The space of the rotation
  107613. * @returns The rotation transform node
  107614. */
  107615. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  107616. /**
  107617. * Translates the mesh
  107618. * @param axis The axis of translation
  107619. * @param distance The distance of translation
  107620. * @param space The space of the translation
  107621. * @returns The transform node
  107622. */
  107623. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  107624. /**
  107625. * Sets the absolute position of the mesh
  107626. * @param absolutePosition The absolute position of the mesh
  107627. * @returns The transform node
  107628. */
  107629. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  107630. /**
  107631. * Gets the class name of the mesh
  107632. * @returns The class name
  107633. */
  107634. getClassName(): string;
  107635. }
  107636. /**
  107637. * Represents a physics imposter
  107638. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107639. */
  107640. export class PhysicsImpostor {
  107641. /**
  107642. * The physics-enabled object used as the physics imposter
  107643. */
  107644. object: IPhysicsEnabledObject;
  107645. /**
  107646. * The type of the physics imposter
  107647. */
  107648. type: number;
  107649. private _options;
  107650. private _scene?;
  107651. /**
  107652. * The default object size of the imposter
  107653. */
  107654. static DEFAULT_OBJECT_SIZE: Vector3;
  107655. /**
  107656. * The identity quaternion of the imposter
  107657. */
  107658. static IDENTITY_QUATERNION: Quaternion;
  107659. /** @hidden */
  107660. _pluginData: any;
  107661. private _physicsEngine;
  107662. private _physicsBody;
  107663. private _bodyUpdateRequired;
  107664. private _onBeforePhysicsStepCallbacks;
  107665. private _onAfterPhysicsStepCallbacks;
  107666. /** @hidden */
  107667. _onPhysicsCollideCallbacks: Array<{
  107668. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  107669. otherImpostors: Array<PhysicsImpostor>;
  107670. }>;
  107671. private _deltaPosition;
  107672. private _deltaRotation;
  107673. private _deltaRotationConjugated;
  107674. /** @hidden */
  107675. _isFromLine: boolean;
  107676. private _parent;
  107677. private _isDisposed;
  107678. private static _tmpVecs;
  107679. private static _tmpQuat;
  107680. /**
  107681. * Specifies if the physics imposter is disposed
  107682. */
  107683. get isDisposed(): boolean;
  107684. /**
  107685. * Gets the mass of the physics imposter
  107686. */
  107687. get mass(): number;
  107688. set mass(value: number);
  107689. /**
  107690. * Gets the coefficient of friction
  107691. */
  107692. get friction(): number;
  107693. /**
  107694. * Sets the coefficient of friction
  107695. */
  107696. set friction(value: number);
  107697. /**
  107698. * Gets the coefficient of restitution
  107699. */
  107700. get restitution(): number;
  107701. /**
  107702. * Sets the coefficient of restitution
  107703. */
  107704. set restitution(value: number);
  107705. /**
  107706. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  107707. */
  107708. get pressure(): number;
  107709. /**
  107710. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  107711. */
  107712. set pressure(value: number);
  107713. /**
  107714. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  107715. */
  107716. get stiffness(): number;
  107717. /**
  107718. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  107719. */
  107720. set stiffness(value: number);
  107721. /**
  107722. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  107723. */
  107724. get velocityIterations(): number;
  107725. /**
  107726. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  107727. */
  107728. set velocityIterations(value: number);
  107729. /**
  107730. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  107731. */
  107732. get positionIterations(): number;
  107733. /**
  107734. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  107735. */
  107736. set positionIterations(value: number);
  107737. /**
  107738. * The unique id of the physics imposter
  107739. * set by the physics engine when adding this impostor to the array
  107740. */
  107741. uniqueId: number;
  107742. /**
  107743. * @hidden
  107744. */
  107745. soft: boolean;
  107746. /**
  107747. * @hidden
  107748. */
  107749. segments: number;
  107750. private _joints;
  107751. /**
  107752. * Initializes the physics imposter
  107753. * @param object The physics-enabled object used as the physics imposter
  107754. * @param type The type of the physics imposter
  107755. * @param _options The options for the physics imposter
  107756. * @param _scene The Babylon scene
  107757. */
  107758. constructor(
  107759. /**
  107760. * The physics-enabled object used as the physics imposter
  107761. */
  107762. object: IPhysicsEnabledObject,
  107763. /**
  107764. * The type of the physics imposter
  107765. */
  107766. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  107767. /**
  107768. * This function will completly initialize this impostor.
  107769. * It will create a new body - but only if this mesh has no parent.
  107770. * If it has, this impostor will not be used other than to define the impostor
  107771. * of the child mesh.
  107772. * @hidden
  107773. */
  107774. _init(): void;
  107775. private _getPhysicsParent;
  107776. /**
  107777. * Should a new body be generated.
  107778. * @returns boolean specifying if body initialization is required
  107779. */
  107780. isBodyInitRequired(): boolean;
  107781. /**
  107782. * Sets the updated scaling
  107783. * @param updated Specifies if the scaling is updated
  107784. */
  107785. setScalingUpdated(): void;
  107786. /**
  107787. * Force a regeneration of this or the parent's impostor's body.
  107788. * Use under cautious - This will remove all joints already implemented.
  107789. */
  107790. forceUpdate(): void;
  107791. /**
  107792. * Gets the body that holds this impostor. Either its own, or its parent.
  107793. */
  107794. get physicsBody(): any;
  107795. /**
  107796. * Get the parent of the physics imposter
  107797. * @returns Physics imposter or null
  107798. */
  107799. get parent(): Nullable<PhysicsImpostor>;
  107800. /**
  107801. * Sets the parent of the physics imposter
  107802. */
  107803. set parent(value: Nullable<PhysicsImpostor>);
  107804. /**
  107805. * Set the physics body. Used mainly by the physics engine/plugin
  107806. */
  107807. set physicsBody(physicsBody: any);
  107808. /**
  107809. * Resets the update flags
  107810. */
  107811. resetUpdateFlags(): void;
  107812. /**
  107813. * Gets the object extend size
  107814. * @returns the object extend size
  107815. */
  107816. getObjectExtendSize(): Vector3;
  107817. /**
  107818. * Gets the object center
  107819. * @returns The object center
  107820. */
  107821. getObjectCenter(): Vector3;
  107822. /**
  107823. * Get a specific parameter from the options parameters
  107824. * @param paramName The object parameter name
  107825. * @returns The object parameter
  107826. */
  107827. getParam(paramName: string): any;
  107828. /**
  107829. * Sets a specific parameter in the options given to the physics plugin
  107830. * @param paramName The parameter name
  107831. * @param value The value of the parameter
  107832. */
  107833. setParam(paramName: string, value: number): void;
  107834. /**
  107835. * Specifically change the body's mass option. Won't recreate the physics body object
  107836. * @param mass The mass of the physics imposter
  107837. */
  107838. setMass(mass: number): void;
  107839. /**
  107840. * Gets the linear velocity
  107841. * @returns linear velocity or null
  107842. */
  107843. getLinearVelocity(): Nullable<Vector3>;
  107844. /**
  107845. * Sets the linear velocity
  107846. * @param velocity linear velocity or null
  107847. */
  107848. setLinearVelocity(velocity: Nullable<Vector3>): void;
  107849. /**
  107850. * Gets the angular velocity
  107851. * @returns angular velocity or null
  107852. */
  107853. getAngularVelocity(): Nullable<Vector3>;
  107854. /**
  107855. * Sets the angular velocity
  107856. * @param velocity The velocity or null
  107857. */
  107858. setAngularVelocity(velocity: Nullable<Vector3>): void;
  107859. /**
  107860. * Execute a function with the physics plugin native code
  107861. * Provide a function the will have two variables - the world object and the physics body object
  107862. * @param func The function to execute with the physics plugin native code
  107863. */
  107864. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  107865. /**
  107866. * Register a function that will be executed before the physics world is stepping forward
  107867. * @param func The function to execute before the physics world is stepped forward
  107868. */
  107869. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  107870. /**
  107871. * Unregister a function that will be executed before the physics world is stepping forward
  107872. * @param func The function to execute before the physics world is stepped forward
  107873. */
  107874. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  107875. /**
  107876. * Register a function that will be executed after the physics step
  107877. * @param func The function to execute after physics step
  107878. */
  107879. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  107880. /**
  107881. * Unregisters a function that will be executed after the physics step
  107882. * @param func The function to execute after physics step
  107883. */
  107884. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  107885. /**
  107886. * register a function that will be executed when this impostor collides against a different body
  107887. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  107888. * @param func Callback that is executed on collision
  107889. */
  107890. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  107891. /**
  107892. * Unregisters the physics imposter on contact
  107893. * @param collideAgainst The physics object to collide against
  107894. * @param func Callback to execute on collision
  107895. */
  107896. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  107897. private _tmpQuat;
  107898. private _tmpQuat2;
  107899. /**
  107900. * Get the parent rotation
  107901. * @returns The parent rotation
  107902. */
  107903. getParentsRotation(): Quaternion;
  107904. /**
  107905. * this function is executed by the physics engine.
  107906. */
  107907. beforeStep: () => void;
  107908. /**
  107909. * this function is executed by the physics engine
  107910. */
  107911. afterStep: () => void;
  107912. /**
  107913. * Legacy collision detection event support
  107914. */
  107915. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  107916. /**
  107917. * event and body object due to cannon's event-based architecture.
  107918. */
  107919. onCollide: (e: {
  107920. body: any;
  107921. }) => void;
  107922. /**
  107923. * Apply a force
  107924. * @param force The force to apply
  107925. * @param contactPoint The contact point for the force
  107926. * @returns The physics imposter
  107927. */
  107928. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  107929. /**
  107930. * Apply an impulse
  107931. * @param force The impulse force
  107932. * @param contactPoint The contact point for the impulse force
  107933. * @returns The physics imposter
  107934. */
  107935. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  107936. /**
  107937. * A help function to create a joint
  107938. * @param otherImpostor A physics imposter used to create a joint
  107939. * @param jointType The type of joint
  107940. * @param jointData The data for the joint
  107941. * @returns The physics imposter
  107942. */
  107943. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  107944. /**
  107945. * Add a joint to this impostor with a different impostor
  107946. * @param otherImpostor A physics imposter used to add a joint
  107947. * @param joint The joint to add
  107948. * @returns The physics imposter
  107949. */
  107950. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  107951. /**
  107952. * Add an anchor to a cloth impostor
  107953. * @param otherImpostor rigid impostor to anchor to
  107954. * @param width ratio across width from 0 to 1
  107955. * @param height ratio up height from 0 to 1
  107956. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  107957. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  107958. * @returns impostor the soft imposter
  107959. */
  107960. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  107961. /**
  107962. * Add a hook to a rope impostor
  107963. * @param otherImpostor rigid impostor to anchor to
  107964. * @param length ratio across rope from 0 to 1
  107965. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  107966. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  107967. * @returns impostor the rope imposter
  107968. */
  107969. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  107970. /**
  107971. * Will keep this body still, in a sleep mode.
  107972. * @returns the physics imposter
  107973. */
  107974. sleep(): PhysicsImpostor;
  107975. /**
  107976. * Wake the body up.
  107977. * @returns The physics imposter
  107978. */
  107979. wakeUp(): PhysicsImpostor;
  107980. /**
  107981. * Clones the physics imposter
  107982. * @param newObject The physics imposter clones to this physics-enabled object
  107983. * @returns A nullable physics imposter
  107984. */
  107985. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  107986. /**
  107987. * Disposes the physics imposter
  107988. */
  107989. dispose(): void;
  107990. /**
  107991. * Sets the delta position
  107992. * @param position The delta position amount
  107993. */
  107994. setDeltaPosition(position: Vector3): void;
  107995. /**
  107996. * Sets the delta rotation
  107997. * @param rotation The delta rotation amount
  107998. */
  107999. setDeltaRotation(rotation: Quaternion): void;
  108000. /**
  108001. * Gets the box size of the physics imposter and stores the result in the input parameter
  108002. * @param result Stores the box size
  108003. * @returns The physics imposter
  108004. */
  108005. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  108006. /**
  108007. * Gets the radius of the physics imposter
  108008. * @returns Radius of the physics imposter
  108009. */
  108010. getRadius(): number;
  108011. /**
  108012. * Sync a bone with this impostor
  108013. * @param bone The bone to sync to the impostor.
  108014. * @param boneMesh The mesh that the bone is influencing.
  108015. * @param jointPivot The pivot of the joint / bone in local space.
  108016. * @param distToJoint Optional distance from the impostor to the joint.
  108017. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  108018. */
  108019. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  108020. /**
  108021. * Sync impostor to a bone
  108022. * @param bone The bone that the impostor will be synced to.
  108023. * @param boneMesh The mesh that the bone is influencing.
  108024. * @param jointPivot The pivot of the joint / bone in local space.
  108025. * @param distToJoint Optional distance from the impostor to the joint.
  108026. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  108027. * @param boneAxis Optional vector3 axis the bone is aligned with
  108028. */
  108029. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  108030. /**
  108031. * No-Imposter type
  108032. */
  108033. static NoImpostor: number;
  108034. /**
  108035. * Sphere-Imposter type
  108036. */
  108037. static SphereImpostor: number;
  108038. /**
  108039. * Box-Imposter type
  108040. */
  108041. static BoxImpostor: number;
  108042. /**
  108043. * Plane-Imposter type
  108044. */
  108045. static PlaneImpostor: number;
  108046. /**
  108047. * Mesh-imposter type
  108048. */
  108049. static MeshImpostor: number;
  108050. /**
  108051. * Capsule-Impostor type (Ammo.js plugin only)
  108052. */
  108053. static CapsuleImpostor: number;
  108054. /**
  108055. * Cylinder-Imposter type
  108056. */
  108057. static CylinderImpostor: number;
  108058. /**
  108059. * Particle-Imposter type
  108060. */
  108061. static ParticleImpostor: number;
  108062. /**
  108063. * Heightmap-Imposter type
  108064. */
  108065. static HeightmapImpostor: number;
  108066. /**
  108067. * ConvexHull-Impostor type (Ammo.js plugin only)
  108068. */
  108069. static ConvexHullImpostor: number;
  108070. /**
  108071. * Custom-Imposter type (Ammo.js plugin only)
  108072. */
  108073. static CustomImpostor: number;
  108074. /**
  108075. * Rope-Imposter type
  108076. */
  108077. static RopeImpostor: number;
  108078. /**
  108079. * Cloth-Imposter type
  108080. */
  108081. static ClothImpostor: number;
  108082. /**
  108083. * Softbody-Imposter type
  108084. */
  108085. static SoftbodyImpostor: number;
  108086. }
  108087. }
  108088. declare module BABYLON {
  108089. /**
  108090. * @hidden
  108091. **/
  108092. export class _CreationDataStorage {
  108093. closePath?: boolean;
  108094. closeArray?: boolean;
  108095. idx: number[];
  108096. dashSize: number;
  108097. gapSize: number;
  108098. path3D: Path3D;
  108099. pathArray: Vector3[][];
  108100. arc: number;
  108101. radius: number;
  108102. cap: number;
  108103. tessellation: number;
  108104. }
  108105. /**
  108106. * @hidden
  108107. **/
  108108. class _InstanceDataStorage {
  108109. visibleInstances: any;
  108110. batchCache: _InstancesBatch;
  108111. instancesBufferSize: number;
  108112. instancesBuffer: Nullable<Buffer>;
  108113. instancesData: Float32Array;
  108114. overridenInstanceCount: number;
  108115. isFrozen: boolean;
  108116. previousBatch: Nullable<_InstancesBatch>;
  108117. hardwareInstancedRendering: boolean;
  108118. sideOrientation: number;
  108119. manualUpdate: boolean;
  108120. previousRenderId: number;
  108121. }
  108122. /**
  108123. * @hidden
  108124. **/
  108125. export class _InstancesBatch {
  108126. mustReturn: boolean;
  108127. visibleInstances: Nullable<InstancedMesh[]>[];
  108128. renderSelf: boolean[];
  108129. hardwareInstancedRendering: boolean[];
  108130. }
  108131. /**
  108132. * @hidden
  108133. **/
  108134. class _ThinInstanceDataStorage {
  108135. instancesCount: number;
  108136. matrixBuffer: Nullable<Buffer>;
  108137. matrixBufferSize: number;
  108138. matrixData: Nullable<Float32Array>;
  108139. boundingVectors: Array<Vector3>;
  108140. worldMatrices: Nullable<Matrix[]>;
  108141. }
  108142. /**
  108143. * Class used to represent renderable models
  108144. */
  108145. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  108146. /**
  108147. * Mesh side orientation : usually the external or front surface
  108148. */
  108149. static readonly FRONTSIDE: number;
  108150. /**
  108151. * Mesh side orientation : usually the internal or back surface
  108152. */
  108153. static readonly BACKSIDE: number;
  108154. /**
  108155. * Mesh side orientation : both internal and external or front and back surfaces
  108156. */
  108157. static readonly DOUBLESIDE: number;
  108158. /**
  108159. * Mesh side orientation : by default, `FRONTSIDE`
  108160. */
  108161. static readonly DEFAULTSIDE: number;
  108162. /**
  108163. * Mesh cap setting : no cap
  108164. */
  108165. static readonly NO_CAP: number;
  108166. /**
  108167. * Mesh cap setting : one cap at the beginning of the mesh
  108168. */
  108169. static readonly CAP_START: number;
  108170. /**
  108171. * Mesh cap setting : one cap at the end of the mesh
  108172. */
  108173. static readonly CAP_END: number;
  108174. /**
  108175. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  108176. */
  108177. static readonly CAP_ALL: number;
  108178. /**
  108179. * Mesh pattern setting : no flip or rotate
  108180. */
  108181. static readonly NO_FLIP: number;
  108182. /**
  108183. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  108184. */
  108185. static readonly FLIP_TILE: number;
  108186. /**
  108187. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  108188. */
  108189. static readonly ROTATE_TILE: number;
  108190. /**
  108191. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  108192. */
  108193. static readonly FLIP_ROW: number;
  108194. /**
  108195. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  108196. */
  108197. static readonly ROTATE_ROW: number;
  108198. /**
  108199. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  108200. */
  108201. static readonly FLIP_N_ROTATE_TILE: number;
  108202. /**
  108203. * Mesh pattern setting : rotate pattern and rotate
  108204. */
  108205. static readonly FLIP_N_ROTATE_ROW: number;
  108206. /**
  108207. * Mesh tile positioning : part tiles same on left/right or top/bottom
  108208. */
  108209. static readonly CENTER: number;
  108210. /**
  108211. * Mesh tile positioning : part tiles on left
  108212. */
  108213. static readonly LEFT: number;
  108214. /**
  108215. * Mesh tile positioning : part tiles on right
  108216. */
  108217. static readonly RIGHT: number;
  108218. /**
  108219. * Mesh tile positioning : part tiles on top
  108220. */
  108221. static readonly TOP: number;
  108222. /**
  108223. * Mesh tile positioning : part tiles on bottom
  108224. */
  108225. static readonly BOTTOM: number;
  108226. /**
  108227. * Gets the default side orientation.
  108228. * @param orientation the orientation to value to attempt to get
  108229. * @returns the default orientation
  108230. * @hidden
  108231. */
  108232. static _GetDefaultSideOrientation(orientation?: number): number;
  108233. private _internalMeshDataInfo;
  108234. get computeBonesUsingShaders(): boolean;
  108235. set computeBonesUsingShaders(value: boolean);
  108236. /**
  108237. * An event triggered before rendering the mesh
  108238. */
  108239. get onBeforeRenderObservable(): Observable<Mesh>;
  108240. /**
  108241. * An event triggered before binding the mesh
  108242. */
  108243. get onBeforeBindObservable(): Observable<Mesh>;
  108244. /**
  108245. * An event triggered after rendering the mesh
  108246. */
  108247. get onAfterRenderObservable(): Observable<Mesh>;
  108248. /**
  108249. * An event triggered before drawing the mesh
  108250. */
  108251. get onBeforeDrawObservable(): Observable<Mesh>;
  108252. private _onBeforeDrawObserver;
  108253. /**
  108254. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  108255. */
  108256. set onBeforeDraw(callback: () => void);
  108257. get hasInstances(): boolean;
  108258. get hasThinInstances(): boolean;
  108259. /**
  108260. * Gets the delay loading state of the mesh (when delay loading is turned on)
  108261. * @see https://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  108262. */
  108263. delayLoadState: number;
  108264. /**
  108265. * Gets the list of instances created from this mesh
  108266. * it is not supposed to be modified manually.
  108267. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  108268. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  108269. */
  108270. instances: InstancedMesh[];
  108271. /**
  108272. * Gets the file containing delay loading data for this mesh
  108273. */
  108274. delayLoadingFile: string;
  108275. /** @hidden */
  108276. _binaryInfo: any;
  108277. /**
  108278. * User defined function used to change how LOD level selection is done
  108279. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  108280. */
  108281. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  108282. /**
  108283. * Gets or sets the morph target manager
  108284. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  108285. */
  108286. get morphTargetManager(): Nullable<MorphTargetManager>;
  108287. set morphTargetManager(value: Nullable<MorphTargetManager>);
  108288. /** @hidden */
  108289. _creationDataStorage: Nullable<_CreationDataStorage>;
  108290. /** @hidden */
  108291. _geometry: Nullable<Geometry>;
  108292. /** @hidden */
  108293. _delayInfo: Array<string>;
  108294. /** @hidden */
  108295. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  108296. /** @hidden */
  108297. _instanceDataStorage: _InstanceDataStorage;
  108298. /** @hidden */
  108299. _thinInstanceDataStorage: _ThinInstanceDataStorage;
  108300. private _effectiveMaterial;
  108301. /** @hidden */
  108302. _shouldGenerateFlatShading: boolean;
  108303. /** @hidden */
  108304. _originalBuilderSideOrientation: number;
  108305. /**
  108306. * Use this property to change the original side orientation defined at construction time
  108307. */
  108308. overrideMaterialSideOrientation: Nullable<number>;
  108309. /**
  108310. * Gets the source mesh (the one used to clone this one from)
  108311. */
  108312. get source(): Nullable<Mesh>;
  108313. /**
  108314. * Gets the list of clones of this mesh
  108315. * The scene must have been constructed with useClonedMeshMap=true for this to work!
  108316. * Note that useClonedMeshMap=true is the default setting
  108317. */
  108318. get cloneMeshMap(): Nullable<{
  108319. [id: string]: Mesh | undefined;
  108320. }>;
  108321. /**
  108322. * Gets or sets a boolean indicating that this mesh does not use index buffer
  108323. */
  108324. get isUnIndexed(): boolean;
  108325. set isUnIndexed(value: boolean);
  108326. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  108327. get worldMatrixInstancedBuffer(): Float32Array;
  108328. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  108329. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  108330. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  108331. /**
  108332. * @constructor
  108333. * @param name The value used by scene.getMeshByName() to do a lookup.
  108334. * @param scene The scene to add this mesh to.
  108335. * @param parent The parent of this mesh, if it has one
  108336. * @param source An optional Mesh from which geometry is shared, cloned.
  108337. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  108338. * When false, achieved by calling a clone(), also passing False.
  108339. * This will make creation of children, recursive.
  108340. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  108341. */
  108342. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  108343. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  108344. doNotInstantiate: boolean;
  108345. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  108346. /**
  108347. * Gets the class name
  108348. * @returns the string "Mesh".
  108349. */
  108350. getClassName(): string;
  108351. /** @hidden */
  108352. get _isMesh(): boolean;
  108353. /**
  108354. * Returns a description of this mesh
  108355. * @param fullDetails define if full details about this mesh must be used
  108356. * @returns a descriptive string representing this mesh
  108357. */
  108358. toString(fullDetails?: boolean): string;
  108359. /** @hidden */
  108360. _unBindEffect(): void;
  108361. /**
  108362. * Gets a boolean indicating if this mesh has LOD
  108363. */
  108364. get hasLODLevels(): boolean;
  108365. /**
  108366. * Gets the list of MeshLODLevel associated with the current mesh
  108367. * @returns an array of MeshLODLevel
  108368. */
  108369. getLODLevels(): MeshLODLevel[];
  108370. private _sortLODLevels;
  108371. /**
  108372. * Add a mesh as LOD level triggered at the given distance.
  108373. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  108374. * @param distance The distance from the center of the object to show this level
  108375. * @param mesh The mesh to be added as LOD level (can be null)
  108376. * @return This mesh (for chaining)
  108377. */
  108378. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  108379. /**
  108380. * Returns the LOD level mesh at the passed distance or null if not found.
  108381. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  108382. * @param distance The distance from the center of the object to show this level
  108383. * @returns a Mesh or `null`
  108384. */
  108385. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  108386. /**
  108387. * Remove a mesh from the LOD array
  108388. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  108389. * @param mesh defines the mesh to be removed
  108390. * @return This mesh (for chaining)
  108391. */
  108392. removeLODLevel(mesh: Mesh): Mesh;
  108393. /**
  108394. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  108395. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  108396. * @param camera defines the camera to use to compute distance
  108397. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  108398. * @return This mesh (for chaining)
  108399. */
  108400. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  108401. /**
  108402. * Gets the mesh internal Geometry object
  108403. */
  108404. get geometry(): Nullable<Geometry>;
  108405. /**
  108406. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  108407. * @returns the total number of vertices
  108408. */
  108409. getTotalVertices(): number;
  108410. /**
  108411. * Returns the content of an associated vertex buffer
  108412. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  108413. * - VertexBuffer.PositionKind
  108414. * - VertexBuffer.UVKind
  108415. * - VertexBuffer.UV2Kind
  108416. * - VertexBuffer.UV3Kind
  108417. * - VertexBuffer.UV4Kind
  108418. * - VertexBuffer.UV5Kind
  108419. * - VertexBuffer.UV6Kind
  108420. * - VertexBuffer.ColorKind
  108421. * - VertexBuffer.MatricesIndicesKind
  108422. * - VertexBuffer.MatricesIndicesExtraKind
  108423. * - VertexBuffer.MatricesWeightsKind
  108424. * - VertexBuffer.MatricesWeightsExtraKind
  108425. * @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
  108426. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  108427. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  108428. */
  108429. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  108430. /**
  108431. * Returns the mesh VertexBuffer object from the requested `kind`
  108432. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  108433. * - VertexBuffer.PositionKind
  108434. * - VertexBuffer.NormalKind
  108435. * - VertexBuffer.UVKind
  108436. * - VertexBuffer.UV2Kind
  108437. * - VertexBuffer.UV3Kind
  108438. * - VertexBuffer.UV4Kind
  108439. * - VertexBuffer.UV5Kind
  108440. * - VertexBuffer.UV6Kind
  108441. * - VertexBuffer.ColorKind
  108442. * - VertexBuffer.MatricesIndicesKind
  108443. * - VertexBuffer.MatricesIndicesExtraKind
  108444. * - VertexBuffer.MatricesWeightsKind
  108445. * - VertexBuffer.MatricesWeightsExtraKind
  108446. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  108447. */
  108448. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  108449. /**
  108450. * Tests if a specific vertex buffer is associated with this mesh
  108451. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  108452. * - VertexBuffer.PositionKind
  108453. * - VertexBuffer.NormalKind
  108454. * - VertexBuffer.UVKind
  108455. * - VertexBuffer.UV2Kind
  108456. * - VertexBuffer.UV3Kind
  108457. * - VertexBuffer.UV4Kind
  108458. * - VertexBuffer.UV5Kind
  108459. * - VertexBuffer.UV6Kind
  108460. * - VertexBuffer.ColorKind
  108461. * - VertexBuffer.MatricesIndicesKind
  108462. * - VertexBuffer.MatricesIndicesExtraKind
  108463. * - VertexBuffer.MatricesWeightsKind
  108464. * - VertexBuffer.MatricesWeightsExtraKind
  108465. * @returns a boolean
  108466. */
  108467. isVerticesDataPresent(kind: string): boolean;
  108468. /**
  108469. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  108470. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  108471. * - VertexBuffer.PositionKind
  108472. * - VertexBuffer.UVKind
  108473. * - VertexBuffer.UV2Kind
  108474. * - VertexBuffer.UV3Kind
  108475. * - VertexBuffer.UV4Kind
  108476. * - VertexBuffer.UV5Kind
  108477. * - VertexBuffer.UV6Kind
  108478. * - VertexBuffer.ColorKind
  108479. * - VertexBuffer.MatricesIndicesKind
  108480. * - VertexBuffer.MatricesIndicesExtraKind
  108481. * - VertexBuffer.MatricesWeightsKind
  108482. * - VertexBuffer.MatricesWeightsExtraKind
  108483. * @returns a boolean
  108484. */
  108485. isVertexBufferUpdatable(kind: string): boolean;
  108486. /**
  108487. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  108488. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  108489. * - VertexBuffer.PositionKind
  108490. * - VertexBuffer.NormalKind
  108491. * - VertexBuffer.UVKind
  108492. * - VertexBuffer.UV2Kind
  108493. * - VertexBuffer.UV3Kind
  108494. * - VertexBuffer.UV4Kind
  108495. * - VertexBuffer.UV5Kind
  108496. * - VertexBuffer.UV6Kind
  108497. * - VertexBuffer.ColorKind
  108498. * - VertexBuffer.MatricesIndicesKind
  108499. * - VertexBuffer.MatricesIndicesExtraKind
  108500. * - VertexBuffer.MatricesWeightsKind
  108501. * - VertexBuffer.MatricesWeightsExtraKind
  108502. * @returns an array of strings
  108503. */
  108504. getVerticesDataKinds(): string[];
  108505. /**
  108506. * Returns a positive integer : the total number of indices in this mesh geometry.
  108507. * @returns the numner of indices or zero if the mesh has no geometry.
  108508. */
  108509. getTotalIndices(): number;
  108510. /**
  108511. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  108512. * @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.
  108513. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  108514. * @returns the indices array or an empty array if the mesh has no geometry
  108515. */
  108516. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  108517. get isBlocked(): boolean;
  108518. /**
  108519. * Determine if the current mesh is ready to be rendered
  108520. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  108521. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  108522. * @returns true if all associated assets are ready (material, textures, shaders)
  108523. */
  108524. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  108525. /**
  108526. * 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.
  108527. */
  108528. get areNormalsFrozen(): boolean;
  108529. /**
  108530. * 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.
  108531. * @returns the current mesh
  108532. */
  108533. freezeNormals(): Mesh;
  108534. /**
  108535. * 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
  108536. * @returns the current mesh
  108537. */
  108538. unfreezeNormals(): Mesh;
  108539. /**
  108540. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  108541. */
  108542. set overridenInstanceCount(count: number);
  108543. /** @hidden */
  108544. _preActivate(): Mesh;
  108545. /** @hidden */
  108546. _preActivateForIntermediateRendering(renderId: number): Mesh;
  108547. /** @hidden */
  108548. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  108549. protected _afterComputeWorldMatrix(): void;
  108550. /** @hidden */
  108551. _postActivate(): void;
  108552. /**
  108553. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  108554. * This means the mesh underlying bounding box and sphere are recomputed.
  108555. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  108556. * @returns the current mesh
  108557. */
  108558. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  108559. /** @hidden */
  108560. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  108561. /**
  108562. * This function will subdivide the mesh into multiple submeshes
  108563. * @param count defines the expected number of submeshes
  108564. */
  108565. subdivide(count: number): void;
  108566. /**
  108567. * Copy a FloatArray into a specific associated vertex buffer
  108568. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  108569. * - VertexBuffer.PositionKind
  108570. * - VertexBuffer.UVKind
  108571. * - VertexBuffer.UV2Kind
  108572. * - VertexBuffer.UV3Kind
  108573. * - VertexBuffer.UV4Kind
  108574. * - VertexBuffer.UV5Kind
  108575. * - VertexBuffer.UV6Kind
  108576. * - VertexBuffer.ColorKind
  108577. * - VertexBuffer.MatricesIndicesKind
  108578. * - VertexBuffer.MatricesIndicesExtraKind
  108579. * - VertexBuffer.MatricesWeightsKind
  108580. * - VertexBuffer.MatricesWeightsExtraKind
  108581. * @param data defines the data source
  108582. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  108583. * @param stride defines the data stride size (can be null)
  108584. * @returns the current mesh
  108585. */
  108586. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  108587. /**
  108588. * Delete a vertex buffer associated with this mesh
  108589. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  108590. * - VertexBuffer.PositionKind
  108591. * - VertexBuffer.UVKind
  108592. * - VertexBuffer.UV2Kind
  108593. * - VertexBuffer.UV3Kind
  108594. * - VertexBuffer.UV4Kind
  108595. * - VertexBuffer.UV5Kind
  108596. * - VertexBuffer.UV6Kind
  108597. * - VertexBuffer.ColorKind
  108598. * - VertexBuffer.MatricesIndicesKind
  108599. * - VertexBuffer.MatricesIndicesExtraKind
  108600. * - VertexBuffer.MatricesWeightsKind
  108601. * - VertexBuffer.MatricesWeightsExtraKind
  108602. */
  108603. removeVerticesData(kind: string): void;
  108604. /**
  108605. * Flags an associated vertex buffer as updatable
  108606. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  108607. * - VertexBuffer.PositionKind
  108608. * - VertexBuffer.UVKind
  108609. * - VertexBuffer.UV2Kind
  108610. * - VertexBuffer.UV3Kind
  108611. * - VertexBuffer.UV4Kind
  108612. * - VertexBuffer.UV5Kind
  108613. * - VertexBuffer.UV6Kind
  108614. * - VertexBuffer.ColorKind
  108615. * - VertexBuffer.MatricesIndicesKind
  108616. * - VertexBuffer.MatricesIndicesExtraKind
  108617. * - VertexBuffer.MatricesWeightsKind
  108618. * - VertexBuffer.MatricesWeightsExtraKind
  108619. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  108620. */
  108621. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  108622. /**
  108623. * Sets the mesh global Vertex Buffer
  108624. * @param buffer defines the buffer to use
  108625. * @returns the current mesh
  108626. */
  108627. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  108628. /**
  108629. * Update a specific associated vertex buffer
  108630. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  108631. * - VertexBuffer.PositionKind
  108632. * - VertexBuffer.UVKind
  108633. * - VertexBuffer.UV2Kind
  108634. * - VertexBuffer.UV3Kind
  108635. * - VertexBuffer.UV4Kind
  108636. * - VertexBuffer.UV5Kind
  108637. * - VertexBuffer.UV6Kind
  108638. * - VertexBuffer.ColorKind
  108639. * - VertexBuffer.MatricesIndicesKind
  108640. * - VertexBuffer.MatricesIndicesExtraKind
  108641. * - VertexBuffer.MatricesWeightsKind
  108642. * - VertexBuffer.MatricesWeightsExtraKind
  108643. * @param data defines the data source
  108644. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  108645. * @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)
  108646. * @returns the current mesh
  108647. */
  108648. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  108649. /**
  108650. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  108651. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  108652. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  108653. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  108654. * @returns the current mesh
  108655. */
  108656. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  108657. /**
  108658. * Creates a un-shared specific occurence of the geometry for the mesh.
  108659. * @returns the current mesh
  108660. */
  108661. makeGeometryUnique(): Mesh;
  108662. /**
  108663. * Set the index buffer of this mesh
  108664. * @param indices defines the source data
  108665. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  108666. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  108667. * @returns the current mesh
  108668. */
  108669. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  108670. /**
  108671. * Update the current index buffer
  108672. * @param indices defines the source data
  108673. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  108674. * @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)
  108675. * @returns the current mesh
  108676. */
  108677. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  108678. /**
  108679. * Invert the geometry to move from a right handed system to a left handed one.
  108680. * @returns the current mesh
  108681. */
  108682. toLeftHanded(): Mesh;
  108683. /** @hidden */
  108684. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  108685. /** @hidden */
  108686. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  108687. /**
  108688. * Registers for this mesh a javascript function called just before the rendering process
  108689. * @param func defines the function to call before rendering this mesh
  108690. * @returns the current mesh
  108691. */
  108692. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  108693. /**
  108694. * Disposes a previously registered javascript function called before the rendering
  108695. * @param func defines the function to remove
  108696. * @returns the current mesh
  108697. */
  108698. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  108699. /**
  108700. * Registers for this mesh a javascript function called just after the rendering is complete
  108701. * @param func defines the function to call after rendering this mesh
  108702. * @returns the current mesh
  108703. */
  108704. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  108705. /**
  108706. * Disposes a previously registered javascript function called after the rendering.
  108707. * @param func defines the function to remove
  108708. * @returns the current mesh
  108709. */
  108710. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  108711. /** @hidden */
  108712. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  108713. /** @hidden */
  108714. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  108715. /** @hidden */
  108716. _renderWithThinInstances(subMesh: SubMesh, fillMode: number, effect: Effect, engine: Engine): void;
  108717. /** @hidden */
  108718. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  108719. /** @hidden */
  108720. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  108721. /** @hidden */
  108722. _rebuild(): void;
  108723. /** @hidden */
  108724. _freeze(): void;
  108725. /** @hidden */
  108726. _unFreeze(): void;
  108727. /**
  108728. * 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
  108729. * @param subMesh defines the subMesh to render
  108730. * @param enableAlphaMode defines if alpha mode can be changed
  108731. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  108732. * @returns the current mesh
  108733. */
  108734. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  108735. private _onBeforeDraw;
  108736. /**
  108737. * Renormalize the mesh and patch it up if there are no weights
  108738. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  108739. * However in the case of zero weights then we set just a single influence to 1.
  108740. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  108741. */
  108742. cleanMatrixWeights(): void;
  108743. private normalizeSkinFourWeights;
  108744. private normalizeSkinWeightsAndExtra;
  108745. /**
  108746. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  108747. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  108748. * the user know there was an issue with importing the mesh
  108749. * @returns a validation object with skinned, valid and report string
  108750. */
  108751. validateSkinning(): {
  108752. skinned: boolean;
  108753. valid: boolean;
  108754. report: string;
  108755. };
  108756. /** @hidden */
  108757. _checkDelayState(): Mesh;
  108758. private _queueLoad;
  108759. /**
  108760. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  108761. * A mesh is in the frustum if its bounding box intersects the frustum
  108762. * @param frustumPlanes defines the frustum to test
  108763. * @returns true if the mesh is in the frustum planes
  108764. */
  108765. isInFrustum(frustumPlanes: Plane[]): boolean;
  108766. /**
  108767. * Sets the mesh material by the material or multiMaterial `id` property
  108768. * @param id is a string identifying the material or the multiMaterial
  108769. * @returns the current mesh
  108770. */
  108771. setMaterialByID(id: string): Mesh;
  108772. /**
  108773. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  108774. * @returns an array of IAnimatable
  108775. */
  108776. getAnimatables(): IAnimatable[];
  108777. /**
  108778. * Modifies the mesh geometry according to the passed transformation matrix.
  108779. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  108780. * The mesh normals are modified using the same transformation.
  108781. * Note that, under the hood, this method sets a new VertexBuffer each call.
  108782. * @param transform defines the transform matrix to use
  108783. * @see https://doc.babylonjs.com/resources/baking_transformations
  108784. * @returns the current mesh
  108785. */
  108786. bakeTransformIntoVertices(transform: Matrix): Mesh;
  108787. /**
  108788. * Modifies the mesh geometry according to its own current World Matrix.
  108789. * The mesh World Matrix is then reset.
  108790. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  108791. * Note that, under the hood, this method sets a new VertexBuffer each call.
  108792. * @see https://doc.babylonjs.com/resources/baking_transformations
  108793. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  108794. * @returns the current mesh
  108795. */
  108796. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  108797. /** @hidden */
  108798. get _positions(): Nullable<Vector3[]>;
  108799. /** @hidden */
  108800. _resetPointsArrayCache(): Mesh;
  108801. /** @hidden */
  108802. _generatePointsArray(): boolean;
  108803. /**
  108804. * Returns a new Mesh object generated from the current mesh properties.
  108805. * This method must not get confused with createInstance()
  108806. * @param name is a string, the name given to the new mesh
  108807. * @param newParent can be any Node object (default `null`)
  108808. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  108809. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  108810. * @returns a new mesh
  108811. */
  108812. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  108813. /**
  108814. * Releases resources associated with this mesh.
  108815. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  108816. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  108817. */
  108818. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  108819. /** @hidden */
  108820. _disposeInstanceSpecificData(): void;
  108821. /** @hidden */
  108822. _disposeThinInstanceSpecificData(): void;
  108823. /**
  108824. * Modifies the mesh geometry according to a displacement map.
  108825. * 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.
  108826. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  108827. * @param url is a string, the URL from the image file is to be downloaded.
  108828. * @param minHeight is the lower limit of the displacement.
  108829. * @param maxHeight is the upper limit of the displacement.
  108830. * @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.
  108831. * @param uvOffset is an optional vector2 used to offset UV.
  108832. * @param uvScale is an optional vector2 used to scale UV.
  108833. * @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.
  108834. * @returns the Mesh.
  108835. */
  108836. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  108837. /**
  108838. * Modifies the mesh geometry according to a displacementMap buffer.
  108839. * 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.
  108840. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  108841. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  108842. * @param heightMapWidth is the width of the buffer image.
  108843. * @param heightMapHeight is the height of the buffer image.
  108844. * @param minHeight is the lower limit of the displacement.
  108845. * @param maxHeight is the upper limit of the displacement.
  108846. * @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.
  108847. * @param uvOffset is an optional vector2 used to offset UV.
  108848. * @param uvScale is an optional vector2 used to scale UV.
  108849. * @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.
  108850. * @returns the Mesh.
  108851. */
  108852. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  108853. /**
  108854. * Modify the mesh to get a flat shading rendering.
  108855. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  108856. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  108857. * @returns current mesh
  108858. */
  108859. convertToFlatShadedMesh(): Mesh;
  108860. /**
  108861. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  108862. * In other words, more vertices, no more indices and a single bigger VBO.
  108863. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  108864. * @returns current mesh
  108865. */
  108866. convertToUnIndexedMesh(): Mesh;
  108867. /**
  108868. * Inverses facet orientations.
  108869. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  108870. * @param flipNormals will also inverts the normals
  108871. * @returns current mesh
  108872. */
  108873. flipFaces(flipNormals?: boolean): Mesh;
  108874. /**
  108875. * Increase the number of facets and hence vertices in a mesh
  108876. * Vertex normals are interpolated from existing vertex normals
  108877. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  108878. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  108879. */
  108880. increaseVertices(numberPerEdge: number): void;
  108881. /**
  108882. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  108883. * This will undo any application of covertToFlatShadedMesh
  108884. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  108885. */
  108886. forceSharedVertices(): void;
  108887. /** @hidden */
  108888. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  108889. /** @hidden */
  108890. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  108891. /**
  108892. * Creates a new InstancedMesh object from the mesh model.
  108893. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  108894. * @param name defines the name of the new instance
  108895. * @returns a new InstancedMesh
  108896. */
  108897. createInstance(name: string): InstancedMesh;
  108898. /**
  108899. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  108900. * After this call, all the mesh instances have the same submeshes than the current mesh.
  108901. * @returns the current mesh
  108902. */
  108903. synchronizeInstances(): Mesh;
  108904. /**
  108905. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  108906. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  108907. * This should be used together with the simplification to avoid disappearing triangles.
  108908. * @param successCallback an optional success callback to be called after the optimization finished.
  108909. * @returns the current mesh
  108910. */
  108911. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  108912. /**
  108913. * Serialize current mesh
  108914. * @param serializationObject defines the object which will receive the serialization data
  108915. */
  108916. serialize(serializationObject: any): void;
  108917. /** @hidden */
  108918. _syncGeometryWithMorphTargetManager(): void;
  108919. /** @hidden */
  108920. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  108921. /**
  108922. * Returns a new Mesh object parsed from the source provided.
  108923. * @param parsedMesh is the source
  108924. * @param scene defines the hosting scene
  108925. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  108926. * @returns a new Mesh
  108927. */
  108928. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  108929. /**
  108930. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  108931. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  108932. * @param name defines the name of the mesh to create
  108933. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  108934. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  108935. * @param closePath creates a seam between the first and the last points of each path of the path array
  108936. * @param offset is taken in account only if the `pathArray` is containing a single path
  108937. * @param scene defines the hosting scene
  108938. * @param updatable defines if the mesh must be flagged as updatable
  108939. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  108940. * @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)
  108941. * @returns a new Mesh
  108942. */
  108943. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  108944. /**
  108945. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  108946. * @param name defines the name of the mesh to create
  108947. * @param radius sets the radius size (float) of the polygon (default 0.5)
  108948. * @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
  108949. * @param scene defines the hosting scene
  108950. * @param updatable defines if the mesh must be flagged as updatable
  108951. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  108952. * @returns a new Mesh
  108953. */
  108954. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  108955. /**
  108956. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  108957. * @param name defines the name of the mesh to create
  108958. * @param size sets the size (float) of each box side (default 1)
  108959. * @param scene defines the hosting scene
  108960. * @param updatable defines if the mesh must be flagged as updatable
  108961. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  108962. * @returns a new Mesh
  108963. */
  108964. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  108965. /**
  108966. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  108967. * @param name defines the name of the mesh to create
  108968. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  108969. * @param diameter sets the diameter size (float) of the sphere (default 1)
  108970. * @param scene defines the hosting scene
  108971. * @param updatable defines if the mesh must be flagged as updatable
  108972. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  108973. * @returns a new Mesh
  108974. */
  108975. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  108976. /**
  108977. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  108978. * @param name defines the name of the mesh to create
  108979. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  108980. * @param diameter sets the diameter size (float) of the sphere (default 1)
  108981. * @param scene defines the hosting scene
  108982. * @returns a new Mesh
  108983. */
  108984. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  108985. /**
  108986. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  108987. * @param name defines the name of the mesh to create
  108988. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  108989. * @param diameterTop set the top cap diameter (floats, default 1)
  108990. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  108991. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  108992. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  108993. * @param scene defines the hosting scene
  108994. * @param updatable defines if the mesh must be flagged as updatable
  108995. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  108996. * @returns a new Mesh
  108997. */
  108998. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  108999. /**
  109000. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  109001. * @param name defines the name of the mesh to create
  109002. * @param diameter sets the diameter size (float) of the torus (default 1)
  109003. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  109004. * @param tessellation sets the number of torus sides (postive integer, default 16)
  109005. * @param scene defines the hosting scene
  109006. * @param updatable defines if the mesh must be flagged as updatable
  109007. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  109008. * @returns a new Mesh
  109009. */
  109010. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  109011. /**
  109012. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  109013. * @param name defines the name of the mesh to create
  109014. * @param radius sets the global radius size (float) of the torus knot (default 2)
  109015. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  109016. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  109017. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  109018. * @param p the number of windings on X axis (positive integers, default 2)
  109019. * @param q the number of windings on Y axis (positive integers, default 3)
  109020. * @param scene defines the hosting scene
  109021. * @param updatable defines if the mesh must be flagged as updatable
  109022. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  109023. * @returns a new Mesh
  109024. */
  109025. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  109026. /**
  109027. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  109028. * @param name defines the name of the mesh to create
  109029. * @param points is an array successive Vector3
  109030. * @param scene defines the hosting scene
  109031. * @param updatable defines if the mesh must be flagged as updatable
  109032. * @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).
  109033. * @returns a new Mesh
  109034. */
  109035. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  109036. /**
  109037. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  109038. * @param name defines the name of the mesh to create
  109039. * @param points is an array successive Vector3
  109040. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  109041. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  109042. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  109043. * @param scene defines the hosting scene
  109044. * @param updatable defines if the mesh must be flagged as updatable
  109045. * @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)
  109046. * @returns a new Mesh
  109047. */
  109048. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  109049. /**
  109050. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  109051. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  109052. * 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.
  109053. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  109054. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  109055. * Remember you can only change the shape positions, not their number when updating a polygon.
  109056. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  109057. * @param name defines the name of the mesh to create
  109058. * @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
  109059. * @param scene defines the hosting scene
  109060. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  109061. * @param updatable defines if the mesh must be flagged as updatable
  109062. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  109063. * @param earcutInjection can be used to inject your own earcut reference
  109064. * @returns a new Mesh
  109065. */
  109066. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  109067. /**
  109068. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  109069. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  109070. * @param name defines the name of the mesh to create
  109071. * @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
  109072. * @param depth defines the height of extrusion
  109073. * @param scene defines the hosting scene
  109074. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  109075. * @param updatable defines if the mesh must be flagged as updatable
  109076. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  109077. * @param earcutInjection can be used to inject your own earcut reference
  109078. * @returns a new Mesh
  109079. */
  109080. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  109081. /**
  109082. * Creates an extruded shape mesh.
  109083. * 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
  109084. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  109085. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  109086. * @param name defines the name of the mesh to create
  109087. * @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
  109088. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  109089. * @param scale is the value to scale the shape
  109090. * @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
  109091. * @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
  109092. * @param scene defines the hosting scene
  109093. * @param updatable defines if the mesh must be flagged as updatable
  109094. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  109095. * @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)
  109096. * @returns a new Mesh
  109097. */
  109098. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  109099. /**
  109100. * Creates an custom extruded shape mesh.
  109101. * The custom extrusion is a parametric shape.
  109102. * It has no predefined shape. Its final shape will depend on the input parameters.
  109103. * Please consider using the same method from the MeshBuilder class instead
  109104. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  109105. * @param name defines the name of the mesh to create
  109106. * @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
  109107. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  109108. * @param scaleFunction is a custom Javascript function called on each path point
  109109. * @param rotationFunction is a custom Javascript function called on each path point
  109110. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  109111. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  109112. * @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
  109113. * @param scene defines the hosting scene
  109114. * @param updatable defines if the mesh must be flagged as updatable
  109115. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  109116. * @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)
  109117. * @returns a new Mesh
  109118. */
  109119. 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;
  109120. /**
  109121. * Creates lathe mesh.
  109122. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  109123. * Please consider using the same method from the MeshBuilder class instead
  109124. * @param name defines the name of the mesh to create
  109125. * @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
  109126. * @param radius is the radius value of the lathe
  109127. * @param tessellation is the side number of the lathe.
  109128. * @param scene defines the hosting scene
  109129. * @param updatable defines if the mesh must be flagged as updatable
  109130. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  109131. * @returns a new Mesh
  109132. */
  109133. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  109134. /**
  109135. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  109136. * @param name defines the name of the mesh to create
  109137. * @param size sets the size (float) of both sides of the plane at once (default 1)
  109138. * @param scene defines the hosting scene
  109139. * @param updatable defines if the mesh must be flagged as updatable
  109140. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  109141. * @returns a new Mesh
  109142. */
  109143. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  109144. /**
  109145. * Creates a ground mesh.
  109146. * Please consider using the same method from the MeshBuilder class instead
  109147. * @param name defines the name of the mesh to create
  109148. * @param width set the width of the ground
  109149. * @param height set the height of the ground
  109150. * @param subdivisions sets the number of subdivisions per side
  109151. * @param scene defines the hosting scene
  109152. * @param updatable defines if the mesh must be flagged as updatable
  109153. * @returns a new Mesh
  109154. */
  109155. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  109156. /**
  109157. * Creates a tiled ground mesh.
  109158. * Please consider using the same method from the MeshBuilder class instead
  109159. * @param name defines the name of the mesh to create
  109160. * @param xmin set the ground minimum X coordinate
  109161. * @param zmin set the ground minimum Y coordinate
  109162. * @param xmax set the ground maximum X coordinate
  109163. * @param zmax set the ground maximum Z coordinate
  109164. * @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
  109165. * @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
  109166. * @param scene defines the hosting scene
  109167. * @param updatable defines if the mesh must be flagged as updatable
  109168. * @returns a new Mesh
  109169. */
  109170. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  109171. w: number;
  109172. h: number;
  109173. }, precision: {
  109174. w: number;
  109175. h: number;
  109176. }, scene: Scene, updatable?: boolean): Mesh;
  109177. /**
  109178. * Creates a ground mesh from a height map.
  109179. * Please consider using the same method from the MeshBuilder class instead
  109180. * @see https://doc.babylonjs.com/babylon101/height_map
  109181. * @param name defines the name of the mesh to create
  109182. * @param url sets the URL of the height map image resource
  109183. * @param width set the ground width size
  109184. * @param height set the ground height size
  109185. * @param subdivisions sets the number of subdivision per side
  109186. * @param minHeight is the minimum altitude on the ground
  109187. * @param maxHeight is the maximum altitude on the ground
  109188. * @param scene defines the hosting scene
  109189. * @param updatable defines if the mesh must be flagged as updatable
  109190. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  109191. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  109192. * @returns a new Mesh
  109193. */
  109194. 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;
  109195. /**
  109196. * Creates a tube mesh.
  109197. * The tube is a parametric shape.
  109198. * It has no predefined shape. Its final shape will depend on the input parameters.
  109199. * Please consider using the same method from the MeshBuilder class instead
  109200. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  109201. * @param name defines the name of the mesh to create
  109202. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  109203. * @param radius sets the tube radius size
  109204. * @param tessellation is the number of sides on the tubular surface
  109205. * @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
  109206. * @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
  109207. * @param scene defines the hosting scene
  109208. * @param updatable defines if the mesh must be flagged as updatable
  109209. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  109210. * @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)
  109211. * @returns a new Mesh
  109212. */
  109213. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  109214. (i: number, distance: number): number;
  109215. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  109216. /**
  109217. * Creates a polyhedron mesh.
  109218. * Please consider using the same method from the MeshBuilder class instead.
  109219. * * 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
  109220. * * The parameter `size` (positive float, default 1) sets the polygon size
  109221. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  109222. * * 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`
  109223. * * 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
  109224. * * 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)`)
  109225. * * 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
  109226. * * 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
  109227. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  109228. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  109229. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109230. * @param name defines the name of the mesh to create
  109231. * @param options defines the options used to create the mesh
  109232. * @param scene defines the hosting scene
  109233. * @returns a new Mesh
  109234. */
  109235. static CreatePolyhedron(name: string, options: {
  109236. type?: number;
  109237. size?: number;
  109238. sizeX?: number;
  109239. sizeY?: number;
  109240. sizeZ?: number;
  109241. custom?: any;
  109242. faceUV?: Vector4[];
  109243. faceColors?: Color4[];
  109244. updatable?: boolean;
  109245. sideOrientation?: number;
  109246. }, scene: Scene): Mesh;
  109247. /**
  109248. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  109249. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  109250. * * 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`)
  109251. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  109252. * * 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
  109253. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  109254. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  109255. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109256. * @param name defines the name of the mesh
  109257. * @param options defines the options used to create the mesh
  109258. * @param scene defines the hosting scene
  109259. * @returns a new Mesh
  109260. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  109261. */
  109262. static CreateIcoSphere(name: string, options: {
  109263. radius?: number;
  109264. flat?: boolean;
  109265. subdivisions?: number;
  109266. sideOrientation?: number;
  109267. updatable?: boolean;
  109268. }, scene: Scene): Mesh;
  109269. /**
  109270. * Creates a decal mesh.
  109271. * Please consider using the same method from the MeshBuilder class instead.
  109272. * A decal is a mesh usually applied as a model onto the surface of another mesh
  109273. * @param name defines the name of the mesh
  109274. * @param sourceMesh defines the mesh receiving the decal
  109275. * @param position sets the position of the decal in world coordinates
  109276. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  109277. * @param size sets the decal scaling
  109278. * @param angle sets the angle to rotate the decal
  109279. * @returns a new Mesh
  109280. */
  109281. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  109282. /** Creates a Capsule Mesh
  109283. * @param name defines the name of the mesh.
  109284. * @param options the constructors options used to shape the mesh.
  109285. * @param scene defines the scene the mesh is scoped to.
  109286. * @returns the capsule mesh
  109287. * @see https://doc.babylonjs.com/how_to/capsule_shape
  109288. */
  109289. static CreateCapsule(name: string, options: ICreateCapsuleOptions, scene: Scene): Mesh;
  109290. /**
  109291. * Prepare internal position array for software CPU skinning
  109292. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  109293. */
  109294. setPositionsForCPUSkinning(): Float32Array;
  109295. /**
  109296. * Prepare internal normal array for software CPU skinning
  109297. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  109298. */
  109299. setNormalsForCPUSkinning(): Float32Array;
  109300. /**
  109301. * Updates the vertex buffer by applying transformation from the bones
  109302. * @param skeleton defines the skeleton to apply to current mesh
  109303. * @returns the current mesh
  109304. */
  109305. applySkeleton(skeleton: Skeleton): Mesh;
  109306. /**
  109307. * 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
  109308. * @param meshes defines the list of meshes to scan
  109309. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  109310. */
  109311. static MinMax(meshes: AbstractMesh[]): {
  109312. min: Vector3;
  109313. max: Vector3;
  109314. };
  109315. /**
  109316. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  109317. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  109318. * @returns a vector3
  109319. */
  109320. static Center(meshesOrMinMaxVector: {
  109321. min: Vector3;
  109322. max: Vector3;
  109323. } | AbstractMesh[]): Vector3;
  109324. /**
  109325. * Merge the array of meshes into a single mesh for performance reasons.
  109326. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  109327. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  109328. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  109329. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  109330. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  109331. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  109332. * @returns a new mesh
  109333. */
  109334. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  109335. /** @hidden */
  109336. addInstance(instance: InstancedMesh): void;
  109337. /** @hidden */
  109338. removeInstance(instance: InstancedMesh): void;
  109339. }
  109340. }
  109341. declare module BABYLON {
  109342. /**
  109343. * This is the base class of all the camera used in the application.
  109344. * @see https://doc.babylonjs.com/features/cameras
  109345. */
  109346. export class Camera extends Node {
  109347. /** @hidden */
  109348. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  109349. /**
  109350. * This is the default projection mode used by the cameras.
  109351. * It helps recreating a feeling of perspective and better appreciate depth.
  109352. * This is the best way to simulate real life cameras.
  109353. */
  109354. static readonly PERSPECTIVE_CAMERA: number;
  109355. /**
  109356. * This helps creating camera with an orthographic mode.
  109357. * 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.
  109358. */
  109359. static readonly ORTHOGRAPHIC_CAMERA: number;
  109360. /**
  109361. * This is the default FOV mode for perspective cameras.
  109362. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  109363. */
  109364. static readonly FOVMODE_VERTICAL_FIXED: number;
  109365. /**
  109366. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  109367. */
  109368. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  109369. /**
  109370. * This specifies ther is no need for a camera rig.
  109371. * Basically only one eye is rendered corresponding to the camera.
  109372. */
  109373. static readonly RIG_MODE_NONE: number;
  109374. /**
  109375. * Simulates a camera Rig with one blue eye and one red eye.
  109376. * This can be use with 3d blue and red glasses.
  109377. */
  109378. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  109379. /**
  109380. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  109381. */
  109382. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  109383. /**
  109384. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  109385. */
  109386. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  109387. /**
  109388. * Defines that both eyes of the camera will be rendered over under each other.
  109389. */
  109390. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  109391. /**
  109392. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  109393. */
  109394. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  109395. /**
  109396. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  109397. */
  109398. static readonly RIG_MODE_VR: number;
  109399. /**
  109400. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  109401. */
  109402. static readonly RIG_MODE_WEBVR: number;
  109403. /**
  109404. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  109405. */
  109406. static readonly RIG_MODE_CUSTOM: number;
  109407. /**
  109408. * Defines if by default attaching controls should prevent the default javascript event to continue.
  109409. */
  109410. static ForceAttachControlToAlwaysPreventDefault: boolean;
  109411. /**
  109412. * Define the input manager associated with the camera.
  109413. */
  109414. inputs: CameraInputsManager<Camera>;
  109415. /** @hidden */
  109416. _position: Vector3;
  109417. /**
  109418. * Define the current local position of the camera in the scene
  109419. */
  109420. get position(): Vector3;
  109421. set position(newPosition: Vector3);
  109422. protected _upVector: Vector3;
  109423. /**
  109424. * The vector the camera should consider as up.
  109425. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  109426. */
  109427. set upVector(vec: Vector3);
  109428. get upVector(): Vector3;
  109429. /**
  109430. * Define the current limit on the left side for an orthographic camera
  109431. * In scene unit
  109432. */
  109433. orthoLeft: Nullable<number>;
  109434. /**
  109435. * Define the current limit on the right side for an orthographic camera
  109436. * In scene unit
  109437. */
  109438. orthoRight: Nullable<number>;
  109439. /**
  109440. * Define the current limit on the bottom side for an orthographic camera
  109441. * In scene unit
  109442. */
  109443. orthoBottom: Nullable<number>;
  109444. /**
  109445. * Define the current limit on the top side for an orthographic camera
  109446. * In scene unit
  109447. */
  109448. orthoTop: Nullable<number>;
  109449. /**
  109450. * Field Of View is set in Radians. (default is 0.8)
  109451. */
  109452. fov: number;
  109453. /**
  109454. * Define the minimum distance the camera can see from.
  109455. * This is important to note that the depth buffer are not infinite and the closer it starts
  109456. * the more your scene might encounter depth fighting issue.
  109457. */
  109458. minZ: number;
  109459. /**
  109460. * Define the maximum distance the camera can see to.
  109461. * This is important to note that the depth buffer are not infinite and the further it end
  109462. * the more your scene might encounter depth fighting issue.
  109463. */
  109464. maxZ: number;
  109465. /**
  109466. * Define the default inertia of the camera.
  109467. * This helps giving a smooth feeling to the camera movement.
  109468. */
  109469. inertia: number;
  109470. /**
  109471. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  109472. */
  109473. mode: number;
  109474. /**
  109475. * Define whether the camera is intermediate.
  109476. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  109477. */
  109478. isIntermediate: boolean;
  109479. /**
  109480. * Define the viewport of the camera.
  109481. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  109482. */
  109483. viewport: Viewport;
  109484. /**
  109485. * Restricts the camera to viewing objects with the same layerMask.
  109486. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  109487. */
  109488. layerMask: number;
  109489. /**
  109490. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  109491. */
  109492. fovMode: number;
  109493. /**
  109494. * Rig mode of the camera.
  109495. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  109496. * This is normally controlled byt the camera themselves as internal use.
  109497. */
  109498. cameraRigMode: number;
  109499. /**
  109500. * Defines the distance between both "eyes" in case of a RIG
  109501. */
  109502. interaxialDistance: number;
  109503. /**
  109504. * Defines if stereoscopic rendering is done side by side or over under.
  109505. */
  109506. isStereoscopicSideBySide: boolean;
  109507. /**
  109508. * 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
  109509. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  109510. * else in the scene. (Eg. security camera)
  109511. *
  109512. * 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)
  109513. */
  109514. customRenderTargets: RenderTargetTexture[];
  109515. /**
  109516. * When set, the camera will render to this render target instead of the default canvas
  109517. *
  109518. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  109519. */
  109520. outputRenderTarget: Nullable<RenderTargetTexture>;
  109521. /**
  109522. * Observable triggered when the camera view matrix has changed.
  109523. */
  109524. onViewMatrixChangedObservable: Observable<Camera>;
  109525. /**
  109526. * Observable triggered when the camera Projection matrix has changed.
  109527. */
  109528. onProjectionMatrixChangedObservable: Observable<Camera>;
  109529. /**
  109530. * Observable triggered when the inputs have been processed.
  109531. */
  109532. onAfterCheckInputsObservable: Observable<Camera>;
  109533. /**
  109534. * Observable triggered when reset has been called and applied to the camera.
  109535. */
  109536. onRestoreStateObservable: Observable<Camera>;
  109537. /**
  109538. * Is this camera a part of a rig system?
  109539. */
  109540. isRigCamera: boolean;
  109541. /**
  109542. * If isRigCamera set to true this will be set with the parent camera.
  109543. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  109544. */
  109545. rigParent?: Camera;
  109546. /** @hidden */
  109547. _cameraRigParams: any;
  109548. /** @hidden */
  109549. _rigCameras: Camera[];
  109550. /** @hidden */
  109551. _rigPostProcess: Nullable<PostProcess>;
  109552. protected _webvrViewMatrix: Matrix;
  109553. /** @hidden */
  109554. _skipRendering: boolean;
  109555. /** @hidden */
  109556. _projectionMatrix: Matrix;
  109557. /** @hidden */
  109558. _postProcesses: Nullable<PostProcess>[];
  109559. /** @hidden */
  109560. _activeMeshes: SmartArray<AbstractMesh>;
  109561. protected _globalPosition: Vector3;
  109562. /** @hidden */
  109563. _computedViewMatrix: Matrix;
  109564. private _doNotComputeProjectionMatrix;
  109565. private _transformMatrix;
  109566. private _frustumPlanes;
  109567. private _refreshFrustumPlanes;
  109568. private _storedFov;
  109569. private _stateStored;
  109570. /**
  109571. * Instantiates a new camera object.
  109572. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  109573. * @see https://doc.babylonjs.com/features/cameras
  109574. * @param name Defines the name of the camera in the scene
  109575. * @param position Defines the position of the camera
  109576. * @param scene Defines the scene the camera belongs too
  109577. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  109578. */
  109579. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  109580. /**
  109581. * Store current camera state (fov, position, etc..)
  109582. * @returns the camera
  109583. */
  109584. storeState(): Camera;
  109585. /**
  109586. * Restores the camera state values if it has been stored. You must call storeState() first
  109587. */
  109588. protected _restoreStateValues(): boolean;
  109589. /**
  109590. * Restored camera state. You must call storeState() first.
  109591. * @returns true if restored and false otherwise
  109592. */
  109593. restoreState(): boolean;
  109594. /**
  109595. * Gets the class name of the camera.
  109596. * @returns the class name
  109597. */
  109598. getClassName(): string;
  109599. /** @hidden */
  109600. readonly _isCamera: boolean;
  109601. /**
  109602. * Gets a string representation of the camera useful for debug purpose.
  109603. * @param fullDetails Defines that a more verboe level of logging is required
  109604. * @returns the string representation
  109605. */
  109606. toString(fullDetails?: boolean): string;
  109607. /**
  109608. * Gets the current world space position of the camera.
  109609. */
  109610. get globalPosition(): Vector3;
  109611. /**
  109612. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  109613. * @returns the active meshe list
  109614. */
  109615. getActiveMeshes(): SmartArray<AbstractMesh>;
  109616. /**
  109617. * Check whether a mesh is part of the current active mesh list of the camera
  109618. * @param mesh Defines the mesh to check
  109619. * @returns true if active, false otherwise
  109620. */
  109621. isActiveMesh(mesh: Mesh): boolean;
  109622. /**
  109623. * Is this camera ready to be used/rendered
  109624. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  109625. * @return true if the camera is ready
  109626. */
  109627. isReady(completeCheck?: boolean): boolean;
  109628. /** @hidden */
  109629. _initCache(): void;
  109630. /** @hidden */
  109631. _updateCache(ignoreParentClass?: boolean): void;
  109632. /** @hidden */
  109633. _isSynchronized(): boolean;
  109634. /** @hidden */
  109635. _isSynchronizedViewMatrix(): boolean;
  109636. /** @hidden */
  109637. _isSynchronizedProjectionMatrix(): boolean;
  109638. /**
  109639. * Attach the input controls to a specific dom element to get the input from.
  109640. * @param element Defines the element the controls should be listened from
  109641. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  109642. */
  109643. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  109644. /**
  109645. * Detach the current controls from the specified dom element.
  109646. * @param element Defines the element to stop listening the inputs from
  109647. */
  109648. detachControl(element: HTMLElement): void;
  109649. /**
  109650. * Update the camera state according to the different inputs gathered during the frame.
  109651. */
  109652. update(): void;
  109653. /** @hidden */
  109654. _checkInputs(): void;
  109655. /** @hidden */
  109656. get rigCameras(): Camera[];
  109657. /**
  109658. * Gets the post process used by the rig cameras
  109659. */
  109660. get rigPostProcess(): Nullable<PostProcess>;
  109661. /**
  109662. * Internal, gets the first post proces.
  109663. * @returns the first post process to be run on this camera.
  109664. */
  109665. _getFirstPostProcess(): Nullable<PostProcess>;
  109666. private _cascadePostProcessesToRigCams;
  109667. /**
  109668. * Attach a post process to the camera.
  109669. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  109670. * @param postProcess The post process to attach to the camera
  109671. * @param insertAt The position of the post process in case several of them are in use in the scene
  109672. * @returns the position the post process has been inserted at
  109673. */
  109674. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  109675. /**
  109676. * Detach a post process to the camera.
  109677. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  109678. * @param postProcess The post process to detach from the camera
  109679. */
  109680. detachPostProcess(postProcess: PostProcess): void;
  109681. /**
  109682. * Gets the current world matrix of the camera
  109683. */
  109684. getWorldMatrix(): Matrix;
  109685. /** @hidden */
  109686. _getViewMatrix(): Matrix;
  109687. /**
  109688. * Gets the current view matrix of the camera.
  109689. * @param force forces the camera to recompute the matrix without looking at the cached state
  109690. * @returns the view matrix
  109691. */
  109692. getViewMatrix(force?: boolean): Matrix;
  109693. /**
  109694. * Freeze the projection matrix.
  109695. * It will prevent the cache check of the camera projection compute and can speed up perf
  109696. * if no parameter of the camera are meant to change
  109697. * @param projection Defines manually a projection if necessary
  109698. */
  109699. freezeProjectionMatrix(projection?: Matrix): void;
  109700. /**
  109701. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  109702. */
  109703. unfreezeProjectionMatrix(): void;
  109704. /**
  109705. * Gets the current projection matrix of the camera.
  109706. * @param force forces the camera to recompute the matrix without looking at the cached state
  109707. * @returns the projection matrix
  109708. */
  109709. getProjectionMatrix(force?: boolean): Matrix;
  109710. /**
  109711. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  109712. * @returns a Matrix
  109713. */
  109714. getTransformationMatrix(): Matrix;
  109715. private _updateFrustumPlanes;
  109716. /**
  109717. * Checks if a cullable object (mesh...) is in the camera frustum
  109718. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  109719. * @param target The object to check
  109720. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  109721. * @returns true if the object is in frustum otherwise false
  109722. */
  109723. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  109724. /**
  109725. * Checks if a cullable object (mesh...) is in the camera frustum
  109726. * Unlike isInFrustum this cheks the full bounding box
  109727. * @param target The object to check
  109728. * @returns true if the object is in frustum otherwise false
  109729. */
  109730. isCompletelyInFrustum(target: ICullable): boolean;
  109731. /**
  109732. * Gets a ray in the forward direction from the camera.
  109733. * @param length Defines the length of the ray to create
  109734. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  109735. * @param origin Defines the start point of the ray which defaults to the camera position
  109736. * @returns the forward ray
  109737. */
  109738. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  109739. /**
  109740. * Gets a ray in the forward direction from the camera.
  109741. * @param refRay the ray to (re)use when setting the values
  109742. * @param length Defines the length of the ray to create
  109743. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  109744. * @param origin Defines the start point of the ray which defaults to the camera position
  109745. * @returns the forward ray
  109746. */
  109747. getForwardRayToRef(refRay: Ray, length?: number, transform?: Matrix, origin?: Vector3): Ray;
  109748. /**
  109749. * Releases resources associated with this node.
  109750. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  109751. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  109752. */
  109753. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  109754. /** @hidden */
  109755. _isLeftCamera: boolean;
  109756. /**
  109757. * Gets the left camera of a rig setup in case of Rigged Camera
  109758. */
  109759. get isLeftCamera(): boolean;
  109760. /** @hidden */
  109761. _isRightCamera: boolean;
  109762. /**
  109763. * Gets the right camera of a rig setup in case of Rigged Camera
  109764. */
  109765. get isRightCamera(): boolean;
  109766. /**
  109767. * Gets the left camera of a rig setup in case of Rigged Camera
  109768. */
  109769. get leftCamera(): Nullable<FreeCamera>;
  109770. /**
  109771. * Gets the right camera of a rig setup in case of Rigged Camera
  109772. */
  109773. get rightCamera(): Nullable<FreeCamera>;
  109774. /**
  109775. * Gets the left camera target of a rig setup in case of Rigged Camera
  109776. * @returns the target position
  109777. */
  109778. getLeftTarget(): Nullable<Vector3>;
  109779. /**
  109780. * Gets the right camera target of a rig setup in case of Rigged Camera
  109781. * @returns the target position
  109782. */
  109783. getRightTarget(): Nullable<Vector3>;
  109784. /**
  109785. * @hidden
  109786. */
  109787. setCameraRigMode(mode: number, rigParams: any): void;
  109788. /** @hidden */
  109789. static _setStereoscopicRigMode(camera: Camera): void;
  109790. /** @hidden */
  109791. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  109792. /** @hidden */
  109793. static _setVRRigMode(camera: Camera, rigParams: any): void;
  109794. /** @hidden */
  109795. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  109796. /** @hidden */
  109797. _getVRProjectionMatrix(): Matrix;
  109798. protected _updateCameraRotationMatrix(): void;
  109799. protected _updateWebVRCameraRotationMatrix(): void;
  109800. /**
  109801. * This function MUST be overwritten by the different WebVR cameras available.
  109802. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  109803. * @hidden
  109804. */
  109805. _getWebVRProjectionMatrix(): Matrix;
  109806. /**
  109807. * This function MUST be overwritten by the different WebVR cameras available.
  109808. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  109809. * @hidden
  109810. */
  109811. _getWebVRViewMatrix(): Matrix;
  109812. /** @hidden */
  109813. setCameraRigParameter(name: string, value: any): void;
  109814. /**
  109815. * needs to be overridden by children so sub has required properties to be copied
  109816. * @hidden
  109817. */
  109818. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  109819. /**
  109820. * May need to be overridden by children
  109821. * @hidden
  109822. */
  109823. _updateRigCameras(): void;
  109824. /** @hidden */
  109825. _setupInputs(): void;
  109826. /**
  109827. * Serialiaze the camera setup to a json represention
  109828. * @returns the JSON representation
  109829. */
  109830. serialize(): any;
  109831. /**
  109832. * Clones the current camera.
  109833. * @param name The cloned camera name
  109834. * @returns the cloned camera
  109835. */
  109836. clone(name: string): Camera;
  109837. /**
  109838. * Gets the direction of the camera relative to a given local axis.
  109839. * @param localAxis Defines the reference axis to provide a relative direction.
  109840. * @return the direction
  109841. */
  109842. getDirection(localAxis: Vector3): Vector3;
  109843. /**
  109844. * Returns the current camera absolute rotation
  109845. */
  109846. get absoluteRotation(): Quaternion;
  109847. /**
  109848. * Gets the direction of the camera relative to a given local axis into a passed vector.
  109849. * @param localAxis Defines the reference axis to provide a relative direction.
  109850. * @param result Defines the vector to store the result in
  109851. */
  109852. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  109853. /**
  109854. * Gets a camera constructor for a given camera type
  109855. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  109856. * @param name The name of the camera the result will be able to instantiate
  109857. * @param scene The scene the result will construct the camera in
  109858. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  109859. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  109860. * @returns a factory method to construc the camera
  109861. */
  109862. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  109863. /**
  109864. * Compute the world matrix of the camera.
  109865. * @returns the camera world matrix
  109866. */
  109867. computeWorldMatrix(): Matrix;
  109868. /**
  109869. * Parse a JSON and creates the camera from the parsed information
  109870. * @param parsedCamera The JSON to parse
  109871. * @param scene The scene to instantiate the camera in
  109872. * @returns the newly constructed camera
  109873. */
  109874. static Parse(parsedCamera: any, scene: Scene): Camera;
  109875. }
  109876. }
  109877. declare module BABYLON {
  109878. /**
  109879. * Class containing static functions to help procedurally build meshes
  109880. */
  109881. export class DiscBuilder {
  109882. /**
  109883. * Creates a plane polygonal mesh. By default, this is a disc
  109884. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  109885. * * 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
  109886. * * 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
  109887. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  109888. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  109889. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109890. * @param name defines the name of the mesh
  109891. * @param options defines the options used to create the mesh
  109892. * @param scene defines the hosting scene
  109893. * @returns the plane polygonal mesh
  109894. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  109895. */
  109896. static CreateDisc(name: string, options: {
  109897. radius?: number;
  109898. tessellation?: number;
  109899. arc?: number;
  109900. updatable?: boolean;
  109901. sideOrientation?: number;
  109902. frontUVs?: Vector4;
  109903. backUVs?: Vector4;
  109904. }, scene?: Nullable<Scene>): Mesh;
  109905. }
  109906. }
  109907. declare module BABYLON {
  109908. /**
  109909. * Options to be used when creating a FresnelParameters.
  109910. */
  109911. export type IFresnelParametersCreationOptions = {
  109912. /**
  109913. * Define the color used on edges (grazing angle)
  109914. */
  109915. leftColor?: Color3;
  109916. /**
  109917. * Define the color used on center
  109918. */
  109919. rightColor?: Color3;
  109920. /**
  109921. * Define bias applied to computed fresnel term
  109922. */
  109923. bias?: number;
  109924. /**
  109925. * Defined the power exponent applied to fresnel term
  109926. */
  109927. power?: number;
  109928. /**
  109929. * Define if the fresnel effect is enable or not.
  109930. */
  109931. isEnabled?: boolean;
  109932. };
  109933. /**
  109934. * Serialized format for FresnelParameters.
  109935. */
  109936. export type IFresnelParametersSerialized = {
  109937. /**
  109938. * Define the color used on edges (grazing angle) [as an array]
  109939. */
  109940. leftColor: number[];
  109941. /**
  109942. * Define the color used on center [as an array]
  109943. */
  109944. rightColor: number[];
  109945. /**
  109946. * Define bias applied to computed fresnel term
  109947. */
  109948. bias: number;
  109949. /**
  109950. * Defined the power exponent applied to fresnel term
  109951. */
  109952. power?: number;
  109953. /**
  109954. * Define if the fresnel effect is enable or not.
  109955. */
  109956. isEnabled: boolean;
  109957. };
  109958. /**
  109959. * This represents all the required information to add a fresnel effect on a material:
  109960. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  109961. */
  109962. export class FresnelParameters {
  109963. private _isEnabled;
  109964. /**
  109965. * Define if the fresnel effect is enable or not.
  109966. */
  109967. get isEnabled(): boolean;
  109968. set isEnabled(value: boolean);
  109969. /**
  109970. * Define the color used on edges (grazing angle)
  109971. */
  109972. leftColor: Color3;
  109973. /**
  109974. * Define the color used on center
  109975. */
  109976. rightColor: Color3;
  109977. /**
  109978. * Define bias applied to computed fresnel term
  109979. */
  109980. bias: number;
  109981. /**
  109982. * Defined the power exponent applied to fresnel term
  109983. */
  109984. power: number;
  109985. /**
  109986. * Creates a new FresnelParameters object.
  109987. *
  109988. * @param options provide your own settings to optionally to override defaults
  109989. */
  109990. constructor(options?: IFresnelParametersCreationOptions);
  109991. /**
  109992. * Clones the current fresnel and its valuues
  109993. * @returns a clone fresnel configuration
  109994. */
  109995. clone(): FresnelParameters;
  109996. /**
  109997. * Determines equality between FresnelParameters objects
  109998. * @param otherFresnelParameters defines the second operand
  109999. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  110000. */
  110001. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  110002. /**
  110003. * Serializes the current fresnel parameters to a JSON representation.
  110004. * @return the JSON serialization
  110005. */
  110006. serialize(): IFresnelParametersSerialized;
  110007. /**
  110008. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  110009. * @param parsedFresnelParameters Define the JSON representation
  110010. * @returns the parsed parameters
  110011. */
  110012. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  110013. }
  110014. }
  110015. declare module BABYLON {
  110016. /**
  110017. * This groups all the flags used to control the materials channel.
  110018. */
  110019. export class MaterialFlags {
  110020. private static _DiffuseTextureEnabled;
  110021. /**
  110022. * Are diffuse textures enabled in the application.
  110023. */
  110024. static get DiffuseTextureEnabled(): boolean;
  110025. static set DiffuseTextureEnabled(value: boolean);
  110026. private static _DetailTextureEnabled;
  110027. /**
  110028. * Are detail textures enabled in the application.
  110029. */
  110030. static get DetailTextureEnabled(): boolean;
  110031. static set DetailTextureEnabled(value: boolean);
  110032. private static _AmbientTextureEnabled;
  110033. /**
  110034. * Are ambient textures enabled in the application.
  110035. */
  110036. static get AmbientTextureEnabled(): boolean;
  110037. static set AmbientTextureEnabled(value: boolean);
  110038. private static _OpacityTextureEnabled;
  110039. /**
  110040. * Are opacity textures enabled in the application.
  110041. */
  110042. static get OpacityTextureEnabled(): boolean;
  110043. static set OpacityTextureEnabled(value: boolean);
  110044. private static _ReflectionTextureEnabled;
  110045. /**
  110046. * Are reflection textures enabled in the application.
  110047. */
  110048. static get ReflectionTextureEnabled(): boolean;
  110049. static set ReflectionTextureEnabled(value: boolean);
  110050. private static _EmissiveTextureEnabled;
  110051. /**
  110052. * Are emissive textures enabled in the application.
  110053. */
  110054. static get EmissiveTextureEnabled(): boolean;
  110055. static set EmissiveTextureEnabled(value: boolean);
  110056. private static _SpecularTextureEnabled;
  110057. /**
  110058. * Are specular textures enabled in the application.
  110059. */
  110060. static get SpecularTextureEnabled(): boolean;
  110061. static set SpecularTextureEnabled(value: boolean);
  110062. private static _BumpTextureEnabled;
  110063. /**
  110064. * Are bump textures enabled in the application.
  110065. */
  110066. static get BumpTextureEnabled(): boolean;
  110067. static set BumpTextureEnabled(value: boolean);
  110068. private static _LightmapTextureEnabled;
  110069. /**
  110070. * Are lightmap textures enabled in the application.
  110071. */
  110072. static get LightmapTextureEnabled(): boolean;
  110073. static set LightmapTextureEnabled(value: boolean);
  110074. private static _RefractionTextureEnabled;
  110075. /**
  110076. * Are refraction textures enabled in the application.
  110077. */
  110078. static get RefractionTextureEnabled(): boolean;
  110079. static set RefractionTextureEnabled(value: boolean);
  110080. private static _ColorGradingTextureEnabled;
  110081. /**
  110082. * Are color grading textures enabled in the application.
  110083. */
  110084. static get ColorGradingTextureEnabled(): boolean;
  110085. static set ColorGradingTextureEnabled(value: boolean);
  110086. private static _FresnelEnabled;
  110087. /**
  110088. * Are fresnels enabled in the application.
  110089. */
  110090. static get FresnelEnabled(): boolean;
  110091. static set FresnelEnabled(value: boolean);
  110092. private static _ClearCoatTextureEnabled;
  110093. /**
  110094. * Are clear coat textures enabled in the application.
  110095. */
  110096. static get ClearCoatTextureEnabled(): boolean;
  110097. static set ClearCoatTextureEnabled(value: boolean);
  110098. private static _ClearCoatBumpTextureEnabled;
  110099. /**
  110100. * Are clear coat bump textures enabled in the application.
  110101. */
  110102. static get ClearCoatBumpTextureEnabled(): boolean;
  110103. static set ClearCoatBumpTextureEnabled(value: boolean);
  110104. private static _ClearCoatTintTextureEnabled;
  110105. /**
  110106. * Are clear coat tint textures enabled in the application.
  110107. */
  110108. static get ClearCoatTintTextureEnabled(): boolean;
  110109. static set ClearCoatTintTextureEnabled(value: boolean);
  110110. private static _SheenTextureEnabled;
  110111. /**
  110112. * Are sheen textures enabled in the application.
  110113. */
  110114. static get SheenTextureEnabled(): boolean;
  110115. static set SheenTextureEnabled(value: boolean);
  110116. private static _AnisotropicTextureEnabled;
  110117. /**
  110118. * Are anisotropic textures enabled in the application.
  110119. */
  110120. static get AnisotropicTextureEnabled(): boolean;
  110121. static set AnisotropicTextureEnabled(value: boolean);
  110122. private static _ThicknessTextureEnabled;
  110123. /**
  110124. * Are thickness textures enabled in the application.
  110125. */
  110126. static get ThicknessTextureEnabled(): boolean;
  110127. static set ThicknessTextureEnabled(value: boolean);
  110128. }
  110129. }
  110130. declare module BABYLON {
  110131. /** @hidden */
  110132. export var defaultFragmentDeclaration: {
  110133. name: string;
  110134. shader: string;
  110135. };
  110136. }
  110137. declare module BABYLON {
  110138. /** @hidden */
  110139. export var defaultUboDeclaration: {
  110140. name: string;
  110141. shader: string;
  110142. };
  110143. }
  110144. declare module BABYLON {
  110145. /** @hidden */
  110146. export var prePassDeclaration: {
  110147. name: string;
  110148. shader: string;
  110149. };
  110150. }
  110151. declare module BABYLON {
  110152. /** @hidden */
  110153. export var lightFragmentDeclaration: {
  110154. name: string;
  110155. shader: string;
  110156. };
  110157. }
  110158. declare module BABYLON {
  110159. /** @hidden */
  110160. export var lightUboDeclaration: {
  110161. name: string;
  110162. shader: string;
  110163. };
  110164. }
  110165. declare module BABYLON {
  110166. /** @hidden */
  110167. export var lightsFragmentFunctions: {
  110168. name: string;
  110169. shader: string;
  110170. };
  110171. }
  110172. declare module BABYLON {
  110173. /** @hidden */
  110174. export var shadowsFragmentFunctions: {
  110175. name: string;
  110176. shader: string;
  110177. };
  110178. }
  110179. declare module BABYLON {
  110180. /** @hidden */
  110181. export var fresnelFunction: {
  110182. name: string;
  110183. shader: string;
  110184. };
  110185. }
  110186. declare module BABYLON {
  110187. /** @hidden */
  110188. export var bumpFragmentMainFunctions: {
  110189. name: string;
  110190. shader: string;
  110191. };
  110192. }
  110193. declare module BABYLON {
  110194. /** @hidden */
  110195. export var bumpFragmentFunctions: {
  110196. name: string;
  110197. shader: string;
  110198. };
  110199. }
  110200. declare module BABYLON {
  110201. /** @hidden */
  110202. export var logDepthDeclaration: {
  110203. name: string;
  110204. shader: string;
  110205. };
  110206. }
  110207. declare module BABYLON {
  110208. /** @hidden */
  110209. export var bumpFragment: {
  110210. name: string;
  110211. shader: string;
  110212. };
  110213. }
  110214. declare module BABYLON {
  110215. /** @hidden */
  110216. export var depthPrePass: {
  110217. name: string;
  110218. shader: string;
  110219. };
  110220. }
  110221. declare module BABYLON {
  110222. /** @hidden */
  110223. export var lightFragment: {
  110224. name: string;
  110225. shader: string;
  110226. };
  110227. }
  110228. declare module BABYLON {
  110229. /** @hidden */
  110230. export var logDepthFragment: {
  110231. name: string;
  110232. shader: string;
  110233. };
  110234. }
  110235. declare module BABYLON {
  110236. /** @hidden */
  110237. export var defaultPixelShader: {
  110238. name: string;
  110239. shader: string;
  110240. };
  110241. }
  110242. declare module BABYLON {
  110243. /** @hidden */
  110244. export var defaultVertexDeclaration: {
  110245. name: string;
  110246. shader: string;
  110247. };
  110248. }
  110249. declare module BABYLON {
  110250. /** @hidden */
  110251. export var bumpVertexDeclaration: {
  110252. name: string;
  110253. shader: string;
  110254. };
  110255. }
  110256. declare module BABYLON {
  110257. /** @hidden */
  110258. export var bumpVertex: {
  110259. name: string;
  110260. shader: string;
  110261. };
  110262. }
  110263. declare module BABYLON {
  110264. /** @hidden */
  110265. export var fogVertex: {
  110266. name: string;
  110267. shader: string;
  110268. };
  110269. }
  110270. declare module BABYLON {
  110271. /** @hidden */
  110272. export var shadowsVertex: {
  110273. name: string;
  110274. shader: string;
  110275. };
  110276. }
  110277. declare module BABYLON {
  110278. /** @hidden */
  110279. export var pointCloudVertex: {
  110280. name: string;
  110281. shader: string;
  110282. };
  110283. }
  110284. declare module BABYLON {
  110285. /** @hidden */
  110286. export var logDepthVertex: {
  110287. name: string;
  110288. shader: string;
  110289. };
  110290. }
  110291. declare module BABYLON {
  110292. /** @hidden */
  110293. export var defaultVertexShader: {
  110294. name: string;
  110295. shader: string;
  110296. };
  110297. }
  110298. declare module BABYLON {
  110299. /**
  110300. * @hidden
  110301. */
  110302. export interface IMaterialDetailMapDefines {
  110303. DETAIL: boolean;
  110304. DETAILDIRECTUV: number;
  110305. DETAIL_NORMALBLENDMETHOD: number;
  110306. /** @hidden */
  110307. _areTexturesDirty: boolean;
  110308. }
  110309. /**
  110310. * Define the code related to the detail map parameters of a material
  110311. *
  110312. * Inspired from:
  110313. * 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
  110314. * Unreal: https://docs.unrealengine.com/en-US/Engine/Rendering/Materials/HowTo/DetailTexturing/index.html
  110315. * Cryengine: https://docs.cryengine.com/display/SDKDOC2/Detail+Maps
  110316. */
  110317. export class DetailMapConfiguration {
  110318. private _texture;
  110319. /**
  110320. * The detail texture of the material.
  110321. */
  110322. texture: Nullable<BaseTexture>;
  110323. /**
  110324. * Defines how strongly the detail diffuse/albedo channel is blended with the regular diffuse/albedo texture
  110325. * Bigger values mean stronger blending
  110326. */
  110327. diffuseBlendLevel: number;
  110328. /**
  110329. * Defines how strongly the detail roughness channel is blended with the regular roughness value
  110330. * Bigger values mean stronger blending. Only used with PBR materials
  110331. */
  110332. roughnessBlendLevel: number;
  110333. /**
  110334. * Defines how strong the bump effect from the detail map is
  110335. * Bigger values mean stronger effect
  110336. */
  110337. bumpLevel: number;
  110338. private _normalBlendMethod;
  110339. /**
  110340. * The method used to blend the bump and detail normals together
  110341. */
  110342. normalBlendMethod: number;
  110343. private _isEnabled;
  110344. /**
  110345. * Enable or disable the detail map on this material
  110346. */
  110347. isEnabled: boolean;
  110348. /** @hidden */
  110349. private _internalMarkAllSubMeshesAsTexturesDirty;
  110350. /** @hidden */
  110351. _markAllSubMeshesAsTexturesDirty(): void;
  110352. /**
  110353. * Instantiate a new detail map
  110354. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  110355. */
  110356. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  110357. /**
  110358. * Gets whether the submesh is ready to be used or not.
  110359. * @param defines the list of "defines" to update.
  110360. * @param scene defines the scene the material belongs to.
  110361. * @returns - boolean indicating that the submesh is ready or not.
  110362. */
  110363. isReadyForSubMesh(defines: IMaterialDetailMapDefines, scene: Scene): boolean;
  110364. /**
  110365. * Update the defines for detail map usage
  110366. * @param defines the list of "defines" to update.
  110367. * @param scene defines the scene the material belongs to.
  110368. */
  110369. prepareDefines(defines: IMaterialDetailMapDefines, scene: Scene): void;
  110370. /**
  110371. * Binds the material data.
  110372. * @param uniformBuffer defines the Uniform buffer to fill in.
  110373. * @param scene defines the scene the material belongs to.
  110374. * @param isFrozen defines whether the material is frozen or not.
  110375. */
  110376. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  110377. /**
  110378. * Checks to see if a texture is used in the material.
  110379. * @param texture - Base texture to use.
  110380. * @returns - Boolean specifying if a texture is used in the material.
  110381. */
  110382. hasTexture(texture: BaseTexture): boolean;
  110383. /**
  110384. * Returns an array of the actively used textures.
  110385. * @param activeTextures Array of BaseTextures
  110386. */
  110387. getActiveTextures(activeTextures: BaseTexture[]): void;
  110388. /**
  110389. * Returns the animatable textures.
  110390. * @param animatables Array of animatable textures.
  110391. */
  110392. getAnimatables(animatables: IAnimatable[]): void;
  110393. /**
  110394. * Disposes the resources of the material.
  110395. * @param forceDisposeTextures - Forces the disposal of all textures.
  110396. */
  110397. dispose(forceDisposeTextures?: boolean): void;
  110398. /**
  110399. * Get the current class name useful for serialization or dynamic coding.
  110400. * @returns "DetailMap"
  110401. */
  110402. getClassName(): string;
  110403. /**
  110404. * Add the required uniforms to the current list.
  110405. * @param uniforms defines the current uniform list.
  110406. */
  110407. static AddUniforms(uniforms: string[]): void;
  110408. /**
  110409. * Add the required samplers to the current list.
  110410. * @param samplers defines the current sampler list.
  110411. */
  110412. static AddSamplers(samplers: string[]): void;
  110413. /**
  110414. * Add the required uniforms to the current buffer.
  110415. * @param uniformBuffer defines the current uniform buffer.
  110416. */
  110417. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  110418. /**
  110419. * Makes a duplicate of the current instance into another one.
  110420. * @param detailMap define the instance where to copy the info
  110421. */
  110422. copyTo(detailMap: DetailMapConfiguration): void;
  110423. /**
  110424. * Serializes this detail map instance
  110425. * @returns - An object with the serialized instance.
  110426. */
  110427. serialize(): any;
  110428. /**
  110429. * Parses a detail map setting from a serialized object.
  110430. * @param source - Serialized object.
  110431. * @param scene Defines the scene we are parsing for
  110432. * @param rootUrl Defines the rootUrl to load from
  110433. */
  110434. parse(source: any, scene: Scene, rootUrl: string): void;
  110435. }
  110436. }
  110437. declare module BABYLON {
  110438. /** @hidden */
  110439. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialDetailMapDefines {
  110440. MAINUV1: boolean;
  110441. MAINUV2: boolean;
  110442. DIFFUSE: boolean;
  110443. DIFFUSEDIRECTUV: number;
  110444. DETAIL: boolean;
  110445. DETAILDIRECTUV: number;
  110446. DETAIL_NORMALBLENDMETHOD: number;
  110447. AMBIENT: boolean;
  110448. AMBIENTDIRECTUV: number;
  110449. OPACITY: boolean;
  110450. OPACITYDIRECTUV: number;
  110451. OPACITYRGB: boolean;
  110452. REFLECTION: boolean;
  110453. EMISSIVE: boolean;
  110454. EMISSIVEDIRECTUV: number;
  110455. SPECULAR: boolean;
  110456. SPECULARDIRECTUV: number;
  110457. BUMP: boolean;
  110458. BUMPDIRECTUV: number;
  110459. PARALLAX: boolean;
  110460. PARALLAXOCCLUSION: boolean;
  110461. SPECULAROVERALPHA: boolean;
  110462. CLIPPLANE: boolean;
  110463. CLIPPLANE2: boolean;
  110464. CLIPPLANE3: boolean;
  110465. CLIPPLANE4: boolean;
  110466. CLIPPLANE5: boolean;
  110467. CLIPPLANE6: boolean;
  110468. ALPHATEST: boolean;
  110469. DEPTHPREPASS: boolean;
  110470. ALPHAFROMDIFFUSE: boolean;
  110471. POINTSIZE: boolean;
  110472. FOG: boolean;
  110473. SPECULARTERM: boolean;
  110474. DIFFUSEFRESNEL: boolean;
  110475. OPACITYFRESNEL: boolean;
  110476. REFLECTIONFRESNEL: boolean;
  110477. REFRACTIONFRESNEL: boolean;
  110478. EMISSIVEFRESNEL: boolean;
  110479. FRESNEL: boolean;
  110480. NORMAL: boolean;
  110481. UV1: boolean;
  110482. UV2: boolean;
  110483. VERTEXCOLOR: boolean;
  110484. VERTEXALPHA: boolean;
  110485. NUM_BONE_INFLUENCERS: number;
  110486. BonesPerMesh: number;
  110487. BONETEXTURE: boolean;
  110488. INSTANCES: boolean;
  110489. THIN_INSTANCES: boolean;
  110490. GLOSSINESS: boolean;
  110491. ROUGHNESS: boolean;
  110492. EMISSIVEASILLUMINATION: boolean;
  110493. LINKEMISSIVEWITHDIFFUSE: boolean;
  110494. REFLECTIONFRESNELFROMSPECULAR: boolean;
  110495. LIGHTMAP: boolean;
  110496. LIGHTMAPDIRECTUV: number;
  110497. OBJECTSPACE_NORMALMAP: boolean;
  110498. USELIGHTMAPASSHADOWMAP: boolean;
  110499. REFLECTIONMAP_3D: boolean;
  110500. REFLECTIONMAP_SPHERICAL: boolean;
  110501. REFLECTIONMAP_PLANAR: boolean;
  110502. REFLECTIONMAP_CUBIC: boolean;
  110503. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  110504. REFLECTIONMAP_PROJECTION: boolean;
  110505. REFLECTIONMAP_SKYBOX: boolean;
  110506. REFLECTIONMAP_EXPLICIT: boolean;
  110507. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  110508. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  110509. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  110510. INVERTCUBICMAP: boolean;
  110511. LOGARITHMICDEPTH: boolean;
  110512. REFRACTION: boolean;
  110513. REFRACTIONMAP_3D: boolean;
  110514. REFLECTIONOVERALPHA: boolean;
  110515. TWOSIDEDLIGHTING: boolean;
  110516. SHADOWFLOAT: boolean;
  110517. MORPHTARGETS: boolean;
  110518. MORPHTARGETS_NORMAL: boolean;
  110519. MORPHTARGETS_TANGENT: boolean;
  110520. MORPHTARGETS_UV: boolean;
  110521. NUM_MORPH_INFLUENCERS: number;
  110522. NONUNIFORMSCALING: boolean;
  110523. PREMULTIPLYALPHA: boolean;
  110524. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  110525. ALPHABLEND: boolean;
  110526. PREPASS: boolean;
  110527. SCENE_MRT_COUNT: number;
  110528. RGBDLIGHTMAP: boolean;
  110529. RGBDREFLECTION: boolean;
  110530. RGBDREFRACTION: boolean;
  110531. IMAGEPROCESSING: boolean;
  110532. VIGNETTE: boolean;
  110533. VIGNETTEBLENDMODEMULTIPLY: boolean;
  110534. VIGNETTEBLENDMODEOPAQUE: boolean;
  110535. TONEMAPPING: boolean;
  110536. TONEMAPPING_ACES: boolean;
  110537. CONTRAST: boolean;
  110538. COLORCURVES: boolean;
  110539. COLORGRADING: boolean;
  110540. COLORGRADING3D: boolean;
  110541. SAMPLER3DGREENDEPTH: boolean;
  110542. SAMPLER3DBGRMAP: boolean;
  110543. IMAGEPROCESSINGPOSTPROCESS: boolean;
  110544. MULTIVIEW: boolean;
  110545. /**
  110546. * If the reflection texture on this material is in linear color space
  110547. * @hidden
  110548. */
  110549. IS_REFLECTION_LINEAR: boolean;
  110550. /**
  110551. * If the refraction texture on this material is in linear color space
  110552. * @hidden
  110553. */
  110554. IS_REFRACTION_LINEAR: boolean;
  110555. EXPOSURE: boolean;
  110556. constructor();
  110557. setReflectionMode(modeToEnable: string): void;
  110558. }
  110559. /**
  110560. * This is the default material used in Babylon. It is the best trade off between quality
  110561. * and performances.
  110562. * @see https://doc.babylonjs.com/babylon101/materials
  110563. */
  110564. export class StandardMaterial extends PushMaterial {
  110565. private _diffuseTexture;
  110566. /**
  110567. * The basic texture of the material as viewed under a light.
  110568. */
  110569. diffuseTexture: Nullable<BaseTexture>;
  110570. private _ambientTexture;
  110571. /**
  110572. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  110573. */
  110574. ambientTexture: Nullable<BaseTexture>;
  110575. private _opacityTexture;
  110576. /**
  110577. * Define the transparency of the material from a texture.
  110578. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  110579. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  110580. */
  110581. opacityTexture: Nullable<BaseTexture>;
  110582. private _reflectionTexture;
  110583. /**
  110584. * Define the texture used to display the reflection.
  110585. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  110586. */
  110587. reflectionTexture: Nullable<BaseTexture>;
  110588. private _emissiveTexture;
  110589. /**
  110590. * Define texture of the material as if self lit.
  110591. * This will be mixed in the final result even in the absence of light.
  110592. */
  110593. emissiveTexture: Nullable<BaseTexture>;
  110594. private _specularTexture;
  110595. /**
  110596. * Define how the color and intensity of the highlight given by the light in the material.
  110597. */
  110598. specularTexture: Nullable<BaseTexture>;
  110599. private _bumpTexture;
  110600. /**
  110601. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  110602. * 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.
  110603. * @see https://doc.babylonjs.com/how_to/more_materials#bump-map
  110604. */
  110605. bumpTexture: Nullable<BaseTexture>;
  110606. private _lightmapTexture;
  110607. /**
  110608. * Complex lighting can be computationally expensive to compute at runtime.
  110609. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  110610. * @see https://doc.babylonjs.com/babylon101/lights#lightmaps
  110611. */
  110612. lightmapTexture: Nullable<BaseTexture>;
  110613. private _refractionTexture;
  110614. /**
  110615. * Define the texture used to display the refraction.
  110616. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  110617. */
  110618. refractionTexture: Nullable<BaseTexture>;
  110619. /**
  110620. * The color of the material lit by the environmental background lighting.
  110621. * @see https://doc.babylonjs.com/babylon101/materials#ambient-color-example
  110622. */
  110623. ambientColor: Color3;
  110624. /**
  110625. * The basic color of the material as viewed under a light.
  110626. */
  110627. diffuseColor: Color3;
  110628. /**
  110629. * Define how the color and intensity of the highlight given by the light in the material.
  110630. */
  110631. specularColor: Color3;
  110632. /**
  110633. * Define the color of the material as if self lit.
  110634. * This will be mixed in the final result even in the absence of light.
  110635. */
  110636. emissiveColor: Color3;
  110637. /**
  110638. * Defines how sharp are the highlights in the material.
  110639. * The bigger the value the sharper giving a more glossy feeling to the result.
  110640. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  110641. */
  110642. specularPower: number;
  110643. private _useAlphaFromDiffuseTexture;
  110644. /**
  110645. * Does the transparency come from the diffuse texture alpha channel.
  110646. */
  110647. useAlphaFromDiffuseTexture: boolean;
  110648. private _useEmissiveAsIllumination;
  110649. /**
  110650. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  110651. */
  110652. useEmissiveAsIllumination: boolean;
  110653. private _linkEmissiveWithDiffuse;
  110654. /**
  110655. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  110656. * the emissive level when the final color is close to one.
  110657. */
  110658. linkEmissiveWithDiffuse: boolean;
  110659. private _useSpecularOverAlpha;
  110660. /**
  110661. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  110662. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  110663. */
  110664. useSpecularOverAlpha: boolean;
  110665. private _useReflectionOverAlpha;
  110666. /**
  110667. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  110668. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  110669. */
  110670. useReflectionOverAlpha: boolean;
  110671. private _disableLighting;
  110672. /**
  110673. * Does lights from the scene impacts this material.
  110674. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  110675. */
  110676. disableLighting: boolean;
  110677. private _useObjectSpaceNormalMap;
  110678. /**
  110679. * Allows using an object space normal map (instead of tangent space).
  110680. */
  110681. useObjectSpaceNormalMap: boolean;
  110682. private _useParallax;
  110683. /**
  110684. * Is parallax enabled or not.
  110685. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  110686. */
  110687. useParallax: boolean;
  110688. private _useParallaxOcclusion;
  110689. /**
  110690. * Is parallax occlusion enabled or not.
  110691. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  110692. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  110693. */
  110694. useParallaxOcclusion: boolean;
  110695. /**
  110696. * 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.
  110697. */
  110698. parallaxScaleBias: number;
  110699. private _roughness;
  110700. /**
  110701. * Helps to define how blurry the reflections should appears in the material.
  110702. */
  110703. roughness: number;
  110704. /**
  110705. * In case of refraction, define the value of the index of refraction.
  110706. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  110707. */
  110708. indexOfRefraction: number;
  110709. /**
  110710. * Invert the refraction texture alongside the y axis.
  110711. * It can be useful with procedural textures or probe for instance.
  110712. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  110713. */
  110714. invertRefractionY: boolean;
  110715. /**
  110716. * Defines the alpha limits in alpha test mode.
  110717. */
  110718. alphaCutOff: number;
  110719. private _useLightmapAsShadowmap;
  110720. /**
  110721. * In case of light mapping, define whether the map contains light or shadow informations.
  110722. */
  110723. useLightmapAsShadowmap: boolean;
  110724. private _diffuseFresnelParameters;
  110725. /**
  110726. * Define the diffuse fresnel parameters of the material.
  110727. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  110728. */
  110729. diffuseFresnelParameters: FresnelParameters;
  110730. private _opacityFresnelParameters;
  110731. /**
  110732. * Define the opacity fresnel parameters of the material.
  110733. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  110734. */
  110735. opacityFresnelParameters: FresnelParameters;
  110736. private _reflectionFresnelParameters;
  110737. /**
  110738. * Define the reflection fresnel parameters of the material.
  110739. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  110740. */
  110741. reflectionFresnelParameters: FresnelParameters;
  110742. private _refractionFresnelParameters;
  110743. /**
  110744. * Define the refraction fresnel parameters of the material.
  110745. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  110746. */
  110747. refractionFresnelParameters: FresnelParameters;
  110748. private _emissiveFresnelParameters;
  110749. /**
  110750. * Define the emissive fresnel parameters of the material.
  110751. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  110752. */
  110753. emissiveFresnelParameters: FresnelParameters;
  110754. private _useReflectionFresnelFromSpecular;
  110755. /**
  110756. * If true automatically deducts the fresnels values from the material specularity.
  110757. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  110758. */
  110759. useReflectionFresnelFromSpecular: boolean;
  110760. private _useGlossinessFromSpecularMapAlpha;
  110761. /**
  110762. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  110763. */
  110764. useGlossinessFromSpecularMapAlpha: boolean;
  110765. private _maxSimultaneousLights;
  110766. /**
  110767. * Defines the maximum number of lights that can be used in the material
  110768. */
  110769. maxSimultaneousLights: number;
  110770. private _invertNormalMapX;
  110771. /**
  110772. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  110773. */
  110774. invertNormalMapX: boolean;
  110775. private _invertNormalMapY;
  110776. /**
  110777. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  110778. */
  110779. invertNormalMapY: boolean;
  110780. private _twoSidedLighting;
  110781. /**
  110782. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  110783. */
  110784. twoSidedLighting: boolean;
  110785. /**
  110786. * Default configuration related to image processing available in the standard Material.
  110787. */
  110788. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  110789. /**
  110790. * Gets the image processing configuration used either in this material.
  110791. */
  110792. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  110793. /**
  110794. * Sets the Default image processing configuration used either in the this material.
  110795. *
  110796. * If sets to null, the scene one is in use.
  110797. */
  110798. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  110799. /**
  110800. * Keep track of the image processing observer to allow dispose and replace.
  110801. */
  110802. private _imageProcessingObserver;
  110803. /**
  110804. * Attaches a new image processing configuration to the Standard Material.
  110805. * @param configuration
  110806. */
  110807. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  110808. /**
  110809. * Gets wether the color curves effect is enabled.
  110810. */
  110811. get cameraColorCurvesEnabled(): boolean;
  110812. /**
  110813. * Sets wether the color curves effect is enabled.
  110814. */
  110815. set cameraColorCurvesEnabled(value: boolean);
  110816. /**
  110817. * Gets wether the color grading effect is enabled.
  110818. */
  110819. get cameraColorGradingEnabled(): boolean;
  110820. /**
  110821. * Gets wether the color grading effect is enabled.
  110822. */
  110823. set cameraColorGradingEnabled(value: boolean);
  110824. /**
  110825. * Gets wether tonemapping is enabled or not.
  110826. */
  110827. get cameraToneMappingEnabled(): boolean;
  110828. /**
  110829. * Sets wether tonemapping is enabled or not
  110830. */
  110831. set cameraToneMappingEnabled(value: boolean);
  110832. /**
  110833. * The camera exposure used on this material.
  110834. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  110835. * This corresponds to a photographic exposure.
  110836. */
  110837. get cameraExposure(): number;
  110838. /**
  110839. * The camera exposure used on this material.
  110840. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  110841. * This corresponds to a photographic exposure.
  110842. */
  110843. set cameraExposure(value: number);
  110844. /**
  110845. * Gets The camera contrast used on this material.
  110846. */
  110847. get cameraContrast(): number;
  110848. /**
  110849. * Sets The camera contrast used on this material.
  110850. */
  110851. set cameraContrast(value: number);
  110852. /**
  110853. * Gets the Color Grading 2D Lookup Texture.
  110854. */
  110855. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  110856. /**
  110857. * Sets the Color Grading 2D Lookup Texture.
  110858. */
  110859. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  110860. /**
  110861. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  110862. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  110863. * 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;
  110864. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  110865. */
  110866. get cameraColorCurves(): Nullable<ColorCurves>;
  110867. /**
  110868. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  110869. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  110870. * 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;
  110871. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  110872. */
  110873. set cameraColorCurves(value: Nullable<ColorCurves>);
  110874. /**
  110875. * Can this material render to several textures at once
  110876. */
  110877. get canRenderToMRT(): boolean;
  110878. /**
  110879. * Defines the detail map parameters for the material.
  110880. */
  110881. readonly detailMap: DetailMapConfiguration;
  110882. protected _renderTargets: SmartArray<RenderTargetTexture>;
  110883. protected _worldViewProjectionMatrix: Matrix;
  110884. protected _globalAmbientColor: Color3;
  110885. protected _useLogarithmicDepth: boolean;
  110886. protected _rebuildInParallel: boolean;
  110887. /**
  110888. * Instantiates a new standard material.
  110889. * This is the default material used in Babylon. It is the best trade off between quality
  110890. * and performances.
  110891. * @see https://doc.babylonjs.com/babylon101/materials
  110892. * @param name Define the name of the material in the scene
  110893. * @param scene Define the scene the material belong to
  110894. */
  110895. constructor(name: string, scene: Scene);
  110896. /**
  110897. * Gets a boolean indicating that current material needs to register RTT
  110898. */
  110899. get hasRenderTargetTextures(): boolean;
  110900. /**
  110901. * Gets the current class name of the material e.g. "StandardMaterial"
  110902. * Mainly use in serialization.
  110903. * @returns the class name
  110904. */
  110905. getClassName(): string;
  110906. /**
  110907. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  110908. * You can try switching to logarithmic depth.
  110909. * @see https://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  110910. */
  110911. get useLogarithmicDepth(): boolean;
  110912. set useLogarithmicDepth(value: boolean);
  110913. /**
  110914. * Specifies if the material will require alpha blending
  110915. * @returns a boolean specifying if alpha blending is needed
  110916. */
  110917. needAlphaBlending(): boolean;
  110918. /**
  110919. * Specifies if this material should be rendered in alpha test mode
  110920. * @returns a boolean specifying if an alpha test is needed.
  110921. */
  110922. needAlphaTesting(): boolean;
  110923. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  110924. /**
  110925. * Get the texture used for alpha test purpose.
  110926. * @returns the diffuse texture in case of the standard material.
  110927. */
  110928. getAlphaTestTexture(): Nullable<BaseTexture>;
  110929. /**
  110930. * Get if the submesh is ready to be used and all its information available.
  110931. * Child classes can use it to update shaders
  110932. * @param mesh defines the mesh to check
  110933. * @param subMesh defines which submesh to check
  110934. * @param useInstances specifies that instances should be used
  110935. * @returns a boolean indicating that the submesh is ready or not
  110936. */
  110937. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  110938. /**
  110939. * Builds the material UBO layouts.
  110940. * Used internally during the effect preparation.
  110941. */
  110942. buildUniformLayout(): void;
  110943. /**
  110944. * Unbinds the material from the mesh
  110945. */
  110946. unbind(): void;
  110947. /**
  110948. * Binds the submesh to this material by preparing the effect and shader to draw
  110949. * @param world defines the world transformation matrix
  110950. * @param mesh defines the mesh containing the submesh
  110951. * @param subMesh defines the submesh to bind the material to
  110952. */
  110953. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  110954. /**
  110955. * Get the list of animatables in the material.
  110956. * @returns the list of animatables object used in the material
  110957. */
  110958. getAnimatables(): IAnimatable[];
  110959. /**
  110960. * Gets the active textures from the material
  110961. * @returns an array of textures
  110962. */
  110963. getActiveTextures(): BaseTexture[];
  110964. /**
  110965. * Specifies if the material uses a texture
  110966. * @param texture defines the texture to check against the material
  110967. * @returns a boolean specifying if the material uses the texture
  110968. */
  110969. hasTexture(texture: BaseTexture): boolean;
  110970. /**
  110971. * Disposes the material
  110972. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  110973. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  110974. */
  110975. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  110976. /**
  110977. * Makes a duplicate of the material, and gives it a new name
  110978. * @param name defines the new name for the duplicated material
  110979. * @returns the cloned material
  110980. */
  110981. clone(name: string): StandardMaterial;
  110982. /**
  110983. * Serializes this material in a JSON representation
  110984. * @returns the serialized material object
  110985. */
  110986. serialize(): any;
  110987. /**
  110988. * Creates a standard material from parsed material data
  110989. * @param source defines the JSON representation of the material
  110990. * @param scene defines the hosting scene
  110991. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  110992. * @returns a new standard material
  110993. */
  110994. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  110995. /**
  110996. * Are diffuse textures enabled in the application.
  110997. */
  110998. static get DiffuseTextureEnabled(): boolean;
  110999. static set DiffuseTextureEnabled(value: boolean);
  111000. /**
  111001. * Are detail textures enabled in the application.
  111002. */
  111003. static get DetailTextureEnabled(): boolean;
  111004. static set DetailTextureEnabled(value: boolean);
  111005. /**
  111006. * Are ambient textures enabled in the application.
  111007. */
  111008. static get AmbientTextureEnabled(): boolean;
  111009. static set AmbientTextureEnabled(value: boolean);
  111010. /**
  111011. * Are opacity textures enabled in the application.
  111012. */
  111013. static get OpacityTextureEnabled(): boolean;
  111014. static set OpacityTextureEnabled(value: boolean);
  111015. /**
  111016. * Are reflection textures enabled in the application.
  111017. */
  111018. static get ReflectionTextureEnabled(): boolean;
  111019. static set ReflectionTextureEnabled(value: boolean);
  111020. /**
  111021. * Are emissive textures enabled in the application.
  111022. */
  111023. static get EmissiveTextureEnabled(): boolean;
  111024. static set EmissiveTextureEnabled(value: boolean);
  111025. /**
  111026. * Are specular textures enabled in the application.
  111027. */
  111028. static get SpecularTextureEnabled(): boolean;
  111029. static set SpecularTextureEnabled(value: boolean);
  111030. /**
  111031. * Are bump textures enabled in the application.
  111032. */
  111033. static get BumpTextureEnabled(): boolean;
  111034. static set BumpTextureEnabled(value: boolean);
  111035. /**
  111036. * Are lightmap textures enabled in the application.
  111037. */
  111038. static get LightmapTextureEnabled(): boolean;
  111039. static set LightmapTextureEnabled(value: boolean);
  111040. /**
  111041. * Are refraction textures enabled in the application.
  111042. */
  111043. static get RefractionTextureEnabled(): boolean;
  111044. static set RefractionTextureEnabled(value: boolean);
  111045. /**
  111046. * Are color grading textures enabled in the application.
  111047. */
  111048. static get ColorGradingTextureEnabled(): boolean;
  111049. static set ColorGradingTextureEnabled(value: boolean);
  111050. /**
  111051. * Are fresnels enabled in the application.
  111052. */
  111053. static get FresnelEnabled(): boolean;
  111054. static set FresnelEnabled(value: boolean);
  111055. }
  111056. }
  111057. declare module BABYLON {
  111058. /**
  111059. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  111060. *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.
  111061. * The SPS is also a particle system. It provides some methods to manage the particles.
  111062. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  111063. *
  111064. * Full documentation here : https://doc.babylonjs.com/how_to/Solid_Particle_System
  111065. */
  111066. export class SolidParticleSystem implements IDisposable {
  111067. /**
  111068. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  111069. * Example : var p = SPS.particles[i];
  111070. */
  111071. particles: SolidParticle[];
  111072. /**
  111073. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  111074. */
  111075. nbParticles: number;
  111076. /**
  111077. * If the particles must ever face the camera (default false). Useful for planar particles.
  111078. */
  111079. billboard: boolean;
  111080. /**
  111081. * Recompute normals when adding a shape
  111082. */
  111083. recomputeNormals: boolean;
  111084. /**
  111085. * This a counter ofr your own usage. It's not set by any SPS functions.
  111086. */
  111087. counter: number;
  111088. /**
  111089. * The SPS name. This name is also given to the underlying mesh.
  111090. */
  111091. name: string;
  111092. /**
  111093. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  111094. */
  111095. mesh: Mesh;
  111096. /**
  111097. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  111098. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  111099. */
  111100. vars: any;
  111101. /**
  111102. * This array is populated when the SPS is set as 'pickable'.
  111103. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  111104. * Each element of this array is an object `{idx: int, faceId: int}`.
  111105. * `idx` is the picked particle index in the `SPS.particles` array
  111106. * `faceId` is the picked face index counted within this particle.
  111107. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  111108. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  111109. * Use the method SPS.pickedParticle(pickingInfo) instead.
  111110. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  111111. */
  111112. pickedParticles: {
  111113. idx: number;
  111114. faceId: number;
  111115. }[];
  111116. /**
  111117. * This array is populated when the SPS is set as 'pickable'
  111118. * Each key of this array is a submesh index.
  111119. * Each element of this array is a second array defined like this :
  111120. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  111121. * Each element of this second array is an object `{idx: int, faceId: int}`.
  111122. * `idx` is the picked particle index in the `SPS.particles` array
  111123. * `faceId` is the picked face index counted within this particle.
  111124. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  111125. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  111126. */
  111127. pickedBySubMesh: {
  111128. idx: number;
  111129. faceId: number;
  111130. }[][];
  111131. /**
  111132. * This array is populated when `enableDepthSort` is set to true.
  111133. * Each element of this array is an instance of the class DepthSortedParticle.
  111134. */
  111135. depthSortedParticles: DepthSortedParticle[];
  111136. /**
  111137. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  111138. * @hidden
  111139. */
  111140. _bSphereOnly: boolean;
  111141. /**
  111142. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  111143. * @hidden
  111144. */
  111145. _bSphereRadiusFactor: number;
  111146. private _scene;
  111147. private _positions;
  111148. private _indices;
  111149. private _normals;
  111150. private _colors;
  111151. private _uvs;
  111152. private _indices32;
  111153. private _positions32;
  111154. private _normals32;
  111155. private _fixedNormal32;
  111156. private _colors32;
  111157. private _uvs32;
  111158. private _index;
  111159. private _updatable;
  111160. private _pickable;
  111161. private _isVisibilityBoxLocked;
  111162. private _alwaysVisible;
  111163. private _depthSort;
  111164. private _expandable;
  111165. private _shapeCounter;
  111166. private _copy;
  111167. private _color;
  111168. private _computeParticleColor;
  111169. private _computeParticleTexture;
  111170. private _computeParticleRotation;
  111171. private _computeParticleVertex;
  111172. private _computeBoundingBox;
  111173. private _depthSortParticles;
  111174. private _camera;
  111175. private _mustUnrotateFixedNormals;
  111176. private _particlesIntersect;
  111177. private _needs32Bits;
  111178. private _isNotBuilt;
  111179. private _lastParticleId;
  111180. private _idxOfId;
  111181. private _multimaterialEnabled;
  111182. private _useModelMaterial;
  111183. private _indicesByMaterial;
  111184. private _materialIndexes;
  111185. private _depthSortFunction;
  111186. private _materialSortFunction;
  111187. private _materials;
  111188. private _multimaterial;
  111189. private _materialIndexesById;
  111190. private _defaultMaterial;
  111191. private _autoUpdateSubMeshes;
  111192. private _tmpVertex;
  111193. /**
  111194. * Creates a SPS (Solid Particle System) object.
  111195. * @param name (String) is the SPS name, this will be the underlying mesh name.
  111196. * @param scene (Scene) is the scene in which the SPS is added.
  111197. * @param options defines the options of the sps e.g.
  111198. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  111199. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  111200. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  111201. * * 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.
  111202. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  111203. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  111204. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  111205. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  111206. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  111207. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  111208. */
  111209. constructor(name: string, scene: Scene, options?: {
  111210. updatable?: boolean;
  111211. isPickable?: boolean;
  111212. enableDepthSort?: boolean;
  111213. particleIntersection?: boolean;
  111214. boundingSphereOnly?: boolean;
  111215. bSphereRadiusFactor?: number;
  111216. expandable?: boolean;
  111217. useModelMaterial?: boolean;
  111218. enableMultiMaterial?: boolean;
  111219. });
  111220. /**
  111221. * Builds the SPS underlying mesh. Returns a standard Mesh.
  111222. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  111223. * @returns the created mesh
  111224. */
  111225. buildMesh(): Mesh;
  111226. /**
  111227. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  111228. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  111229. * Thus the particles generated from `digest()` have their property `position` set yet.
  111230. * @param mesh ( Mesh ) is the mesh to be digested
  111231. * @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
  111232. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  111233. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  111234. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  111235. * @returns the current SPS
  111236. */
  111237. digest(mesh: Mesh, options?: {
  111238. facetNb?: number;
  111239. number?: number;
  111240. delta?: number;
  111241. storage?: [];
  111242. }): SolidParticleSystem;
  111243. /**
  111244. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  111245. * @hidden
  111246. */
  111247. private _unrotateFixedNormals;
  111248. /**
  111249. * Resets the temporary working copy particle
  111250. * @hidden
  111251. */
  111252. private _resetCopy;
  111253. /**
  111254. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  111255. * @param p the current index in the positions array to be updated
  111256. * @param ind the current index in the indices array
  111257. * @param shape a Vector3 array, the shape geometry
  111258. * @param positions the positions array to be updated
  111259. * @param meshInd the shape indices array
  111260. * @param indices the indices array to be updated
  111261. * @param meshUV the shape uv array
  111262. * @param uvs the uv array to be updated
  111263. * @param meshCol the shape color array
  111264. * @param colors the color array to be updated
  111265. * @param meshNor the shape normals array
  111266. * @param normals the normals array to be updated
  111267. * @param idx the particle index
  111268. * @param idxInShape the particle index in its shape
  111269. * @param options the addShape() method passed options
  111270. * @model the particle model
  111271. * @hidden
  111272. */
  111273. private _meshBuilder;
  111274. /**
  111275. * Returns a shape Vector3 array from positions float array
  111276. * @param positions float array
  111277. * @returns a vector3 array
  111278. * @hidden
  111279. */
  111280. private _posToShape;
  111281. /**
  111282. * Returns a shapeUV array from a float uvs (array deep copy)
  111283. * @param uvs as a float array
  111284. * @returns a shapeUV array
  111285. * @hidden
  111286. */
  111287. private _uvsToShapeUV;
  111288. /**
  111289. * Adds a new particle object in the particles array
  111290. * @param idx particle index in particles array
  111291. * @param id particle id
  111292. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  111293. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  111294. * @param model particle ModelShape object
  111295. * @param shapeId model shape identifier
  111296. * @param idxInShape index of the particle in the current model
  111297. * @param bInfo model bounding info object
  111298. * @param storage target storage array, if any
  111299. * @hidden
  111300. */
  111301. private _addParticle;
  111302. /**
  111303. * Adds some particles to the SPS from the model shape. Returns the shape id.
  111304. * Please read the doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  111305. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  111306. * @param nb (positive integer) the number of particles to be created from this model
  111307. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  111308. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  111309. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  111310. * @returns the number of shapes in the system
  111311. */
  111312. addShape(mesh: Mesh, nb: number, options?: {
  111313. positionFunction?: any;
  111314. vertexFunction?: any;
  111315. storage?: [];
  111316. }): number;
  111317. /**
  111318. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  111319. * @hidden
  111320. */
  111321. private _rebuildParticle;
  111322. /**
  111323. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  111324. * @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.
  111325. * @returns the SPS.
  111326. */
  111327. rebuildMesh(reset?: boolean): SolidParticleSystem;
  111328. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  111329. * Returns an array with the removed particles.
  111330. * 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.
  111331. * The SPS can't be empty so at least one particle needs to remain in place.
  111332. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  111333. * @param start index of the first particle to remove
  111334. * @param end index of the last particle to remove (included)
  111335. * @returns an array populated with the removed particles
  111336. */
  111337. removeParticles(start: number, end: number): SolidParticle[];
  111338. /**
  111339. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  111340. * @param solidParticleArray an array populated with Solid Particles objects
  111341. * @returns the SPS
  111342. */
  111343. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  111344. /**
  111345. * Creates a new particle and modifies the SPS mesh geometry :
  111346. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  111347. * - calls _addParticle() to populate the particle array
  111348. * factorized code from addShape() and insertParticlesFromArray()
  111349. * @param idx particle index in the particles array
  111350. * @param i particle index in its shape
  111351. * @param modelShape particle ModelShape object
  111352. * @param shape shape vertex array
  111353. * @param meshInd shape indices array
  111354. * @param meshUV shape uv array
  111355. * @param meshCol shape color array
  111356. * @param meshNor shape normals array
  111357. * @param bbInfo shape bounding info
  111358. * @param storage target particle storage
  111359. * @options addShape() passed options
  111360. * @hidden
  111361. */
  111362. private _insertNewParticle;
  111363. /**
  111364. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  111365. * This method calls `updateParticle()` for each particle of the SPS.
  111366. * For an animated SPS, it is usually called within the render loop.
  111367. * 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.
  111368. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  111369. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  111370. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  111371. * @returns the SPS.
  111372. */
  111373. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  111374. /**
  111375. * Disposes the SPS.
  111376. */
  111377. dispose(): void;
  111378. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  111379. * idx is the particle index in the SPS
  111380. * faceId is the picked face index counted within this particle.
  111381. * Returns null if the pickInfo can't identify a picked particle.
  111382. * @param pickingInfo (PickingInfo object)
  111383. * @returns {idx: number, faceId: number} or null
  111384. */
  111385. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  111386. idx: number;
  111387. faceId: number;
  111388. }>;
  111389. /**
  111390. * Returns a SolidParticle object from its identifier : particle.id
  111391. * @param id (integer) the particle Id
  111392. * @returns the searched particle or null if not found in the SPS.
  111393. */
  111394. getParticleById(id: number): Nullable<SolidParticle>;
  111395. /**
  111396. * Returns a new array populated with the particles having the passed shapeId.
  111397. * @param shapeId (integer) the shape identifier
  111398. * @returns a new solid particle array
  111399. */
  111400. getParticlesByShapeId(shapeId: number): SolidParticle[];
  111401. /**
  111402. * Populates the passed array "ref" with the particles having the passed shapeId.
  111403. * @param shapeId the shape identifier
  111404. * @returns the SPS
  111405. * @param ref
  111406. */
  111407. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  111408. /**
  111409. * Computes the required SubMeshes according the materials assigned to the particles.
  111410. * @returns the solid particle system.
  111411. * Does nothing if called before the SPS mesh is built.
  111412. */
  111413. computeSubMeshes(): SolidParticleSystem;
  111414. /**
  111415. * Sorts the solid particles by material when MultiMaterial is enabled.
  111416. * Updates the indices32 array.
  111417. * Updates the indicesByMaterial array.
  111418. * Updates the mesh indices array.
  111419. * @returns the SPS
  111420. * @hidden
  111421. */
  111422. private _sortParticlesByMaterial;
  111423. /**
  111424. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  111425. * @hidden
  111426. */
  111427. private _setMaterialIndexesById;
  111428. /**
  111429. * Returns an array with unique values of Materials from the passed array
  111430. * @param array the material array to be checked and filtered
  111431. * @hidden
  111432. */
  111433. private _filterUniqueMaterialId;
  111434. /**
  111435. * Sets a new Standard Material as _defaultMaterial if not already set.
  111436. * @hidden
  111437. */
  111438. private _setDefaultMaterial;
  111439. /**
  111440. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  111441. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  111442. * @returns the SPS.
  111443. */
  111444. refreshVisibleSize(): SolidParticleSystem;
  111445. /**
  111446. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  111447. * @param size the size (float) of the visibility box
  111448. * note : this doesn't lock the SPS mesh bounding box.
  111449. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  111450. */
  111451. setVisibilityBox(size: number): void;
  111452. /**
  111453. * Gets whether the SPS as always visible or not
  111454. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  111455. */
  111456. get isAlwaysVisible(): boolean;
  111457. /**
  111458. * Sets the SPS as always visible or not
  111459. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  111460. */
  111461. set isAlwaysVisible(val: boolean);
  111462. /**
  111463. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  111464. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  111465. */
  111466. set isVisibilityBoxLocked(val: boolean);
  111467. /**
  111468. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  111469. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  111470. */
  111471. get isVisibilityBoxLocked(): boolean;
  111472. /**
  111473. * Tells to `setParticles()` to compute the particle rotations or not.
  111474. * Default value : true. The SPS is faster when it's set to false.
  111475. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  111476. */
  111477. set computeParticleRotation(val: boolean);
  111478. /**
  111479. * Tells to `setParticles()` to compute the particle colors or not.
  111480. * Default value : true. The SPS is faster when it's set to false.
  111481. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  111482. */
  111483. set computeParticleColor(val: boolean);
  111484. set computeParticleTexture(val: boolean);
  111485. /**
  111486. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  111487. * Default value : false. The SPS is faster when it's set to false.
  111488. * Note : the particle custom vertex positions aren't stored values.
  111489. */
  111490. set computeParticleVertex(val: boolean);
  111491. /**
  111492. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  111493. */
  111494. set computeBoundingBox(val: boolean);
  111495. /**
  111496. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  111497. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  111498. * Default : `true`
  111499. */
  111500. set depthSortParticles(val: boolean);
  111501. /**
  111502. * Gets if `setParticles()` computes the particle rotations or not.
  111503. * Default value : true. The SPS is faster when it's set to false.
  111504. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  111505. */
  111506. get computeParticleRotation(): boolean;
  111507. /**
  111508. * Gets if `setParticles()` computes the particle colors or not.
  111509. * Default value : true. The SPS is faster when it's set to false.
  111510. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  111511. */
  111512. get computeParticleColor(): boolean;
  111513. /**
  111514. * Gets if `setParticles()` computes the particle textures or not.
  111515. * Default value : true. The SPS is faster when it's set to false.
  111516. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  111517. */
  111518. get computeParticleTexture(): boolean;
  111519. /**
  111520. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  111521. * Default value : false. The SPS is faster when it's set to false.
  111522. * Note : the particle custom vertex positions aren't stored values.
  111523. */
  111524. get computeParticleVertex(): boolean;
  111525. /**
  111526. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  111527. */
  111528. get computeBoundingBox(): boolean;
  111529. /**
  111530. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  111531. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  111532. * Default : `true`
  111533. */
  111534. get depthSortParticles(): boolean;
  111535. /**
  111536. * Gets if the SPS is created as expandable at construction time.
  111537. * Default : `false`
  111538. */
  111539. get expandable(): boolean;
  111540. /**
  111541. * Gets if the SPS supports the Multi Materials
  111542. */
  111543. get multimaterialEnabled(): boolean;
  111544. /**
  111545. * Gets if the SPS uses the model materials for its own multimaterial.
  111546. */
  111547. get useModelMaterial(): boolean;
  111548. /**
  111549. * The SPS used material array.
  111550. */
  111551. get materials(): Material[];
  111552. /**
  111553. * Sets the SPS MultiMaterial from the passed materials.
  111554. * Note : the passed array is internally copied and not used then by reference.
  111555. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  111556. */
  111557. setMultiMaterial(materials: Material[]): void;
  111558. /**
  111559. * The SPS computed multimaterial object
  111560. */
  111561. get multimaterial(): MultiMaterial;
  111562. set multimaterial(mm: MultiMaterial);
  111563. /**
  111564. * If the subMeshes must be updated on the next call to setParticles()
  111565. */
  111566. get autoUpdateSubMeshes(): boolean;
  111567. set autoUpdateSubMeshes(val: boolean);
  111568. /**
  111569. * This function does nothing. It may be overwritten to set all the particle first values.
  111570. * The SPS doesn't call this function, you may have to call it by your own.
  111571. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  111572. */
  111573. initParticles(): void;
  111574. /**
  111575. * This function does nothing. It may be overwritten to recycle a particle.
  111576. * The SPS doesn't call this function, you may have to call it by your own.
  111577. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  111578. * @param particle The particle to recycle
  111579. * @returns the recycled particle
  111580. */
  111581. recycleParticle(particle: SolidParticle): SolidParticle;
  111582. /**
  111583. * Updates a particle : this function should be overwritten by the user.
  111584. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  111585. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  111586. * @example : just set a particle position or velocity and recycle conditions
  111587. * @param particle The particle to update
  111588. * @returns the updated particle
  111589. */
  111590. updateParticle(particle: SolidParticle): SolidParticle;
  111591. /**
  111592. * Updates a vertex of a particle : it can be overwritten by the user.
  111593. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  111594. * @param particle the current particle
  111595. * @param vertex the current vertex of the current particle : a SolidParticleVertex object
  111596. * @param pt the index of the current vertex in the particle shape
  111597. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  111598. * @example : just set a vertex particle position or color
  111599. * @returns the sps
  111600. */
  111601. updateParticleVertex(particle: SolidParticle, vertex: SolidParticleVertex, pt: number): SolidParticleSystem;
  111602. /**
  111603. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  111604. * This does nothing and may be overwritten by the user.
  111605. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  111606. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  111607. * @param update the boolean update value actually passed to setParticles()
  111608. */
  111609. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  111610. /**
  111611. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  111612. * This will be passed three parameters.
  111613. * This does nothing and may be overwritten by the user.
  111614. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  111615. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  111616. * @param update the boolean update value actually passed to setParticles()
  111617. */
  111618. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  111619. }
  111620. }
  111621. declare module BABYLON {
  111622. /**
  111623. * Represents one particle of a solid particle system.
  111624. */
  111625. export class SolidParticle {
  111626. /**
  111627. * particle global index
  111628. */
  111629. idx: number;
  111630. /**
  111631. * particle identifier
  111632. */
  111633. id: number;
  111634. /**
  111635. * The color of the particle
  111636. */
  111637. color: Nullable<Color4>;
  111638. /**
  111639. * The world space position of the particle.
  111640. */
  111641. position: Vector3;
  111642. /**
  111643. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  111644. */
  111645. rotation: Vector3;
  111646. /**
  111647. * The world space rotation quaternion of the particle.
  111648. */
  111649. rotationQuaternion: Nullable<Quaternion>;
  111650. /**
  111651. * The scaling of the particle.
  111652. */
  111653. scaling: Vector3;
  111654. /**
  111655. * The uvs of the particle.
  111656. */
  111657. uvs: Vector4;
  111658. /**
  111659. * The current speed of the particle.
  111660. */
  111661. velocity: Vector3;
  111662. /**
  111663. * The pivot point in the particle local space.
  111664. */
  111665. pivot: Vector3;
  111666. /**
  111667. * Must the particle be translated from its pivot point in its local space ?
  111668. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  111669. * Default : false
  111670. */
  111671. translateFromPivot: boolean;
  111672. /**
  111673. * Is the particle active or not ?
  111674. */
  111675. alive: boolean;
  111676. /**
  111677. * Is the particle visible or not ?
  111678. */
  111679. isVisible: boolean;
  111680. /**
  111681. * Index of this particle in the global "positions" array (Internal use)
  111682. * @hidden
  111683. */
  111684. _pos: number;
  111685. /**
  111686. * @hidden Index of this particle in the global "indices" array (Internal use)
  111687. */
  111688. _ind: number;
  111689. /**
  111690. * @hidden ModelShape of this particle (Internal use)
  111691. */
  111692. _model: ModelShape;
  111693. /**
  111694. * ModelShape id of this particle
  111695. */
  111696. shapeId: number;
  111697. /**
  111698. * Index of the particle in its shape id
  111699. */
  111700. idxInShape: number;
  111701. /**
  111702. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  111703. */
  111704. _modelBoundingInfo: BoundingInfo;
  111705. /**
  111706. * @hidden Particle BoundingInfo object (Internal use)
  111707. */
  111708. _boundingInfo: BoundingInfo;
  111709. /**
  111710. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  111711. */
  111712. _sps: SolidParticleSystem;
  111713. /**
  111714. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  111715. */
  111716. _stillInvisible: boolean;
  111717. /**
  111718. * @hidden Last computed particle rotation matrix
  111719. */
  111720. _rotationMatrix: number[];
  111721. /**
  111722. * Parent particle Id, if any.
  111723. * Default null.
  111724. */
  111725. parentId: Nullable<number>;
  111726. /**
  111727. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  111728. */
  111729. materialIndex: Nullable<number>;
  111730. /**
  111731. * Custom object or properties.
  111732. */
  111733. props: Nullable<any>;
  111734. /**
  111735. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  111736. * The possible values are :
  111737. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  111738. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  111739. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  111740. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  111741. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  111742. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  111743. * */
  111744. cullingStrategy: number;
  111745. /**
  111746. * @hidden Internal global position in the SPS.
  111747. */
  111748. _globalPosition: Vector3;
  111749. /**
  111750. * Creates a Solid Particle object.
  111751. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  111752. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  111753. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  111754. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  111755. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  111756. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  111757. * @param shapeId (integer) is the model shape identifier in the SPS.
  111758. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  111759. * @param sps defines the sps it is associated to
  111760. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  111761. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  111762. */
  111763. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  111764. /**
  111765. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  111766. * @param target the particle target
  111767. * @returns the current particle
  111768. */
  111769. copyToRef(target: SolidParticle): SolidParticle;
  111770. /**
  111771. * Legacy support, changed scale to scaling
  111772. */
  111773. get scale(): Vector3;
  111774. /**
  111775. * Legacy support, changed scale to scaling
  111776. */
  111777. set scale(scale: Vector3);
  111778. /**
  111779. * Legacy support, changed quaternion to rotationQuaternion
  111780. */
  111781. get quaternion(): Nullable<Quaternion>;
  111782. /**
  111783. * Legacy support, changed quaternion to rotationQuaternion
  111784. */
  111785. set quaternion(q: Nullable<Quaternion>);
  111786. /**
  111787. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  111788. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  111789. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  111790. * @returns true if it intersects
  111791. */
  111792. intersectsMesh(target: Mesh | SolidParticle): boolean;
  111793. /**
  111794. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  111795. * A particle is in the frustum if its bounding box intersects the frustum
  111796. * @param frustumPlanes defines the frustum to test
  111797. * @returns true if the particle is in the frustum planes
  111798. */
  111799. isInFrustum(frustumPlanes: Plane[]): boolean;
  111800. /**
  111801. * get the rotation matrix of the particle
  111802. * @hidden
  111803. */
  111804. getRotationMatrix(m: Matrix): void;
  111805. }
  111806. /**
  111807. * Represents the shape of the model used by one particle of a solid particle system.
  111808. * SPS internal tool, don't use it manually.
  111809. */
  111810. export class ModelShape {
  111811. /**
  111812. * The shape id
  111813. * @hidden
  111814. */
  111815. shapeID: number;
  111816. /**
  111817. * flat array of model positions (internal use)
  111818. * @hidden
  111819. */
  111820. _shape: Vector3[];
  111821. /**
  111822. * flat array of model UVs (internal use)
  111823. * @hidden
  111824. */
  111825. _shapeUV: number[];
  111826. /**
  111827. * color array of the model
  111828. * @hidden
  111829. */
  111830. _shapeColors: number[];
  111831. /**
  111832. * indices array of the model
  111833. * @hidden
  111834. */
  111835. _indices: number[];
  111836. /**
  111837. * normals array of the model
  111838. * @hidden
  111839. */
  111840. _normals: number[];
  111841. /**
  111842. * length of the shape in the model indices array (internal use)
  111843. * @hidden
  111844. */
  111845. _indicesLength: number;
  111846. /**
  111847. * Custom position function (internal use)
  111848. * @hidden
  111849. */
  111850. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  111851. /**
  111852. * Custom vertex function (internal use)
  111853. * @hidden
  111854. */
  111855. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  111856. /**
  111857. * Model material (internal use)
  111858. * @hidden
  111859. */
  111860. _material: Nullable<Material>;
  111861. /**
  111862. * 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.
  111863. * SPS internal tool, don't use it manually.
  111864. * @hidden
  111865. */
  111866. 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>);
  111867. }
  111868. /**
  111869. * Represents a Depth Sorted Particle in the solid particle system.
  111870. * @hidden
  111871. */
  111872. export class DepthSortedParticle {
  111873. /**
  111874. * Particle index
  111875. */
  111876. idx: number;
  111877. /**
  111878. * Index of the particle in the "indices" array
  111879. */
  111880. ind: number;
  111881. /**
  111882. * Length of the particle shape in the "indices" array
  111883. */
  111884. indicesLength: number;
  111885. /**
  111886. * Squared distance from the particle to the camera
  111887. */
  111888. sqDistance: number;
  111889. /**
  111890. * Material index when used with MultiMaterials
  111891. */
  111892. materialIndex: number;
  111893. /**
  111894. * Creates a new sorted particle
  111895. * @param materialIndex
  111896. */
  111897. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  111898. }
  111899. /**
  111900. * Represents a solid particle vertex
  111901. */
  111902. export class SolidParticleVertex {
  111903. /**
  111904. * Vertex position
  111905. */
  111906. position: Vector3;
  111907. /**
  111908. * Vertex color
  111909. */
  111910. color: Color4;
  111911. /**
  111912. * Vertex UV
  111913. */
  111914. uv: Vector2;
  111915. /**
  111916. * Creates a new solid particle vertex
  111917. */
  111918. constructor();
  111919. /** Vertex x coordinate */
  111920. get x(): number;
  111921. set x(val: number);
  111922. /** Vertex y coordinate */
  111923. get y(): number;
  111924. set y(val: number);
  111925. /** Vertex z coordinate */
  111926. get z(): number;
  111927. set z(val: number);
  111928. }
  111929. }
  111930. declare module BABYLON {
  111931. /**
  111932. * @hidden
  111933. */
  111934. export class _MeshCollisionData {
  111935. _checkCollisions: boolean;
  111936. _collisionMask: number;
  111937. _collisionGroup: number;
  111938. _surroundingMeshes: Nullable<AbstractMesh[]>;
  111939. _collider: Nullable<Collider>;
  111940. _oldPositionForCollisions: Vector3;
  111941. _diffPositionForCollisions: Vector3;
  111942. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  111943. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  111944. _collisionResponse: boolean;
  111945. }
  111946. }
  111947. declare module BABYLON {
  111948. /** @hidden */
  111949. class _FacetDataStorage {
  111950. facetPositions: Vector3[];
  111951. facetNormals: Vector3[];
  111952. facetPartitioning: number[][];
  111953. facetNb: number;
  111954. partitioningSubdivisions: number;
  111955. partitioningBBoxRatio: number;
  111956. facetDataEnabled: boolean;
  111957. facetParameters: any;
  111958. bbSize: Vector3;
  111959. subDiv: {
  111960. max: number;
  111961. X: number;
  111962. Y: number;
  111963. Z: number;
  111964. };
  111965. facetDepthSort: boolean;
  111966. facetDepthSortEnabled: boolean;
  111967. depthSortedIndices: IndicesArray;
  111968. depthSortedFacets: {
  111969. ind: number;
  111970. sqDistance: number;
  111971. }[];
  111972. facetDepthSortFunction: (f1: {
  111973. ind: number;
  111974. sqDistance: number;
  111975. }, f2: {
  111976. ind: number;
  111977. sqDistance: number;
  111978. }) => number;
  111979. facetDepthSortFrom: Vector3;
  111980. facetDepthSortOrigin: Vector3;
  111981. invertedMatrix: Matrix;
  111982. }
  111983. /**
  111984. * @hidden
  111985. **/
  111986. class _InternalAbstractMeshDataInfo {
  111987. _hasVertexAlpha: boolean;
  111988. _useVertexColors: boolean;
  111989. _numBoneInfluencers: number;
  111990. _applyFog: boolean;
  111991. _receiveShadows: boolean;
  111992. _facetData: _FacetDataStorage;
  111993. _visibility: number;
  111994. _skeleton: Nullable<Skeleton>;
  111995. _layerMask: number;
  111996. _computeBonesUsingShaders: boolean;
  111997. _isActive: boolean;
  111998. _onlyForInstances: boolean;
  111999. _isActiveIntermediate: boolean;
  112000. _onlyForInstancesIntermediate: boolean;
  112001. _actAsRegularMesh: boolean;
  112002. }
  112003. /**
  112004. * Class used to store all common mesh properties
  112005. */
  112006. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  112007. /** No occlusion */
  112008. static OCCLUSION_TYPE_NONE: number;
  112009. /** Occlusion set to optimisitic */
  112010. static OCCLUSION_TYPE_OPTIMISTIC: number;
  112011. /** Occlusion set to strict */
  112012. static OCCLUSION_TYPE_STRICT: number;
  112013. /** Use an accurante occlusion algorithm */
  112014. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  112015. /** Use a conservative occlusion algorithm */
  112016. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  112017. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  112018. * Test order :
  112019. * Is the bounding sphere outside the frustum ?
  112020. * If not, are the bounding box vertices outside the frustum ?
  112021. * It not, then the cullable object is in the frustum.
  112022. */
  112023. static readonly CULLINGSTRATEGY_STANDARD: number;
  112024. /** Culling strategy : Bounding Sphere Only.
  112025. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  112026. * It's also less accurate than the standard because some not visible objects can still be selected.
  112027. * Test : is the bounding sphere outside the frustum ?
  112028. * If not, then the cullable object is in the frustum.
  112029. */
  112030. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  112031. /** Culling strategy : Optimistic Inclusion.
  112032. * This in an inclusion test first, then the standard exclusion test.
  112033. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  112034. * 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.
  112035. * Anyway, it's as accurate as the standard strategy.
  112036. * Test :
  112037. * Is the cullable object bounding sphere center in the frustum ?
  112038. * If not, apply the default culling strategy.
  112039. */
  112040. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  112041. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  112042. * This in an inclusion test first, then the bounding sphere only exclusion test.
  112043. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  112044. * 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.
  112045. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  112046. * Test :
  112047. * Is the cullable object bounding sphere center in the frustum ?
  112048. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  112049. */
  112050. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  112051. /**
  112052. * No billboard
  112053. */
  112054. static get BILLBOARDMODE_NONE(): number;
  112055. /** Billboard on X axis */
  112056. static get BILLBOARDMODE_X(): number;
  112057. /** Billboard on Y axis */
  112058. static get BILLBOARDMODE_Y(): number;
  112059. /** Billboard on Z axis */
  112060. static get BILLBOARDMODE_Z(): number;
  112061. /** Billboard on all axes */
  112062. static get BILLBOARDMODE_ALL(): number;
  112063. /** Billboard on using position instead of orientation */
  112064. static get BILLBOARDMODE_USE_POSITION(): number;
  112065. /** @hidden */
  112066. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  112067. /**
  112068. * The culling strategy to use to check whether the mesh must be rendered or not.
  112069. * This value can be changed at any time and will be used on the next render mesh selection.
  112070. * The possible values are :
  112071. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  112072. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  112073. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  112074. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  112075. * Please read each static variable documentation to get details about the culling process.
  112076. * */
  112077. cullingStrategy: number;
  112078. /**
  112079. * Gets the number of facets in the mesh
  112080. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  112081. */
  112082. get facetNb(): number;
  112083. /**
  112084. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  112085. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  112086. */
  112087. get partitioningSubdivisions(): number;
  112088. set partitioningSubdivisions(nb: number);
  112089. /**
  112090. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  112091. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  112092. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  112093. */
  112094. get partitioningBBoxRatio(): number;
  112095. set partitioningBBoxRatio(ratio: number);
  112096. /**
  112097. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  112098. * Works only for updatable meshes.
  112099. * Doesn't work with multi-materials
  112100. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  112101. */
  112102. get mustDepthSortFacets(): boolean;
  112103. set mustDepthSortFacets(sort: boolean);
  112104. /**
  112105. * The location (Vector3) where the facet depth sort must be computed from.
  112106. * By default, the active camera position.
  112107. * Used only when facet depth sort is enabled
  112108. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  112109. */
  112110. get facetDepthSortFrom(): Vector3;
  112111. set facetDepthSortFrom(location: Vector3);
  112112. /**
  112113. * gets a boolean indicating if facetData is enabled
  112114. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  112115. */
  112116. get isFacetDataEnabled(): boolean;
  112117. /** @hidden */
  112118. _updateNonUniformScalingState(value: boolean): boolean;
  112119. /**
  112120. * An event triggered when this mesh collides with another one
  112121. */
  112122. onCollideObservable: Observable<AbstractMesh>;
  112123. /** Set a function to call when this mesh collides with another one */
  112124. set onCollide(callback: () => void);
  112125. /**
  112126. * An event triggered when the collision's position changes
  112127. */
  112128. onCollisionPositionChangeObservable: Observable<Vector3>;
  112129. /** Set a function to call when the collision's position changes */
  112130. set onCollisionPositionChange(callback: () => void);
  112131. /**
  112132. * An event triggered when material is changed
  112133. */
  112134. onMaterialChangedObservable: Observable<AbstractMesh>;
  112135. /**
  112136. * Gets or sets the orientation for POV movement & rotation
  112137. */
  112138. definedFacingForward: boolean;
  112139. /** @hidden */
  112140. _occlusionQuery: Nullable<WebGLQuery>;
  112141. /** @hidden */
  112142. _renderingGroup: Nullable<RenderingGroup>;
  112143. /**
  112144. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  112145. */
  112146. get visibility(): number;
  112147. /**
  112148. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  112149. */
  112150. set visibility(value: number);
  112151. /** Gets or sets the alpha index used to sort transparent meshes
  112152. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  112153. */
  112154. alphaIndex: number;
  112155. /**
  112156. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  112157. */
  112158. isVisible: boolean;
  112159. /**
  112160. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  112161. */
  112162. isPickable: boolean;
  112163. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  112164. showSubMeshesBoundingBox: boolean;
  112165. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  112166. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  112167. */
  112168. isBlocker: boolean;
  112169. /**
  112170. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  112171. */
  112172. enablePointerMoveEvents: boolean;
  112173. private _renderingGroupId;
  112174. /**
  112175. * Specifies the rendering group id for this mesh (0 by default)
  112176. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  112177. */
  112178. get renderingGroupId(): number;
  112179. set renderingGroupId(value: number);
  112180. private _material;
  112181. /** Gets or sets current material */
  112182. get material(): Nullable<Material>;
  112183. set material(value: Nullable<Material>);
  112184. /**
  112185. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  112186. * @see https://doc.babylonjs.com/babylon101/shadows
  112187. */
  112188. get receiveShadows(): boolean;
  112189. set receiveShadows(value: boolean);
  112190. /** Defines color to use when rendering outline */
  112191. outlineColor: Color3;
  112192. /** Define width to use when rendering outline */
  112193. outlineWidth: number;
  112194. /** Defines color to use when rendering overlay */
  112195. overlayColor: Color3;
  112196. /** Defines alpha to use when rendering overlay */
  112197. overlayAlpha: number;
  112198. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  112199. get hasVertexAlpha(): boolean;
  112200. set hasVertexAlpha(value: boolean);
  112201. /** 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) */
  112202. get useVertexColors(): boolean;
  112203. set useVertexColors(value: boolean);
  112204. /**
  112205. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  112206. */
  112207. get computeBonesUsingShaders(): boolean;
  112208. set computeBonesUsingShaders(value: boolean);
  112209. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  112210. get numBoneInfluencers(): number;
  112211. set numBoneInfluencers(value: number);
  112212. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  112213. get applyFog(): boolean;
  112214. set applyFog(value: boolean);
  112215. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  112216. useOctreeForRenderingSelection: boolean;
  112217. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  112218. useOctreeForPicking: boolean;
  112219. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  112220. useOctreeForCollisions: boolean;
  112221. /**
  112222. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  112223. * @see https://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  112224. */
  112225. get layerMask(): number;
  112226. set layerMask(value: number);
  112227. /**
  112228. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  112229. */
  112230. alwaysSelectAsActiveMesh: boolean;
  112231. /**
  112232. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  112233. */
  112234. doNotSyncBoundingInfo: boolean;
  112235. /**
  112236. * Gets or sets the current action manager
  112237. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  112238. */
  112239. actionManager: Nullable<AbstractActionManager>;
  112240. private _meshCollisionData;
  112241. /**
  112242. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  112243. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  112244. */
  112245. ellipsoid: Vector3;
  112246. /**
  112247. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  112248. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  112249. */
  112250. ellipsoidOffset: Vector3;
  112251. /**
  112252. * Gets or sets a collision mask used to mask collisions (default is -1).
  112253. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  112254. */
  112255. get collisionMask(): number;
  112256. set collisionMask(mask: number);
  112257. /**
  112258. * Gets or sets a collision response flag (default is true).
  112259. * when collisionResponse is false, events are still triggered but colliding entity has no response
  112260. * This helps creating trigger volume when user wants collision feedback events but not position/velocity
  112261. * to respond to the collision.
  112262. */
  112263. get collisionResponse(): boolean;
  112264. set collisionResponse(response: boolean);
  112265. /**
  112266. * Gets or sets the current collision group mask (-1 by default).
  112267. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  112268. */
  112269. get collisionGroup(): number;
  112270. set collisionGroup(mask: number);
  112271. /**
  112272. * Gets or sets current surrounding meshes (null by default).
  112273. *
  112274. * By default collision detection is tested against every mesh in the scene.
  112275. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  112276. * meshes will be tested for the collision.
  112277. *
  112278. * Note: if set to an empty array no collision will happen when this mesh is moved.
  112279. */
  112280. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  112281. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  112282. /**
  112283. * Defines edge width used when edgesRenderer is enabled
  112284. * @see https://www.babylonjs-playground.com/#10OJSG#13
  112285. */
  112286. edgesWidth: number;
  112287. /**
  112288. * Defines edge color used when edgesRenderer is enabled
  112289. * @see https://www.babylonjs-playground.com/#10OJSG#13
  112290. */
  112291. edgesColor: Color4;
  112292. /** @hidden */
  112293. _edgesRenderer: Nullable<IEdgesRenderer>;
  112294. /** @hidden */
  112295. _masterMesh: Nullable<AbstractMesh>;
  112296. /** @hidden */
  112297. _boundingInfo: Nullable<BoundingInfo>;
  112298. /** @hidden */
  112299. _renderId: number;
  112300. /**
  112301. * Gets or sets the list of subMeshes
  112302. * @see https://doc.babylonjs.com/how_to/multi_materials
  112303. */
  112304. subMeshes: SubMesh[];
  112305. /** @hidden */
  112306. _intersectionsInProgress: AbstractMesh[];
  112307. /** @hidden */
  112308. _unIndexed: boolean;
  112309. /** @hidden */
  112310. _lightSources: Light[];
  112311. /** Gets the list of lights affecting that mesh */
  112312. get lightSources(): Light[];
  112313. /** @hidden */
  112314. get _positions(): Nullable<Vector3[]>;
  112315. /** @hidden */
  112316. _waitingData: {
  112317. lods: Nullable<any>;
  112318. actions: Nullable<any>;
  112319. freezeWorldMatrix: Nullable<boolean>;
  112320. };
  112321. /** @hidden */
  112322. _bonesTransformMatrices: Nullable<Float32Array>;
  112323. /** @hidden */
  112324. _transformMatrixTexture: Nullable<RawTexture>;
  112325. /**
  112326. * Gets or sets a skeleton to apply skining transformations
  112327. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  112328. */
  112329. set skeleton(value: Nullable<Skeleton>);
  112330. get skeleton(): Nullable<Skeleton>;
  112331. /**
  112332. * An event triggered when the mesh is rebuilt.
  112333. */
  112334. onRebuildObservable: Observable<AbstractMesh>;
  112335. /**
  112336. * Creates a new AbstractMesh
  112337. * @param name defines the name of the mesh
  112338. * @param scene defines the hosting scene
  112339. */
  112340. constructor(name: string, scene?: Nullable<Scene>);
  112341. /**
  112342. * Returns the string "AbstractMesh"
  112343. * @returns "AbstractMesh"
  112344. */
  112345. getClassName(): string;
  112346. /**
  112347. * Gets a string representation of the current mesh
  112348. * @param fullDetails defines a boolean indicating if full details must be included
  112349. * @returns a string representation of the current mesh
  112350. */
  112351. toString(fullDetails?: boolean): string;
  112352. /**
  112353. * @hidden
  112354. */
  112355. protected _getEffectiveParent(): Nullable<Node>;
  112356. /** @hidden */
  112357. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  112358. /** @hidden */
  112359. _rebuild(): void;
  112360. /** @hidden */
  112361. _resyncLightSources(): void;
  112362. /** @hidden */
  112363. _resyncLightSource(light: Light): void;
  112364. /** @hidden */
  112365. _unBindEffect(): void;
  112366. /** @hidden */
  112367. _removeLightSource(light: Light, dispose: boolean): void;
  112368. private _markSubMeshesAsDirty;
  112369. /** @hidden */
  112370. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  112371. /** @hidden */
  112372. _markSubMeshesAsAttributesDirty(): void;
  112373. /** @hidden */
  112374. _markSubMeshesAsMiscDirty(): void;
  112375. /**
  112376. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  112377. */
  112378. get scaling(): Vector3;
  112379. set scaling(newScaling: Vector3);
  112380. /**
  112381. * Returns true if the mesh is blocked. Implemented by child classes
  112382. */
  112383. get isBlocked(): boolean;
  112384. /**
  112385. * Returns the mesh itself by default. Implemented by child classes
  112386. * @param camera defines the camera to use to pick the right LOD level
  112387. * @returns the currentAbstractMesh
  112388. */
  112389. getLOD(camera: Camera): Nullable<AbstractMesh>;
  112390. /**
  112391. * Returns 0 by default. Implemented by child classes
  112392. * @returns an integer
  112393. */
  112394. getTotalVertices(): number;
  112395. /**
  112396. * Returns a positive integer : the total number of indices in this mesh geometry.
  112397. * @returns the numner of indices or zero if the mesh has no geometry.
  112398. */
  112399. getTotalIndices(): number;
  112400. /**
  112401. * Returns null by default. Implemented by child classes
  112402. * @returns null
  112403. */
  112404. getIndices(): Nullable<IndicesArray>;
  112405. /**
  112406. * Returns the array of the requested vertex data kind. Implemented by child classes
  112407. * @param kind defines the vertex data kind to use
  112408. * @returns null
  112409. */
  112410. getVerticesData(kind: string): Nullable<FloatArray>;
  112411. /**
  112412. * Sets the vertex data of the mesh geometry for the requested `kind`.
  112413. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  112414. * Note that a new underlying VertexBuffer object is created each call.
  112415. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  112416. * @param kind defines vertex data kind:
  112417. * * VertexBuffer.PositionKind
  112418. * * VertexBuffer.UVKind
  112419. * * VertexBuffer.UV2Kind
  112420. * * VertexBuffer.UV3Kind
  112421. * * VertexBuffer.UV4Kind
  112422. * * VertexBuffer.UV5Kind
  112423. * * VertexBuffer.UV6Kind
  112424. * * VertexBuffer.ColorKind
  112425. * * VertexBuffer.MatricesIndicesKind
  112426. * * VertexBuffer.MatricesIndicesExtraKind
  112427. * * VertexBuffer.MatricesWeightsKind
  112428. * * VertexBuffer.MatricesWeightsExtraKind
  112429. * @param data defines the data source
  112430. * @param updatable defines if the data must be flagged as updatable (or static)
  112431. * @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
  112432. * @returns the current mesh
  112433. */
  112434. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  112435. /**
  112436. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  112437. * If the mesh has no geometry, it is simply returned as it is.
  112438. * @param kind defines vertex data kind:
  112439. * * VertexBuffer.PositionKind
  112440. * * VertexBuffer.UVKind
  112441. * * VertexBuffer.UV2Kind
  112442. * * VertexBuffer.UV3Kind
  112443. * * VertexBuffer.UV4Kind
  112444. * * VertexBuffer.UV5Kind
  112445. * * VertexBuffer.UV6Kind
  112446. * * VertexBuffer.ColorKind
  112447. * * VertexBuffer.MatricesIndicesKind
  112448. * * VertexBuffer.MatricesIndicesExtraKind
  112449. * * VertexBuffer.MatricesWeightsKind
  112450. * * VertexBuffer.MatricesWeightsExtraKind
  112451. * @param data defines the data source
  112452. * @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
  112453. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  112454. * @returns the current mesh
  112455. */
  112456. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  112457. /**
  112458. * Sets the mesh indices,
  112459. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  112460. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  112461. * @param totalVertices Defines the total number of vertices
  112462. * @returns the current mesh
  112463. */
  112464. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  112465. /**
  112466. * Gets a boolean indicating if specific vertex data is present
  112467. * @param kind defines the vertex data kind to use
  112468. * @returns true is data kind is present
  112469. */
  112470. isVerticesDataPresent(kind: string): boolean;
  112471. /**
  112472. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  112473. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  112474. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  112475. * @returns a BoundingInfo
  112476. */
  112477. getBoundingInfo(): BoundingInfo;
  112478. /**
  112479. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  112480. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  112481. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  112482. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  112483. * @returns the current mesh
  112484. */
  112485. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  112486. /**
  112487. * Overwrite the current bounding info
  112488. * @param boundingInfo defines the new bounding info
  112489. * @returns the current mesh
  112490. */
  112491. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  112492. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  112493. get useBones(): boolean;
  112494. /** @hidden */
  112495. _preActivate(): void;
  112496. /** @hidden */
  112497. _preActivateForIntermediateRendering(renderId: number): void;
  112498. /** @hidden */
  112499. _activate(renderId: number, intermediateRendering: boolean): boolean;
  112500. /** @hidden */
  112501. _postActivate(): void;
  112502. /** @hidden */
  112503. _freeze(): void;
  112504. /** @hidden */
  112505. _unFreeze(): void;
  112506. /**
  112507. * Gets the current world matrix
  112508. * @returns a Matrix
  112509. */
  112510. getWorldMatrix(): Matrix;
  112511. /** @hidden */
  112512. _getWorldMatrixDeterminant(): number;
  112513. /**
  112514. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  112515. */
  112516. get isAnInstance(): boolean;
  112517. /**
  112518. * Gets a boolean indicating if this mesh has instances
  112519. */
  112520. get hasInstances(): boolean;
  112521. /**
  112522. * Gets a boolean indicating if this mesh has thin instances
  112523. */
  112524. get hasThinInstances(): boolean;
  112525. /**
  112526. * Perform relative position change from the point of view of behind the front of the mesh.
  112527. * This is performed taking into account the meshes current rotation, so you do not have to care.
  112528. * Supports definition of mesh facing forward or backward
  112529. * @param amountRight defines the distance on the right axis
  112530. * @param amountUp defines the distance on the up axis
  112531. * @param amountForward defines the distance on the forward axis
  112532. * @returns the current mesh
  112533. */
  112534. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  112535. /**
  112536. * Calculate relative position change from the point of view of behind the front of the mesh.
  112537. * This is performed taking into account the meshes current rotation, so you do not have to care.
  112538. * Supports definition of mesh facing forward or backward
  112539. * @param amountRight defines the distance on the right axis
  112540. * @param amountUp defines the distance on the up axis
  112541. * @param amountForward defines the distance on the forward axis
  112542. * @returns the new displacement vector
  112543. */
  112544. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  112545. /**
  112546. * Perform relative rotation change from the point of view of behind the front of the mesh.
  112547. * Supports definition of mesh facing forward or backward
  112548. * @param flipBack defines the flip
  112549. * @param twirlClockwise defines the twirl
  112550. * @param tiltRight defines the tilt
  112551. * @returns the current mesh
  112552. */
  112553. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  112554. /**
  112555. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  112556. * Supports definition of mesh facing forward or backward.
  112557. * @param flipBack defines the flip
  112558. * @param twirlClockwise defines the twirl
  112559. * @param tiltRight defines the tilt
  112560. * @returns the new rotation vector
  112561. */
  112562. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  112563. /**
  112564. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  112565. * This means the mesh underlying bounding box and sphere are recomputed.
  112566. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  112567. * @returns the current mesh
  112568. */
  112569. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  112570. /** @hidden */
  112571. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  112572. /** @hidden */
  112573. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  112574. /** @hidden */
  112575. _updateBoundingInfo(): AbstractMesh;
  112576. /** @hidden */
  112577. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  112578. /** @hidden */
  112579. protected _afterComputeWorldMatrix(): void;
  112580. /** @hidden */
  112581. get _effectiveMesh(): AbstractMesh;
  112582. /**
  112583. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  112584. * A mesh is in the frustum if its bounding box intersects the frustum
  112585. * @param frustumPlanes defines the frustum to test
  112586. * @returns true if the mesh is in the frustum planes
  112587. */
  112588. isInFrustum(frustumPlanes: Plane[]): boolean;
  112589. /**
  112590. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  112591. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  112592. * @param frustumPlanes defines the frustum to test
  112593. * @returns true if the mesh is completely in the frustum planes
  112594. */
  112595. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  112596. /**
  112597. * True if the mesh intersects another mesh or a SolidParticle object
  112598. * @param mesh defines a target mesh or SolidParticle to test
  112599. * @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)
  112600. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  112601. * @returns true if there is an intersection
  112602. */
  112603. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  112604. /**
  112605. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  112606. * @param point defines the point to test
  112607. * @returns true if there is an intersection
  112608. */
  112609. intersectsPoint(point: Vector3): boolean;
  112610. /**
  112611. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  112612. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  112613. */
  112614. get checkCollisions(): boolean;
  112615. set checkCollisions(collisionEnabled: boolean);
  112616. /**
  112617. * Gets Collider object used to compute collisions (not physics)
  112618. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  112619. */
  112620. get collider(): Nullable<Collider>;
  112621. /**
  112622. * Move the mesh using collision engine
  112623. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  112624. * @param displacement defines the requested displacement vector
  112625. * @returns the current mesh
  112626. */
  112627. moveWithCollisions(displacement: Vector3): AbstractMesh;
  112628. private _onCollisionPositionChange;
  112629. /** @hidden */
  112630. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  112631. /** @hidden */
  112632. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  112633. /** @hidden */
  112634. _checkCollision(collider: Collider): AbstractMesh;
  112635. /** @hidden */
  112636. _generatePointsArray(): boolean;
  112637. /**
  112638. * Checks if the passed Ray intersects with the mesh
  112639. * @param ray defines the ray to use
  112640. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  112641. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  112642. * @param onlyBoundingInfo defines a boolean indicating if picking should only happen using bounding info (false by default)
  112643. * @param worldToUse defines the world matrix to use to get the world coordinate of the intersection point
  112644. * @returns the picking info
  112645. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  112646. */
  112647. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate, onlyBoundingInfo?: boolean, worldToUse?: Matrix): PickingInfo;
  112648. /**
  112649. * Clones the current mesh
  112650. * @param name defines the mesh name
  112651. * @param newParent defines the new mesh parent
  112652. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  112653. * @returns the new mesh
  112654. */
  112655. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  112656. /**
  112657. * Disposes all the submeshes of the current meshnp
  112658. * @returns the current mesh
  112659. */
  112660. releaseSubMeshes(): AbstractMesh;
  112661. /**
  112662. * Releases resources associated with this abstract mesh.
  112663. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  112664. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  112665. */
  112666. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  112667. /**
  112668. * Adds the passed mesh as a child to the current mesh
  112669. * @param mesh defines the child mesh
  112670. * @returns the current mesh
  112671. */
  112672. addChild(mesh: AbstractMesh): AbstractMesh;
  112673. /**
  112674. * Removes the passed mesh from the current mesh children list
  112675. * @param mesh defines the child mesh
  112676. * @returns the current mesh
  112677. */
  112678. removeChild(mesh: AbstractMesh): AbstractMesh;
  112679. /** @hidden */
  112680. private _initFacetData;
  112681. /**
  112682. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  112683. * This method can be called within the render loop.
  112684. * 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
  112685. * @returns the current mesh
  112686. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  112687. */
  112688. updateFacetData(): AbstractMesh;
  112689. /**
  112690. * Returns the facetLocalNormals array.
  112691. * The normals are expressed in the mesh local spac
  112692. * @returns an array of Vector3
  112693. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  112694. */
  112695. getFacetLocalNormals(): Vector3[];
  112696. /**
  112697. * Returns the facetLocalPositions array.
  112698. * The facet positions are expressed in the mesh local space
  112699. * @returns an array of Vector3
  112700. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  112701. */
  112702. getFacetLocalPositions(): Vector3[];
  112703. /**
  112704. * Returns the facetLocalPartioning array
  112705. * @returns an array of array of numbers
  112706. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  112707. */
  112708. getFacetLocalPartitioning(): number[][];
  112709. /**
  112710. * Returns the i-th facet position in the world system.
  112711. * This method allocates a new Vector3 per call
  112712. * @param i defines the facet index
  112713. * @returns a new Vector3
  112714. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  112715. */
  112716. getFacetPosition(i: number): Vector3;
  112717. /**
  112718. * Sets the reference Vector3 with the i-th facet position in the world system
  112719. * @param i defines the facet index
  112720. * @param ref defines the target vector
  112721. * @returns the current mesh
  112722. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  112723. */
  112724. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  112725. /**
  112726. * Returns the i-th facet normal in the world system.
  112727. * This method allocates a new Vector3 per call
  112728. * @param i defines the facet index
  112729. * @returns a new Vector3
  112730. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  112731. */
  112732. getFacetNormal(i: number): Vector3;
  112733. /**
  112734. * Sets the reference Vector3 with the i-th facet normal in the world system
  112735. * @param i defines the facet index
  112736. * @param ref defines the target vector
  112737. * @returns the current mesh
  112738. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  112739. */
  112740. getFacetNormalToRef(i: number, ref: Vector3): this;
  112741. /**
  112742. * 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)
  112743. * @param x defines x coordinate
  112744. * @param y defines y coordinate
  112745. * @param z defines z coordinate
  112746. * @returns the array of facet indexes
  112747. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  112748. */
  112749. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  112750. /**
  112751. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  112752. * @param projected sets as the (x,y,z) world projection on the facet
  112753. * @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
  112754. * @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
  112755. * @param x defines x coordinate
  112756. * @param y defines y coordinate
  112757. * @param z defines z coordinate
  112758. * @returns the face index if found (or null instead)
  112759. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  112760. */
  112761. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  112762. /**
  112763. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  112764. * @param projected sets as the (x,y,z) local projection on the facet
  112765. * @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
  112766. * @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
  112767. * @param x defines x coordinate
  112768. * @param y defines y coordinate
  112769. * @param z defines z coordinate
  112770. * @returns the face index if found (or null instead)
  112771. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  112772. */
  112773. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  112774. /**
  112775. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  112776. * @returns the parameters
  112777. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  112778. */
  112779. getFacetDataParameters(): any;
  112780. /**
  112781. * Disables the feature FacetData and frees the related memory
  112782. * @returns the current mesh
  112783. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  112784. */
  112785. disableFacetData(): AbstractMesh;
  112786. /**
  112787. * Updates the AbstractMesh indices array
  112788. * @param indices defines the data source
  112789. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  112790. * @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)
  112791. * @returns the current mesh
  112792. */
  112793. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  112794. /**
  112795. * Creates new normals data for the mesh
  112796. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  112797. * @returns the current mesh
  112798. */
  112799. createNormals(updatable: boolean): AbstractMesh;
  112800. /**
  112801. * Align the mesh with a normal
  112802. * @param normal defines the normal to use
  112803. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  112804. * @returns the current mesh
  112805. */
  112806. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  112807. /** @hidden */
  112808. _checkOcclusionQuery(): boolean;
  112809. /**
  112810. * Disables the mesh edge rendering mode
  112811. * @returns the currentAbstractMesh
  112812. */
  112813. disableEdgesRendering(): AbstractMesh;
  112814. /**
  112815. * Enables the edge rendering mode on the mesh.
  112816. * This mode makes the mesh edges visible
  112817. * @param epsilon defines the maximal distance between two angles to detect a face
  112818. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  112819. * @returns the currentAbstractMesh
  112820. * @see https://www.babylonjs-playground.com/#19O9TU#0
  112821. */
  112822. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  112823. /**
  112824. * This function returns all of the particle systems in the scene that use the mesh as an emitter.
  112825. * @returns an array of particle systems in the scene that use the mesh as an emitter
  112826. */
  112827. getConnectedParticleSystems(): IParticleSystem[];
  112828. }
  112829. }
  112830. declare module BABYLON {
  112831. /**
  112832. * Interface used to define ActionEvent
  112833. */
  112834. export interface IActionEvent {
  112835. /** The mesh or sprite that triggered the action */
  112836. source: any;
  112837. /** The X mouse cursor position at the time of the event */
  112838. pointerX: number;
  112839. /** The Y mouse cursor position at the time of the event */
  112840. pointerY: number;
  112841. /** The mesh that is currently pointed at (can be null) */
  112842. meshUnderPointer: Nullable<AbstractMesh>;
  112843. /** the original (browser) event that triggered the ActionEvent */
  112844. sourceEvent?: any;
  112845. /** additional data for the event */
  112846. additionalData?: any;
  112847. }
  112848. /**
  112849. * ActionEvent is the event being sent when an action is triggered.
  112850. */
  112851. export class ActionEvent implements IActionEvent {
  112852. /** The mesh or sprite that triggered the action */
  112853. source: any;
  112854. /** The X mouse cursor position at the time of the event */
  112855. pointerX: number;
  112856. /** The Y mouse cursor position at the time of the event */
  112857. pointerY: number;
  112858. /** The mesh that is currently pointed at (can be null) */
  112859. meshUnderPointer: Nullable<AbstractMesh>;
  112860. /** the original (browser) event that triggered the ActionEvent */
  112861. sourceEvent?: any;
  112862. /** additional data for the event */
  112863. additionalData?: any;
  112864. /**
  112865. * Creates a new ActionEvent
  112866. * @param source The mesh or sprite that triggered the action
  112867. * @param pointerX The X mouse cursor position at the time of the event
  112868. * @param pointerY The Y mouse cursor position at the time of the event
  112869. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  112870. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  112871. * @param additionalData additional data for the event
  112872. */
  112873. constructor(
  112874. /** The mesh or sprite that triggered the action */
  112875. source: any,
  112876. /** The X mouse cursor position at the time of the event */
  112877. pointerX: number,
  112878. /** The Y mouse cursor position at the time of the event */
  112879. pointerY: number,
  112880. /** The mesh that is currently pointed at (can be null) */
  112881. meshUnderPointer: Nullable<AbstractMesh>,
  112882. /** the original (browser) event that triggered the ActionEvent */
  112883. sourceEvent?: any,
  112884. /** additional data for the event */
  112885. additionalData?: any);
  112886. /**
  112887. * Helper function to auto-create an ActionEvent from a source mesh.
  112888. * @param source The source mesh that triggered the event
  112889. * @param evt The original (browser) event
  112890. * @param additionalData additional data for the event
  112891. * @returns the new ActionEvent
  112892. */
  112893. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  112894. /**
  112895. * Helper function to auto-create an ActionEvent from a source sprite
  112896. * @param source The source sprite that triggered the event
  112897. * @param scene Scene associated with the sprite
  112898. * @param evt The original (browser) event
  112899. * @param additionalData additional data for the event
  112900. * @returns the new ActionEvent
  112901. */
  112902. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  112903. /**
  112904. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  112905. * @param scene the scene where the event occurred
  112906. * @param evt The original (browser) event
  112907. * @returns the new ActionEvent
  112908. */
  112909. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  112910. /**
  112911. * Helper function to auto-create an ActionEvent from a primitive
  112912. * @param prim defines the target primitive
  112913. * @param pointerPos defines the pointer position
  112914. * @param evt The original (browser) event
  112915. * @param additionalData additional data for the event
  112916. * @returns the new ActionEvent
  112917. */
  112918. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  112919. }
  112920. }
  112921. declare module BABYLON {
  112922. /**
  112923. * Abstract class used to decouple action Manager from scene and meshes.
  112924. * Do not instantiate.
  112925. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  112926. */
  112927. export abstract class AbstractActionManager implements IDisposable {
  112928. /** Gets the list of active triggers */
  112929. static Triggers: {
  112930. [key: string]: number;
  112931. };
  112932. /** Gets the cursor to use when hovering items */
  112933. hoverCursor: string;
  112934. /** Gets the list of actions */
  112935. actions: IAction[];
  112936. /**
  112937. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  112938. */
  112939. isRecursive: boolean;
  112940. /**
  112941. * Releases all associated resources
  112942. */
  112943. abstract dispose(): void;
  112944. /**
  112945. * Does this action manager has pointer triggers
  112946. */
  112947. abstract get hasPointerTriggers(): boolean;
  112948. /**
  112949. * Does this action manager has pick triggers
  112950. */
  112951. abstract get hasPickTriggers(): boolean;
  112952. /**
  112953. * Process a specific trigger
  112954. * @param trigger defines the trigger to process
  112955. * @param evt defines the event details to be processed
  112956. */
  112957. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  112958. /**
  112959. * Does this action manager handles actions of any of the given triggers
  112960. * @param triggers defines the triggers to be tested
  112961. * @return a boolean indicating whether one (or more) of the triggers is handled
  112962. */
  112963. abstract hasSpecificTriggers(triggers: number[]): boolean;
  112964. /**
  112965. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  112966. * speed.
  112967. * @param triggerA defines the trigger to be tested
  112968. * @param triggerB defines the trigger to be tested
  112969. * @return a boolean indicating whether one (or more) of the triggers is handled
  112970. */
  112971. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  112972. /**
  112973. * Does this action manager handles actions of a given trigger
  112974. * @param trigger defines the trigger to be tested
  112975. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  112976. * @return whether the trigger is handled
  112977. */
  112978. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  112979. /**
  112980. * Serialize this manager to a JSON object
  112981. * @param name defines the property name to store this manager
  112982. * @returns a JSON representation of this manager
  112983. */
  112984. abstract serialize(name: string): any;
  112985. /**
  112986. * Registers an action to this action manager
  112987. * @param action defines the action to be registered
  112988. * @return the action amended (prepared) after registration
  112989. */
  112990. abstract registerAction(action: IAction): Nullable<IAction>;
  112991. /**
  112992. * Unregisters an action to this action manager
  112993. * @param action defines the action to be unregistered
  112994. * @return a boolean indicating whether the action has been unregistered
  112995. */
  112996. abstract unregisterAction(action: IAction): Boolean;
  112997. /**
  112998. * Does exist one action manager with at least one trigger
  112999. **/
  113000. static get HasTriggers(): boolean;
  113001. /**
  113002. * Does exist one action manager with at least one pick trigger
  113003. **/
  113004. static get HasPickTriggers(): boolean;
  113005. /**
  113006. * Does exist one action manager that handles actions of a given trigger
  113007. * @param trigger defines the trigger to be tested
  113008. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  113009. **/
  113010. static HasSpecificTrigger(trigger: number): boolean;
  113011. }
  113012. }
  113013. declare module BABYLON {
  113014. /**
  113015. * Defines how a node can be built from a string name.
  113016. */
  113017. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  113018. /**
  113019. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  113020. */
  113021. export class Node implements IBehaviorAware<Node> {
  113022. /** @hidden */
  113023. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  113024. private static _NodeConstructors;
  113025. /**
  113026. * Add a new node constructor
  113027. * @param type defines the type name of the node to construct
  113028. * @param constructorFunc defines the constructor function
  113029. */
  113030. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  113031. /**
  113032. * Returns a node constructor based on type name
  113033. * @param type defines the type name
  113034. * @param name defines the new node name
  113035. * @param scene defines the hosting scene
  113036. * @param options defines optional options to transmit to constructors
  113037. * @returns the new constructor or null
  113038. */
  113039. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  113040. /**
  113041. * Gets or sets the name of the node
  113042. */
  113043. name: string;
  113044. /**
  113045. * Gets or sets the id of the node
  113046. */
  113047. id: string;
  113048. /**
  113049. * Gets or sets the unique id of the node
  113050. */
  113051. uniqueId: number;
  113052. /**
  113053. * Gets or sets a string used to store user defined state for the node
  113054. */
  113055. state: string;
  113056. /**
  113057. * Gets or sets an object used to store user defined information for the node
  113058. */
  113059. metadata: any;
  113060. /**
  113061. * For internal use only. Please do not use.
  113062. */
  113063. reservedDataStore: any;
  113064. /**
  113065. * List of inspectable custom properties (used by the Inspector)
  113066. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  113067. */
  113068. inspectableCustomProperties: IInspectable[];
  113069. private _doNotSerialize;
  113070. /**
  113071. * Gets or sets a boolean used to define if the node must be serialized
  113072. */
  113073. get doNotSerialize(): boolean;
  113074. set doNotSerialize(value: boolean);
  113075. /** @hidden */
  113076. _isDisposed: boolean;
  113077. /**
  113078. * Gets a list of Animations associated with the node
  113079. */
  113080. animations: Animation[];
  113081. protected _ranges: {
  113082. [name: string]: Nullable<AnimationRange>;
  113083. };
  113084. /**
  113085. * Callback raised when the node is ready to be used
  113086. */
  113087. onReady: Nullable<(node: Node) => void>;
  113088. private _isEnabled;
  113089. private _isParentEnabled;
  113090. private _isReady;
  113091. /** @hidden */
  113092. _currentRenderId: number;
  113093. private _parentUpdateId;
  113094. /** @hidden */
  113095. _childUpdateId: number;
  113096. /** @hidden */
  113097. _waitingParentId: Nullable<string>;
  113098. /** @hidden */
  113099. _scene: Scene;
  113100. /** @hidden */
  113101. _cache: any;
  113102. private _parentNode;
  113103. private _children;
  113104. /** @hidden */
  113105. _worldMatrix: Matrix;
  113106. /** @hidden */
  113107. _worldMatrixDeterminant: number;
  113108. /** @hidden */
  113109. _worldMatrixDeterminantIsDirty: boolean;
  113110. /** @hidden */
  113111. private _sceneRootNodesIndex;
  113112. /**
  113113. * Gets a boolean indicating if the node has been disposed
  113114. * @returns true if the node was disposed
  113115. */
  113116. isDisposed(): boolean;
  113117. /**
  113118. * Gets or sets the parent of the node (without keeping the current position in the scene)
  113119. * @see https://doc.babylonjs.com/how_to/parenting
  113120. */
  113121. set parent(parent: Nullable<Node>);
  113122. get parent(): Nullable<Node>;
  113123. /** @hidden */
  113124. _addToSceneRootNodes(): void;
  113125. /** @hidden */
  113126. _removeFromSceneRootNodes(): void;
  113127. private _animationPropertiesOverride;
  113128. /**
  113129. * Gets or sets the animation properties override
  113130. */
  113131. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  113132. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  113133. /**
  113134. * Gets a string identifying the name of the class
  113135. * @returns "Node" string
  113136. */
  113137. getClassName(): string;
  113138. /** @hidden */
  113139. readonly _isNode: boolean;
  113140. /**
  113141. * An event triggered when the mesh is disposed
  113142. */
  113143. onDisposeObservable: Observable<Node>;
  113144. private _onDisposeObserver;
  113145. /**
  113146. * Sets a callback that will be raised when the node will be disposed
  113147. */
  113148. set onDispose(callback: () => void);
  113149. /**
  113150. * Creates a new Node
  113151. * @param name the name and id to be given to this node
  113152. * @param scene the scene this node will be added to
  113153. */
  113154. constructor(name: string, scene?: Nullable<Scene>);
  113155. /**
  113156. * Gets the scene of the node
  113157. * @returns a scene
  113158. */
  113159. getScene(): Scene;
  113160. /**
  113161. * Gets the engine of the node
  113162. * @returns a Engine
  113163. */
  113164. getEngine(): Engine;
  113165. private _behaviors;
  113166. /**
  113167. * Attach a behavior to the node
  113168. * @see https://doc.babylonjs.com/features/behaviour
  113169. * @param behavior defines the behavior to attach
  113170. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  113171. * @returns the current Node
  113172. */
  113173. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  113174. /**
  113175. * Remove an attached behavior
  113176. * @see https://doc.babylonjs.com/features/behaviour
  113177. * @param behavior defines the behavior to attach
  113178. * @returns the current Node
  113179. */
  113180. removeBehavior(behavior: Behavior<Node>): Node;
  113181. /**
  113182. * Gets the list of attached behaviors
  113183. * @see https://doc.babylonjs.com/features/behaviour
  113184. */
  113185. get behaviors(): Behavior<Node>[];
  113186. /**
  113187. * Gets an attached behavior by name
  113188. * @param name defines the name of the behavior to look for
  113189. * @see https://doc.babylonjs.com/features/behaviour
  113190. * @returns null if behavior was not found else the requested behavior
  113191. */
  113192. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  113193. /**
  113194. * Returns the latest update of the World matrix
  113195. * @returns a Matrix
  113196. */
  113197. getWorldMatrix(): Matrix;
  113198. /** @hidden */
  113199. _getWorldMatrixDeterminant(): number;
  113200. /**
  113201. * Returns directly the latest state of the mesh World matrix.
  113202. * A Matrix is returned.
  113203. */
  113204. get worldMatrixFromCache(): Matrix;
  113205. /** @hidden */
  113206. _initCache(): void;
  113207. /** @hidden */
  113208. updateCache(force?: boolean): void;
  113209. /** @hidden */
  113210. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  113211. /** @hidden */
  113212. _updateCache(ignoreParentClass?: boolean): void;
  113213. /** @hidden */
  113214. _isSynchronized(): boolean;
  113215. /** @hidden */
  113216. _markSyncedWithParent(): void;
  113217. /** @hidden */
  113218. isSynchronizedWithParent(): boolean;
  113219. /** @hidden */
  113220. isSynchronized(): boolean;
  113221. /**
  113222. * Is this node ready to be used/rendered
  113223. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  113224. * @return true if the node is ready
  113225. */
  113226. isReady(completeCheck?: boolean): boolean;
  113227. /**
  113228. * Is this node enabled?
  113229. * 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
  113230. * @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
  113231. * @return whether this node (and its parent) is enabled
  113232. */
  113233. isEnabled(checkAncestors?: boolean): boolean;
  113234. /** @hidden */
  113235. protected _syncParentEnabledState(): void;
  113236. /**
  113237. * Set the enabled state of this node
  113238. * @param value defines the new enabled state
  113239. */
  113240. setEnabled(value: boolean): void;
  113241. /**
  113242. * Is this node a descendant of the given node?
  113243. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  113244. * @param ancestor defines the parent node to inspect
  113245. * @returns a boolean indicating if this node is a descendant of the given node
  113246. */
  113247. isDescendantOf(ancestor: Node): boolean;
  113248. /** @hidden */
  113249. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  113250. /**
  113251. * Will return all nodes that have this node as ascendant
  113252. * @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
  113253. * @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
  113254. * @return all children nodes of all types
  113255. */
  113256. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  113257. /**
  113258. * Get all child-meshes of this node
  113259. * @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)
  113260. * @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
  113261. * @returns an array of AbstractMesh
  113262. */
  113263. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  113264. /**
  113265. * Get all direct children of this node
  113266. * @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
  113267. * @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)
  113268. * @returns an array of Node
  113269. */
  113270. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  113271. /** @hidden */
  113272. _setReady(state: boolean): void;
  113273. /**
  113274. * Get an animation by name
  113275. * @param name defines the name of the animation to look for
  113276. * @returns null if not found else the requested animation
  113277. */
  113278. getAnimationByName(name: string): Nullable<Animation>;
  113279. /**
  113280. * Creates an animation range for this node
  113281. * @param name defines the name of the range
  113282. * @param from defines the starting key
  113283. * @param to defines the end key
  113284. */
  113285. createAnimationRange(name: string, from: number, to: number): void;
  113286. /**
  113287. * Delete a specific animation range
  113288. * @param name defines the name of the range to delete
  113289. * @param deleteFrames defines if animation frames from the range must be deleted as well
  113290. */
  113291. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  113292. /**
  113293. * Get an animation range by name
  113294. * @param name defines the name of the animation range to look for
  113295. * @returns null if not found else the requested animation range
  113296. */
  113297. getAnimationRange(name: string): Nullable<AnimationRange>;
  113298. /**
  113299. * Gets the list of all animation ranges defined on this node
  113300. * @returns an array
  113301. */
  113302. getAnimationRanges(): Nullable<AnimationRange>[];
  113303. /**
  113304. * Will start the animation sequence
  113305. * @param name defines the range frames for animation sequence
  113306. * @param loop defines if the animation should loop (false by default)
  113307. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  113308. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  113309. * @returns the object created for this animation. If range does not exist, it will return null
  113310. */
  113311. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  113312. /**
  113313. * Serialize animation ranges into a JSON compatible object
  113314. * @returns serialization object
  113315. */
  113316. serializeAnimationRanges(): any;
  113317. /**
  113318. * Computes the world matrix of the node
  113319. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  113320. * @returns the world matrix
  113321. */
  113322. computeWorldMatrix(force?: boolean): Matrix;
  113323. /**
  113324. * Releases resources associated with this node.
  113325. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  113326. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  113327. */
  113328. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  113329. /**
  113330. * Parse animation range data from a serialization object and store them into a given node
  113331. * @param node defines where to store the animation ranges
  113332. * @param parsedNode defines the serialization object to read data from
  113333. * @param scene defines the hosting scene
  113334. */
  113335. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  113336. /**
  113337. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  113338. * @param includeDescendants Include bounding info from descendants as well (true by default)
  113339. * @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
  113340. * @returns the new bounding vectors
  113341. */
  113342. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  113343. min: Vector3;
  113344. max: Vector3;
  113345. };
  113346. }
  113347. }
  113348. declare module BABYLON {
  113349. /**
  113350. * @hidden
  113351. */
  113352. export class _IAnimationState {
  113353. key: number;
  113354. repeatCount: number;
  113355. workValue?: any;
  113356. loopMode?: number;
  113357. offsetValue?: any;
  113358. highLimitValue?: any;
  113359. }
  113360. /**
  113361. * Class used to store any kind of animation
  113362. */
  113363. export class Animation {
  113364. /**Name of the animation */
  113365. name: string;
  113366. /**Property to animate */
  113367. targetProperty: string;
  113368. /**The frames per second of the animation */
  113369. framePerSecond: number;
  113370. /**The data type of the animation */
  113371. dataType: number;
  113372. /**The loop mode of the animation */
  113373. loopMode?: number | undefined;
  113374. /**Specifies if blending should be enabled */
  113375. enableBlending?: boolean | undefined;
  113376. /**
  113377. * Use matrix interpolation instead of using direct key value when animating matrices
  113378. */
  113379. static AllowMatricesInterpolation: boolean;
  113380. /**
  113381. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  113382. */
  113383. static AllowMatrixDecomposeForInterpolation: boolean;
  113384. /** Define the Url to load snippets */
  113385. static SnippetUrl: string;
  113386. /** Snippet ID if the animation was created from the snippet server */
  113387. snippetId: string;
  113388. /**
  113389. * Stores the key frames of the animation
  113390. */
  113391. private _keys;
  113392. /**
  113393. * Stores the easing function of the animation
  113394. */
  113395. private _easingFunction;
  113396. /**
  113397. * @hidden Internal use only
  113398. */
  113399. _runtimeAnimations: RuntimeAnimation[];
  113400. /**
  113401. * The set of event that will be linked to this animation
  113402. */
  113403. private _events;
  113404. /**
  113405. * Stores an array of target property paths
  113406. */
  113407. targetPropertyPath: string[];
  113408. /**
  113409. * Stores the blending speed of the animation
  113410. */
  113411. blendingSpeed: number;
  113412. /**
  113413. * Stores the animation ranges for the animation
  113414. */
  113415. private _ranges;
  113416. /**
  113417. * @hidden Internal use
  113418. */
  113419. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  113420. /**
  113421. * Sets up an animation
  113422. * @param property The property to animate
  113423. * @param animationType The animation type to apply
  113424. * @param framePerSecond The frames per second of the animation
  113425. * @param easingFunction The easing function used in the animation
  113426. * @returns The created animation
  113427. */
  113428. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  113429. /**
  113430. * Create and start an animation on a node
  113431. * @param name defines the name of the global animation that will be run on all nodes
  113432. * @param node defines the root node where the animation will take place
  113433. * @param targetProperty defines property to animate
  113434. * @param framePerSecond defines the number of frame per second yo use
  113435. * @param totalFrame defines the number of frames in total
  113436. * @param from defines the initial value
  113437. * @param to defines the final value
  113438. * @param loopMode defines which loop mode you want to use (off by default)
  113439. * @param easingFunction defines the easing function to use (linear by default)
  113440. * @param onAnimationEnd defines the callback to call when animation end
  113441. * @returns the animatable created for this animation
  113442. */
  113443. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  113444. /**
  113445. * Create and start an animation on a node and its descendants
  113446. * @param name defines the name of the global animation that will be run on all nodes
  113447. * @param node defines the root node where the animation will take place
  113448. * @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
  113449. * @param targetProperty defines property to animate
  113450. * @param framePerSecond defines the number of frame per second to use
  113451. * @param totalFrame defines the number of frames in total
  113452. * @param from defines the initial value
  113453. * @param to defines the final value
  113454. * @param loopMode defines which loop mode you want to use (off by default)
  113455. * @param easingFunction defines the easing function to use (linear by default)
  113456. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  113457. * @returns the list of animatables created for all nodes
  113458. * @example https://www.babylonjs-playground.com/#MH0VLI
  113459. */
  113460. 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[]>;
  113461. /**
  113462. * Creates a new animation, merges it with the existing animations and starts it
  113463. * @param name Name of the animation
  113464. * @param node Node which contains the scene that begins the animations
  113465. * @param targetProperty Specifies which property to animate
  113466. * @param framePerSecond The frames per second of the animation
  113467. * @param totalFrame The total number of frames
  113468. * @param from The frame at the beginning of the animation
  113469. * @param to The frame at the end of the animation
  113470. * @param loopMode Specifies the loop mode of the animation
  113471. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  113472. * @param onAnimationEnd Callback to run once the animation is complete
  113473. * @returns Nullable animation
  113474. */
  113475. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  113476. /**
  113477. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  113478. * @param sourceAnimation defines the Animation containing keyframes to convert
  113479. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  113480. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  113481. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  113482. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  113483. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  113484. */
  113485. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  113486. /**
  113487. * Transition property of an host to the target Value
  113488. * @param property The property to transition
  113489. * @param targetValue The target Value of the property
  113490. * @param host The object where the property to animate belongs
  113491. * @param scene Scene used to run the animation
  113492. * @param frameRate Framerate (in frame/s) to use
  113493. * @param transition The transition type we want to use
  113494. * @param duration The duration of the animation, in milliseconds
  113495. * @param onAnimationEnd Callback trigger at the end of the animation
  113496. * @returns Nullable animation
  113497. */
  113498. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  113499. /**
  113500. * Return the array of runtime animations currently using this animation
  113501. */
  113502. get runtimeAnimations(): RuntimeAnimation[];
  113503. /**
  113504. * Specifies if any of the runtime animations are currently running
  113505. */
  113506. get hasRunningRuntimeAnimations(): boolean;
  113507. /**
  113508. * Initializes the animation
  113509. * @param name Name of the animation
  113510. * @param targetProperty Property to animate
  113511. * @param framePerSecond The frames per second of the animation
  113512. * @param dataType The data type of the animation
  113513. * @param loopMode The loop mode of the animation
  113514. * @param enableBlending Specifies if blending should be enabled
  113515. */
  113516. constructor(
  113517. /**Name of the animation */
  113518. name: string,
  113519. /**Property to animate */
  113520. targetProperty: string,
  113521. /**The frames per second of the animation */
  113522. framePerSecond: number,
  113523. /**The data type of the animation */
  113524. dataType: number,
  113525. /**The loop mode of the animation */
  113526. loopMode?: number | undefined,
  113527. /**Specifies if blending should be enabled */
  113528. enableBlending?: boolean | undefined);
  113529. /**
  113530. * Converts the animation to a string
  113531. * @param fullDetails support for multiple levels of logging within scene loading
  113532. * @returns String form of the animation
  113533. */
  113534. toString(fullDetails?: boolean): string;
  113535. /**
  113536. * Add an event to this animation
  113537. * @param event Event to add
  113538. */
  113539. addEvent(event: AnimationEvent): void;
  113540. /**
  113541. * Remove all events found at the given frame
  113542. * @param frame The frame to remove events from
  113543. */
  113544. removeEvents(frame: number): void;
  113545. /**
  113546. * Retrieves all the events from the animation
  113547. * @returns Events from the animation
  113548. */
  113549. getEvents(): AnimationEvent[];
  113550. /**
  113551. * Creates an animation range
  113552. * @param name Name of the animation range
  113553. * @param from Starting frame of the animation range
  113554. * @param to Ending frame of the animation
  113555. */
  113556. createRange(name: string, from: number, to: number): void;
  113557. /**
  113558. * Deletes an animation range by name
  113559. * @param name Name of the animation range to delete
  113560. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  113561. */
  113562. deleteRange(name: string, deleteFrames?: boolean): void;
  113563. /**
  113564. * Gets the animation range by name, or null if not defined
  113565. * @param name Name of the animation range
  113566. * @returns Nullable animation range
  113567. */
  113568. getRange(name: string): Nullable<AnimationRange>;
  113569. /**
  113570. * Gets the key frames from the animation
  113571. * @returns The key frames of the animation
  113572. */
  113573. getKeys(): Array<IAnimationKey>;
  113574. /**
  113575. * Gets the highest frame rate of the animation
  113576. * @returns Highest frame rate of the animation
  113577. */
  113578. getHighestFrame(): number;
  113579. /**
  113580. * Gets the easing function of the animation
  113581. * @returns Easing function of the animation
  113582. */
  113583. getEasingFunction(): IEasingFunction;
  113584. /**
  113585. * Sets the easing function of the animation
  113586. * @param easingFunction A custom mathematical formula for animation
  113587. */
  113588. setEasingFunction(easingFunction: EasingFunction): void;
  113589. /**
  113590. * Interpolates a scalar linearly
  113591. * @param startValue Start value of the animation curve
  113592. * @param endValue End value of the animation curve
  113593. * @param gradient Scalar amount to interpolate
  113594. * @returns Interpolated scalar value
  113595. */
  113596. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  113597. /**
  113598. * Interpolates a scalar cubically
  113599. * @param startValue Start value of the animation curve
  113600. * @param outTangent End tangent of the animation
  113601. * @param endValue End value of the animation curve
  113602. * @param inTangent Start tangent of the animation curve
  113603. * @param gradient Scalar amount to interpolate
  113604. * @returns Interpolated scalar value
  113605. */
  113606. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  113607. /**
  113608. * Interpolates a quaternion using a spherical linear interpolation
  113609. * @param startValue Start value of the animation curve
  113610. * @param endValue End value of the animation curve
  113611. * @param gradient Scalar amount to interpolate
  113612. * @returns Interpolated quaternion value
  113613. */
  113614. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  113615. /**
  113616. * Interpolates a quaternion cubically
  113617. * @param startValue Start value of the animation curve
  113618. * @param outTangent End tangent of the animation curve
  113619. * @param endValue End value of the animation curve
  113620. * @param inTangent Start tangent of the animation curve
  113621. * @param gradient Scalar amount to interpolate
  113622. * @returns Interpolated quaternion value
  113623. */
  113624. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  113625. /**
  113626. * Interpolates a Vector3 linearl
  113627. * @param startValue Start value of the animation curve
  113628. * @param endValue End value of the animation curve
  113629. * @param gradient Scalar amount to interpolate
  113630. * @returns Interpolated scalar value
  113631. */
  113632. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  113633. /**
  113634. * Interpolates a Vector3 cubically
  113635. * @param startValue Start value of the animation curve
  113636. * @param outTangent End tangent of the animation
  113637. * @param endValue End value of the animation curve
  113638. * @param inTangent Start tangent of the animation curve
  113639. * @param gradient Scalar amount to interpolate
  113640. * @returns InterpolatedVector3 value
  113641. */
  113642. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  113643. /**
  113644. * Interpolates a Vector2 linearly
  113645. * @param startValue Start value of the animation curve
  113646. * @param endValue End value of the animation curve
  113647. * @param gradient Scalar amount to interpolate
  113648. * @returns Interpolated Vector2 value
  113649. */
  113650. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  113651. /**
  113652. * Interpolates a Vector2 cubically
  113653. * @param startValue Start value of the animation curve
  113654. * @param outTangent End tangent of the animation
  113655. * @param endValue End value of the animation curve
  113656. * @param inTangent Start tangent of the animation curve
  113657. * @param gradient Scalar amount to interpolate
  113658. * @returns Interpolated Vector2 value
  113659. */
  113660. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  113661. /**
  113662. * Interpolates a size linearly
  113663. * @param startValue Start value of the animation curve
  113664. * @param endValue End value of the animation curve
  113665. * @param gradient Scalar amount to interpolate
  113666. * @returns Interpolated Size value
  113667. */
  113668. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  113669. /**
  113670. * Interpolates a Color3 linearly
  113671. * @param startValue Start value of the animation curve
  113672. * @param endValue End value of the animation curve
  113673. * @param gradient Scalar amount to interpolate
  113674. * @returns Interpolated Color3 value
  113675. */
  113676. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  113677. /**
  113678. * Interpolates a Color4 linearly
  113679. * @param startValue Start value of the animation curve
  113680. * @param endValue End value of the animation curve
  113681. * @param gradient Scalar amount to interpolate
  113682. * @returns Interpolated Color3 value
  113683. */
  113684. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  113685. /**
  113686. * @hidden Internal use only
  113687. */
  113688. _getKeyValue(value: any): any;
  113689. /**
  113690. * @hidden Internal use only
  113691. */
  113692. _interpolate(currentFrame: number, state: _IAnimationState): any;
  113693. /**
  113694. * Defines the function to use to interpolate matrices
  113695. * @param startValue defines the start matrix
  113696. * @param endValue defines the end matrix
  113697. * @param gradient defines the gradient between both matrices
  113698. * @param result defines an optional target matrix where to store the interpolation
  113699. * @returns the interpolated matrix
  113700. */
  113701. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  113702. /**
  113703. * Makes a copy of the animation
  113704. * @returns Cloned animation
  113705. */
  113706. clone(): Animation;
  113707. /**
  113708. * Sets the key frames of the animation
  113709. * @param values The animation key frames to set
  113710. */
  113711. setKeys(values: Array<IAnimationKey>): void;
  113712. /**
  113713. * Serializes the animation to an object
  113714. * @returns Serialized object
  113715. */
  113716. serialize(): any;
  113717. /**
  113718. * Float animation type
  113719. */
  113720. static readonly ANIMATIONTYPE_FLOAT: number;
  113721. /**
  113722. * Vector3 animation type
  113723. */
  113724. static readonly ANIMATIONTYPE_VECTOR3: number;
  113725. /**
  113726. * Quaternion animation type
  113727. */
  113728. static readonly ANIMATIONTYPE_QUATERNION: number;
  113729. /**
  113730. * Matrix animation type
  113731. */
  113732. static readonly ANIMATIONTYPE_MATRIX: number;
  113733. /**
  113734. * Color3 animation type
  113735. */
  113736. static readonly ANIMATIONTYPE_COLOR3: number;
  113737. /**
  113738. * Color3 animation type
  113739. */
  113740. static readonly ANIMATIONTYPE_COLOR4: number;
  113741. /**
  113742. * Vector2 animation type
  113743. */
  113744. static readonly ANIMATIONTYPE_VECTOR2: number;
  113745. /**
  113746. * Size animation type
  113747. */
  113748. static readonly ANIMATIONTYPE_SIZE: number;
  113749. /**
  113750. * Relative Loop Mode
  113751. */
  113752. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  113753. /**
  113754. * Cycle Loop Mode
  113755. */
  113756. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  113757. /**
  113758. * Constant Loop Mode
  113759. */
  113760. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  113761. /** @hidden */
  113762. static _UniversalLerp(left: any, right: any, amount: number): any;
  113763. /**
  113764. * Parses an animation object and creates an animation
  113765. * @param parsedAnimation Parsed animation object
  113766. * @returns Animation object
  113767. */
  113768. static Parse(parsedAnimation: any): Animation;
  113769. /**
  113770. * Appends the serialized animations from the source animations
  113771. * @param source Source containing the animations
  113772. * @param destination Target to store the animations
  113773. */
  113774. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  113775. /**
  113776. * Creates a new animation or an array of animations from a snippet saved in a remote file
  113777. * @param name defines the name of the animation to create (can be null or empty to use the one from the json data)
  113778. * @param url defines the url to load from
  113779. * @returns a promise that will resolve to the new animation or an array of animations
  113780. */
  113781. static ParseFromFileAsync(name: Nullable<string>, url: string): Promise<Animation | Array<Animation>>;
  113782. /**
  113783. * Creates an animation or an array of animations from a snippet saved by the Inspector
  113784. * @param snippetId defines the snippet to load
  113785. * @returns a promise that will resolve to the new animation or a new array of animations
  113786. */
  113787. static CreateFromSnippetAsync(snippetId: string): Promise<Animation | Array<Animation>>;
  113788. }
  113789. }
  113790. declare module BABYLON {
  113791. /**
  113792. * Interface containing an array of animations
  113793. */
  113794. export interface IAnimatable {
  113795. /**
  113796. * Array of animations
  113797. */
  113798. animations: Nullable<Array<Animation>>;
  113799. }
  113800. }
  113801. declare module BABYLON {
  113802. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  113803. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  113804. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  113805. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  113806. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  113807. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  113808. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  113809. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  113810. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  113811. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  113812. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  113813. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  113814. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  113815. /**
  113816. * Decorator used to define property that can be serialized as reference to a camera
  113817. * @param sourceName defines the name of the property to decorate
  113818. */
  113819. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  113820. /**
  113821. * Class used to help serialization objects
  113822. */
  113823. export class SerializationHelper {
  113824. /** @hidden */
  113825. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  113826. /** @hidden */
  113827. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  113828. /** @hidden */
  113829. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  113830. /** @hidden */
  113831. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  113832. /**
  113833. * Appends the serialized animations from the source animations
  113834. * @param source Source containing the animations
  113835. * @param destination Target to store the animations
  113836. */
  113837. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  113838. /**
  113839. * Static function used to serialized a specific entity
  113840. * @param entity defines the entity to serialize
  113841. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  113842. * @returns a JSON compatible object representing the serialization of the entity
  113843. */
  113844. static Serialize<T>(entity: T, serializationObject?: any): any;
  113845. /**
  113846. * Creates a new entity from a serialization data object
  113847. * @param creationFunction defines a function used to instanciated the new entity
  113848. * @param source defines the source serialization data
  113849. * @param scene defines the hosting scene
  113850. * @param rootUrl defines the root url for resources
  113851. * @returns a new entity
  113852. */
  113853. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  113854. /**
  113855. * Clones an object
  113856. * @param creationFunction defines the function used to instanciate the new object
  113857. * @param source defines the source object
  113858. * @returns the cloned object
  113859. */
  113860. static Clone<T>(creationFunction: () => T, source: T): T;
  113861. /**
  113862. * Instanciates a new object based on a source one (some data will be shared between both object)
  113863. * @param creationFunction defines the function used to instanciate the new object
  113864. * @param source defines the source object
  113865. * @returns the new object
  113866. */
  113867. static Instanciate<T>(creationFunction: () => T, source: T): T;
  113868. }
  113869. }
  113870. declare module BABYLON {
  113871. /**
  113872. * Base class of all the textures in babylon.
  113873. * It groups all the common properties the materials, post process, lights... might need
  113874. * in order to make a correct use of the texture.
  113875. */
  113876. export class BaseTexture implements IAnimatable {
  113877. /**
  113878. * Default anisotropic filtering level for the application.
  113879. * It is set to 4 as a good tradeoff between perf and quality.
  113880. */
  113881. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  113882. /**
  113883. * Gets or sets the unique id of the texture
  113884. */
  113885. uniqueId: number;
  113886. /**
  113887. * Define the name of the texture.
  113888. */
  113889. name: string;
  113890. /**
  113891. * Gets or sets an object used to store user defined information.
  113892. */
  113893. metadata: any;
  113894. /**
  113895. * For internal use only. Please do not use.
  113896. */
  113897. reservedDataStore: any;
  113898. private _hasAlpha;
  113899. /**
  113900. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  113901. */
  113902. set hasAlpha(value: boolean);
  113903. get hasAlpha(): boolean;
  113904. /**
  113905. * Defines if the alpha value should be determined via the rgb values.
  113906. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  113907. */
  113908. getAlphaFromRGB: boolean;
  113909. /**
  113910. * Intensity or strength of the texture.
  113911. * It is commonly used by materials to fine tune the intensity of the texture
  113912. */
  113913. level: number;
  113914. /**
  113915. * Define the UV chanel to use starting from 0 and defaulting to 0.
  113916. * This is part of the texture as textures usually maps to one uv set.
  113917. */
  113918. coordinatesIndex: number;
  113919. protected _coordinatesMode: number;
  113920. /**
  113921. * How a texture is mapped.
  113922. *
  113923. * | Value | Type | Description |
  113924. * | ----- | ----------------------------------- | ----------- |
  113925. * | 0 | EXPLICIT_MODE | |
  113926. * | 1 | SPHERICAL_MODE | |
  113927. * | 2 | PLANAR_MODE | |
  113928. * | 3 | CUBIC_MODE | |
  113929. * | 4 | PROJECTION_MODE | |
  113930. * | 5 | SKYBOX_MODE | |
  113931. * | 6 | INVCUBIC_MODE | |
  113932. * | 7 | EQUIRECTANGULAR_MODE | |
  113933. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  113934. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  113935. */
  113936. set coordinatesMode(value: number);
  113937. get coordinatesMode(): number;
  113938. private _wrapU;
  113939. /**
  113940. * | Value | Type | Description |
  113941. * | ----- | ------------------ | ----------- |
  113942. * | 0 | CLAMP_ADDRESSMODE | |
  113943. * | 1 | WRAP_ADDRESSMODE | |
  113944. * | 2 | MIRROR_ADDRESSMODE | |
  113945. */
  113946. get wrapU(): number;
  113947. set wrapU(value: number);
  113948. private _wrapV;
  113949. /**
  113950. * | Value | Type | Description |
  113951. * | ----- | ------------------ | ----------- |
  113952. * | 0 | CLAMP_ADDRESSMODE | |
  113953. * | 1 | WRAP_ADDRESSMODE | |
  113954. * | 2 | MIRROR_ADDRESSMODE | |
  113955. */
  113956. get wrapV(): number;
  113957. set wrapV(value: number);
  113958. /**
  113959. * | Value | Type | Description |
  113960. * | ----- | ------------------ | ----------- |
  113961. * | 0 | CLAMP_ADDRESSMODE | |
  113962. * | 1 | WRAP_ADDRESSMODE | |
  113963. * | 2 | MIRROR_ADDRESSMODE | |
  113964. */
  113965. wrapR: number;
  113966. /**
  113967. * With compliant hardware and browser (supporting anisotropic filtering)
  113968. * this defines the level of anisotropic filtering in the texture.
  113969. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  113970. */
  113971. anisotropicFilteringLevel: number;
  113972. /**
  113973. * Define if the texture is a cube texture or if false a 2d texture.
  113974. */
  113975. get isCube(): boolean;
  113976. set isCube(value: boolean);
  113977. /**
  113978. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  113979. */
  113980. get is3D(): boolean;
  113981. set is3D(value: boolean);
  113982. /**
  113983. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  113984. */
  113985. get is2DArray(): boolean;
  113986. set is2DArray(value: boolean);
  113987. private _gammaSpace;
  113988. /**
  113989. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  113990. * HDR texture are usually stored in linear space.
  113991. * This only impacts the PBR and Background materials
  113992. */
  113993. get gammaSpace(): boolean;
  113994. set gammaSpace(gamma: boolean);
  113995. /**
  113996. * Gets or sets whether or not the texture contains RGBD data.
  113997. */
  113998. get isRGBD(): boolean;
  113999. set isRGBD(value: boolean);
  114000. /**
  114001. * Is Z inverted in the texture (useful in a cube texture).
  114002. */
  114003. invertZ: boolean;
  114004. /**
  114005. * Are mip maps generated for this texture or not.
  114006. */
  114007. get noMipmap(): boolean;
  114008. /**
  114009. * @hidden
  114010. */
  114011. lodLevelInAlpha: boolean;
  114012. /**
  114013. * With prefiltered texture, defined the offset used during the prefiltering steps.
  114014. */
  114015. get lodGenerationOffset(): number;
  114016. set lodGenerationOffset(value: number);
  114017. /**
  114018. * With prefiltered texture, defined the scale used during the prefiltering steps.
  114019. */
  114020. get lodGenerationScale(): number;
  114021. set lodGenerationScale(value: number);
  114022. /**
  114023. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  114024. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  114025. * average roughness values.
  114026. */
  114027. get linearSpecularLOD(): boolean;
  114028. set linearSpecularLOD(value: boolean);
  114029. /**
  114030. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  114031. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  114032. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  114033. */
  114034. get irradianceTexture(): Nullable<BaseTexture>;
  114035. set irradianceTexture(value: Nullable<BaseTexture>);
  114036. /**
  114037. * Define if the texture is a render target.
  114038. */
  114039. isRenderTarget: boolean;
  114040. /**
  114041. * Define the unique id of the texture in the scene.
  114042. */
  114043. get uid(): string;
  114044. /** @hidden */
  114045. _prefiltered: boolean;
  114046. /**
  114047. * Return a string representation of the texture.
  114048. * @returns the texture as a string
  114049. */
  114050. toString(): string;
  114051. /**
  114052. * Get the class name of the texture.
  114053. * @returns "BaseTexture"
  114054. */
  114055. getClassName(): string;
  114056. /**
  114057. * Define the list of animation attached to the texture.
  114058. */
  114059. animations: Animation[];
  114060. /**
  114061. * An event triggered when the texture is disposed.
  114062. */
  114063. onDisposeObservable: Observable<BaseTexture>;
  114064. private _onDisposeObserver;
  114065. /**
  114066. * Callback triggered when the texture has been disposed.
  114067. * Kept for back compatibility, you can use the onDisposeObservable instead.
  114068. */
  114069. set onDispose(callback: () => void);
  114070. /**
  114071. * Define the current state of the loading sequence when in delayed load mode.
  114072. */
  114073. delayLoadState: number;
  114074. protected _scene: Nullable<Scene>;
  114075. protected _engine: Nullable<ThinEngine>;
  114076. /** @hidden */
  114077. _texture: Nullable<InternalTexture>;
  114078. private _uid;
  114079. /**
  114080. * Define if the texture is preventinga material to render or not.
  114081. * If not and the texture is not ready, the engine will use a default black texture instead.
  114082. */
  114083. get isBlocking(): boolean;
  114084. /**
  114085. * Instantiates a new BaseTexture.
  114086. * Base class of all the textures in babylon.
  114087. * It groups all the common properties the materials, post process, lights... might need
  114088. * in order to make a correct use of the texture.
  114089. * @param sceneOrEngine Define the scene or engine the texture blongs to
  114090. */
  114091. constructor(sceneOrEngine: Nullable<Scene | ThinEngine>);
  114092. /**
  114093. * Get the scene the texture belongs to.
  114094. * @returns the scene or null if undefined
  114095. */
  114096. getScene(): Nullable<Scene>;
  114097. /** @hidden */
  114098. protected _getEngine(): Nullable<ThinEngine>;
  114099. /**
  114100. * Get the texture transform matrix used to offset tile the texture for istance.
  114101. * @returns the transformation matrix
  114102. */
  114103. getTextureMatrix(): Matrix;
  114104. /**
  114105. * Get the texture reflection matrix used to rotate/transform the reflection.
  114106. * @returns the reflection matrix
  114107. */
  114108. getReflectionTextureMatrix(): Matrix;
  114109. /**
  114110. * Get the underlying lower level texture from Babylon.
  114111. * @returns the insternal texture
  114112. */
  114113. getInternalTexture(): Nullable<InternalTexture>;
  114114. /**
  114115. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  114116. * @returns true if ready or not blocking
  114117. */
  114118. isReadyOrNotBlocking(): boolean;
  114119. /**
  114120. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  114121. * @returns true if fully ready
  114122. */
  114123. isReady(): boolean;
  114124. private _cachedSize;
  114125. /**
  114126. * Get the size of the texture.
  114127. * @returns the texture size.
  114128. */
  114129. getSize(): ISize;
  114130. /**
  114131. * Get the base size of the texture.
  114132. * It can be different from the size if the texture has been resized for POT for instance
  114133. * @returns the base size
  114134. */
  114135. getBaseSize(): ISize;
  114136. /**
  114137. * Update the sampling mode of the texture.
  114138. * Default is Trilinear mode.
  114139. *
  114140. * | Value | Type | Description |
  114141. * | ----- | ------------------ | ----------- |
  114142. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  114143. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  114144. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  114145. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  114146. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  114147. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  114148. * | 7 | NEAREST_LINEAR | |
  114149. * | 8 | NEAREST_NEAREST | |
  114150. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  114151. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  114152. * | 11 | LINEAR_LINEAR | |
  114153. * | 12 | LINEAR_NEAREST | |
  114154. *
  114155. * > _mag_: magnification filter (close to the viewer)
  114156. * > _min_: minification filter (far from the viewer)
  114157. * > _mip_: filter used between mip map levels
  114158. *@param samplingMode Define the new sampling mode of the texture
  114159. */
  114160. updateSamplingMode(samplingMode: number): void;
  114161. /**
  114162. * Scales the texture if is `canRescale()`
  114163. * @param ratio the resize factor we want to use to rescale
  114164. */
  114165. scale(ratio: number): void;
  114166. /**
  114167. * Get if the texture can rescale.
  114168. */
  114169. get canRescale(): boolean;
  114170. /** @hidden */
  114171. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  114172. /** @hidden */
  114173. _rebuild(): void;
  114174. /**
  114175. * Triggers the load sequence in delayed load mode.
  114176. */
  114177. delayLoad(): void;
  114178. /**
  114179. * Clones the texture.
  114180. * @returns the cloned texture
  114181. */
  114182. clone(): Nullable<BaseTexture>;
  114183. /**
  114184. * Get the texture underlying type (INT, FLOAT...)
  114185. */
  114186. get textureType(): number;
  114187. /**
  114188. * Get the texture underlying format (RGB, RGBA...)
  114189. */
  114190. get textureFormat(): number;
  114191. /**
  114192. * Indicates that textures need to be re-calculated for all materials
  114193. */
  114194. protected _markAllSubMeshesAsTexturesDirty(): void;
  114195. /**
  114196. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  114197. * This will returns an RGBA array buffer containing either in values (0-255) or
  114198. * float values (0-1) depending of the underlying buffer type.
  114199. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  114200. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  114201. * @param buffer defines a user defined buffer to fill with data (can be null)
  114202. * @returns The Array buffer containing the pixels data.
  114203. */
  114204. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  114205. /**
  114206. * Release and destroy the underlying lower level texture aka internalTexture.
  114207. */
  114208. releaseInternalTexture(): void;
  114209. /** @hidden */
  114210. get _lodTextureHigh(): Nullable<BaseTexture>;
  114211. /** @hidden */
  114212. get _lodTextureMid(): Nullable<BaseTexture>;
  114213. /** @hidden */
  114214. get _lodTextureLow(): Nullable<BaseTexture>;
  114215. /**
  114216. * Dispose the texture and release its associated resources.
  114217. */
  114218. dispose(): void;
  114219. /**
  114220. * Serialize the texture into a JSON representation that can be parsed later on.
  114221. * @returns the JSON representation of the texture
  114222. */
  114223. serialize(): any;
  114224. /**
  114225. * Helper function to be called back once a list of texture contains only ready textures.
  114226. * @param textures Define the list of textures to wait for
  114227. * @param callback Define the callback triggered once the entire list will be ready
  114228. */
  114229. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  114230. private static _isScene;
  114231. }
  114232. }
  114233. declare module BABYLON {
  114234. /**
  114235. * Options to be used when creating an effect.
  114236. */
  114237. export interface IEffectCreationOptions {
  114238. /**
  114239. * Atrributes that will be used in the shader.
  114240. */
  114241. attributes: string[];
  114242. /**
  114243. * Uniform varible names that will be set in the shader.
  114244. */
  114245. uniformsNames: string[];
  114246. /**
  114247. * Uniform buffer variable names that will be set in the shader.
  114248. */
  114249. uniformBuffersNames: string[];
  114250. /**
  114251. * Sampler texture variable names that will be set in the shader.
  114252. */
  114253. samplers: string[];
  114254. /**
  114255. * Define statements that will be set in the shader.
  114256. */
  114257. defines: any;
  114258. /**
  114259. * Possible fallbacks for this effect to improve performance when needed.
  114260. */
  114261. fallbacks: Nullable<IEffectFallbacks>;
  114262. /**
  114263. * Callback that will be called when the shader is compiled.
  114264. */
  114265. onCompiled: Nullable<(effect: Effect) => void>;
  114266. /**
  114267. * Callback that will be called if an error occurs during shader compilation.
  114268. */
  114269. onError: Nullable<(effect: Effect, errors: string) => void>;
  114270. /**
  114271. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  114272. */
  114273. indexParameters?: any;
  114274. /**
  114275. * Max number of lights that can be used in the shader.
  114276. */
  114277. maxSimultaneousLights?: number;
  114278. /**
  114279. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  114280. */
  114281. transformFeedbackVaryings?: Nullable<string[]>;
  114282. /**
  114283. * 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
  114284. */
  114285. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  114286. /**
  114287. * Is this effect rendering to several color attachments ?
  114288. */
  114289. multiTarget?: boolean;
  114290. }
  114291. /**
  114292. * Effect containing vertex and fragment shader that can be executed on an object.
  114293. */
  114294. export class Effect implements IDisposable {
  114295. /**
  114296. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  114297. */
  114298. static ShadersRepository: string;
  114299. /**
  114300. * Enable logging of the shader code when a compilation error occurs
  114301. */
  114302. static LogShaderCodeOnCompilationError: boolean;
  114303. /**
  114304. * Name of the effect.
  114305. */
  114306. name: any;
  114307. /**
  114308. * String container all the define statements that should be set on the shader.
  114309. */
  114310. defines: string;
  114311. /**
  114312. * Callback that will be called when the shader is compiled.
  114313. */
  114314. onCompiled: Nullable<(effect: Effect) => void>;
  114315. /**
  114316. * Callback that will be called if an error occurs during shader compilation.
  114317. */
  114318. onError: Nullable<(effect: Effect, errors: string) => void>;
  114319. /**
  114320. * Callback that will be called when effect is bound.
  114321. */
  114322. onBind: Nullable<(effect: Effect) => void>;
  114323. /**
  114324. * Unique ID of the effect.
  114325. */
  114326. uniqueId: number;
  114327. /**
  114328. * Observable that will be called when the shader is compiled.
  114329. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  114330. */
  114331. onCompileObservable: Observable<Effect>;
  114332. /**
  114333. * Observable that will be called if an error occurs during shader compilation.
  114334. */
  114335. onErrorObservable: Observable<Effect>;
  114336. /** @hidden */
  114337. _onBindObservable: Nullable<Observable<Effect>>;
  114338. /**
  114339. * @hidden
  114340. * Specifies if the effect was previously ready
  114341. */
  114342. _wasPreviouslyReady: boolean;
  114343. /**
  114344. * Observable that will be called when effect is bound.
  114345. */
  114346. get onBindObservable(): Observable<Effect>;
  114347. /** @hidden */
  114348. _bonesComputationForcedToCPU: boolean;
  114349. /** @hidden */
  114350. _multiTarget: boolean;
  114351. private static _uniqueIdSeed;
  114352. private _engine;
  114353. private _uniformBuffersNames;
  114354. private _uniformBuffersNamesList;
  114355. private _uniformsNames;
  114356. private _samplerList;
  114357. private _samplers;
  114358. private _isReady;
  114359. private _compilationError;
  114360. private _allFallbacksProcessed;
  114361. private _attributesNames;
  114362. private _attributes;
  114363. private _attributeLocationByName;
  114364. private _uniforms;
  114365. /**
  114366. * Key for the effect.
  114367. * @hidden
  114368. */
  114369. _key: string;
  114370. private _indexParameters;
  114371. private _fallbacks;
  114372. private _vertexSourceCode;
  114373. private _fragmentSourceCode;
  114374. private _vertexSourceCodeOverride;
  114375. private _fragmentSourceCodeOverride;
  114376. private _transformFeedbackVaryings;
  114377. /**
  114378. * Compiled shader to webGL program.
  114379. * @hidden
  114380. */
  114381. _pipelineContext: Nullable<IPipelineContext>;
  114382. private _valueCache;
  114383. private static _baseCache;
  114384. /**
  114385. * Instantiates an effect.
  114386. * An effect can be used to create/manage/execute vertex and fragment shaders.
  114387. * @param baseName Name of the effect.
  114388. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  114389. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  114390. * @param samplers List of sampler variables that will be passed to the shader.
  114391. * @param engine Engine to be used to render the effect
  114392. * @param defines Define statements to be added to the shader.
  114393. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  114394. * @param onCompiled Callback that will be called when the shader is compiled.
  114395. * @param onError Callback that will be called if an error occurs during shader compilation.
  114396. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  114397. */
  114398. 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);
  114399. private _useFinalCode;
  114400. /**
  114401. * Unique key for this effect
  114402. */
  114403. get key(): string;
  114404. /**
  114405. * If the effect has been compiled and prepared.
  114406. * @returns if the effect is compiled and prepared.
  114407. */
  114408. isReady(): boolean;
  114409. private _isReadyInternal;
  114410. /**
  114411. * The engine the effect was initialized with.
  114412. * @returns the engine.
  114413. */
  114414. getEngine(): Engine;
  114415. /**
  114416. * The pipeline context for this effect
  114417. * @returns the associated pipeline context
  114418. */
  114419. getPipelineContext(): Nullable<IPipelineContext>;
  114420. /**
  114421. * The set of names of attribute variables for the shader.
  114422. * @returns An array of attribute names.
  114423. */
  114424. getAttributesNames(): string[];
  114425. /**
  114426. * Returns the attribute at the given index.
  114427. * @param index The index of the attribute.
  114428. * @returns The location of the attribute.
  114429. */
  114430. getAttributeLocation(index: number): number;
  114431. /**
  114432. * Returns the attribute based on the name of the variable.
  114433. * @param name of the attribute to look up.
  114434. * @returns the attribute location.
  114435. */
  114436. getAttributeLocationByName(name: string): number;
  114437. /**
  114438. * The number of attributes.
  114439. * @returns the numnber of attributes.
  114440. */
  114441. getAttributesCount(): number;
  114442. /**
  114443. * Gets the index of a uniform variable.
  114444. * @param uniformName of the uniform to look up.
  114445. * @returns the index.
  114446. */
  114447. getUniformIndex(uniformName: string): number;
  114448. /**
  114449. * Returns the attribute based on the name of the variable.
  114450. * @param uniformName of the uniform to look up.
  114451. * @returns the location of the uniform.
  114452. */
  114453. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  114454. /**
  114455. * Returns an array of sampler variable names
  114456. * @returns The array of sampler variable names.
  114457. */
  114458. getSamplers(): string[];
  114459. /**
  114460. * Returns an array of uniform variable names
  114461. * @returns The array of uniform variable names.
  114462. */
  114463. getUniformNames(): string[];
  114464. /**
  114465. * Returns an array of uniform buffer variable names
  114466. * @returns The array of uniform buffer variable names.
  114467. */
  114468. getUniformBuffersNames(): string[];
  114469. /**
  114470. * Returns the index parameters used to create the effect
  114471. * @returns The index parameters object
  114472. */
  114473. getIndexParameters(): any;
  114474. /**
  114475. * The error from the last compilation.
  114476. * @returns the error string.
  114477. */
  114478. getCompilationError(): string;
  114479. /**
  114480. * Gets a boolean indicating that all fallbacks were used during compilation
  114481. * @returns true if all fallbacks were used
  114482. */
  114483. allFallbacksProcessed(): boolean;
  114484. /**
  114485. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  114486. * @param func The callback to be used.
  114487. */
  114488. executeWhenCompiled(func: (effect: Effect) => void): void;
  114489. private _checkIsReady;
  114490. private _loadShader;
  114491. /**
  114492. * Gets the vertex shader source code of this effect
  114493. */
  114494. get vertexSourceCode(): string;
  114495. /**
  114496. * Gets the fragment shader source code of this effect
  114497. */
  114498. get fragmentSourceCode(): string;
  114499. /**
  114500. * Recompiles the webGL program
  114501. * @param vertexSourceCode The source code for the vertex shader.
  114502. * @param fragmentSourceCode The source code for the fragment shader.
  114503. * @param onCompiled Callback called when completed.
  114504. * @param onError Callback called on error.
  114505. * @hidden
  114506. */
  114507. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  114508. /**
  114509. * Prepares the effect
  114510. * @hidden
  114511. */
  114512. _prepareEffect(): void;
  114513. private _getShaderCodeAndErrorLine;
  114514. private _processCompilationErrors;
  114515. /**
  114516. * Checks if the effect is supported. (Must be called after compilation)
  114517. */
  114518. get isSupported(): boolean;
  114519. /**
  114520. * Binds a texture to the engine to be used as output of the shader.
  114521. * @param channel Name of the output variable.
  114522. * @param texture Texture to bind.
  114523. * @hidden
  114524. */
  114525. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  114526. /**
  114527. * Sets a texture on the engine to be used in the shader.
  114528. * @param channel Name of the sampler variable.
  114529. * @param texture Texture to set.
  114530. */
  114531. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  114532. /**
  114533. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  114534. * @param channel Name of the sampler variable.
  114535. * @param texture Texture to set.
  114536. */
  114537. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  114538. /**
  114539. * Sets an array of textures on the engine to be used in the shader.
  114540. * @param channel Name of the variable.
  114541. * @param textures Textures to set.
  114542. */
  114543. setTextureArray(channel: string, textures: BaseTexture[]): void;
  114544. /**
  114545. * 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)
  114546. * @param channel Name of the sampler variable.
  114547. * @param postProcess Post process to get the input texture from.
  114548. */
  114549. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  114550. /**
  114551. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  114552. * 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)
  114553. * @param channel Name of the sampler variable.
  114554. * @param postProcess Post process to get the output texture from.
  114555. */
  114556. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  114557. /** @hidden */
  114558. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  114559. /** @hidden */
  114560. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  114561. /** @hidden */
  114562. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  114563. /** @hidden */
  114564. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  114565. /**
  114566. * Binds a buffer to a uniform.
  114567. * @param buffer Buffer to bind.
  114568. * @param name Name of the uniform variable to bind to.
  114569. */
  114570. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  114571. /**
  114572. * Binds block to a uniform.
  114573. * @param blockName Name of the block to bind.
  114574. * @param index Index to bind.
  114575. */
  114576. bindUniformBlock(blockName: string, index: number): void;
  114577. /**
  114578. * Sets an interger value on a uniform variable.
  114579. * @param uniformName Name of the variable.
  114580. * @param value Value to be set.
  114581. * @returns this effect.
  114582. */
  114583. setInt(uniformName: string, value: number): Effect;
  114584. /**
  114585. * Sets an int array on a uniform variable.
  114586. * @param uniformName Name of the variable.
  114587. * @param array array to be set.
  114588. * @returns this effect.
  114589. */
  114590. setIntArray(uniformName: string, array: Int32Array): Effect;
  114591. /**
  114592. * 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)
  114593. * @param uniformName Name of the variable.
  114594. * @param array array to be set.
  114595. * @returns this effect.
  114596. */
  114597. setIntArray2(uniformName: string, array: Int32Array): Effect;
  114598. /**
  114599. * 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)
  114600. * @param uniformName Name of the variable.
  114601. * @param array array to be set.
  114602. * @returns this effect.
  114603. */
  114604. setIntArray3(uniformName: string, array: Int32Array): Effect;
  114605. /**
  114606. * 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)
  114607. * @param uniformName Name of the variable.
  114608. * @param array array to be set.
  114609. * @returns this effect.
  114610. */
  114611. setIntArray4(uniformName: string, array: Int32Array): Effect;
  114612. /**
  114613. * Sets an float array on a uniform variable.
  114614. * @param uniformName Name of the variable.
  114615. * @param array array to be set.
  114616. * @returns this effect.
  114617. */
  114618. setFloatArray(uniformName: string, array: Float32Array): Effect;
  114619. /**
  114620. * 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)
  114621. * @param uniformName Name of the variable.
  114622. * @param array array to be set.
  114623. * @returns this effect.
  114624. */
  114625. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  114626. /**
  114627. * 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)
  114628. * @param uniformName Name of the variable.
  114629. * @param array array to be set.
  114630. * @returns this effect.
  114631. */
  114632. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  114633. /**
  114634. * 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)
  114635. * @param uniformName Name of the variable.
  114636. * @param array array to be set.
  114637. * @returns this effect.
  114638. */
  114639. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  114640. /**
  114641. * Sets an array on a uniform variable.
  114642. * @param uniformName Name of the variable.
  114643. * @param array array to be set.
  114644. * @returns this effect.
  114645. */
  114646. setArray(uniformName: string, array: number[]): Effect;
  114647. /**
  114648. * 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)
  114649. * @param uniformName Name of the variable.
  114650. * @param array array to be set.
  114651. * @returns this effect.
  114652. */
  114653. setArray2(uniformName: string, array: number[]): Effect;
  114654. /**
  114655. * 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)
  114656. * @param uniformName Name of the variable.
  114657. * @param array array to be set.
  114658. * @returns this effect.
  114659. */
  114660. setArray3(uniformName: string, array: number[]): Effect;
  114661. /**
  114662. * 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)
  114663. * @param uniformName Name of the variable.
  114664. * @param array array to be set.
  114665. * @returns this effect.
  114666. */
  114667. setArray4(uniformName: string, array: number[]): Effect;
  114668. /**
  114669. * Sets matrices on a uniform variable.
  114670. * @param uniformName Name of the variable.
  114671. * @param matrices matrices to be set.
  114672. * @returns this effect.
  114673. */
  114674. setMatrices(uniformName: string, matrices: Float32Array | Array<number>): Effect;
  114675. /**
  114676. * Sets matrix on a uniform variable.
  114677. * @param uniformName Name of the variable.
  114678. * @param matrix matrix to be set.
  114679. * @returns this effect.
  114680. */
  114681. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  114682. /**
  114683. * 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)
  114684. * @param uniformName Name of the variable.
  114685. * @param matrix matrix to be set.
  114686. * @returns this effect.
  114687. */
  114688. setMatrix3x3(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  114689. /**
  114690. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  114691. * @param uniformName Name of the variable.
  114692. * @param matrix matrix to be set.
  114693. * @returns this effect.
  114694. */
  114695. setMatrix2x2(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  114696. /**
  114697. * Sets a float on a uniform variable.
  114698. * @param uniformName Name of the variable.
  114699. * @param value value to be set.
  114700. * @returns this effect.
  114701. */
  114702. setFloat(uniformName: string, value: number): Effect;
  114703. /**
  114704. * Sets a boolean on a uniform variable.
  114705. * @param uniformName Name of the variable.
  114706. * @param bool value to be set.
  114707. * @returns this effect.
  114708. */
  114709. setBool(uniformName: string, bool: boolean): Effect;
  114710. /**
  114711. * Sets a Vector2 on a uniform variable.
  114712. * @param uniformName Name of the variable.
  114713. * @param vector2 vector2 to be set.
  114714. * @returns this effect.
  114715. */
  114716. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  114717. /**
  114718. * Sets a float2 on a uniform variable.
  114719. * @param uniformName Name of the variable.
  114720. * @param x First float in float2.
  114721. * @param y Second float in float2.
  114722. * @returns this effect.
  114723. */
  114724. setFloat2(uniformName: string, x: number, y: number): Effect;
  114725. /**
  114726. * Sets a Vector3 on a uniform variable.
  114727. * @param uniformName Name of the variable.
  114728. * @param vector3 Value to be set.
  114729. * @returns this effect.
  114730. */
  114731. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  114732. /**
  114733. * Sets a float3 on a uniform variable.
  114734. * @param uniformName Name of the variable.
  114735. * @param x First float in float3.
  114736. * @param y Second float in float3.
  114737. * @param z Third float in float3.
  114738. * @returns this effect.
  114739. */
  114740. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  114741. /**
  114742. * Sets a Vector4 on a uniform variable.
  114743. * @param uniformName Name of the variable.
  114744. * @param vector4 Value to be set.
  114745. * @returns this effect.
  114746. */
  114747. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  114748. /**
  114749. * Sets a float4 on a uniform variable.
  114750. * @param uniformName Name of the variable.
  114751. * @param x First float in float4.
  114752. * @param y Second float in float4.
  114753. * @param z Third float in float4.
  114754. * @param w Fourth float in float4.
  114755. * @returns this effect.
  114756. */
  114757. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  114758. /**
  114759. * Sets a Color3 on a uniform variable.
  114760. * @param uniformName Name of the variable.
  114761. * @param color3 Value to be set.
  114762. * @returns this effect.
  114763. */
  114764. setColor3(uniformName: string, color3: IColor3Like): Effect;
  114765. /**
  114766. * Sets a Color4 on a uniform variable.
  114767. * @param uniformName Name of the variable.
  114768. * @param color3 Value to be set.
  114769. * @param alpha Alpha value to be set.
  114770. * @returns this effect.
  114771. */
  114772. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  114773. /**
  114774. * Sets a Color4 on a uniform variable
  114775. * @param uniformName defines the name of the variable
  114776. * @param color4 defines the value to be set
  114777. * @returns this effect.
  114778. */
  114779. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  114780. /** Release all associated resources */
  114781. dispose(): void;
  114782. /**
  114783. * This function will add a new shader to the shader store
  114784. * @param name the name of the shader
  114785. * @param pixelShader optional pixel shader content
  114786. * @param vertexShader optional vertex shader content
  114787. */
  114788. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  114789. /**
  114790. * Store of each shader (The can be looked up using effect.key)
  114791. */
  114792. static ShadersStore: {
  114793. [key: string]: string;
  114794. };
  114795. /**
  114796. * Store of each included file for a shader (The can be looked up using effect.key)
  114797. */
  114798. static IncludesShadersStore: {
  114799. [key: string]: string;
  114800. };
  114801. /**
  114802. * Resets the cache of effects.
  114803. */
  114804. static ResetCache(): void;
  114805. }
  114806. }
  114807. declare module BABYLON {
  114808. /**
  114809. * Interface used to describe the capabilities of the engine relatively to the current browser
  114810. */
  114811. export interface EngineCapabilities {
  114812. /** Maximum textures units per fragment shader */
  114813. maxTexturesImageUnits: number;
  114814. /** Maximum texture units per vertex shader */
  114815. maxVertexTextureImageUnits: number;
  114816. /** Maximum textures units in the entire pipeline */
  114817. maxCombinedTexturesImageUnits: number;
  114818. /** Maximum texture size */
  114819. maxTextureSize: number;
  114820. /** Maximum texture samples */
  114821. maxSamples?: number;
  114822. /** Maximum cube texture size */
  114823. maxCubemapTextureSize: number;
  114824. /** Maximum render texture size */
  114825. maxRenderTextureSize: number;
  114826. /** Maximum number of vertex attributes */
  114827. maxVertexAttribs: number;
  114828. /** Maximum number of varyings */
  114829. maxVaryingVectors: number;
  114830. /** Maximum number of uniforms per vertex shader */
  114831. maxVertexUniformVectors: number;
  114832. /** Maximum number of uniforms per fragment shader */
  114833. maxFragmentUniformVectors: number;
  114834. /** Defines if standard derivates (dx/dy) are supported */
  114835. standardDerivatives: boolean;
  114836. /** Defines if s3tc texture compression is supported */
  114837. s3tc?: WEBGL_compressed_texture_s3tc;
  114838. /** Defines if pvrtc texture compression is supported */
  114839. pvrtc: any;
  114840. /** Defines if etc1 texture compression is supported */
  114841. etc1: any;
  114842. /** Defines if etc2 texture compression is supported */
  114843. etc2: any;
  114844. /** Defines if astc texture compression is supported */
  114845. astc: any;
  114846. /** Defines if bptc texture compression is supported */
  114847. bptc: any;
  114848. /** Defines if float textures are supported */
  114849. textureFloat: boolean;
  114850. /** Defines if vertex array objects are supported */
  114851. vertexArrayObject: boolean;
  114852. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  114853. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  114854. /** Gets the maximum level of anisotropy supported */
  114855. maxAnisotropy: number;
  114856. /** Defines if instancing is supported */
  114857. instancedArrays: boolean;
  114858. /** Defines if 32 bits indices are supported */
  114859. uintIndices: boolean;
  114860. /** Defines if high precision shaders are supported */
  114861. highPrecisionShaderSupported: boolean;
  114862. /** Defines if depth reading in the fragment shader is supported */
  114863. fragmentDepthSupported: boolean;
  114864. /** Defines if float texture linear filtering is supported*/
  114865. textureFloatLinearFiltering: boolean;
  114866. /** Defines if rendering to float textures is supported */
  114867. textureFloatRender: boolean;
  114868. /** Defines if half float textures are supported*/
  114869. textureHalfFloat: boolean;
  114870. /** Defines if half float texture linear filtering is supported*/
  114871. textureHalfFloatLinearFiltering: boolean;
  114872. /** Defines if rendering to half float textures is supported */
  114873. textureHalfFloatRender: boolean;
  114874. /** Defines if textureLOD shader command is supported */
  114875. textureLOD: boolean;
  114876. /** Defines if draw buffers extension is supported */
  114877. drawBuffersExtension: boolean;
  114878. /** Defines if depth textures are supported */
  114879. depthTextureExtension: boolean;
  114880. /** Defines if float color buffer are supported */
  114881. colorBufferFloat: boolean;
  114882. /** Gets disjoint timer query extension (null if not supported) */
  114883. timerQuery?: EXT_disjoint_timer_query;
  114884. /** Defines if timestamp can be used with timer query */
  114885. canUseTimestampForTimerQuery: boolean;
  114886. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  114887. multiview?: any;
  114888. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  114889. oculusMultiview?: any;
  114890. /** Function used to let the system compiles shaders in background */
  114891. parallelShaderCompile?: {
  114892. COMPLETION_STATUS_KHR: number;
  114893. };
  114894. /** Max number of texture samples for MSAA */
  114895. maxMSAASamples: number;
  114896. /** Defines if the blend min max extension is supported */
  114897. blendMinMax: boolean;
  114898. }
  114899. }
  114900. declare module BABYLON {
  114901. /**
  114902. * @hidden
  114903. **/
  114904. export class DepthCullingState {
  114905. private _isDepthTestDirty;
  114906. private _isDepthMaskDirty;
  114907. private _isDepthFuncDirty;
  114908. private _isCullFaceDirty;
  114909. private _isCullDirty;
  114910. private _isZOffsetDirty;
  114911. private _isFrontFaceDirty;
  114912. private _depthTest;
  114913. private _depthMask;
  114914. private _depthFunc;
  114915. private _cull;
  114916. private _cullFace;
  114917. private _zOffset;
  114918. private _frontFace;
  114919. /**
  114920. * Initializes the state.
  114921. */
  114922. constructor();
  114923. get isDirty(): boolean;
  114924. get zOffset(): number;
  114925. set zOffset(value: number);
  114926. get cullFace(): Nullable<number>;
  114927. set cullFace(value: Nullable<number>);
  114928. get cull(): Nullable<boolean>;
  114929. set cull(value: Nullable<boolean>);
  114930. get depthFunc(): Nullable<number>;
  114931. set depthFunc(value: Nullable<number>);
  114932. get depthMask(): boolean;
  114933. set depthMask(value: boolean);
  114934. get depthTest(): boolean;
  114935. set depthTest(value: boolean);
  114936. get frontFace(): Nullable<number>;
  114937. set frontFace(value: Nullable<number>);
  114938. reset(): void;
  114939. apply(gl: WebGLRenderingContext): void;
  114940. }
  114941. }
  114942. declare module BABYLON {
  114943. /**
  114944. * @hidden
  114945. **/
  114946. export class StencilState {
  114947. /** 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 */
  114948. static readonly ALWAYS: number;
  114949. /** Passed to stencilOperation to specify that stencil value must be kept */
  114950. static readonly KEEP: number;
  114951. /** Passed to stencilOperation to specify that stencil value must be replaced */
  114952. static readonly REPLACE: number;
  114953. private _isStencilTestDirty;
  114954. private _isStencilMaskDirty;
  114955. private _isStencilFuncDirty;
  114956. private _isStencilOpDirty;
  114957. private _stencilTest;
  114958. private _stencilMask;
  114959. private _stencilFunc;
  114960. private _stencilFuncRef;
  114961. private _stencilFuncMask;
  114962. private _stencilOpStencilFail;
  114963. private _stencilOpDepthFail;
  114964. private _stencilOpStencilDepthPass;
  114965. get isDirty(): boolean;
  114966. get stencilFunc(): number;
  114967. set stencilFunc(value: number);
  114968. get stencilFuncRef(): number;
  114969. set stencilFuncRef(value: number);
  114970. get stencilFuncMask(): number;
  114971. set stencilFuncMask(value: number);
  114972. get stencilOpStencilFail(): number;
  114973. set stencilOpStencilFail(value: number);
  114974. get stencilOpDepthFail(): number;
  114975. set stencilOpDepthFail(value: number);
  114976. get stencilOpStencilDepthPass(): number;
  114977. set stencilOpStencilDepthPass(value: number);
  114978. get stencilMask(): number;
  114979. set stencilMask(value: number);
  114980. get stencilTest(): boolean;
  114981. set stencilTest(value: boolean);
  114982. constructor();
  114983. reset(): void;
  114984. apply(gl: WebGLRenderingContext): void;
  114985. }
  114986. }
  114987. declare module BABYLON {
  114988. /**
  114989. * @hidden
  114990. **/
  114991. export class AlphaState {
  114992. private _isAlphaBlendDirty;
  114993. private _isBlendFunctionParametersDirty;
  114994. private _isBlendEquationParametersDirty;
  114995. private _isBlendConstantsDirty;
  114996. private _alphaBlend;
  114997. private _blendFunctionParameters;
  114998. private _blendEquationParameters;
  114999. private _blendConstants;
  115000. /**
  115001. * Initializes the state.
  115002. */
  115003. constructor();
  115004. get isDirty(): boolean;
  115005. get alphaBlend(): boolean;
  115006. set alphaBlend(value: boolean);
  115007. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  115008. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  115009. setAlphaEquationParameters(rgb: number, alpha: number): void;
  115010. reset(): void;
  115011. apply(gl: WebGLRenderingContext): void;
  115012. }
  115013. }
  115014. declare module BABYLON {
  115015. /** @hidden */
  115016. export class WebGL2ShaderProcessor implements IShaderProcessor {
  115017. attributeProcessor(attribute: string): string;
  115018. varyingProcessor(varying: string, isFragment: boolean): string;
  115019. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  115020. }
  115021. }
  115022. declare module BABYLON {
  115023. /**
  115024. * Interface for attribute information associated with buffer instanciation
  115025. */
  115026. export interface InstancingAttributeInfo {
  115027. /**
  115028. * Name of the GLSL attribute
  115029. * if attribute index is not specified, this is used to retrieve the index from the effect
  115030. */
  115031. attributeName: string;
  115032. /**
  115033. * Index/offset of the attribute in the vertex shader
  115034. * if not specified, this will be computes from the name.
  115035. */
  115036. index?: number;
  115037. /**
  115038. * size of the attribute, 1, 2, 3 or 4
  115039. */
  115040. attributeSize: number;
  115041. /**
  115042. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  115043. */
  115044. offset: number;
  115045. /**
  115046. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  115047. * default to 1
  115048. */
  115049. divisor?: number;
  115050. /**
  115051. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  115052. * default is FLOAT
  115053. */
  115054. attributeType?: number;
  115055. /**
  115056. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  115057. */
  115058. normalized?: boolean;
  115059. }
  115060. }
  115061. declare module BABYLON {
  115062. interface ThinEngine {
  115063. /**
  115064. * Update a video texture
  115065. * @param texture defines the texture to update
  115066. * @param video defines the video element to use
  115067. * @param invertY defines if data must be stored with Y axis inverted
  115068. */
  115069. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  115070. }
  115071. }
  115072. declare module BABYLON {
  115073. interface ThinEngine {
  115074. /**
  115075. * Creates a dynamic texture
  115076. * @param width defines the width of the texture
  115077. * @param height defines the height of the texture
  115078. * @param generateMipMaps defines if the engine should generate the mip levels
  115079. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  115080. * @returns the dynamic texture inside an InternalTexture
  115081. */
  115082. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  115083. /**
  115084. * Update the content of a dynamic texture
  115085. * @param texture defines the texture to update
  115086. * @param canvas defines the canvas containing the source
  115087. * @param invertY defines if data must be stored with Y axis inverted
  115088. * @param premulAlpha defines if alpha is stored as premultiplied
  115089. * @param format defines the format of the data
  115090. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  115091. */
  115092. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  115093. }
  115094. }
  115095. declare module BABYLON {
  115096. /**
  115097. * Settings for finer control over video usage
  115098. */
  115099. export interface VideoTextureSettings {
  115100. /**
  115101. * Applies `autoplay` to video, if specified
  115102. */
  115103. autoPlay?: boolean;
  115104. /**
  115105. * Applies `loop` to video, if specified
  115106. */
  115107. loop?: boolean;
  115108. /**
  115109. * Automatically updates internal texture from video at every frame in the render loop
  115110. */
  115111. autoUpdateTexture: boolean;
  115112. /**
  115113. * Image src displayed during the video loading or until the user interacts with the video.
  115114. */
  115115. poster?: string;
  115116. }
  115117. /**
  115118. * If you want to display a video in your scene, this is the special texture for that.
  115119. * This special texture works similar to other textures, with the exception of a few parameters.
  115120. * @see https://doc.babylonjs.com/how_to/video_texture
  115121. */
  115122. export class VideoTexture extends Texture {
  115123. /**
  115124. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  115125. */
  115126. readonly autoUpdateTexture: boolean;
  115127. /**
  115128. * The video instance used by the texture internally
  115129. */
  115130. readonly video: HTMLVideoElement;
  115131. private _onUserActionRequestedObservable;
  115132. /**
  115133. * Event triggerd when a dom action is required by the user to play the video.
  115134. * This happens due to recent changes in browser policies preventing video to auto start.
  115135. */
  115136. get onUserActionRequestedObservable(): Observable<Texture>;
  115137. private _generateMipMaps;
  115138. private _stillImageCaptured;
  115139. private _displayingPosterTexture;
  115140. private _settings;
  115141. private _createInternalTextureOnEvent;
  115142. private _frameId;
  115143. private _currentSrc;
  115144. /**
  115145. * Creates a video texture.
  115146. * If you want to display a video in your scene, this is the special texture for that.
  115147. * This special texture works similar to other textures, with the exception of a few parameters.
  115148. * @see https://doc.babylonjs.com/how_to/video_texture
  115149. * @param name optional name, will detect from video source, if not defined
  115150. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  115151. * @param scene is obviously the current scene.
  115152. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  115153. * @param invertY is false by default but can be used to invert video on Y axis
  115154. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  115155. * @param settings allows finer control over video usage
  115156. */
  115157. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  115158. private _getName;
  115159. private _getVideo;
  115160. private _createInternalTexture;
  115161. private reset;
  115162. /**
  115163. * @hidden Internal method to initiate `update`.
  115164. */
  115165. _rebuild(): void;
  115166. /**
  115167. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  115168. */
  115169. update(): void;
  115170. /**
  115171. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  115172. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  115173. */
  115174. updateTexture(isVisible: boolean): void;
  115175. protected _updateInternalTexture: () => void;
  115176. /**
  115177. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  115178. * @param url New url.
  115179. */
  115180. updateURL(url: string): void;
  115181. /**
  115182. * Clones the texture.
  115183. * @returns the cloned texture
  115184. */
  115185. clone(): VideoTexture;
  115186. /**
  115187. * Dispose the texture and release its associated resources.
  115188. */
  115189. dispose(): void;
  115190. /**
  115191. * Creates a video texture straight from a stream.
  115192. * @param scene Define the scene the texture should be created in
  115193. * @param stream Define the stream the texture should be created from
  115194. * @returns The created video texture as a promise
  115195. */
  115196. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  115197. /**
  115198. * Creates a video texture straight from your WebCam video feed.
  115199. * @param scene Define the scene the texture should be created in
  115200. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  115201. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  115202. * @returns The created video texture as a promise
  115203. */
  115204. static CreateFromWebCamAsync(scene: Scene, constraints: {
  115205. minWidth: number;
  115206. maxWidth: number;
  115207. minHeight: number;
  115208. maxHeight: number;
  115209. deviceId: string;
  115210. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  115211. /**
  115212. * Creates a video texture straight from your WebCam video feed.
  115213. * @param scene Define the scene the texture should be created in
  115214. * @param onReady Define a callback to triggered once the texture will be ready
  115215. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  115216. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  115217. */
  115218. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  115219. minWidth: number;
  115220. maxWidth: number;
  115221. minHeight: number;
  115222. maxHeight: number;
  115223. deviceId: string;
  115224. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  115225. }
  115226. }
  115227. declare module BABYLON {
  115228. /**
  115229. * Defines the interface used by objects working like Scene
  115230. * @hidden
  115231. */
  115232. export interface ISceneLike {
  115233. _addPendingData(data: any): void;
  115234. _removePendingData(data: any): void;
  115235. offlineProvider: IOfflineProvider;
  115236. }
  115237. /**
  115238. * Information about the current host
  115239. */
  115240. export interface HostInformation {
  115241. /**
  115242. * Defines if the current host is a mobile
  115243. */
  115244. isMobile: boolean;
  115245. }
  115246. /** Interface defining initialization parameters for Engine class */
  115247. export interface EngineOptions extends WebGLContextAttributes {
  115248. /**
  115249. * Defines if the engine should no exceed a specified device ratio
  115250. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  115251. */
  115252. limitDeviceRatio?: number;
  115253. /**
  115254. * Defines if webvr should be enabled automatically
  115255. * @see https://doc.babylonjs.com/how_to/webvr_camera
  115256. */
  115257. autoEnableWebVR?: boolean;
  115258. /**
  115259. * Defines if webgl2 should be turned off even if supported
  115260. * @see https://doc.babylonjs.com/features/webgl2
  115261. */
  115262. disableWebGL2Support?: boolean;
  115263. /**
  115264. * Defines if webaudio should be initialized as well
  115265. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  115266. */
  115267. audioEngine?: boolean;
  115268. /**
  115269. * Defines if animations should run using a deterministic lock step
  115270. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  115271. */
  115272. deterministicLockstep?: boolean;
  115273. /** Defines the maximum steps to use with deterministic lock step mode */
  115274. lockstepMaxSteps?: number;
  115275. /** Defines the seconds between each deterministic lock step */
  115276. timeStep?: number;
  115277. /**
  115278. * Defines that engine should ignore context lost events
  115279. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  115280. */
  115281. doNotHandleContextLost?: boolean;
  115282. /**
  115283. * Defines that engine should ignore modifying touch action attribute and style
  115284. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  115285. */
  115286. doNotHandleTouchAction?: boolean;
  115287. /**
  115288. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  115289. */
  115290. useHighPrecisionFloats?: boolean;
  115291. /**
  115292. * Make the canvas XR Compatible for XR sessions
  115293. */
  115294. xrCompatible?: boolean;
  115295. /**
  115296. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  115297. */
  115298. useHighPrecisionMatrix?: boolean;
  115299. }
  115300. /**
  115301. * The base engine class (root of all engines)
  115302. */
  115303. export class ThinEngine {
  115304. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  115305. static ExceptionList: ({
  115306. key: string;
  115307. capture: string;
  115308. captureConstraint: number;
  115309. targets: string[];
  115310. } | {
  115311. key: string;
  115312. capture: null;
  115313. captureConstraint: null;
  115314. targets: string[];
  115315. })[];
  115316. /** @hidden */
  115317. static _TextureLoaders: IInternalTextureLoader[];
  115318. /**
  115319. * Returns the current npm package of the sdk
  115320. */
  115321. static get NpmPackage(): string;
  115322. /**
  115323. * Returns the current version of the framework
  115324. */
  115325. static get Version(): string;
  115326. /**
  115327. * Returns a string describing the current engine
  115328. */
  115329. get description(): string;
  115330. /**
  115331. * Gets or sets the epsilon value used by collision engine
  115332. */
  115333. static CollisionsEpsilon: number;
  115334. /**
  115335. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  115336. */
  115337. static get ShadersRepository(): string;
  115338. static set ShadersRepository(value: string);
  115339. /** @hidden */
  115340. _shaderProcessor: IShaderProcessor;
  115341. /**
  115342. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  115343. */
  115344. forcePOTTextures: boolean;
  115345. /**
  115346. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  115347. */
  115348. isFullscreen: boolean;
  115349. /**
  115350. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  115351. */
  115352. cullBackFaces: boolean;
  115353. /**
  115354. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  115355. */
  115356. renderEvenInBackground: boolean;
  115357. /**
  115358. * Gets or sets a boolean indicating that cache can be kept between frames
  115359. */
  115360. preventCacheWipeBetweenFrames: boolean;
  115361. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  115362. validateShaderPrograms: boolean;
  115363. /**
  115364. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  115365. * This can provide greater z depth for distant objects.
  115366. */
  115367. useReverseDepthBuffer: boolean;
  115368. /**
  115369. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  115370. */
  115371. disableUniformBuffers: boolean;
  115372. /** @hidden */
  115373. _uniformBuffers: UniformBuffer[];
  115374. /**
  115375. * Gets a boolean indicating that the engine supports uniform buffers
  115376. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  115377. */
  115378. get supportsUniformBuffers(): boolean;
  115379. /** @hidden */
  115380. _gl: WebGLRenderingContext;
  115381. /** @hidden */
  115382. _webGLVersion: number;
  115383. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  115384. protected _windowIsBackground: boolean;
  115385. protected _creationOptions: EngineOptions;
  115386. protected _highPrecisionShadersAllowed: boolean;
  115387. /** @hidden */
  115388. get _shouldUseHighPrecisionShader(): boolean;
  115389. /**
  115390. * Gets a boolean indicating that only power of 2 textures are supported
  115391. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  115392. */
  115393. get needPOTTextures(): boolean;
  115394. /** @hidden */
  115395. _badOS: boolean;
  115396. /** @hidden */
  115397. _badDesktopOS: boolean;
  115398. private _hardwareScalingLevel;
  115399. /** @hidden */
  115400. _caps: EngineCapabilities;
  115401. private _isStencilEnable;
  115402. private _glVersion;
  115403. private _glRenderer;
  115404. private _glVendor;
  115405. /** @hidden */
  115406. _videoTextureSupported: boolean;
  115407. protected _renderingQueueLaunched: boolean;
  115408. protected _activeRenderLoops: (() => void)[];
  115409. /**
  115410. * Observable signaled when a context lost event is raised
  115411. */
  115412. onContextLostObservable: Observable<ThinEngine>;
  115413. /**
  115414. * Observable signaled when a context restored event is raised
  115415. */
  115416. onContextRestoredObservable: Observable<ThinEngine>;
  115417. private _onContextLost;
  115418. private _onContextRestored;
  115419. protected _contextWasLost: boolean;
  115420. /** @hidden */
  115421. _doNotHandleContextLost: boolean;
  115422. /**
  115423. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  115424. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  115425. */
  115426. get doNotHandleContextLost(): boolean;
  115427. set doNotHandleContextLost(value: boolean);
  115428. /**
  115429. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  115430. */
  115431. disableVertexArrayObjects: boolean;
  115432. /** @hidden */
  115433. protected _colorWrite: boolean;
  115434. /** @hidden */
  115435. protected _colorWriteChanged: boolean;
  115436. /** @hidden */
  115437. protected _depthCullingState: DepthCullingState;
  115438. /** @hidden */
  115439. protected _stencilState: StencilState;
  115440. /** @hidden */
  115441. _alphaState: AlphaState;
  115442. /** @hidden */
  115443. _alphaMode: number;
  115444. /** @hidden */
  115445. _alphaEquation: number;
  115446. /** @hidden */
  115447. _internalTexturesCache: InternalTexture[];
  115448. /** @hidden */
  115449. protected _activeChannel: number;
  115450. private _currentTextureChannel;
  115451. /** @hidden */
  115452. protected _boundTexturesCache: {
  115453. [key: string]: Nullable<InternalTexture>;
  115454. };
  115455. /** @hidden */
  115456. protected _currentEffect: Nullable<Effect>;
  115457. /** @hidden */
  115458. protected _currentProgram: Nullable<WebGLProgram>;
  115459. private _compiledEffects;
  115460. private _vertexAttribArraysEnabled;
  115461. /** @hidden */
  115462. protected _cachedViewport: Nullable<IViewportLike>;
  115463. private _cachedVertexArrayObject;
  115464. /** @hidden */
  115465. protected _cachedVertexBuffers: any;
  115466. /** @hidden */
  115467. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  115468. /** @hidden */
  115469. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  115470. /** @hidden */
  115471. _currentRenderTarget: Nullable<InternalTexture>;
  115472. private _uintIndicesCurrentlySet;
  115473. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  115474. /** @hidden */
  115475. _currentFramebuffer: Nullable<WebGLFramebuffer>;
  115476. /** @hidden */
  115477. _dummyFramebuffer: Nullable<WebGLFramebuffer>;
  115478. private _currentBufferPointers;
  115479. private _currentInstanceLocations;
  115480. private _currentInstanceBuffers;
  115481. private _textureUnits;
  115482. /** @hidden */
  115483. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  115484. /** @hidden */
  115485. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  115486. /** @hidden */
  115487. _boundRenderFunction: any;
  115488. private _vaoRecordInProgress;
  115489. private _mustWipeVertexAttributes;
  115490. private _emptyTexture;
  115491. private _emptyCubeTexture;
  115492. private _emptyTexture3D;
  115493. private _emptyTexture2DArray;
  115494. /** @hidden */
  115495. _frameHandler: number;
  115496. private _nextFreeTextureSlots;
  115497. private _maxSimultaneousTextures;
  115498. private _activeRequests;
  115499. /** @hidden */
  115500. _transformTextureUrl: Nullable<(url: string) => string>;
  115501. /**
  115502. * Gets information about the current host
  115503. */
  115504. hostInformation: HostInformation;
  115505. protected get _supportsHardwareTextureRescaling(): boolean;
  115506. private _framebufferDimensionsObject;
  115507. /**
  115508. * sets the object from which width and height will be taken from when getting render width and height
  115509. * Will fallback to the gl object
  115510. * @param dimensions the framebuffer width and height that will be used.
  115511. */
  115512. set framebufferDimensionsObject(dimensions: Nullable<{
  115513. framebufferWidth: number;
  115514. framebufferHeight: number;
  115515. }>);
  115516. /**
  115517. * Gets the current viewport
  115518. */
  115519. get currentViewport(): Nullable<IViewportLike>;
  115520. /**
  115521. * Gets the default empty texture
  115522. */
  115523. get emptyTexture(): InternalTexture;
  115524. /**
  115525. * Gets the default empty 3D texture
  115526. */
  115527. get emptyTexture3D(): InternalTexture;
  115528. /**
  115529. * Gets the default empty 2D array texture
  115530. */
  115531. get emptyTexture2DArray(): InternalTexture;
  115532. /**
  115533. * Gets the default empty cube texture
  115534. */
  115535. get emptyCubeTexture(): InternalTexture;
  115536. /**
  115537. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  115538. */
  115539. readonly premultipliedAlpha: boolean;
  115540. /**
  115541. * Observable event triggered before each texture is initialized
  115542. */
  115543. onBeforeTextureInitObservable: Observable<Texture>;
  115544. /**
  115545. * Creates a new engine
  115546. * @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
  115547. * @param antialias defines enable antialiasing (default: false)
  115548. * @param options defines further options to be sent to the getContext() function
  115549. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  115550. */
  115551. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  115552. private _rebuildInternalTextures;
  115553. private _rebuildEffects;
  115554. /**
  115555. * Gets a boolean indicating if all created effects are ready
  115556. * @returns true if all effects are ready
  115557. */
  115558. areAllEffectsReady(): boolean;
  115559. protected _rebuildBuffers(): void;
  115560. protected _initGLContext(): void;
  115561. /**
  115562. * Gets version of the current webGL context
  115563. */
  115564. get webGLVersion(): number;
  115565. /**
  115566. * Gets a string identifying the name of the class
  115567. * @returns "Engine" string
  115568. */
  115569. getClassName(): string;
  115570. /**
  115571. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  115572. */
  115573. get isStencilEnable(): boolean;
  115574. /** @hidden */
  115575. _prepareWorkingCanvas(): void;
  115576. /**
  115577. * Reset the texture cache to empty state
  115578. */
  115579. resetTextureCache(): void;
  115580. /**
  115581. * Gets an object containing information about the current webGL context
  115582. * @returns an object containing the vender, the renderer and the version of the current webGL context
  115583. */
  115584. getGlInfo(): {
  115585. vendor: string;
  115586. renderer: string;
  115587. version: string;
  115588. };
  115589. /**
  115590. * Defines the hardware scaling level.
  115591. * By default the hardware scaling level is computed from the window device ratio.
  115592. * 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.
  115593. * @param level defines the level to use
  115594. */
  115595. setHardwareScalingLevel(level: number): void;
  115596. /**
  115597. * Gets the current hardware scaling level.
  115598. * By default the hardware scaling level is computed from the window device ratio.
  115599. * 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.
  115600. * @returns a number indicating the current hardware scaling level
  115601. */
  115602. getHardwareScalingLevel(): number;
  115603. /**
  115604. * Gets the list of loaded textures
  115605. * @returns an array containing all loaded textures
  115606. */
  115607. getLoadedTexturesCache(): InternalTexture[];
  115608. /**
  115609. * Gets the object containing all engine capabilities
  115610. * @returns the EngineCapabilities object
  115611. */
  115612. getCaps(): EngineCapabilities;
  115613. /**
  115614. * stop executing a render loop function and remove it from the execution array
  115615. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  115616. */
  115617. stopRenderLoop(renderFunction?: () => void): void;
  115618. /** @hidden */
  115619. _renderLoop(): void;
  115620. /**
  115621. * Gets the HTML canvas attached with the current webGL context
  115622. * @returns a HTML canvas
  115623. */
  115624. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  115625. /**
  115626. * Gets host window
  115627. * @returns the host window object
  115628. */
  115629. getHostWindow(): Nullable<Window>;
  115630. /**
  115631. * Gets the current render width
  115632. * @param useScreen defines if screen size must be used (or the current render target if any)
  115633. * @returns a number defining the current render width
  115634. */
  115635. getRenderWidth(useScreen?: boolean): number;
  115636. /**
  115637. * Gets the current render height
  115638. * @param useScreen defines if screen size must be used (or the current render target if any)
  115639. * @returns a number defining the current render height
  115640. */
  115641. getRenderHeight(useScreen?: boolean): number;
  115642. /**
  115643. * Can be used to override the current requestAnimationFrame requester.
  115644. * @hidden
  115645. */
  115646. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  115647. /**
  115648. * Register and execute a render loop. The engine can have more than one render function
  115649. * @param renderFunction defines the function to continuously execute
  115650. */
  115651. runRenderLoop(renderFunction: () => void): void;
  115652. /**
  115653. * Clear the current render buffer or the current render target (if any is set up)
  115654. * @param color defines the color to use
  115655. * @param backBuffer defines if the back buffer must be cleared
  115656. * @param depth defines if the depth buffer must be cleared
  115657. * @param stencil defines if the stencil buffer must be cleared
  115658. */
  115659. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  115660. private _viewportCached;
  115661. /** @hidden */
  115662. _viewport(x: number, y: number, width: number, height: number): void;
  115663. /**
  115664. * Set the WebGL's viewport
  115665. * @param viewport defines the viewport element to be used
  115666. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  115667. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  115668. */
  115669. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  115670. /**
  115671. * Begin a new frame
  115672. */
  115673. beginFrame(): void;
  115674. /**
  115675. * Enf the current frame
  115676. */
  115677. endFrame(): void;
  115678. /**
  115679. * Resize the view according to the canvas' size
  115680. */
  115681. resize(): void;
  115682. /**
  115683. * Force a specific size of the canvas
  115684. * @param width defines the new canvas' width
  115685. * @param height defines the new canvas' height
  115686. * @returns true if the size was changed
  115687. */
  115688. setSize(width: number, height: number): boolean;
  115689. /**
  115690. * Binds the frame buffer to the specified texture.
  115691. * @param texture The texture to render to or null for the default canvas
  115692. * @param faceIndex The face of the texture to render to in case of cube texture
  115693. * @param requiredWidth The width of the target to render to
  115694. * @param requiredHeight The height of the target to render to
  115695. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  115696. * @param lodLevel defines the lod level to bind to the frame buffer
  115697. * @param layer defines the 2d array index to bind to frame buffer to
  115698. */
  115699. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  115700. /** @hidden */
  115701. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  115702. /**
  115703. * Unbind the current render target texture from the webGL context
  115704. * @param texture defines the render target texture to unbind
  115705. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  115706. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  115707. */
  115708. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  115709. /**
  115710. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  115711. */
  115712. flushFramebuffer(): void;
  115713. /**
  115714. * Unbind the current render target and bind the default framebuffer
  115715. */
  115716. restoreDefaultFramebuffer(): void;
  115717. /** @hidden */
  115718. protected _resetVertexBufferBinding(): void;
  115719. /**
  115720. * Creates a vertex buffer
  115721. * @param data the data for the vertex buffer
  115722. * @returns the new WebGL static buffer
  115723. */
  115724. createVertexBuffer(data: DataArray): DataBuffer;
  115725. private _createVertexBuffer;
  115726. /**
  115727. * Creates a dynamic vertex buffer
  115728. * @param data the data for the dynamic vertex buffer
  115729. * @returns the new WebGL dynamic buffer
  115730. */
  115731. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  115732. protected _resetIndexBufferBinding(): void;
  115733. /**
  115734. * Creates a new index buffer
  115735. * @param indices defines the content of the index buffer
  115736. * @param updatable defines if the index buffer must be updatable
  115737. * @returns a new webGL buffer
  115738. */
  115739. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  115740. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  115741. /**
  115742. * Bind a webGL buffer to the webGL context
  115743. * @param buffer defines the buffer to bind
  115744. */
  115745. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  115746. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  115747. private bindBuffer;
  115748. /**
  115749. * update the bound buffer with the given data
  115750. * @param data defines the data to update
  115751. */
  115752. updateArrayBuffer(data: Float32Array): void;
  115753. private _vertexAttribPointer;
  115754. /** @hidden */
  115755. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  115756. private _bindVertexBuffersAttributes;
  115757. /**
  115758. * Records a vertex array object
  115759. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  115760. * @param vertexBuffers defines the list of vertex buffers to store
  115761. * @param indexBuffer defines the index buffer to store
  115762. * @param effect defines the effect to store
  115763. * @returns the new vertex array object
  115764. */
  115765. recordVertexArrayObject(vertexBuffers: {
  115766. [key: string]: VertexBuffer;
  115767. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  115768. /**
  115769. * Bind a specific vertex array object
  115770. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  115771. * @param vertexArrayObject defines the vertex array object to bind
  115772. * @param indexBuffer defines the index buffer to bind
  115773. */
  115774. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  115775. /**
  115776. * Bind webGl buffers directly to the webGL context
  115777. * @param vertexBuffer defines the vertex buffer to bind
  115778. * @param indexBuffer defines the index buffer to bind
  115779. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  115780. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  115781. * @param effect defines the effect associated with the vertex buffer
  115782. */
  115783. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  115784. private _unbindVertexArrayObject;
  115785. /**
  115786. * Bind a list of vertex buffers to the webGL context
  115787. * @param vertexBuffers defines the list of vertex buffers to bind
  115788. * @param indexBuffer defines the index buffer to bind
  115789. * @param effect defines the effect associated with the vertex buffers
  115790. */
  115791. bindBuffers(vertexBuffers: {
  115792. [key: string]: Nullable<VertexBuffer>;
  115793. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  115794. /**
  115795. * Unbind all instance attributes
  115796. */
  115797. unbindInstanceAttributes(): void;
  115798. /**
  115799. * Release and free the memory of a vertex array object
  115800. * @param vao defines the vertex array object to delete
  115801. */
  115802. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  115803. /** @hidden */
  115804. _releaseBuffer(buffer: DataBuffer): boolean;
  115805. protected _deleteBuffer(buffer: DataBuffer): void;
  115806. /**
  115807. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  115808. * @param instancesBuffer defines the webGL buffer to update and bind
  115809. * @param data defines the data to store in the buffer
  115810. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  115811. */
  115812. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  115813. /**
  115814. * Bind the content of a webGL buffer used with instantiation
  115815. * @param instancesBuffer defines the webGL buffer to bind
  115816. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  115817. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  115818. */
  115819. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  115820. /**
  115821. * Disable the instance attribute corresponding to the name in parameter
  115822. * @param name defines the name of the attribute to disable
  115823. */
  115824. disableInstanceAttributeByName(name: string): void;
  115825. /**
  115826. * Disable the instance attribute corresponding to the location in parameter
  115827. * @param attributeLocation defines the attribute location of the attribute to disable
  115828. */
  115829. disableInstanceAttribute(attributeLocation: number): void;
  115830. /**
  115831. * Disable the attribute corresponding to the location in parameter
  115832. * @param attributeLocation defines the attribute location of the attribute to disable
  115833. */
  115834. disableAttributeByIndex(attributeLocation: number): void;
  115835. /**
  115836. * Send a draw order
  115837. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  115838. * @param indexStart defines the starting index
  115839. * @param indexCount defines the number of index to draw
  115840. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  115841. */
  115842. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  115843. /**
  115844. * Draw a list of points
  115845. * @param verticesStart defines the index of first vertex to draw
  115846. * @param verticesCount defines the count of vertices to draw
  115847. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  115848. */
  115849. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  115850. /**
  115851. * Draw a list of unindexed primitives
  115852. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  115853. * @param verticesStart defines the index of first vertex to draw
  115854. * @param verticesCount defines the count of vertices to draw
  115855. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  115856. */
  115857. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  115858. /**
  115859. * Draw a list of indexed primitives
  115860. * @param fillMode defines the primitive to use
  115861. * @param indexStart defines the starting index
  115862. * @param indexCount defines the number of index to draw
  115863. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  115864. */
  115865. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  115866. /**
  115867. * Draw a list of unindexed primitives
  115868. * @param fillMode defines the primitive to use
  115869. * @param verticesStart defines the index of first vertex to draw
  115870. * @param verticesCount defines the count of vertices to draw
  115871. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  115872. */
  115873. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  115874. private _drawMode;
  115875. /** @hidden */
  115876. protected _reportDrawCall(): void;
  115877. /** @hidden */
  115878. _releaseEffect(effect: Effect): void;
  115879. /** @hidden */
  115880. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  115881. /**
  115882. * Create a new effect (used to store vertex/fragment shaders)
  115883. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  115884. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  115885. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  115886. * @param samplers defines an array of string used to represent textures
  115887. * @param defines defines the string containing the defines to use to compile the shaders
  115888. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  115889. * @param onCompiled defines a function to call when the effect creation is successful
  115890. * @param onError defines a function to call when the effect creation has failed
  115891. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  115892. * @returns the new Effect
  115893. */
  115894. 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;
  115895. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  115896. private _compileShader;
  115897. private _compileRawShader;
  115898. /** @hidden */
  115899. _getShaderSource(shader: WebGLShader): Nullable<string>;
  115900. /**
  115901. * Directly creates a webGL program
  115902. * @param pipelineContext defines the pipeline context to attach to
  115903. * @param vertexCode defines the vertex shader code to use
  115904. * @param fragmentCode defines the fragment shader code to use
  115905. * @param context defines the webGL context to use (if not set, the current one will be used)
  115906. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  115907. * @returns the new webGL program
  115908. */
  115909. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  115910. /**
  115911. * Creates a webGL program
  115912. * @param pipelineContext defines the pipeline context to attach to
  115913. * @param vertexCode defines the vertex shader code to use
  115914. * @param fragmentCode defines the fragment shader code to use
  115915. * @param defines defines the string containing the defines to use to compile the shaders
  115916. * @param context defines the webGL context to use (if not set, the current one will be used)
  115917. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  115918. * @returns the new webGL program
  115919. */
  115920. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  115921. /**
  115922. * Creates a new pipeline context
  115923. * @returns the new pipeline
  115924. */
  115925. createPipelineContext(): IPipelineContext;
  115926. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  115927. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  115928. /** @hidden */
  115929. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  115930. /** @hidden */
  115931. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  115932. /** @hidden */
  115933. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  115934. /**
  115935. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  115936. * @param pipelineContext defines the pipeline context to use
  115937. * @param uniformsNames defines the list of uniform names
  115938. * @returns an array of webGL uniform locations
  115939. */
  115940. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  115941. /**
  115942. * Gets the lsit of active attributes for a given webGL program
  115943. * @param pipelineContext defines the pipeline context to use
  115944. * @param attributesNames defines the list of attribute names to get
  115945. * @returns an array of indices indicating the offset of each attribute
  115946. */
  115947. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  115948. /**
  115949. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  115950. * @param effect defines the effect to activate
  115951. */
  115952. enableEffect(effect: Nullable<Effect>): void;
  115953. /**
  115954. * Set the value of an uniform to a number (int)
  115955. * @param uniform defines the webGL uniform location where to store the value
  115956. * @param value defines the int number to store
  115957. */
  115958. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  115959. /**
  115960. * Set the value of an uniform to an array of int32
  115961. * @param uniform defines the webGL uniform location where to store the value
  115962. * @param array defines the array of int32 to store
  115963. */
  115964. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  115965. /**
  115966. * Set the value of an uniform to an array of int32 (stored as vec2)
  115967. * @param uniform defines the webGL uniform location where to store the value
  115968. * @param array defines the array of int32 to store
  115969. */
  115970. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  115971. /**
  115972. * Set the value of an uniform to an array of int32 (stored as vec3)
  115973. * @param uniform defines the webGL uniform location where to store the value
  115974. * @param array defines the array of int32 to store
  115975. */
  115976. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  115977. /**
  115978. * Set the value of an uniform to an array of int32 (stored as vec4)
  115979. * @param uniform defines the webGL uniform location where to store the value
  115980. * @param array defines the array of int32 to store
  115981. */
  115982. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  115983. /**
  115984. * Set the value of an uniform to an array of number
  115985. * @param uniform defines the webGL uniform location where to store the value
  115986. * @param array defines the array of number to store
  115987. */
  115988. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  115989. /**
  115990. * Set the value of an uniform to an array of number (stored as vec2)
  115991. * @param uniform defines the webGL uniform location where to store the value
  115992. * @param array defines the array of number to store
  115993. */
  115994. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  115995. /**
  115996. * Set the value of an uniform to an array of number (stored as vec3)
  115997. * @param uniform defines the webGL uniform location where to store the value
  115998. * @param array defines the array of number to store
  115999. */
  116000. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  116001. /**
  116002. * Set the value of an uniform to an array of number (stored as vec4)
  116003. * @param uniform defines the webGL uniform location where to store the value
  116004. * @param array defines the array of number to store
  116005. */
  116006. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  116007. /**
  116008. * Set the value of an uniform to an array of float32 (stored as matrices)
  116009. * @param uniform defines the webGL uniform location where to store the value
  116010. * @param matrices defines the array of float32 to store
  116011. */
  116012. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  116013. /**
  116014. * Set the value of an uniform to a matrix (3x3)
  116015. * @param uniform defines the webGL uniform location where to store the value
  116016. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  116017. */
  116018. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  116019. /**
  116020. * Set the value of an uniform to a matrix (2x2)
  116021. * @param uniform defines the webGL uniform location where to store the value
  116022. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  116023. */
  116024. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  116025. /**
  116026. * Set the value of an uniform to a number (float)
  116027. * @param uniform defines the webGL uniform location where to store the value
  116028. * @param value defines the float number to store
  116029. */
  116030. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  116031. /**
  116032. * Set the value of an uniform to a vec2
  116033. * @param uniform defines the webGL uniform location where to store the value
  116034. * @param x defines the 1st component of the value
  116035. * @param y defines the 2nd component of the value
  116036. */
  116037. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  116038. /**
  116039. * Set the value of an uniform to a vec3
  116040. * @param uniform defines the webGL uniform location where to store the value
  116041. * @param x defines the 1st component of the value
  116042. * @param y defines the 2nd component of the value
  116043. * @param z defines the 3rd component of the value
  116044. */
  116045. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  116046. /**
  116047. * Set the value of an uniform to a vec4
  116048. * @param uniform defines the webGL uniform location where to store the value
  116049. * @param x defines the 1st component of the value
  116050. * @param y defines the 2nd component of the value
  116051. * @param z defines the 3rd component of the value
  116052. * @param w defines the 4th component of the value
  116053. */
  116054. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  116055. /**
  116056. * Apply all cached states (depth, culling, stencil and alpha)
  116057. */
  116058. applyStates(): void;
  116059. /**
  116060. * Enable or disable color writing
  116061. * @param enable defines the state to set
  116062. */
  116063. setColorWrite(enable: boolean): void;
  116064. /**
  116065. * Gets a boolean indicating if color writing is enabled
  116066. * @returns the current color writing state
  116067. */
  116068. getColorWrite(): boolean;
  116069. /**
  116070. * Gets the depth culling state manager
  116071. */
  116072. get depthCullingState(): DepthCullingState;
  116073. /**
  116074. * Gets the alpha state manager
  116075. */
  116076. get alphaState(): AlphaState;
  116077. /**
  116078. * Gets the stencil state manager
  116079. */
  116080. get stencilState(): StencilState;
  116081. /**
  116082. * Clears the list of texture accessible through engine.
  116083. * This can help preventing texture load conflict due to name collision.
  116084. */
  116085. clearInternalTexturesCache(): void;
  116086. /**
  116087. * Force the entire cache to be cleared
  116088. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  116089. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  116090. */
  116091. wipeCaches(bruteForce?: boolean): void;
  116092. /** @hidden */
  116093. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  116094. min: number;
  116095. mag: number;
  116096. };
  116097. /** @hidden */
  116098. _createTexture(): WebGLTexture;
  116099. /**
  116100. * Usually called from Texture.ts.
  116101. * Passed information to create a WebGLTexture
  116102. * @param url defines a value which contains one of the following:
  116103. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  116104. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  116105. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  116106. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  116107. * @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)
  116108. * @param scene needed for loading to the correct scene
  116109. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  116110. * @param onLoad optional callback to be called upon successful completion
  116111. * @param onError optional callback to be called upon failure
  116112. * @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
  116113. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  116114. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  116115. * @param forcedExtension defines the extension to use to pick the right loader
  116116. * @param mimeType defines an optional mime type
  116117. * @returns a InternalTexture for assignment back into BABYLON.Texture
  116118. */
  116119. 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;
  116120. /**
  116121. * Loads an image as an HTMLImageElement.
  116122. * @param input url string, ArrayBuffer, or Blob to load
  116123. * @param onLoad callback called when the image successfully loads
  116124. * @param onError callback called when the image fails to load
  116125. * @param offlineProvider offline provider for caching
  116126. * @param mimeType optional mime type
  116127. * @returns the HTMLImageElement of the loaded image
  116128. * @hidden
  116129. */
  116130. 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>;
  116131. /**
  116132. * @hidden
  116133. */
  116134. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  116135. private _unpackFlipYCached;
  116136. /**
  116137. * In case you are sharing the context with other applications, it might
  116138. * be interested to not cache the unpack flip y state to ensure a consistent
  116139. * value would be set.
  116140. */
  116141. enableUnpackFlipYCached: boolean;
  116142. /** @hidden */
  116143. _unpackFlipY(value: boolean): void;
  116144. /** @hidden */
  116145. _getUnpackAlignement(): number;
  116146. private _getTextureTarget;
  116147. /**
  116148. * Update the sampling mode of a given texture
  116149. * @param samplingMode defines the required sampling mode
  116150. * @param texture defines the texture to update
  116151. * @param generateMipMaps defines whether to generate mipmaps for the texture
  116152. */
  116153. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  116154. /**
  116155. * Update the sampling mode of a given texture
  116156. * @param texture defines the texture to update
  116157. * @param wrapU defines the texture wrap mode of the u coordinates
  116158. * @param wrapV defines the texture wrap mode of the v coordinates
  116159. * @param wrapR defines the texture wrap mode of the r coordinates
  116160. */
  116161. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  116162. /** @hidden */
  116163. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  116164. width: number;
  116165. height: number;
  116166. layers?: number;
  116167. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  116168. /** @hidden */
  116169. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  116170. /** @hidden */
  116171. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  116172. /**
  116173. * Update a portion of an internal texture
  116174. * @param texture defines the texture to update
  116175. * @param imageData defines the data to store into the texture
  116176. * @param xOffset defines the x coordinates of the update rectangle
  116177. * @param yOffset defines the y coordinates of the update rectangle
  116178. * @param width defines the width of the update rectangle
  116179. * @param height defines the height of the update rectangle
  116180. * @param faceIndex defines the face index if texture is a cube (0 by default)
  116181. * @param lod defines the lod level to update (0 by default)
  116182. */
  116183. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  116184. /** @hidden */
  116185. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  116186. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  116187. private _prepareWebGLTexture;
  116188. /** @hidden */
  116189. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  116190. private _getDepthStencilBuffer;
  116191. /** @hidden */
  116192. _releaseFramebufferObjects(texture: InternalTexture): void;
  116193. /** @hidden */
  116194. _releaseTexture(texture: InternalTexture): void;
  116195. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  116196. protected _setProgram(program: WebGLProgram): void;
  116197. protected _boundUniforms: {
  116198. [key: number]: WebGLUniformLocation;
  116199. };
  116200. /**
  116201. * Binds an effect to the webGL context
  116202. * @param effect defines the effect to bind
  116203. */
  116204. bindSamplers(effect: Effect): void;
  116205. private _activateCurrentTexture;
  116206. /** @hidden */
  116207. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  116208. /** @hidden */
  116209. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  116210. /**
  116211. * Unbind all textures from the webGL context
  116212. */
  116213. unbindAllTextures(): void;
  116214. /**
  116215. * Sets a texture to the according uniform.
  116216. * @param channel The texture channel
  116217. * @param uniform The uniform to set
  116218. * @param texture The texture to apply
  116219. */
  116220. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  116221. private _bindSamplerUniformToChannel;
  116222. private _getTextureWrapMode;
  116223. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  116224. /**
  116225. * Sets an array of texture to the webGL context
  116226. * @param channel defines the channel where the texture array must be set
  116227. * @param uniform defines the associated uniform location
  116228. * @param textures defines the array of textures to bind
  116229. */
  116230. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  116231. /** @hidden */
  116232. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  116233. private _setTextureParameterFloat;
  116234. private _setTextureParameterInteger;
  116235. /**
  116236. * Unbind all vertex attributes from the webGL context
  116237. */
  116238. unbindAllAttributes(): void;
  116239. /**
  116240. * 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
  116241. */
  116242. releaseEffects(): void;
  116243. /**
  116244. * Dispose and release all associated resources
  116245. */
  116246. dispose(): void;
  116247. /**
  116248. * Attach a new callback raised when context lost event is fired
  116249. * @param callback defines the callback to call
  116250. */
  116251. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  116252. /**
  116253. * Attach a new callback raised when context restored event is fired
  116254. * @param callback defines the callback to call
  116255. */
  116256. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  116257. /**
  116258. * Get the current error code of the webGL context
  116259. * @returns the error code
  116260. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  116261. */
  116262. getError(): number;
  116263. private _canRenderToFloatFramebuffer;
  116264. private _canRenderToHalfFloatFramebuffer;
  116265. private _canRenderToFramebuffer;
  116266. /** @hidden */
  116267. _getWebGLTextureType(type: number): number;
  116268. /** @hidden */
  116269. _getInternalFormat(format: number): number;
  116270. /** @hidden */
  116271. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  116272. /** @hidden */
  116273. _getRGBAMultiSampleBufferFormat(type: number): number;
  116274. /** @hidden */
  116275. _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;
  116276. /**
  116277. * Loads a file from a url
  116278. * @param url url to load
  116279. * @param onSuccess callback called when the file successfully loads
  116280. * @param onProgress callback called while file is loading (if the server supports this mode)
  116281. * @param offlineProvider defines the offline provider for caching
  116282. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  116283. * @param onError callback called when the file fails to load
  116284. * @returns a file request object
  116285. * @hidden
  116286. */
  116287. 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;
  116288. /**
  116289. * Reads pixels from the current frame buffer. Please note that this function can be slow
  116290. * @param x defines the x coordinate of the rectangle where pixels must be read
  116291. * @param y defines the y coordinate of the rectangle where pixels must be read
  116292. * @param width defines the width of the rectangle where pixels must be read
  116293. * @param height defines the height of the rectangle where pixels must be read
  116294. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  116295. * @returns a Uint8Array containing RGBA colors
  116296. */
  116297. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  116298. private static _isSupported;
  116299. /**
  116300. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  116301. * @returns true if the engine can be created
  116302. * @ignorenaming
  116303. */
  116304. static isSupported(): boolean;
  116305. /**
  116306. * Find the next highest power of two.
  116307. * @param x Number to start search from.
  116308. * @return Next highest power of two.
  116309. */
  116310. static CeilingPOT(x: number): number;
  116311. /**
  116312. * Find the next lowest power of two.
  116313. * @param x Number to start search from.
  116314. * @return Next lowest power of two.
  116315. */
  116316. static FloorPOT(x: number): number;
  116317. /**
  116318. * Find the nearest power of two.
  116319. * @param x Number to start search from.
  116320. * @return Next nearest power of two.
  116321. */
  116322. static NearestPOT(x: number): number;
  116323. /**
  116324. * Get the closest exponent of two
  116325. * @param value defines the value to approximate
  116326. * @param max defines the maximum value to return
  116327. * @param mode defines how to define the closest value
  116328. * @returns closest exponent of two of the given value
  116329. */
  116330. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  116331. /**
  116332. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  116333. * @param func - the function to be called
  116334. * @param requester - the object that will request the next frame. Falls back to window.
  116335. * @returns frame number
  116336. */
  116337. static QueueNewFrame(func: () => void, requester?: any): number;
  116338. /**
  116339. * Gets host document
  116340. * @returns the host document object
  116341. */
  116342. getHostDocument(): Nullable<Document>;
  116343. }
  116344. }
  116345. declare module BABYLON {
  116346. /**
  116347. * Class representing spherical harmonics coefficients to the 3rd degree
  116348. */
  116349. export class SphericalHarmonics {
  116350. /**
  116351. * Defines whether or not the harmonics have been prescaled for rendering.
  116352. */
  116353. preScaled: boolean;
  116354. /**
  116355. * The l0,0 coefficients of the spherical harmonics
  116356. */
  116357. l00: Vector3;
  116358. /**
  116359. * The l1,-1 coefficients of the spherical harmonics
  116360. */
  116361. l1_1: Vector3;
  116362. /**
  116363. * The l1,0 coefficients of the spherical harmonics
  116364. */
  116365. l10: Vector3;
  116366. /**
  116367. * The l1,1 coefficients of the spherical harmonics
  116368. */
  116369. l11: Vector3;
  116370. /**
  116371. * The l2,-2 coefficients of the spherical harmonics
  116372. */
  116373. l2_2: Vector3;
  116374. /**
  116375. * The l2,-1 coefficients of the spherical harmonics
  116376. */
  116377. l2_1: Vector3;
  116378. /**
  116379. * The l2,0 coefficients of the spherical harmonics
  116380. */
  116381. l20: Vector3;
  116382. /**
  116383. * The l2,1 coefficients of the spherical harmonics
  116384. */
  116385. l21: Vector3;
  116386. /**
  116387. * The l2,2 coefficients of the spherical harmonics
  116388. */
  116389. l22: Vector3;
  116390. /**
  116391. * Adds a light to the spherical harmonics
  116392. * @param direction the direction of the light
  116393. * @param color the color of the light
  116394. * @param deltaSolidAngle the delta solid angle of the light
  116395. */
  116396. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  116397. /**
  116398. * Scales the spherical harmonics by the given amount
  116399. * @param scale the amount to scale
  116400. */
  116401. scaleInPlace(scale: number): void;
  116402. /**
  116403. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  116404. *
  116405. * ```
  116406. * E_lm = A_l * L_lm
  116407. * ```
  116408. *
  116409. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  116410. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  116411. * the scaling factors are given in equation 9.
  116412. */
  116413. convertIncidentRadianceToIrradiance(): void;
  116414. /**
  116415. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  116416. *
  116417. * ```
  116418. * L = (1/pi) * E * rho
  116419. * ```
  116420. *
  116421. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  116422. */
  116423. convertIrradianceToLambertianRadiance(): void;
  116424. /**
  116425. * Integrates the reconstruction coefficients directly in to the SH preventing further
  116426. * required operations at run time.
  116427. *
  116428. * This is simply done by scaling back the SH with Ylm constants parameter.
  116429. * The trigonometric part being applied by the shader at run time.
  116430. */
  116431. preScaleForRendering(): void;
  116432. /**
  116433. * Constructs a spherical harmonics from an array.
  116434. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  116435. * @returns the spherical harmonics
  116436. */
  116437. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  116438. /**
  116439. * Gets the spherical harmonics from polynomial
  116440. * @param polynomial the spherical polynomial
  116441. * @returns the spherical harmonics
  116442. */
  116443. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  116444. }
  116445. /**
  116446. * Class representing spherical polynomial coefficients to the 3rd degree
  116447. */
  116448. export class SphericalPolynomial {
  116449. private _harmonics;
  116450. /**
  116451. * The spherical harmonics used to create the polynomials.
  116452. */
  116453. get preScaledHarmonics(): SphericalHarmonics;
  116454. /**
  116455. * The x coefficients of the spherical polynomial
  116456. */
  116457. x: Vector3;
  116458. /**
  116459. * The y coefficients of the spherical polynomial
  116460. */
  116461. y: Vector3;
  116462. /**
  116463. * The z coefficients of the spherical polynomial
  116464. */
  116465. z: Vector3;
  116466. /**
  116467. * The xx coefficients of the spherical polynomial
  116468. */
  116469. xx: Vector3;
  116470. /**
  116471. * The yy coefficients of the spherical polynomial
  116472. */
  116473. yy: Vector3;
  116474. /**
  116475. * The zz coefficients of the spherical polynomial
  116476. */
  116477. zz: Vector3;
  116478. /**
  116479. * The xy coefficients of the spherical polynomial
  116480. */
  116481. xy: Vector3;
  116482. /**
  116483. * The yz coefficients of the spherical polynomial
  116484. */
  116485. yz: Vector3;
  116486. /**
  116487. * The zx coefficients of the spherical polynomial
  116488. */
  116489. zx: Vector3;
  116490. /**
  116491. * Adds an ambient color to the spherical polynomial
  116492. * @param color the color to add
  116493. */
  116494. addAmbient(color: Color3): void;
  116495. /**
  116496. * Scales the spherical polynomial by the given amount
  116497. * @param scale the amount to scale
  116498. */
  116499. scaleInPlace(scale: number): void;
  116500. /**
  116501. * Gets the spherical polynomial from harmonics
  116502. * @param harmonics the spherical harmonics
  116503. * @returns the spherical polynomial
  116504. */
  116505. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  116506. /**
  116507. * Constructs a spherical polynomial from an array.
  116508. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  116509. * @returns the spherical polynomial
  116510. */
  116511. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  116512. }
  116513. }
  116514. declare module BABYLON {
  116515. /**
  116516. * Defines the source of the internal texture
  116517. */
  116518. export enum InternalTextureSource {
  116519. /**
  116520. * The source of the texture data is unknown
  116521. */
  116522. Unknown = 0,
  116523. /**
  116524. * Texture data comes from an URL
  116525. */
  116526. Url = 1,
  116527. /**
  116528. * Texture data is only used for temporary storage
  116529. */
  116530. Temp = 2,
  116531. /**
  116532. * Texture data comes from raw data (ArrayBuffer)
  116533. */
  116534. Raw = 3,
  116535. /**
  116536. * Texture content is dynamic (video or dynamic texture)
  116537. */
  116538. Dynamic = 4,
  116539. /**
  116540. * Texture content is generated by rendering to it
  116541. */
  116542. RenderTarget = 5,
  116543. /**
  116544. * Texture content is part of a multi render target process
  116545. */
  116546. MultiRenderTarget = 6,
  116547. /**
  116548. * Texture data comes from a cube data file
  116549. */
  116550. Cube = 7,
  116551. /**
  116552. * Texture data comes from a raw cube data
  116553. */
  116554. CubeRaw = 8,
  116555. /**
  116556. * Texture data come from a prefiltered cube data file
  116557. */
  116558. CubePrefiltered = 9,
  116559. /**
  116560. * Texture content is raw 3D data
  116561. */
  116562. Raw3D = 10,
  116563. /**
  116564. * Texture content is raw 2D array data
  116565. */
  116566. Raw2DArray = 11,
  116567. /**
  116568. * Texture content is a depth texture
  116569. */
  116570. Depth = 12,
  116571. /**
  116572. * Texture data comes from a raw cube data encoded with RGBD
  116573. */
  116574. CubeRawRGBD = 13
  116575. }
  116576. /**
  116577. * Class used to store data associated with WebGL texture data for the engine
  116578. * This class should not be used directly
  116579. */
  116580. export class InternalTexture {
  116581. /** @hidden */
  116582. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  116583. /**
  116584. * Defines if the texture is ready
  116585. */
  116586. isReady: boolean;
  116587. /**
  116588. * Defines if the texture is a cube texture
  116589. */
  116590. isCube: boolean;
  116591. /**
  116592. * Defines if the texture contains 3D data
  116593. */
  116594. is3D: boolean;
  116595. /**
  116596. * Defines if the texture contains 2D array data
  116597. */
  116598. is2DArray: boolean;
  116599. /**
  116600. * Defines if the texture contains multiview data
  116601. */
  116602. isMultiview: boolean;
  116603. /**
  116604. * Gets the URL used to load this texture
  116605. */
  116606. url: string;
  116607. /**
  116608. * Gets the sampling mode of the texture
  116609. */
  116610. samplingMode: number;
  116611. /**
  116612. * Gets a boolean indicating if the texture needs mipmaps generation
  116613. */
  116614. generateMipMaps: boolean;
  116615. /**
  116616. * Gets the number of samples used by the texture (WebGL2+ only)
  116617. */
  116618. samples: number;
  116619. /**
  116620. * Gets the type of the texture (int, float...)
  116621. */
  116622. type: number;
  116623. /**
  116624. * Gets the format of the texture (RGB, RGBA...)
  116625. */
  116626. format: number;
  116627. /**
  116628. * Observable called when the texture is loaded
  116629. */
  116630. onLoadedObservable: Observable<InternalTexture>;
  116631. /**
  116632. * Gets the width of the texture
  116633. */
  116634. width: number;
  116635. /**
  116636. * Gets the height of the texture
  116637. */
  116638. height: number;
  116639. /**
  116640. * Gets the depth of the texture
  116641. */
  116642. depth: number;
  116643. /**
  116644. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  116645. */
  116646. baseWidth: number;
  116647. /**
  116648. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  116649. */
  116650. baseHeight: number;
  116651. /**
  116652. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  116653. */
  116654. baseDepth: number;
  116655. /**
  116656. * Gets a boolean indicating if the texture is inverted on Y axis
  116657. */
  116658. invertY: boolean;
  116659. /** @hidden */
  116660. _invertVScale: boolean;
  116661. /** @hidden */
  116662. _associatedChannel: number;
  116663. /** @hidden */
  116664. _source: InternalTextureSource;
  116665. /** @hidden */
  116666. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  116667. /** @hidden */
  116668. _bufferView: Nullable<ArrayBufferView>;
  116669. /** @hidden */
  116670. _bufferViewArray: Nullable<ArrayBufferView[]>;
  116671. /** @hidden */
  116672. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  116673. /** @hidden */
  116674. _size: number;
  116675. /** @hidden */
  116676. _extension: string;
  116677. /** @hidden */
  116678. _files: Nullable<string[]>;
  116679. /** @hidden */
  116680. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  116681. /** @hidden */
  116682. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  116683. /** @hidden */
  116684. _framebuffer: Nullable<WebGLFramebuffer>;
  116685. /** @hidden */
  116686. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  116687. /** @hidden */
  116688. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  116689. /** @hidden */
  116690. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  116691. /** @hidden */
  116692. _attachments: Nullable<number[]>;
  116693. /** @hidden */
  116694. _textureArray: Nullable<InternalTexture[]>;
  116695. /** @hidden */
  116696. _cachedCoordinatesMode: Nullable<number>;
  116697. /** @hidden */
  116698. _cachedWrapU: Nullable<number>;
  116699. /** @hidden */
  116700. _cachedWrapV: Nullable<number>;
  116701. /** @hidden */
  116702. _cachedWrapR: Nullable<number>;
  116703. /** @hidden */
  116704. _cachedAnisotropicFilteringLevel: Nullable<number>;
  116705. /** @hidden */
  116706. _isDisabled: boolean;
  116707. /** @hidden */
  116708. _compression: Nullable<string>;
  116709. /** @hidden */
  116710. _generateStencilBuffer: boolean;
  116711. /** @hidden */
  116712. _generateDepthBuffer: boolean;
  116713. /** @hidden */
  116714. _comparisonFunction: number;
  116715. /** @hidden */
  116716. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  116717. /** @hidden */
  116718. _lodGenerationScale: number;
  116719. /** @hidden */
  116720. _lodGenerationOffset: number;
  116721. /** @hidden */
  116722. _depthStencilTexture: Nullable<InternalTexture>;
  116723. /** @hidden */
  116724. _colorTextureArray: Nullable<WebGLTexture>;
  116725. /** @hidden */
  116726. _depthStencilTextureArray: Nullable<WebGLTexture>;
  116727. /** @hidden */
  116728. _lodTextureHigh: Nullable<BaseTexture>;
  116729. /** @hidden */
  116730. _lodTextureMid: Nullable<BaseTexture>;
  116731. /** @hidden */
  116732. _lodTextureLow: Nullable<BaseTexture>;
  116733. /** @hidden */
  116734. _isRGBD: boolean;
  116735. /** @hidden */
  116736. _linearSpecularLOD: boolean;
  116737. /** @hidden */
  116738. _irradianceTexture: Nullable<BaseTexture>;
  116739. /** @hidden */
  116740. _webGLTexture: Nullable<WebGLTexture>;
  116741. /** @hidden */
  116742. _references: number;
  116743. /** @hidden */
  116744. _gammaSpace: Nullable<boolean>;
  116745. private _engine;
  116746. /**
  116747. * Gets the Engine the texture belongs to.
  116748. * @returns The babylon engine
  116749. */
  116750. getEngine(): ThinEngine;
  116751. /**
  116752. * Gets the data source type of the texture
  116753. */
  116754. get source(): InternalTextureSource;
  116755. /**
  116756. * Creates a new InternalTexture
  116757. * @param engine defines the engine to use
  116758. * @param source defines the type of data that will be used
  116759. * @param delayAllocation if the texture allocation should be delayed (default: false)
  116760. */
  116761. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  116762. /**
  116763. * Increments the number of references (ie. the number of Texture that point to it)
  116764. */
  116765. incrementReferences(): void;
  116766. /**
  116767. * Change the size of the texture (not the size of the content)
  116768. * @param width defines the new width
  116769. * @param height defines the new height
  116770. * @param depth defines the new depth (1 by default)
  116771. */
  116772. updateSize(width: int, height: int, depth?: int): void;
  116773. /** @hidden */
  116774. _rebuild(): void;
  116775. /** @hidden */
  116776. _swapAndDie(target: InternalTexture): void;
  116777. /**
  116778. * Dispose the current allocated resources
  116779. */
  116780. dispose(): void;
  116781. }
  116782. }
  116783. declare module BABYLON {
  116784. /**
  116785. * Class used to work with sound analyzer using fast fourier transform (FFT)
  116786. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  116787. */
  116788. export class Analyser {
  116789. /**
  116790. * Gets or sets the smoothing
  116791. * @ignorenaming
  116792. */
  116793. SMOOTHING: number;
  116794. /**
  116795. * Gets or sets the FFT table size
  116796. * @ignorenaming
  116797. */
  116798. FFT_SIZE: number;
  116799. /**
  116800. * Gets or sets the bar graph amplitude
  116801. * @ignorenaming
  116802. */
  116803. BARGRAPHAMPLITUDE: number;
  116804. /**
  116805. * Gets or sets the position of the debug canvas
  116806. * @ignorenaming
  116807. */
  116808. DEBUGCANVASPOS: {
  116809. x: number;
  116810. y: number;
  116811. };
  116812. /**
  116813. * Gets or sets the debug canvas size
  116814. * @ignorenaming
  116815. */
  116816. DEBUGCANVASSIZE: {
  116817. width: number;
  116818. height: number;
  116819. };
  116820. private _byteFreqs;
  116821. private _byteTime;
  116822. private _floatFreqs;
  116823. private _webAudioAnalyser;
  116824. private _debugCanvas;
  116825. private _debugCanvasContext;
  116826. private _scene;
  116827. private _registerFunc;
  116828. private _audioEngine;
  116829. /**
  116830. * Creates a new analyser
  116831. * @param scene defines hosting scene
  116832. */
  116833. constructor(scene: Scene);
  116834. /**
  116835. * Get the number of data values you will have to play with for the visualization
  116836. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  116837. * @returns a number
  116838. */
  116839. getFrequencyBinCount(): number;
  116840. /**
  116841. * Gets the current frequency data as a byte array
  116842. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  116843. * @returns a Uint8Array
  116844. */
  116845. getByteFrequencyData(): Uint8Array;
  116846. /**
  116847. * Gets the current waveform as a byte array
  116848. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  116849. * @returns a Uint8Array
  116850. */
  116851. getByteTimeDomainData(): Uint8Array;
  116852. /**
  116853. * Gets the current frequency data as a float array
  116854. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  116855. * @returns a Float32Array
  116856. */
  116857. getFloatFrequencyData(): Float32Array;
  116858. /**
  116859. * Renders the debug canvas
  116860. */
  116861. drawDebugCanvas(): void;
  116862. /**
  116863. * Stops rendering the debug canvas and removes it
  116864. */
  116865. stopDebugCanvas(): void;
  116866. /**
  116867. * Connects two audio nodes
  116868. * @param inputAudioNode defines first node to connect
  116869. * @param outputAudioNode defines second node to connect
  116870. */
  116871. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  116872. /**
  116873. * Releases all associated resources
  116874. */
  116875. dispose(): void;
  116876. }
  116877. }
  116878. declare module BABYLON {
  116879. /**
  116880. * This represents an audio engine and it is responsible
  116881. * to play, synchronize and analyse sounds throughout the application.
  116882. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  116883. */
  116884. export interface IAudioEngine extends IDisposable {
  116885. /**
  116886. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  116887. */
  116888. readonly canUseWebAudio: boolean;
  116889. /**
  116890. * Gets the current AudioContext if available.
  116891. */
  116892. readonly audioContext: Nullable<AudioContext>;
  116893. /**
  116894. * The master gain node defines the global audio volume of your audio engine.
  116895. */
  116896. readonly masterGain: GainNode;
  116897. /**
  116898. * Gets whether or not mp3 are supported by your browser.
  116899. */
  116900. readonly isMP3supported: boolean;
  116901. /**
  116902. * Gets whether or not ogg are supported by your browser.
  116903. */
  116904. readonly isOGGsupported: boolean;
  116905. /**
  116906. * Defines if Babylon should emit a warning if WebAudio is not supported.
  116907. * @ignoreNaming
  116908. */
  116909. WarnedWebAudioUnsupported: boolean;
  116910. /**
  116911. * Defines if the audio engine relies on a custom unlocked button.
  116912. * In this case, the embedded button will not be displayed.
  116913. */
  116914. useCustomUnlockedButton: boolean;
  116915. /**
  116916. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  116917. */
  116918. readonly unlocked: boolean;
  116919. /**
  116920. * Event raised when audio has been unlocked on the browser.
  116921. */
  116922. onAudioUnlockedObservable: Observable<AudioEngine>;
  116923. /**
  116924. * Event raised when audio has been locked on the browser.
  116925. */
  116926. onAudioLockedObservable: Observable<AudioEngine>;
  116927. /**
  116928. * Flags the audio engine in Locked state.
  116929. * This happens due to new browser policies preventing audio to autoplay.
  116930. */
  116931. lock(): void;
  116932. /**
  116933. * Unlocks the audio engine once a user action has been done on the dom.
  116934. * This is helpful to resume play once browser policies have been satisfied.
  116935. */
  116936. unlock(): void;
  116937. /**
  116938. * Gets the global volume sets on the master gain.
  116939. * @returns the global volume if set or -1 otherwise
  116940. */
  116941. getGlobalVolume(): number;
  116942. /**
  116943. * Sets the global volume of your experience (sets on the master gain).
  116944. * @param newVolume Defines the new global volume of the application
  116945. */
  116946. setGlobalVolume(newVolume: number): void;
  116947. /**
  116948. * Connect the audio engine to an audio analyser allowing some amazing
  116949. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  116950. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  116951. * @param analyser The analyser to connect to the engine
  116952. */
  116953. connectToAnalyser(analyser: Analyser): void;
  116954. }
  116955. /**
  116956. * This represents the default audio engine used in babylon.
  116957. * It is responsible to play, synchronize and analyse sounds throughout the application.
  116958. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  116959. */
  116960. export class AudioEngine implements IAudioEngine {
  116961. private _audioContext;
  116962. private _audioContextInitialized;
  116963. private _muteButton;
  116964. private _hostElement;
  116965. /**
  116966. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  116967. */
  116968. canUseWebAudio: boolean;
  116969. /**
  116970. * The master gain node defines the global audio volume of your audio engine.
  116971. */
  116972. masterGain: GainNode;
  116973. /**
  116974. * Defines if Babylon should emit a warning if WebAudio is not supported.
  116975. * @ignoreNaming
  116976. */
  116977. WarnedWebAudioUnsupported: boolean;
  116978. /**
  116979. * Gets whether or not mp3 are supported by your browser.
  116980. */
  116981. isMP3supported: boolean;
  116982. /**
  116983. * Gets whether or not ogg are supported by your browser.
  116984. */
  116985. isOGGsupported: boolean;
  116986. /**
  116987. * Gets whether audio has been unlocked on the device.
  116988. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  116989. * a user interaction has happened.
  116990. */
  116991. unlocked: boolean;
  116992. /**
  116993. * Defines if the audio engine relies on a custom unlocked button.
  116994. * In this case, the embedded button will not be displayed.
  116995. */
  116996. useCustomUnlockedButton: boolean;
  116997. /**
  116998. * Event raised when audio has been unlocked on the browser.
  116999. */
  117000. onAudioUnlockedObservable: Observable<AudioEngine>;
  117001. /**
  117002. * Event raised when audio has been locked on the browser.
  117003. */
  117004. onAudioLockedObservable: Observable<AudioEngine>;
  117005. /**
  117006. * Gets the current AudioContext if available.
  117007. */
  117008. get audioContext(): Nullable<AudioContext>;
  117009. private _connectedAnalyser;
  117010. /**
  117011. * Instantiates a new audio engine.
  117012. *
  117013. * There should be only one per page as some browsers restrict the number
  117014. * of audio contexts you can create.
  117015. * @param hostElement defines the host element where to display the mute icon if necessary
  117016. */
  117017. constructor(hostElement?: Nullable<HTMLElement>);
  117018. /**
  117019. * Flags the audio engine in Locked state.
  117020. * This happens due to new browser policies preventing audio to autoplay.
  117021. */
  117022. lock(): void;
  117023. /**
  117024. * Unlocks the audio engine once a user action has been done on the dom.
  117025. * This is helpful to resume play once browser policies have been satisfied.
  117026. */
  117027. unlock(): void;
  117028. private _resumeAudioContext;
  117029. private _initializeAudioContext;
  117030. private _tryToRun;
  117031. private _triggerRunningState;
  117032. private _triggerSuspendedState;
  117033. private _displayMuteButton;
  117034. private _moveButtonToTopLeft;
  117035. private _onResize;
  117036. private _hideMuteButton;
  117037. /**
  117038. * Destroy and release the resources associated with the audio ccontext.
  117039. */
  117040. dispose(): void;
  117041. /**
  117042. * Gets the global volume sets on the master gain.
  117043. * @returns the global volume if set or -1 otherwise
  117044. */
  117045. getGlobalVolume(): number;
  117046. /**
  117047. * Sets the global volume of your experience (sets on the master gain).
  117048. * @param newVolume Defines the new global volume of the application
  117049. */
  117050. setGlobalVolume(newVolume: number): void;
  117051. /**
  117052. * Connect the audio engine to an audio analyser allowing some amazing
  117053. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  117054. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  117055. * @param analyser The analyser to connect to the engine
  117056. */
  117057. connectToAnalyser(analyser: Analyser): void;
  117058. }
  117059. }
  117060. declare module BABYLON {
  117061. /**
  117062. * Interface used to present a loading screen while loading a scene
  117063. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  117064. */
  117065. export interface ILoadingScreen {
  117066. /**
  117067. * Function called to display the loading screen
  117068. */
  117069. displayLoadingUI: () => void;
  117070. /**
  117071. * Function called to hide the loading screen
  117072. */
  117073. hideLoadingUI: () => void;
  117074. /**
  117075. * Gets or sets the color to use for the background
  117076. */
  117077. loadingUIBackgroundColor: string;
  117078. /**
  117079. * Gets or sets the text to display while loading
  117080. */
  117081. loadingUIText: string;
  117082. }
  117083. /**
  117084. * Class used for the default loading screen
  117085. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  117086. */
  117087. export class DefaultLoadingScreen implements ILoadingScreen {
  117088. private _renderingCanvas;
  117089. private _loadingText;
  117090. private _loadingDivBackgroundColor;
  117091. private _loadingDiv;
  117092. private _loadingTextDiv;
  117093. /** Gets or sets the logo url to use for the default loading screen */
  117094. static DefaultLogoUrl: string;
  117095. /** Gets or sets the spinner url to use for the default loading screen */
  117096. static DefaultSpinnerUrl: string;
  117097. /**
  117098. * Creates a new default loading screen
  117099. * @param _renderingCanvas defines the canvas used to render the scene
  117100. * @param _loadingText defines the default text to display
  117101. * @param _loadingDivBackgroundColor defines the default background color
  117102. */
  117103. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  117104. /**
  117105. * Function called to display the loading screen
  117106. */
  117107. displayLoadingUI(): void;
  117108. /**
  117109. * Function called to hide the loading screen
  117110. */
  117111. hideLoadingUI(): void;
  117112. /**
  117113. * Gets or sets the text to display while loading
  117114. */
  117115. set loadingUIText(text: string);
  117116. get loadingUIText(): string;
  117117. /**
  117118. * Gets or sets the color to use for the background
  117119. */
  117120. get loadingUIBackgroundColor(): string;
  117121. set loadingUIBackgroundColor(color: string);
  117122. private _resizeLoadingUI;
  117123. }
  117124. }
  117125. declare module BABYLON {
  117126. /**
  117127. * Interface for any object that can request an animation frame
  117128. */
  117129. export interface ICustomAnimationFrameRequester {
  117130. /**
  117131. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  117132. */
  117133. renderFunction?: Function;
  117134. /**
  117135. * Called to request the next frame to render to
  117136. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  117137. */
  117138. requestAnimationFrame: Function;
  117139. /**
  117140. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  117141. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  117142. */
  117143. requestID?: number;
  117144. }
  117145. }
  117146. declare module BABYLON {
  117147. /**
  117148. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  117149. */
  117150. export class PerformanceMonitor {
  117151. private _enabled;
  117152. private _rollingFrameTime;
  117153. private _lastFrameTimeMs;
  117154. /**
  117155. * constructor
  117156. * @param frameSampleSize The number of samples required to saturate the sliding window
  117157. */
  117158. constructor(frameSampleSize?: number);
  117159. /**
  117160. * Samples current frame
  117161. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  117162. */
  117163. sampleFrame(timeMs?: number): void;
  117164. /**
  117165. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  117166. */
  117167. get averageFrameTime(): number;
  117168. /**
  117169. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  117170. */
  117171. get averageFrameTimeVariance(): number;
  117172. /**
  117173. * Returns the frame time of the most recent frame
  117174. */
  117175. get instantaneousFrameTime(): number;
  117176. /**
  117177. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  117178. */
  117179. get averageFPS(): number;
  117180. /**
  117181. * Returns the average framerate in frames per second using the most recent frame time
  117182. */
  117183. get instantaneousFPS(): number;
  117184. /**
  117185. * Returns true if enough samples have been taken to completely fill the sliding window
  117186. */
  117187. get isSaturated(): boolean;
  117188. /**
  117189. * Enables contributions to the sliding window sample set
  117190. */
  117191. enable(): void;
  117192. /**
  117193. * Disables contributions to the sliding window sample set
  117194. * Samples will not be interpolated over the disabled period
  117195. */
  117196. disable(): void;
  117197. /**
  117198. * Returns true if sampling is enabled
  117199. */
  117200. get isEnabled(): boolean;
  117201. /**
  117202. * Resets performance monitor
  117203. */
  117204. reset(): void;
  117205. }
  117206. /**
  117207. * RollingAverage
  117208. *
  117209. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  117210. */
  117211. export class RollingAverage {
  117212. /**
  117213. * Current average
  117214. */
  117215. average: number;
  117216. /**
  117217. * Current variance
  117218. */
  117219. variance: number;
  117220. protected _samples: Array<number>;
  117221. protected _sampleCount: number;
  117222. protected _pos: number;
  117223. protected _m2: number;
  117224. /**
  117225. * constructor
  117226. * @param length The number of samples required to saturate the sliding window
  117227. */
  117228. constructor(length: number);
  117229. /**
  117230. * Adds a sample to the sample set
  117231. * @param v The sample value
  117232. */
  117233. add(v: number): void;
  117234. /**
  117235. * Returns previously added values or null if outside of history or outside the sliding window domain
  117236. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  117237. * @return Value previously recorded with add() or null if outside of range
  117238. */
  117239. history(i: number): number;
  117240. /**
  117241. * Returns true if enough samples have been taken to completely fill the sliding window
  117242. * @return true if sample-set saturated
  117243. */
  117244. isSaturated(): boolean;
  117245. /**
  117246. * Resets the rolling average (equivalent to 0 samples taken so far)
  117247. */
  117248. reset(): void;
  117249. /**
  117250. * Wraps a value around the sample range boundaries
  117251. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  117252. * @return Wrapped position in sample range
  117253. */
  117254. protected _wrapPosition(i: number): number;
  117255. }
  117256. }
  117257. declare module BABYLON {
  117258. /**
  117259. * This class is used to track a performance counter which is number based.
  117260. * The user has access to many properties which give statistics of different nature.
  117261. *
  117262. * The implementer can track two kinds of Performance Counter: time and count.
  117263. * 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.
  117264. * 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.
  117265. */
  117266. export class PerfCounter {
  117267. /**
  117268. * Gets or sets a global boolean to turn on and off all the counters
  117269. */
  117270. static Enabled: boolean;
  117271. /**
  117272. * Returns the smallest value ever
  117273. */
  117274. get min(): number;
  117275. /**
  117276. * Returns the biggest value ever
  117277. */
  117278. get max(): number;
  117279. /**
  117280. * Returns the average value since the performance counter is running
  117281. */
  117282. get average(): number;
  117283. /**
  117284. * Returns the average value of the last second the counter was monitored
  117285. */
  117286. get lastSecAverage(): number;
  117287. /**
  117288. * Returns the current value
  117289. */
  117290. get current(): number;
  117291. /**
  117292. * Gets the accumulated total
  117293. */
  117294. get total(): number;
  117295. /**
  117296. * Gets the total value count
  117297. */
  117298. get count(): number;
  117299. /**
  117300. * Creates a new counter
  117301. */
  117302. constructor();
  117303. /**
  117304. * Call this method to start monitoring a new frame.
  117305. * 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.
  117306. */
  117307. fetchNewFrame(): void;
  117308. /**
  117309. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  117310. * @param newCount the count value to add to the monitored count
  117311. * @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.
  117312. */
  117313. addCount(newCount: number, fetchResult: boolean): void;
  117314. /**
  117315. * Start monitoring this performance counter
  117316. */
  117317. beginMonitoring(): void;
  117318. /**
  117319. * Compute the time lapsed since the previous beginMonitoring() call.
  117320. * @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
  117321. */
  117322. endMonitoring(newFrame?: boolean): void;
  117323. private _fetchResult;
  117324. private _startMonitoringTime;
  117325. private _min;
  117326. private _max;
  117327. private _average;
  117328. private _current;
  117329. private _totalValueCount;
  117330. private _totalAccumulated;
  117331. private _lastSecAverage;
  117332. private _lastSecAccumulated;
  117333. private _lastSecTime;
  117334. private _lastSecValueCount;
  117335. }
  117336. }
  117337. declare module BABYLON {
  117338. interface ThinEngine {
  117339. /** @hidden */
  117340. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  117341. }
  117342. }
  117343. declare module BABYLON {
  117344. /**
  117345. * Defines the interface used by display changed events
  117346. */
  117347. export interface IDisplayChangedEventArgs {
  117348. /** Gets the vrDisplay object (if any) */
  117349. vrDisplay: Nullable<any>;
  117350. /** Gets a boolean indicating if webVR is supported */
  117351. vrSupported: boolean;
  117352. }
  117353. /**
  117354. * Defines the interface used by objects containing a viewport (like a camera)
  117355. */
  117356. interface IViewportOwnerLike {
  117357. /**
  117358. * Gets or sets the viewport
  117359. */
  117360. viewport: IViewportLike;
  117361. }
  117362. /**
  117363. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  117364. */
  117365. export class Engine extends ThinEngine {
  117366. /** Defines that alpha blending is disabled */
  117367. static readonly ALPHA_DISABLE: number;
  117368. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  117369. static readonly ALPHA_ADD: number;
  117370. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  117371. static readonly ALPHA_COMBINE: number;
  117372. /** Defines that alpha blending to DEST - SRC * DEST */
  117373. static readonly ALPHA_SUBTRACT: number;
  117374. /** Defines that alpha blending to SRC * DEST */
  117375. static readonly ALPHA_MULTIPLY: number;
  117376. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  117377. static readonly ALPHA_MAXIMIZED: number;
  117378. /** Defines that alpha blending to SRC + DEST */
  117379. static readonly ALPHA_ONEONE: number;
  117380. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  117381. static readonly ALPHA_PREMULTIPLIED: number;
  117382. /**
  117383. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  117384. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  117385. */
  117386. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  117387. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  117388. static readonly ALPHA_INTERPOLATE: number;
  117389. /**
  117390. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  117391. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  117392. */
  117393. static readonly ALPHA_SCREENMODE: number;
  117394. /** Defines that the ressource is not delayed*/
  117395. static readonly DELAYLOADSTATE_NONE: number;
  117396. /** Defines that the ressource was successfully delay loaded */
  117397. static readonly DELAYLOADSTATE_LOADED: number;
  117398. /** Defines that the ressource is currently delay loading */
  117399. static readonly DELAYLOADSTATE_LOADING: number;
  117400. /** Defines that the ressource is delayed and has not started loading */
  117401. static readonly DELAYLOADSTATE_NOTLOADED: number;
  117402. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  117403. static readonly NEVER: number;
  117404. /** 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 */
  117405. static readonly ALWAYS: number;
  117406. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  117407. static readonly LESS: number;
  117408. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  117409. static readonly EQUAL: number;
  117410. /** 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 */
  117411. static readonly LEQUAL: number;
  117412. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  117413. static readonly GREATER: number;
  117414. /** 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 */
  117415. static readonly GEQUAL: number;
  117416. /** 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 */
  117417. static readonly NOTEQUAL: number;
  117418. /** Passed to stencilOperation to specify that stencil value must be kept */
  117419. static readonly KEEP: number;
  117420. /** Passed to stencilOperation to specify that stencil value must be replaced */
  117421. static readonly REPLACE: number;
  117422. /** Passed to stencilOperation to specify that stencil value must be incremented */
  117423. static readonly INCR: number;
  117424. /** Passed to stencilOperation to specify that stencil value must be decremented */
  117425. static readonly DECR: number;
  117426. /** Passed to stencilOperation to specify that stencil value must be inverted */
  117427. static readonly INVERT: number;
  117428. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  117429. static readonly INCR_WRAP: number;
  117430. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  117431. static readonly DECR_WRAP: number;
  117432. /** Texture is not repeating outside of 0..1 UVs */
  117433. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  117434. /** Texture is repeating outside of 0..1 UVs */
  117435. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  117436. /** Texture is repeating and mirrored */
  117437. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  117438. /** ALPHA */
  117439. static readonly TEXTUREFORMAT_ALPHA: number;
  117440. /** LUMINANCE */
  117441. static readonly TEXTUREFORMAT_LUMINANCE: number;
  117442. /** LUMINANCE_ALPHA */
  117443. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  117444. /** RGB */
  117445. static readonly TEXTUREFORMAT_RGB: number;
  117446. /** RGBA */
  117447. static readonly TEXTUREFORMAT_RGBA: number;
  117448. /** RED */
  117449. static readonly TEXTUREFORMAT_RED: number;
  117450. /** RED (2nd reference) */
  117451. static readonly TEXTUREFORMAT_R: number;
  117452. /** RG */
  117453. static readonly TEXTUREFORMAT_RG: number;
  117454. /** RED_INTEGER */
  117455. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  117456. /** RED_INTEGER (2nd reference) */
  117457. static readonly TEXTUREFORMAT_R_INTEGER: number;
  117458. /** RG_INTEGER */
  117459. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  117460. /** RGB_INTEGER */
  117461. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  117462. /** RGBA_INTEGER */
  117463. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  117464. /** UNSIGNED_BYTE */
  117465. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  117466. /** UNSIGNED_BYTE (2nd reference) */
  117467. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  117468. /** FLOAT */
  117469. static readonly TEXTURETYPE_FLOAT: number;
  117470. /** HALF_FLOAT */
  117471. static readonly TEXTURETYPE_HALF_FLOAT: number;
  117472. /** BYTE */
  117473. static readonly TEXTURETYPE_BYTE: number;
  117474. /** SHORT */
  117475. static readonly TEXTURETYPE_SHORT: number;
  117476. /** UNSIGNED_SHORT */
  117477. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  117478. /** INT */
  117479. static readonly TEXTURETYPE_INT: number;
  117480. /** UNSIGNED_INT */
  117481. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  117482. /** UNSIGNED_SHORT_4_4_4_4 */
  117483. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  117484. /** UNSIGNED_SHORT_5_5_5_1 */
  117485. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  117486. /** UNSIGNED_SHORT_5_6_5 */
  117487. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  117488. /** UNSIGNED_INT_2_10_10_10_REV */
  117489. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  117490. /** UNSIGNED_INT_24_8 */
  117491. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  117492. /** UNSIGNED_INT_10F_11F_11F_REV */
  117493. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  117494. /** UNSIGNED_INT_5_9_9_9_REV */
  117495. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  117496. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  117497. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  117498. /** nearest is mag = nearest and min = nearest and mip = linear */
  117499. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  117500. /** Bilinear is mag = linear and min = linear and mip = nearest */
  117501. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  117502. /** Trilinear is mag = linear and min = linear and mip = linear */
  117503. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  117504. /** nearest is mag = nearest and min = nearest and mip = linear */
  117505. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  117506. /** Bilinear is mag = linear and min = linear and mip = nearest */
  117507. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  117508. /** Trilinear is mag = linear and min = linear and mip = linear */
  117509. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  117510. /** mag = nearest and min = nearest and mip = nearest */
  117511. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  117512. /** mag = nearest and min = linear and mip = nearest */
  117513. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  117514. /** mag = nearest and min = linear and mip = linear */
  117515. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  117516. /** mag = nearest and min = linear and mip = none */
  117517. static readonly TEXTURE_NEAREST_LINEAR: number;
  117518. /** mag = nearest and min = nearest and mip = none */
  117519. static readonly TEXTURE_NEAREST_NEAREST: number;
  117520. /** mag = linear and min = nearest and mip = nearest */
  117521. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  117522. /** mag = linear and min = nearest and mip = linear */
  117523. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  117524. /** mag = linear and min = linear and mip = none */
  117525. static readonly TEXTURE_LINEAR_LINEAR: number;
  117526. /** mag = linear and min = nearest and mip = none */
  117527. static readonly TEXTURE_LINEAR_NEAREST: number;
  117528. /** Explicit coordinates mode */
  117529. static readonly TEXTURE_EXPLICIT_MODE: number;
  117530. /** Spherical coordinates mode */
  117531. static readonly TEXTURE_SPHERICAL_MODE: number;
  117532. /** Planar coordinates mode */
  117533. static readonly TEXTURE_PLANAR_MODE: number;
  117534. /** Cubic coordinates mode */
  117535. static readonly TEXTURE_CUBIC_MODE: number;
  117536. /** Projection coordinates mode */
  117537. static readonly TEXTURE_PROJECTION_MODE: number;
  117538. /** Skybox coordinates mode */
  117539. static readonly TEXTURE_SKYBOX_MODE: number;
  117540. /** Inverse Cubic coordinates mode */
  117541. static readonly TEXTURE_INVCUBIC_MODE: number;
  117542. /** Equirectangular coordinates mode */
  117543. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  117544. /** Equirectangular Fixed coordinates mode */
  117545. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  117546. /** Equirectangular Fixed Mirrored coordinates mode */
  117547. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  117548. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  117549. static readonly SCALEMODE_FLOOR: number;
  117550. /** Defines that texture rescaling will look for the nearest power of 2 size */
  117551. static readonly SCALEMODE_NEAREST: number;
  117552. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  117553. static readonly SCALEMODE_CEILING: number;
  117554. /**
  117555. * Returns the current npm package of the sdk
  117556. */
  117557. static get NpmPackage(): string;
  117558. /**
  117559. * Returns the current version of the framework
  117560. */
  117561. static get Version(): string;
  117562. /** Gets the list of created engines */
  117563. static get Instances(): Engine[];
  117564. /**
  117565. * Gets the latest created engine
  117566. */
  117567. static get LastCreatedEngine(): Nullable<Engine>;
  117568. /**
  117569. * Gets the latest created scene
  117570. */
  117571. static get LastCreatedScene(): Nullable<Scene>;
  117572. /**
  117573. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  117574. * @param flag defines which part of the materials must be marked as dirty
  117575. * @param predicate defines a predicate used to filter which materials should be affected
  117576. */
  117577. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  117578. /**
  117579. * Method called to create the default loading screen.
  117580. * This can be overriden in your own app.
  117581. * @param canvas The rendering canvas element
  117582. * @returns The loading screen
  117583. */
  117584. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  117585. /**
  117586. * Method called to create the default rescale post process on each engine.
  117587. */
  117588. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  117589. /**
  117590. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  117591. **/
  117592. enableOfflineSupport: boolean;
  117593. /**
  117594. * 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)
  117595. **/
  117596. disableManifestCheck: boolean;
  117597. /**
  117598. * Gets the list of created scenes
  117599. */
  117600. scenes: Scene[];
  117601. /**
  117602. * Event raised when a new scene is created
  117603. */
  117604. onNewSceneAddedObservable: Observable<Scene>;
  117605. /**
  117606. * Gets the list of created postprocesses
  117607. */
  117608. postProcesses: PostProcess[];
  117609. /**
  117610. * Gets a boolean indicating if the pointer is currently locked
  117611. */
  117612. isPointerLock: boolean;
  117613. /**
  117614. * Observable event triggered each time the rendering canvas is resized
  117615. */
  117616. onResizeObservable: Observable<Engine>;
  117617. /**
  117618. * Observable event triggered each time the canvas loses focus
  117619. */
  117620. onCanvasBlurObservable: Observable<Engine>;
  117621. /**
  117622. * Observable event triggered each time the canvas gains focus
  117623. */
  117624. onCanvasFocusObservable: Observable<Engine>;
  117625. /**
  117626. * Observable event triggered each time the canvas receives pointerout event
  117627. */
  117628. onCanvasPointerOutObservable: Observable<PointerEvent>;
  117629. /**
  117630. * Observable raised when the engine begins a new frame
  117631. */
  117632. onBeginFrameObservable: Observable<Engine>;
  117633. /**
  117634. * If set, will be used to request the next animation frame for the render loop
  117635. */
  117636. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  117637. /**
  117638. * Observable raised when the engine ends the current frame
  117639. */
  117640. onEndFrameObservable: Observable<Engine>;
  117641. /**
  117642. * Observable raised when the engine is about to compile a shader
  117643. */
  117644. onBeforeShaderCompilationObservable: Observable<Engine>;
  117645. /**
  117646. * Observable raised when the engine has jsut compiled a shader
  117647. */
  117648. onAfterShaderCompilationObservable: Observable<Engine>;
  117649. /**
  117650. * Gets the audio engine
  117651. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  117652. * @ignorenaming
  117653. */
  117654. static audioEngine: IAudioEngine;
  117655. /**
  117656. * Default AudioEngine factory responsible of creating the Audio Engine.
  117657. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  117658. */
  117659. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  117660. /**
  117661. * Default offline support factory responsible of creating a tool used to store data locally.
  117662. * By default, this will create a Database object if the workload has been embedded.
  117663. */
  117664. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  117665. private _loadingScreen;
  117666. private _pointerLockRequested;
  117667. private _rescalePostProcess;
  117668. private _deterministicLockstep;
  117669. private _lockstepMaxSteps;
  117670. private _timeStep;
  117671. protected get _supportsHardwareTextureRescaling(): boolean;
  117672. private _fps;
  117673. private _deltaTime;
  117674. /** @hidden */
  117675. _drawCalls: PerfCounter;
  117676. /** 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 */
  117677. canvasTabIndex: number;
  117678. /**
  117679. * Turn this value on if you want to pause FPS computation when in background
  117680. */
  117681. disablePerformanceMonitorInBackground: boolean;
  117682. private _performanceMonitor;
  117683. /**
  117684. * Gets the performance monitor attached to this engine
  117685. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  117686. */
  117687. get performanceMonitor(): PerformanceMonitor;
  117688. private _onFocus;
  117689. private _onBlur;
  117690. private _onCanvasPointerOut;
  117691. private _onCanvasBlur;
  117692. private _onCanvasFocus;
  117693. private _onFullscreenChange;
  117694. private _onPointerLockChange;
  117695. /**
  117696. * Gets the HTML element used to attach event listeners
  117697. * @returns a HTML element
  117698. */
  117699. getInputElement(): Nullable<HTMLElement>;
  117700. /**
  117701. * Creates a new engine
  117702. * @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
  117703. * @param antialias defines enable antialiasing (default: false)
  117704. * @param options defines further options to be sent to the getContext() function
  117705. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  117706. */
  117707. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  117708. /**
  117709. * Gets current aspect ratio
  117710. * @param viewportOwner defines the camera to use to get the aspect ratio
  117711. * @param useScreen defines if screen size must be used (or the current render target if any)
  117712. * @returns a number defining the aspect ratio
  117713. */
  117714. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  117715. /**
  117716. * Gets current screen aspect ratio
  117717. * @returns a number defining the aspect ratio
  117718. */
  117719. getScreenAspectRatio(): number;
  117720. /**
  117721. * Gets the client rect of the HTML canvas attached with the current webGL context
  117722. * @returns a client rectanglee
  117723. */
  117724. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  117725. /**
  117726. * Gets the client rect of the HTML element used for events
  117727. * @returns a client rectanglee
  117728. */
  117729. getInputElementClientRect(): Nullable<ClientRect>;
  117730. /**
  117731. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  117732. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  117733. * @returns true if engine is in deterministic lock step mode
  117734. */
  117735. isDeterministicLockStep(): boolean;
  117736. /**
  117737. * Gets the max steps when engine is running in deterministic lock step
  117738. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  117739. * @returns the max steps
  117740. */
  117741. getLockstepMaxSteps(): number;
  117742. /**
  117743. * Returns the time in ms between steps when using deterministic lock step.
  117744. * @returns time step in (ms)
  117745. */
  117746. getTimeStep(): number;
  117747. /**
  117748. * Force the mipmap generation for the given render target texture
  117749. * @param texture defines the render target texture to use
  117750. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  117751. */
  117752. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  117753. /** States */
  117754. /**
  117755. * Set various states to the webGL context
  117756. * @param culling defines backface culling state
  117757. * @param zOffset defines the value to apply to zOffset (0 by default)
  117758. * @param force defines if states must be applied even if cache is up to date
  117759. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  117760. */
  117761. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  117762. /**
  117763. * Set the z offset to apply to current rendering
  117764. * @param value defines the offset to apply
  117765. */
  117766. setZOffset(value: number): void;
  117767. /**
  117768. * Gets the current value of the zOffset
  117769. * @returns the current zOffset state
  117770. */
  117771. getZOffset(): number;
  117772. /**
  117773. * Enable or disable depth buffering
  117774. * @param enable defines the state to set
  117775. */
  117776. setDepthBuffer(enable: boolean): void;
  117777. /**
  117778. * Gets a boolean indicating if depth writing is enabled
  117779. * @returns the current depth writing state
  117780. */
  117781. getDepthWrite(): boolean;
  117782. /**
  117783. * Enable or disable depth writing
  117784. * @param enable defines the state to set
  117785. */
  117786. setDepthWrite(enable: boolean): void;
  117787. /**
  117788. * Gets a boolean indicating if stencil buffer is enabled
  117789. * @returns the current stencil buffer state
  117790. */
  117791. getStencilBuffer(): boolean;
  117792. /**
  117793. * Enable or disable the stencil buffer
  117794. * @param enable defines if the stencil buffer must be enabled or disabled
  117795. */
  117796. setStencilBuffer(enable: boolean): void;
  117797. /**
  117798. * Gets the current stencil mask
  117799. * @returns a number defining the new stencil mask to use
  117800. */
  117801. getStencilMask(): number;
  117802. /**
  117803. * Sets the current stencil mask
  117804. * @param mask defines the new stencil mask to use
  117805. */
  117806. setStencilMask(mask: number): void;
  117807. /**
  117808. * Gets the current stencil function
  117809. * @returns a number defining the stencil function to use
  117810. */
  117811. getStencilFunction(): number;
  117812. /**
  117813. * Gets the current stencil reference value
  117814. * @returns a number defining the stencil reference value to use
  117815. */
  117816. getStencilFunctionReference(): number;
  117817. /**
  117818. * Gets the current stencil mask
  117819. * @returns a number defining the stencil mask to use
  117820. */
  117821. getStencilFunctionMask(): number;
  117822. /**
  117823. * Sets the current stencil function
  117824. * @param stencilFunc defines the new stencil function to use
  117825. */
  117826. setStencilFunction(stencilFunc: number): void;
  117827. /**
  117828. * Sets the current stencil reference
  117829. * @param reference defines the new stencil reference to use
  117830. */
  117831. setStencilFunctionReference(reference: number): void;
  117832. /**
  117833. * Sets the current stencil mask
  117834. * @param mask defines the new stencil mask to use
  117835. */
  117836. setStencilFunctionMask(mask: number): void;
  117837. /**
  117838. * Gets the current stencil operation when stencil fails
  117839. * @returns a number defining stencil operation to use when stencil fails
  117840. */
  117841. getStencilOperationFail(): number;
  117842. /**
  117843. * Gets the current stencil operation when depth fails
  117844. * @returns a number defining stencil operation to use when depth fails
  117845. */
  117846. getStencilOperationDepthFail(): number;
  117847. /**
  117848. * Gets the current stencil operation when stencil passes
  117849. * @returns a number defining stencil operation to use when stencil passes
  117850. */
  117851. getStencilOperationPass(): number;
  117852. /**
  117853. * Sets the stencil operation to use when stencil fails
  117854. * @param operation defines the stencil operation to use when stencil fails
  117855. */
  117856. setStencilOperationFail(operation: number): void;
  117857. /**
  117858. * Sets the stencil operation to use when depth fails
  117859. * @param operation defines the stencil operation to use when depth fails
  117860. */
  117861. setStencilOperationDepthFail(operation: number): void;
  117862. /**
  117863. * Sets the stencil operation to use when stencil passes
  117864. * @param operation defines the stencil operation to use when stencil passes
  117865. */
  117866. setStencilOperationPass(operation: number): void;
  117867. /**
  117868. * Sets a boolean indicating if the dithering state is enabled or disabled
  117869. * @param value defines the dithering state
  117870. */
  117871. setDitheringState(value: boolean): void;
  117872. /**
  117873. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  117874. * @param value defines the rasterizer state
  117875. */
  117876. setRasterizerState(value: boolean): void;
  117877. /**
  117878. * Gets the current depth function
  117879. * @returns a number defining the depth function
  117880. */
  117881. getDepthFunction(): Nullable<number>;
  117882. /**
  117883. * Sets the current depth function
  117884. * @param depthFunc defines the function to use
  117885. */
  117886. setDepthFunction(depthFunc: number): void;
  117887. /**
  117888. * Sets the current depth function to GREATER
  117889. */
  117890. setDepthFunctionToGreater(): void;
  117891. /**
  117892. * Sets the current depth function to GEQUAL
  117893. */
  117894. setDepthFunctionToGreaterOrEqual(): void;
  117895. /**
  117896. * Sets the current depth function to LESS
  117897. */
  117898. setDepthFunctionToLess(): void;
  117899. /**
  117900. * Sets the current depth function to LEQUAL
  117901. */
  117902. setDepthFunctionToLessOrEqual(): void;
  117903. private _cachedStencilBuffer;
  117904. private _cachedStencilFunction;
  117905. private _cachedStencilMask;
  117906. private _cachedStencilOperationPass;
  117907. private _cachedStencilOperationFail;
  117908. private _cachedStencilOperationDepthFail;
  117909. private _cachedStencilReference;
  117910. /**
  117911. * Caches the the state of the stencil buffer
  117912. */
  117913. cacheStencilState(): void;
  117914. /**
  117915. * Restores the state of the stencil buffer
  117916. */
  117917. restoreStencilState(): void;
  117918. /**
  117919. * Directly set the WebGL Viewport
  117920. * @param x defines the x coordinate of the viewport (in screen space)
  117921. * @param y defines the y coordinate of the viewport (in screen space)
  117922. * @param width defines the width of the viewport (in screen space)
  117923. * @param height defines the height of the viewport (in screen space)
  117924. * @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
  117925. */
  117926. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  117927. /**
  117928. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  117929. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  117930. * @param y defines the y-coordinate of the corner of the clear rectangle
  117931. * @param width defines the width of the clear rectangle
  117932. * @param height defines the height of the clear rectangle
  117933. * @param clearColor defines the clear color
  117934. */
  117935. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  117936. /**
  117937. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  117938. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  117939. * @param y defines the y-coordinate of the corner of the clear rectangle
  117940. * @param width defines the width of the clear rectangle
  117941. * @param height defines the height of the clear rectangle
  117942. */
  117943. enableScissor(x: number, y: number, width: number, height: number): void;
  117944. /**
  117945. * Disable previously set scissor test rectangle
  117946. */
  117947. disableScissor(): void;
  117948. protected _reportDrawCall(): void;
  117949. /**
  117950. * Initializes a webVR display and starts listening to display change events
  117951. * The onVRDisplayChangedObservable will be notified upon these changes
  117952. * @returns The onVRDisplayChangedObservable
  117953. */
  117954. initWebVR(): Observable<IDisplayChangedEventArgs>;
  117955. /** @hidden */
  117956. _prepareVRComponent(): void;
  117957. /** @hidden */
  117958. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  117959. /** @hidden */
  117960. _submitVRFrame(): void;
  117961. /**
  117962. * Call this function to leave webVR mode
  117963. * Will do nothing if webVR is not supported or if there is no webVR device
  117964. * @see https://doc.babylonjs.com/how_to/webvr_camera
  117965. */
  117966. disableVR(): void;
  117967. /**
  117968. * Gets a boolean indicating that the system is in VR mode and is presenting
  117969. * @returns true if VR mode is engaged
  117970. */
  117971. isVRPresenting(): boolean;
  117972. /** @hidden */
  117973. _requestVRFrame(): void;
  117974. /** @hidden */
  117975. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  117976. /**
  117977. * Gets the source code of the vertex shader associated with a specific webGL program
  117978. * @param program defines the program to use
  117979. * @returns a string containing the source code of the vertex shader associated with the program
  117980. */
  117981. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  117982. /**
  117983. * Gets the source code of the fragment shader associated with a specific webGL program
  117984. * @param program defines the program to use
  117985. * @returns a string containing the source code of the fragment shader associated with the program
  117986. */
  117987. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  117988. /**
  117989. * Sets a depth stencil texture from a render target to the according uniform.
  117990. * @param channel The texture channel
  117991. * @param uniform The uniform to set
  117992. * @param texture The render target texture containing the depth stencil texture to apply
  117993. */
  117994. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  117995. /**
  117996. * Sets a texture to the webGL context from a postprocess
  117997. * @param channel defines the channel to use
  117998. * @param postProcess defines the source postprocess
  117999. */
  118000. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  118001. /**
  118002. * Binds the output of the passed in post process to the texture channel specified
  118003. * @param channel The channel the texture should be bound to
  118004. * @param postProcess The post process which's output should be bound
  118005. */
  118006. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  118007. protected _rebuildBuffers(): void;
  118008. /** @hidden */
  118009. _renderFrame(): void;
  118010. _renderLoop(): void;
  118011. /** @hidden */
  118012. _renderViews(): boolean;
  118013. /**
  118014. * Toggle full screen mode
  118015. * @param requestPointerLock defines if a pointer lock should be requested from the user
  118016. */
  118017. switchFullscreen(requestPointerLock: boolean): void;
  118018. /**
  118019. * Enters full screen mode
  118020. * @param requestPointerLock defines if a pointer lock should be requested from the user
  118021. */
  118022. enterFullscreen(requestPointerLock: boolean): void;
  118023. /**
  118024. * Exits full screen mode
  118025. */
  118026. exitFullscreen(): void;
  118027. /**
  118028. * Enters Pointerlock mode
  118029. */
  118030. enterPointerlock(): void;
  118031. /**
  118032. * Exits Pointerlock mode
  118033. */
  118034. exitPointerlock(): void;
  118035. /**
  118036. * Begin a new frame
  118037. */
  118038. beginFrame(): void;
  118039. /**
  118040. * Enf the current frame
  118041. */
  118042. endFrame(): void;
  118043. resize(): void;
  118044. /**
  118045. * Force a specific size of the canvas
  118046. * @param width defines the new canvas' width
  118047. * @param height defines the new canvas' height
  118048. * @returns true if the size was changed
  118049. */
  118050. setSize(width: number, height: number): boolean;
  118051. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  118052. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  118053. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  118054. _releaseTexture(texture: InternalTexture): void;
  118055. /**
  118056. * @hidden
  118057. * Rescales a texture
  118058. * @param source input texutre
  118059. * @param destination destination texture
  118060. * @param scene scene to use to render the resize
  118061. * @param internalFormat format to use when resizing
  118062. * @param onComplete callback to be called when resize has completed
  118063. */
  118064. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  118065. /**
  118066. * Gets the current framerate
  118067. * @returns a number representing the framerate
  118068. */
  118069. getFps(): number;
  118070. /**
  118071. * Gets the time spent between current and previous frame
  118072. * @returns a number representing the delta time in ms
  118073. */
  118074. getDeltaTime(): number;
  118075. private _measureFps;
  118076. /** @hidden */
  118077. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  118078. /**
  118079. * Updates the sample count of a render target texture
  118080. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  118081. * @param texture defines the texture to update
  118082. * @param samples defines the sample count to set
  118083. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  118084. */
  118085. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  118086. /**
  118087. * Updates a depth texture Comparison Mode and Function.
  118088. * If the comparison Function is equal to 0, the mode will be set to none.
  118089. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  118090. * @param texture The texture to set the comparison function for
  118091. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  118092. */
  118093. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  118094. /**
  118095. * Creates a webGL buffer to use with instanciation
  118096. * @param capacity defines the size of the buffer
  118097. * @returns the webGL buffer
  118098. */
  118099. createInstancesBuffer(capacity: number): DataBuffer;
  118100. /**
  118101. * Delete a webGL buffer used with instanciation
  118102. * @param buffer defines the webGL buffer to delete
  118103. */
  118104. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  118105. private _clientWaitAsync;
  118106. /** @hidden */
  118107. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  118108. dispose(): void;
  118109. private _disableTouchAction;
  118110. /**
  118111. * Display the loading screen
  118112. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  118113. */
  118114. displayLoadingUI(): void;
  118115. /**
  118116. * Hide the loading screen
  118117. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  118118. */
  118119. hideLoadingUI(): void;
  118120. /**
  118121. * Gets the current loading screen object
  118122. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  118123. */
  118124. get loadingScreen(): ILoadingScreen;
  118125. /**
  118126. * Sets the current loading screen object
  118127. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  118128. */
  118129. set loadingScreen(loadingScreen: ILoadingScreen);
  118130. /**
  118131. * Sets the current loading screen text
  118132. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  118133. */
  118134. set loadingUIText(text: string);
  118135. /**
  118136. * Sets the current loading screen background color
  118137. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  118138. */
  118139. set loadingUIBackgroundColor(color: string);
  118140. /** Pointerlock and fullscreen */
  118141. /**
  118142. * Ask the browser to promote the current element to pointerlock mode
  118143. * @param element defines the DOM element to promote
  118144. */
  118145. static _RequestPointerlock(element: HTMLElement): void;
  118146. /**
  118147. * Asks the browser to exit pointerlock mode
  118148. */
  118149. static _ExitPointerlock(): void;
  118150. /**
  118151. * Ask the browser to promote the current element to fullscreen rendering mode
  118152. * @param element defines the DOM element to promote
  118153. */
  118154. static _RequestFullscreen(element: HTMLElement): void;
  118155. /**
  118156. * Asks the browser to exit fullscreen mode
  118157. */
  118158. static _ExitFullscreen(): void;
  118159. }
  118160. }
  118161. declare module BABYLON {
  118162. /**
  118163. * The engine store class is responsible to hold all the instances of Engine and Scene created
  118164. * during the life time of the application.
  118165. */
  118166. export class EngineStore {
  118167. /** Gets the list of created engines */
  118168. static Instances: Engine[];
  118169. /** @hidden */
  118170. static _LastCreatedScene: Nullable<Scene>;
  118171. /**
  118172. * Gets the latest created engine
  118173. */
  118174. static get LastCreatedEngine(): Nullable<Engine>;
  118175. /**
  118176. * Gets the latest created scene
  118177. */
  118178. static get LastCreatedScene(): Nullable<Scene>;
  118179. /**
  118180. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  118181. * @ignorenaming
  118182. */
  118183. static UseFallbackTexture: boolean;
  118184. /**
  118185. * Texture content used if a texture cannot loaded
  118186. * @ignorenaming
  118187. */
  118188. static FallbackTexture: string;
  118189. }
  118190. }
  118191. declare module BABYLON {
  118192. /**
  118193. * Helper class that provides a small promise polyfill
  118194. */
  118195. export class PromisePolyfill {
  118196. /**
  118197. * Static function used to check if the polyfill is required
  118198. * If this is the case then the function will inject the polyfill to window.Promise
  118199. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  118200. */
  118201. static Apply(force?: boolean): void;
  118202. }
  118203. }
  118204. declare module BABYLON {
  118205. /**
  118206. * Interface for screenshot methods with describe argument called `size` as object with options
  118207. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  118208. */
  118209. export interface IScreenshotSize {
  118210. /**
  118211. * number in pixels for canvas height
  118212. */
  118213. height?: number;
  118214. /**
  118215. * multiplier allowing render at a higher or lower resolution
  118216. * If value is defined then height and width will be ignored and taken from camera
  118217. */
  118218. precision?: number;
  118219. /**
  118220. * number in pixels for canvas width
  118221. */
  118222. width?: number;
  118223. }
  118224. }
  118225. declare module BABYLON {
  118226. interface IColor4Like {
  118227. r: float;
  118228. g: float;
  118229. b: float;
  118230. a: float;
  118231. }
  118232. /**
  118233. * Class containing a set of static utilities functions
  118234. */
  118235. export class Tools {
  118236. /**
  118237. * Gets or sets the base URL to use to load assets
  118238. */
  118239. static get BaseUrl(): string;
  118240. static set BaseUrl(value: string);
  118241. /**
  118242. * Enable/Disable Custom HTTP Request Headers globally.
  118243. * default = false
  118244. * @see CustomRequestHeaders
  118245. */
  118246. static UseCustomRequestHeaders: boolean;
  118247. /**
  118248. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  118249. * i.e. when loading files, where the server/service expects an Authorization header
  118250. */
  118251. static CustomRequestHeaders: {
  118252. [key: string]: string;
  118253. };
  118254. /**
  118255. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  118256. */
  118257. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  118258. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  118259. /**
  118260. * Default behaviour for cors in the application.
  118261. * It can be a string if the expected behavior is identical in the entire app.
  118262. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  118263. */
  118264. static get CorsBehavior(): string | ((url: string | string[]) => string);
  118265. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  118266. /**
  118267. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  118268. * @ignorenaming
  118269. */
  118270. static get UseFallbackTexture(): boolean;
  118271. static set UseFallbackTexture(value: boolean);
  118272. /**
  118273. * Use this object to register external classes like custom textures or material
  118274. * to allow the laoders to instantiate them
  118275. */
  118276. static get RegisteredExternalClasses(): {
  118277. [key: string]: Object;
  118278. };
  118279. static set RegisteredExternalClasses(classes: {
  118280. [key: string]: Object;
  118281. });
  118282. /**
  118283. * Texture content used if a texture cannot loaded
  118284. * @ignorenaming
  118285. */
  118286. static get fallbackTexture(): string;
  118287. static set fallbackTexture(value: string);
  118288. /**
  118289. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  118290. * @param u defines the coordinate on X axis
  118291. * @param v defines the coordinate on Y axis
  118292. * @param width defines the width of the source data
  118293. * @param height defines the height of the source data
  118294. * @param pixels defines the source byte array
  118295. * @param color defines the output color
  118296. */
  118297. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  118298. /**
  118299. * Interpolates between a and b via alpha
  118300. * @param a The lower value (returned when alpha = 0)
  118301. * @param b The upper value (returned when alpha = 1)
  118302. * @param alpha The interpolation-factor
  118303. * @return The mixed value
  118304. */
  118305. static Mix(a: number, b: number, alpha: number): number;
  118306. /**
  118307. * Tries to instantiate a new object from a given class name
  118308. * @param className defines the class name to instantiate
  118309. * @returns the new object or null if the system was not able to do the instantiation
  118310. */
  118311. static Instantiate(className: string): any;
  118312. /**
  118313. * Provides a slice function that will work even on IE
  118314. * @param data defines the array to slice
  118315. * @param start defines the start of the data (optional)
  118316. * @param end defines the end of the data (optional)
  118317. * @returns the new sliced array
  118318. */
  118319. static Slice<T>(data: T, start?: number, end?: number): T;
  118320. /**
  118321. * Polyfill for setImmediate
  118322. * @param action defines the action to execute after the current execution block
  118323. */
  118324. static SetImmediate(action: () => void): void;
  118325. /**
  118326. * Function indicating if a number is an exponent of 2
  118327. * @param value defines the value to test
  118328. * @returns true if the value is an exponent of 2
  118329. */
  118330. static IsExponentOfTwo(value: number): boolean;
  118331. private static _tmpFloatArray;
  118332. /**
  118333. * Returns the nearest 32-bit single precision float representation of a Number
  118334. * @param value A Number. If the parameter is of a different type, it will get converted
  118335. * to a number or to NaN if it cannot be converted
  118336. * @returns number
  118337. */
  118338. static FloatRound(value: number): number;
  118339. /**
  118340. * Extracts the filename from a path
  118341. * @param path defines the path to use
  118342. * @returns the filename
  118343. */
  118344. static GetFilename(path: string): string;
  118345. /**
  118346. * Extracts the "folder" part of a path (everything before the filename).
  118347. * @param uri The URI to extract the info from
  118348. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  118349. * @returns The "folder" part of the path
  118350. */
  118351. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  118352. /**
  118353. * Extracts text content from a DOM element hierarchy
  118354. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  118355. */
  118356. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  118357. /**
  118358. * Convert an angle in radians to degrees
  118359. * @param angle defines the angle to convert
  118360. * @returns the angle in degrees
  118361. */
  118362. static ToDegrees(angle: number): number;
  118363. /**
  118364. * Convert an angle in degrees to radians
  118365. * @param angle defines the angle to convert
  118366. * @returns the angle in radians
  118367. */
  118368. static ToRadians(angle: number): number;
  118369. /**
  118370. * Returns an array if obj is not an array
  118371. * @param obj defines the object to evaluate as an array
  118372. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  118373. * @returns either obj directly if obj is an array or a new array containing obj
  118374. */
  118375. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  118376. /**
  118377. * Gets the pointer prefix to use
  118378. * @param engine defines the engine we are finding the prefix for
  118379. * @returns "pointer" if touch is enabled. Else returns "mouse"
  118380. */
  118381. static GetPointerPrefix(engine: Engine): string;
  118382. /**
  118383. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  118384. * @param url define the url we are trying
  118385. * @param element define the dom element where to configure the cors policy
  118386. */
  118387. static SetCorsBehavior(url: string | string[], element: {
  118388. crossOrigin: string | null;
  118389. }): void;
  118390. /**
  118391. * Removes unwanted characters from an url
  118392. * @param url defines the url to clean
  118393. * @returns the cleaned url
  118394. */
  118395. static CleanUrl(url: string): string;
  118396. /**
  118397. * Gets or sets a function used to pre-process url before using them to load assets
  118398. */
  118399. static get PreprocessUrl(): (url: string) => string;
  118400. static set PreprocessUrl(processor: (url: string) => string);
  118401. /**
  118402. * Loads an image as an HTMLImageElement.
  118403. * @param input url string, ArrayBuffer, or Blob to load
  118404. * @param onLoad callback called when the image successfully loads
  118405. * @param onError callback called when the image fails to load
  118406. * @param offlineProvider offline provider for caching
  118407. * @param mimeType optional mime type
  118408. * @returns the HTMLImageElement of the loaded image
  118409. */
  118410. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  118411. /**
  118412. * Loads a file from a url
  118413. * @param url url string, ArrayBuffer, or Blob to load
  118414. * @param onSuccess callback called when the file successfully loads
  118415. * @param onProgress callback called while file is loading (if the server supports this mode)
  118416. * @param offlineProvider defines the offline provider for caching
  118417. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  118418. * @param onError callback called when the file fails to load
  118419. * @returns a file request object
  118420. */
  118421. 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;
  118422. /**
  118423. * Loads a file from a url
  118424. * @param url the file url to load
  118425. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  118426. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  118427. */
  118428. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  118429. /**
  118430. * Load a script (identified by an url). When the url returns, the
  118431. * content of this file is added into a new script element, attached to the DOM (body element)
  118432. * @param scriptUrl defines the url of the script to laod
  118433. * @param onSuccess defines the callback called when the script is loaded
  118434. * @param onError defines the callback to call if an error occurs
  118435. * @param scriptId defines the id of the script element
  118436. */
  118437. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  118438. /**
  118439. * Load an asynchronous script (identified by an url). When the url returns, the
  118440. * content of this file is added into a new script element, attached to the DOM (body element)
  118441. * @param scriptUrl defines the url of the script to laod
  118442. * @param scriptId defines the id of the script element
  118443. * @returns a promise request object
  118444. */
  118445. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  118446. /**
  118447. * Loads a file from a blob
  118448. * @param fileToLoad defines the blob to use
  118449. * @param callback defines the callback to call when data is loaded
  118450. * @param progressCallback defines the callback to call during loading process
  118451. * @returns a file request object
  118452. */
  118453. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  118454. /**
  118455. * Reads a file from a File object
  118456. * @param file defines the file to load
  118457. * @param onSuccess defines the callback to call when data is loaded
  118458. * @param onProgress defines the callback to call during loading process
  118459. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  118460. * @param onError defines the callback to call when an error occurs
  118461. * @returns a file request object
  118462. */
  118463. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  118464. /**
  118465. * Creates a data url from a given string content
  118466. * @param content defines the content to convert
  118467. * @returns the new data url link
  118468. */
  118469. static FileAsURL(content: string): string;
  118470. /**
  118471. * Format the given number to a specific decimal format
  118472. * @param value defines the number to format
  118473. * @param decimals defines the number of decimals to use
  118474. * @returns the formatted string
  118475. */
  118476. static Format(value: number, decimals?: number): string;
  118477. /**
  118478. * Tries to copy an object by duplicating every property
  118479. * @param source defines the source object
  118480. * @param destination defines the target object
  118481. * @param doNotCopyList defines a list of properties to avoid
  118482. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  118483. */
  118484. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  118485. /**
  118486. * Gets a boolean indicating if the given object has no own property
  118487. * @param obj defines the object to test
  118488. * @returns true if object has no own property
  118489. */
  118490. static IsEmpty(obj: any): boolean;
  118491. /**
  118492. * Function used to register events at window level
  118493. * @param windowElement defines the Window object to use
  118494. * @param events defines the events to register
  118495. */
  118496. static RegisterTopRootEvents(windowElement: Window, events: {
  118497. name: string;
  118498. handler: Nullable<(e: FocusEvent) => any>;
  118499. }[]): void;
  118500. /**
  118501. * Function used to unregister events from window level
  118502. * @param windowElement defines the Window object to use
  118503. * @param events defines the events to unregister
  118504. */
  118505. static UnregisterTopRootEvents(windowElement: Window, events: {
  118506. name: string;
  118507. handler: Nullable<(e: FocusEvent) => any>;
  118508. }[]): void;
  118509. /**
  118510. * @ignore
  118511. */
  118512. static _ScreenshotCanvas: HTMLCanvasElement;
  118513. /**
  118514. * Dumps the current bound framebuffer
  118515. * @param width defines the rendering width
  118516. * @param height defines the rendering height
  118517. * @param engine defines the hosting engine
  118518. * @param successCallback defines the callback triggered once the data are available
  118519. * @param mimeType defines the mime type of the result
  118520. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  118521. */
  118522. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  118523. /**
  118524. * Converts the canvas data to blob.
  118525. * This acts as a polyfill for browsers not supporting the to blob function.
  118526. * @param canvas Defines the canvas to extract the data from
  118527. * @param successCallback Defines the callback triggered once the data are available
  118528. * @param mimeType Defines the mime type of the result
  118529. */
  118530. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  118531. /**
  118532. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  118533. * @param successCallback defines the callback triggered once the data are available
  118534. * @param mimeType defines the mime type of the result
  118535. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  118536. */
  118537. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  118538. /**
  118539. * Downloads a blob in the browser
  118540. * @param blob defines the blob to download
  118541. * @param fileName defines the name of the downloaded file
  118542. */
  118543. static Download(blob: Blob, fileName: string): void;
  118544. /**
  118545. * Captures a screenshot of the current rendering
  118546. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  118547. * @param engine defines the rendering engine
  118548. * @param camera defines the source camera
  118549. * @param size This parameter can be set to a single number or to an object with the
  118550. * following (optional) properties: precision, width, height. If a single number is passed,
  118551. * it will be used for both width and height. If an object is passed, the screenshot size
  118552. * will be derived from the parameters. The precision property is a multiplier allowing
  118553. * rendering at a higher or lower resolution
  118554. * @param successCallback defines the callback receives a single parameter which contains the
  118555. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  118556. * src parameter of an <img> to display it
  118557. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  118558. * Check your browser for supported MIME types
  118559. */
  118560. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  118561. /**
  118562. * Captures a screenshot of the current rendering
  118563. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  118564. * @param engine defines the rendering engine
  118565. * @param camera defines the source camera
  118566. * @param size This parameter can be set to a single number or to an object with the
  118567. * following (optional) properties: precision, width, height. If a single number is passed,
  118568. * it will be used for both width and height. If an object is passed, the screenshot size
  118569. * will be derived from the parameters. The precision property is a multiplier allowing
  118570. * rendering at a higher or lower resolution
  118571. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  118572. * Check your browser for supported MIME types
  118573. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  118574. * to the src parameter of an <img> to display it
  118575. */
  118576. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  118577. /**
  118578. * Generates an image screenshot from the specified camera.
  118579. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  118580. * @param engine The engine to use for rendering
  118581. * @param camera The camera to use for rendering
  118582. * @param size This parameter can be set to a single number or to an object with the
  118583. * following (optional) properties: precision, width, height. If a single number is passed,
  118584. * it will be used for both width and height. If an object is passed, the screenshot size
  118585. * will be derived from the parameters. The precision property is a multiplier allowing
  118586. * rendering at a higher or lower resolution
  118587. * @param successCallback The callback receives a single parameter which contains the
  118588. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  118589. * src parameter of an <img> to display it
  118590. * @param mimeType The MIME type of the screenshot image (default: image/png).
  118591. * Check your browser for supported MIME types
  118592. * @param samples Texture samples (default: 1)
  118593. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  118594. * @param fileName A name for for the downloaded file.
  118595. */
  118596. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  118597. /**
  118598. * Generates an image screenshot from the specified camera.
  118599. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  118600. * @param engine The engine to use for rendering
  118601. * @param camera The camera to use for rendering
  118602. * @param size This parameter can be set to a single number or to an object with the
  118603. * following (optional) properties: precision, width, height. If a single number is passed,
  118604. * it will be used for both width and height. If an object is passed, the screenshot size
  118605. * will be derived from the parameters. The precision property is a multiplier allowing
  118606. * rendering at a higher or lower resolution
  118607. * @param mimeType The MIME type of the screenshot image (default: image/png).
  118608. * Check your browser for supported MIME types
  118609. * @param samples Texture samples (default: 1)
  118610. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  118611. * @param fileName A name for for the downloaded file.
  118612. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  118613. * to the src parameter of an <img> to display it
  118614. */
  118615. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  118616. /**
  118617. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  118618. * Be aware Math.random() could cause collisions, but:
  118619. * "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"
  118620. * @returns a pseudo random id
  118621. */
  118622. static RandomId(): string;
  118623. /**
  118624. * Test if the given uri is a base64 string
  118625. * @param uri The uri to test
  118626. * @return True if the uri is a base64 string or false otherwise
  118627. */
  118628. static IsBase64(uri: string): boolean;
  118629. /**
  118630. * Decode the given base64 uri.
  118631. * @param uri The uri to decode
  118632. * @return The decoded base64 data.
  118633. */
  118634. static DecodeBase64(uri: string): ArrayBuffer;
  118635. /**
  118636. * Gets the absolute url.
  118637. * @param url the input url
  118638. * @return the absolute url
  118639. */
  118640. static GetAbsoluteUrl(url: string): string;
  118641. /**
  118642. * No log
  118643. */
  118644. static readonly NoneLogLevel: number;
  118645. /**
  118646. * Only message logs
  118647. */
  118648. static readonly MessageLogLevel: number;
  118649. /**
  118650. * Only warning logs
  118651. */
  118652. static readonly WarningLogLevel: number;
  118653. /**
  118654. * Only error logs
  118655. */
  118656. static readonly ErrorLogLevel: number;
  118657. /**
  118658. * All logs
  118659. */
  118660. static readonly AllLogLevel: number;
  118661. /**
  118662. * Gets a value indicating the number of loading errors
  118663. * @ignorenaming
  118664. */
  118665. static get errorsCount(): number;
  118666. /**
  118667. * Callback called when a new log is added
  118668. */
  118669. static OnNewCacheEntry: (entry: string) => void;
  118670. /**
  118671. * Log a message to the console
  118672. * @param message defines the message to log
  118673. */
  118674. static Log(message: string): void;
  118675. /**
  118676. * Write a warning message to the console
  118677. * @param message defines the message to log
  118678. */
  118679. static Warn(message: string): void;
  118680. /**
  118681. * Write an error message to the console
  118682. * @param message defines the message to log
  118683. */
  118684. static Error(message: string): void;
  118685. /**
  118686. * Gets current log cache (list of logs)
  118687. */
  118688. static get LogCache(): string;
  118689. /**
  118690. * Clears the log cache
  118691. */
  118692. static ClearLogCache(): void;
  118693. /**
  118694. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  118695. */
  118696. static set LogLevels(level: number);
  118697. /**
  118698. * Checks if the window object exists
  118699. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  118700. */
  118701. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  118702. /**
  118703. * No performance log
  118704. */
  118705. static readonly PerformanceNoneLogLevel: number;
  118706. /**
  118707. * Use user marks to log performance
  118708. */
  118709. static readonly PerformanceUserMarkLogLevel: number;
  118710. /**
  118711. * Log performance to the console
  118712. */
  118713. static readonly PerformanceConsoleLogLevel: number;
  118714. private static _performance;
  118715. /**
  118716. * Sets the current performance log level
  118717. */
  118718. static set PerformanceLogLevel(level: number);
  118719. private static _StartPerformanceCounterDisabled;
  118720. private static _EndPerformanceCounterDisabled;
  118721. private static _StartUserMark;
  118722. private static _EndUserMark;
  118723. private static _StartPerformanceConsole;
  118724. private static _EndPerformanceConsole;
  118725. /**
  118726. * Starts a performance counter
  118727. */
  118728. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  118729. /**
  118730. * Ends a specific performance coutner
  118731. */
  118732. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  118733. /**
  118734. * Gets either window.performance.now() if supported or Date.now() else
  118735. */
  118736. static get Now(): number;
  118737. /**
  118738. * This method will return the name of the class used to create the instance of the given object.
  118739. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  118740. * @param object the object to get the class name from
  118741. * @param isType defines if the object is actually a type
  118742. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  118743. */
  118744. static GetClassName(object: any, isType?: boolean): string;
  118745. /**
  118746. * Gets the first element of an array satisfying a given predicate
  118747. * @param array defines the array to browse
  118748. * @param predicate defines the predicate to use
  118749. * @returns null if not found or the element
  118750. */
  118751. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  118752. /**
  118753. * This method will return the name of the full name of the class, including its owning module (if any).
  118754. * 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).
  118755. * @param object the object to get the class name from
  118756. * @param isType defines if the object is actually a type
  118757. * @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.
  118758. * @ignorenaming
  118759. */
  118760. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  118761. /**
  118762. * Returns a promise that resolves after the given amount of time.
  118763. * @param delay Number of milliseconds to delay
  118764. * @returns Promise that resolves after the given amount of time
  118765. */
  118766. static DelayAsync(delay: number): Promise<void>;
  118767. /**
  118768. * Utility function to detect if the current user agent is Safari
  118769. * @returns whether or not the current user agent is safari
  118770. */
  118771. static IsSafari(): boolean;
  118772. }
  118773. /**
  118774. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  118775. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  118776. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  118777. * @param name The name of the class, case should be preserved
  118778. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  118779. */
  118780. export function className(name: string, module?: string): (target: Object) => void;
  118781. /**
  118782. * An implementation of a loop for asynchronous functions.
  118783. */
  118784. export class AsyncLoop {
  118785. /**
  118786. * Defines the number of iterations for the loop
  118787. */
  118788. iterations: number;
  118789. /**
  118790. * Defines the current index of the loop.
  118791. */
  118792. index: number;
  118793. private _done;
  118794. private _fn;
  118795. private _successCallback;
  118796. /**
  118797. * Constructor.
  118798. * @param iterations the number of iterations.
  118799. * @param func the function to run each iteration
  118800. * @param successCallback the callback that will be called upon succesful execution
  118801. * @param offset starting offset.
  118802. */
  118803. constructor(
  118804. /**
  118805. * Defines the number of iterations for the loop
  118806. */
  118807. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  118808. /**
  118809. * Execute the next iteration. Must be called after the last iteration was finished.
  118810. */
  118811. executeNext(): void;
  118812. /**
  118813. * Break the loop and run the success callback.
  118814. */
  118815. breakLoop(): void;
  118816. /**
  118817. * Create and run an async loop.
  118818. * @param iterations the number of iterations.
  118819. * @param fn the function to run each iteration
  118820. * @param successCallback the callback that will be called upon succesful execution
  118821. * @param offset starting offset.
  118822. * @returns the created async loop object
  118823. */
  118824. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  118825. /**
  118826. * A for-loop that will run a given number of iterations synchronous and the rest async.
  118827. * @param iterations total number of iterations
  118828. * @param syncedIterations number of synchronous iterations in each async iteration.
  118829. * @param fn the function to call each iteration.
  118830. * @param callback a success call back that will be called when iterating stops.
  118831. * @param breakFunction a break condition (optional)
  118832. * @param timeout timeout settings for the setTimeout function. default - 0.
  118833. * @returns the created async loop object
  118834. */
  118835. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  118836. }
  118837. }
  118838. declare module BABYLON {
  118839. /**
  118840. * This class implement a typical dictionary using a string as key and the generic type T as value.
  118841. * The underlying implementation relies on an associative array to ensure the best performances.
  118842. * The value can be anything including 'null' but except 'undefined'
  118843. */
  118844. export class StringDictionary<T> {
  118845. /**
  118846. * This will clear this dictionary and copy the content from the 'source' one.
  118847. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  118848. * @param source the dictionary to take the content from and copy to this dictionary
  118849. */
  118850. copyFrom(source: StringDictionary<T>): void;
  118851. /**
  118852. * Get a value based from its key
  118853. * @param key the given key to get the matching value from
  118854. * @return the value if found, otherwise undefined is returned
  118855. */
  118856. get(key: string): T | undefined;
  118857. /**
  118858. * Get a value from its key or add it if it doesn't exist.
  118859. * This method will ensure you that a given key/data will be present in the dictionary.
  118860. * @param key the given key to get the matching value from
  118861. * @param factory the factory that will create the value if the key is not present in the dictionary.
  118862. * The factory will only be invoked if there's no data for the given key.
  118863. * @return the value corresponding to the key.
  118864. */
  118865. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  118866. /**
  118867. * Get a value from its key if present in the dictionary otherwise add it
  118868. * @param key the key to get the value from
  118869. * @param val if there's no such key/value pair in the dictionary add it with this value
  118870. * @return the value corresponding to the key
  118871. */
  118872. getOrAdd(key: string, val: T): T;
  118873. /**
  118874. * Check if there's a given key in the dictionary
  118875. * @param key the key to check for
  118876. * @return true if the key is present, false otherwise
  118877. */
  118878. contains(key: string): boolean;
  118879. /**
  118880. * Add a new key and its corresponding value
  118881. * @param key the key to add
  118882. * @param value the value corresponding to the key
  118883. * @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
  118884. */
  118885. add(key: string, value: T): boolean;
  118886. /**
  118887. * Update a specific value associated to a key
  118888. * @param key defines the key to use
  118889. * @param value defines the value to store
  118890. * @returns true if the value was updated (or false if the key was not found)
  118891. */
  118892. set(key: string, value: T): boolean;
  118893. /**
  118894. * Get the element of the given key and remove it from the dictionary
  118895. * @param key defines the key to search
  118896. * @returns the value associated with the key or null if not found
  118897. */
  118898. getAndRemove(key: string): Nullable<T>;
  118899. /**
  118900. * Remove a key/value from the dictionary.
  118901. * @param key the key to remove
  118902. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  118903. */
  118904. remove(key: string): boolean;
  118905. /**
  118906. * Clear the whole content of the dictionary
  118907. */
  118908. clear(): void;
  118909. /**
  118910. * Gets the current count
  118911. */
  118912. get count(): number;
  118913. /**
  118914. * Execute a callback on each key/val of the dictionary.
  118915. * Note that you can remove any element in this dictionary in the callback implementation
  118916. * @param callback the callback to execute on a given key/value pair
  118917. */
  118918. forEach(callback: (key: string, val: T) => void): void;
  118919. /**
  118920. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  118921. * If the callback returns null or undefined the method will iterate to the next key/value pair
  118922. * Note that you can remove any element in this dictionary in the callback implementation
  118923. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  118924. * @returns the first item
  118925. */
  118926. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  118927. private _count;
  118928. private _data;
  118929. }
  118930. }
  118931. declare module BABYLON {
  118932. /** @hidden */
  118933. export interface ICollisionCoordinator {
  118934. createCollider(): Collider;
  118935. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  118936. init(scene: Scene): void;
  118937. }
  118938. /** @hidden */
  118939. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  118940. private _scene;
  118941. private _scaledPosition;
  118942. private _scaledVelocity;
  118943. private _finalPosition;
  118944. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  118945. createCollider(): Collider;
  118946. init(scene: Scene): void;
  118947. private _collideWithWorld;
  118948. }
  118949. }
  118950. declare module BABYLON {
  118951. /**
  118952. * Class used to manage all inputs for the scene.
  118953. */
  118954. export class InputManager {
  118955. /** The distance in pixel that you have to move to prevent some events */
  118956. static DragMovementThreshold: number;
  118957. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  118958. static LongPressDelay: number;
  118959. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  118960. static DoubleClickDelay: number;
  118961. /** If you need to check double click without raising a single click at first click, enable this flag */
  118962. static ExclusiveDoubleClickMode: boolean;
  118963. /** 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. */
  118964. private _alreadyAttached;
  118965. private _wheelEventName;
  118966. private _onPointerMove;
  118967. private _onPointerDown;
  118968. private _onPointerUp;
  118969. private _initClickEvent;
  118970. private _initActionManager;
  118971. private _delayedSimpleClick;
  118972. private _delayedSimpleClickTimeout;
  118973. private _previousDelayedSimpleClickTimeout;
  118974. private _meshPickProceed;
  118975. private _previousButtonPressed;
  118976. private _currentPickResult;
  118977. private _previousPickResult;
  118978. private _totalPointersPressed;
  118979. private _doubleClickOccured;
  118980. private _pointerOverMesh;
  118981. private _pickedDownMesh;
  118982. private _pickedUpMesh;
  118983. private _pointerX;
  118984. private _pointerY;
  118985. private _unTranslatedPointerX;
  118986. private _unTranslatedPointerY;
  118987. private _startingPointerPosition;
  118988. private _previousStartingPointerPosition;
  118989. private _startingPointerTime;
  118990. private _previousStartingPointerTime;
  118991. private _pointerCaptures;
  118992. private _meshUnderPointerId;
  118993. private _onKeyDown;
  118994. private _onKeyUp;
  118995. private _onCanvasFocusObserver;
  118996. private _onCanvasBlurObserver;
  118997. private _scene;
  118998. /**
  118999. * Creates a new InputManager
  119000. * @param scene defines the hosting scene
  119001. */
  119002. constructor(scene: Scene);
  119003. /**
  119004. * Gets the mesh that is currently under the pointer
  119005. */
  119006. get meshUnderPointer(): Nullable<AbstractMesh>;
  119007. /**
  119008. * When using more than one pointer (for example in XR) you can get the mesh under the specific pointer
  119009. * @param pointerId the pointer id to use
  119010. * @returns The mesh under this pointer id or null if not found
  119011. */
  119012. getMeshUnderPointerByPointerId(pointerId: number): Nullable<AbstractMesh>;
  119013. /**
  119014. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  119015. */
  119016. get unTranslatedPointer(): Vector2;
  119017. /**
  119018. * Gets or sets the current on-screen X position of the pointer
  119019. */
  119020. get pointerX(): number;
  119021. set pointerX(value: number);
  119022. /**
  119023. * Gets or sets the current on-screen Y position of the pointer
  119024. */
  119025. get pointerY(): number;
  119026. set pointerY(value: number);
  119027. private _updatePointerPosition;
  119028. private _processPointerMove;
  119029. private _setRayOnPointerInfo;
  119030. private _checkPrePointerObservable;
  119031. /**
  119032. * Use this method to simulate a pointer move on a mesh
  119033. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  119034. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  119035. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  119036. */
  119037. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  119038. /**
  119039. * Use this method to simulate a pointer down on a mesh
  119040. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  119041. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  119042. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  119043. */
  119044. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  119045. private _processPointerDown;
  119046. /** @hidden */
  119047. _isPointerSwiping(): boolean;
  119048. /**
  119049. * Use this method to simulate a pointer up on a mesh
  119050. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  119051. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  119052. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  119053. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  119054. */
  119055. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  119056. private _processPointerUp;
  119057. /**
  119058. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  119059. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  119060. * @returns true if the pointer was captured
  119061. */
  119062. isPointerCaptured(pointerId?: number): boolean;
  119063. /**
  119064. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  119065. * @param attachUp defines if you want to attach events to pointerup
  119066. * @param attachDown defines if you want to attach events to pointerdown
  119067. * @param attachMove defines if you want to attach events to pointermove
  119068. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  119069. */
  119070. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  119071. /**
  119072. * Detaches all event handlers
  119073. */
  119074. detachControl(): void;
  119075. /**
  119076. * Force the value of meshUnderPointer
  119077. * @param mesh defines the mesh to use
  119078. * @param pointerId optional pointer id when using more than one pointer. Defaults to 0
  119079. */
  119080. setPointerOverMesh(mesh: Nullable<AbstractMesh>, pointerId?: number): void;
  119081. /**
  119082. * Gets the mesh under the pointer
  119083. * @returns a Mesh or null if no mesh is under the pointer
  119084. */
  119085. getPointerOverMesh(): Nullable<AbstractMesh>;
  119086. }
  119087. }
  119088. declare module BABYLON {
  119089. /**
  119090. * This class defines the direct association between an animation and a target
  119091. */
  119092. export class TargetedAnimation {
  119093. /**
  119094. * Animation to perform
  119095. */
  119096. animation: Animation;
  119097. /**
  119098. * Target to animate
  119099. */
  119100. target: any;
  119101. /**
  119102. * Returns the string "TargetedAnimation"
  119103. * @returns "TargetedAnimation"
  119104. */
  119105. getClassName(): string;
  119106. /**
  119107. * Serialize the object
  119108. * @returns the JSON object representing the current entity
  119109. */
  119110. serialize(): any;
  119111. }
  119112. /**
  119113. * Use this class to create coordinated animations on multiple targets
  119114. */
  119115. export class AnimationGroup implements IDisposable {
  119116. /** The name of the animation group */
  119117. name: string;
  119118. private _scene;
  119119. private _targetedAnimations;
  119120. private _animatables;
  119121. private _from;
  119122. private _to;
  119123. private _isStarted;
  119124. private _isPaused;
  119125. private _speedRatio;
  119126. private _loopAnimation;
  119127. private _isAdditive;
  119128. /**
  119129. * Gets or sets the unique id of the node
  119130. */
  119131. uniqueId: number;
  119132. /**
  119133. * This observable will notify when one animation have ended
  119134. */
  119135. onAnimationEndObservable: Observable<TargetedAnimation>;
  119136. /**
  119137. * Observer raised when one animation loops
  119138. */
  119139. onAnimationLoopObservable: Observable<TargetedAnimation>;
  119140. /**
  119141. * Observer raised when all animations have looped
  119142. */
  119143. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  119144. /**
  119145. * This observable will notify when all animations have ended.
  119146. */
  119147. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  119148. /**
  119149. * This observable will notify when all animations have paused.
  119150. */
  119151. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  119152. /**
  119153. * This observable will notify when all animations are playing.
  119154. */
  119155. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  119156. /**
  119157. * Gets the first frame
  119158. */
  119159. get from(): number;
  119160. /**
  119161. * Gets the last frame
  119162. */
  119163. get to(): number;
  119164. /**
  119165. * Define if the animations are started
  119166. */
  119167. get isStarted(): boolean;
  119168. /**
  119169. * Gets a value indicating that the current group is playing
  119170. */
  119171. get isPlaying(): boolean;
  119172. /**
  119173. * Gets or sets the speed ratio to use for all animations
  119174. */
  119175. get speedRatio(): number;
  119176. /**
  119177. * Gets or sets the speed ratio to use for all animations
  119178. */
  119179. set speedRatio(value: number);
  119180. /**
  119181. * Gets or sets if all animations should loop or not
  119182. */
  119183. get loopAnimation(): boolean;
  119184. set loopAnimation(value: boolean);
  119185. /**
  119186. * Gets or sets if all animations should be evaluated additively
  119187. */
  119188. get isAdditive(): boolean;
  119189. set isAdditive(value: boolean);
  119190. /**
  119191. * Gets the targeted animations for this animation group
  119192. */
  119193. get targetedAnimations(): Array<TargetedAnimation>;
  119194. /**
  119195. * returning the list of animatables controlled by this animation group.
  119196. */
  119197. get animatables(): Array<Animatable>;
  119198. /**
  119199. * Gets the list of target animations
  119200. */
  119201. get children(): TargetedAnimation[];
  119202. /**
  119203. * Instantiates a new Animation Group.
  119204. * This helps managing several animations at once.
  119205. * @see https://doc.babylonjs.com/how_to/group
  119206. * @param name Defines the name of the group
  119207. * @param scene Defines the scene the group belongs to
  119208. */
  119209. constructor(
  119210. /** The name of the animation group */
  119211. name: string, scene?: Nullable<Scene>);
  119212. /**
  119213. * Add an animation (with its target) in the group
  119214. * @param animation defines the animation we want to add
  119215. * @param target defines the target of the animation
  119216. * @returns the TargetedAnimation object
  119217. */
  119218. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  119219. /**
  119220. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  119221. * It can add constant keys at begin or end
  119222. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  119223. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  119224. * @returns the animation group
  119225. */
  119226. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  119227. private _animationLoopCount;
  119228. private _animationLoopFlags;
  119229. private _processLoop;
  119230. /**
  119231. * Start all animations on given targets
  119232. * @param loop defines if animations must loop
  119233. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  119234. * @param from defines the from key (optional)
  119235. * @param to defines the to key (optional)
  119236. * @param isAdditive defines the additive state for the resulting animatables (optional)
  119237. * @returns the current animation group
  119238. */
  119239. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  119240. /**
  119241. * Pause all animations
  119242. * @returns the animation group
  119243. */
  119244. pause(): AnimationGroup;
  119245. /**
  119246. * Play all animations to initial state
  119247. * This function will start() the animations if they were not started or will restart() them if they were paused
  119248. * @param loop defines if animations must loop
  119249. * @returns the animation group
  119250. */
  119251. play(loop?: boolean): AnimationGroup;
  119252. /**
  119253. * Reset all animations to initial state
  119254. * @returns the animation group
  119255. */
  119256. reset(): AnimationGroup;
  119257. /**
  119258. * Restart animations from key 0
  119259. * @returns the animation group
  119260. */
  119261. restart(): AnimationGroup;
  119262. /**
  119263. * Stop all animations
  119264. * @returns the animation group
  119265. */
  119266. stop(): AnimationGroup;
  119267. /**
  119268. * Set animation weight for all animatables
  119269. * @param weight defines the weight to use
  119270. * @return the animationGroup
  119271. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  119272. */
  119273. setWeightForAllAnimatables(weight: number): AnimationGroup;
  119274. /**
  119275. * Synchronize and normalize all animatables with a source animatable
  119276. * @param root defines the root animatable to synchronize with
  119277. * @return the animationGroup
  119278. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  119279. */
  119280. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  119281. /**
  119282. * Goes to a specific frame in this animation group
  119283. * @param frame the frame number to go to
  119284. * @return the animationGroup
  119285. */
  119286. goToFrame(frame: number): AnimationGroup;
  119287. /**
  119288. * Dispose all associated resources
  119289. */
  119290. dispose(): void;
  119291. private _checkAnimationGroupEnded;
  119292. /**
  119293. * Clone the current animation group and returns a copy
  119294. * @param newName defines the name of the new group
  119295. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  119296. * @returns the new aniamtion group
  119297. */
  119298. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  119299. /**
  119300. * Serializes the animationGroup to an object
  119301. * @returns Serialized object
  119302. */
  119303. serialize(): any;
  119304. /**
  119305. * Returns a new AnimationGroup object parsed from the source provided.
  119306. * @param parsedAnimationGroup defines the source
  119307. * @param scene defines the scene that will receive the animationGroup
  119308. * @returns a new AnimationGroup
  119309. */
  119310. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  119311. /**
  119312. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  119313. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  119314. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  119315. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  119316. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  119317. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  119318. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  119319. */
  119320. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  119321. /**
  119322. * Returns the string "AnimationGroup"
  119323. * @returns "AnimationGroup"
  119324. */
  119325. getClassName(): string;
  119326. /**
  119327. * Creates a detailled string about the object
  119328. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  119329. * @returns a string representing the object
  119330. */
  119331. toString(fullDetails?: boolean): string;
  119332. }
  119333. }
  119334. declare module BABYLON {
  119335. /**
  119336. * Define an interface for all classes that will hold resources
  119337. */
  119338. export interface IDisposable {
  119339. /**
  119340. * Releases all held resources
  119341. */
  119342. dispose(): void;
  119343. }
  119344. /** Interface defining initialization parameters for Scene class */
  119345. export interface SceneOptions {
  119346. /**
  119347. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  119348. * It will improve performance when the number of geometries becomes important.
  119349. */
  119350. useGeometryUniqueIdsMap?: boolean;
  119351. /**
  119352. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  119353. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  119354. */
  119355. useMaterialMeshMap?: boolean;
  119356. /**
  119357. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  119358. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  119359. */
  119360. useClonedMeshMap?: boolean;
  119361. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  119362. virtual?: boolean;
  119363. }
  119364. /**
  119365. * Represents a scene to be rendered by the engine.
  119366. * @see https://doc.babylonjs.com/features/scene
  119367. */
  119368. export class Scene extends AbstractScene implements IAnimatable, IClipPlanesHolder {
  119369. /** The fog is deactivated */
  119370. static readonly FOGMODE_NONE: number;
  119371. /** The fog density is following an exponential function */
  119372. static readonly FOGMODE_EXP: number;
  119373. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  119374. static readonly FOGMODE_EXP2: number;
  119375. /** The fog density is following a linear function. */
  119376. static readonly FOGMODE_LINEAR: number;
  119377. /**
  119378. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  119379. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  119380. */
  119381. static MinDeltaTime: number;
  119382. /**
  119383. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  119384. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  119385. */
  119386. static MaxDeltaTime: number;
  119387. /**
  119388. * Factory used to create the default material.
  119389. * @param name The name of the material to create
  119390. * @param scene The scene to create the material for
  119391. * @returns The default material
  119392. */
  119393. static DefaultMaterialFactory(scene: Scene): Material;
  119394. /**
  119395. * Factory used to create the a collision coordinator.
  119396. * @returns The collision coordinator
  119397. */
  119398. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  119399. /** @hidden */
  119400. _inputManager: InputManager;
  119401. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  119402. cameraToUseForPointers: Nullable<Camera>;
  119403. /** @hidden */
  119404. readonly _isScene: boolean;
  119405. /** @hidden */
  119406. _blockEntityCollection: boolean;
  119407. /**
  119408. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  119409. */
  119410. autoClear: boolean;
  119411. /**
  119412. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  119413. */
  119414. autoClearDepthAndStencil: boolean;
  119415. /**
  119416. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  119417. */
  119418. clearColor: Color4;
  119419. /**
  119420. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  119421. */
  119422. ambientColor: Color3;
  119423. /**
  119424. * This is use to store the default BRDF lookup for PBR materials in your scene.
  119425. * It should only be one of the following (if not the default embedded one):
  119426. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  119427. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  119428. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  119429. * The material properties need to be setup according to the type of texture in use.
  119430. */
  119431. environmentBRDFTexture: BaseTexture;
  119432. /**
  119433. * Texture used in all pbr material as the reflection texture.
  119434. * As in the majority of the scene they are the same (exception for multi room and so on),
  119435. * this is easier to reference from here than from all the materials.
  119436. */
  119437. get environmentTexture(): Nullable<BaseTexture>;
  119438. /**
  119439. * Texture used in all pbr material as the reflection texture.
  119440. * As in the majority of the scene they are the same (exception for multi room and so on),
  119441. * this is easier to set here than in all the materials.
  119442. */
  119443. set environmentTexture(value: Nullable<BaseTexture>);
  119444. /** @hidden */
  119445. protected _environmentIntensity: number;
  119446. /**
  119447. * Intensity of the environment in all pbr material.
  119448. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  119449. * As in the majority of the scene they are the same (exception for multi room and so on),
  119450. * this is easier to reference from here than from all the materials.
  119451. */
  119452. get environmentIntensity(): number;
  119453. /**
  119454. * Intensity of the environment in all pbr material.
  119455. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  119456. * As in the majority of the scene they are the same (exception for multi room and so on),
  119457. * this is easier to set here than in all the materials.
  119458. */
  119459. set environmentIntensity(value: number);
  119460. /** @hidden */
  119461. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  119462. /**
  119463. * Default image processing configuration used either in the rendering
  119464. * Forward main pass or through the imageProcessingPostProcess if present.
  119465. * As in the majority of the scene they are the same (exception for multi camera),
  119466. * this is easier to reference from here than from all the materials and post process.
  119467. *
  119468. * No setter as we it is a shared configuration, you can set the values instead.
  119469. */
  119470. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  119471. private _forceWireframe;
  119472. /**
  119473. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  119474. */
  119475. set forceWireframe(value: boolean);
  119476. get forceWireframe(): boolean;
  119477. private _skipFrustumClipping;
  119478. /**
  119479. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  119480. */
  119481. set skipFrustumClipping(value: boolean);
  119482. get skipFrustumClipping(): boolean;
  119483. private _forcePointsCloud;
  119484. /**
  119485. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  119486. */
  119487. set forcePointsCloud(value: boolean);
  119488. get forcePointsCloud(): boolean;
  119489. /**
  119490. * Gets or sets the active clipplane 1
  119491. */
  119492. clipPlane: Nullable<Plane>;
  119493. /**
  119494. * Gets or sets the active clipplane 2
  119495. */
  119496. clipPlane2: Nullable<Plane>;
  119497. /**
  119498. * Gets or sets the active clipplane 3
  119499. */
  119500. clipPlane3: Nullable<Plane>;
  119501. /**
  119502. * Gets or sets the active clipplane 4
  119503. */
  119504. clipPlane4: Nullable<Plane>;
  119505. /**
  119506. * Gets or sets the active clipplane 5
  119507. */
  119508. clipPlane5: Nullable<Plane>;
  119509. /**
  119510. * Gets or sets the active clipplane 6
  119511. */
  119512. clipPlane6: Nullable<Plane>;
  119513. /**
  119514. * Gets or sets a boolean indicating if animations are enabled
  119515. */
  119516. animationsEnabled: boolean;
  119517. private _animationPropertiesOverride;
  119518. /**
  119519. * Gets or sets the animation properties override
  119520. */
  119521. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  119522. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  119523. /**
  119524. * Gets or sets a boolean indicating if a constant deltatime has to be used
  119525. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  119526. */
  119527. useConstantAnimationDeltaTime: boolean;
  119528. /**
  119529. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  119530. * Please note that it requires to run a ray cast through the scene on every frame
  119531. */
  119532. constantlyUpdateMeshUnderPointer: boolean;
  119533. /**
  119534. * Defines the HTML cursor to use when hovering over interactive elements
  119535. */
  119536. hoverCursor: string;
  119537. /**
  119538. * Defines the HTML default cursor to use (empty by default)
  119539. */
  119540. defaultCursor: string;
  119541. /**
  119542. * Defines whether cursors are handled by the scene.
  119543. */
  119544. doNotHandleCursors: boolean;
  119545. /**
  119546. * This is used to call preventDefault() on pointer down
  119547. * in order to block unwanted artifacts like system double clicks
  119548. */
  119549. preventDefaultOnPointerDown: boolean;
  119550. /**
  119551. * This is used to call preventDefault() on pointer up
  119552. * in order to block unwanted artifacts like system double clicks
  119553. */
  119554. preventDefaultOnPointerUp: boolean;
  119555. /**
  119556. * Gets or sets user defined metadata
  119557. */
  119558. metadata: any;
  119559. /**
  119560. * For internal use only. Please do not use.
  119561. */
  119562. reservedDataStore: any;
  119563. /**
  119564. * Gets the name of the plugin used to load this scene (null by default)
  119565. */
  119566. loadingPluginName: string;
  119567. /**
  119568. * Use this array to add regular expressions used to disable offline support for specific urls
  119569. */
  119570. disableOfflineSupportExceptionRules: RegExp[];
  119571. /**
  119572. * An event triggered when the scene is disposed.
  119573. */
  119574. onDisposeObservable: Observable<Scene>;
  119575. private _onDisposeObserver;
  119576. /** Sets a function to be executed when this scene is disposed. */
  119577. set onDispose(callback: () => void);
  119578. /**
  119579. * An event triggered before rendering the scene (right after animations and physics)
  119580. */
  119581. onBeforeRenderObservable: Observable<Scene>;
  119582. private _onBeforeRenderObserver;
  119583. /** Sets a function to be executed before rendering this scene */
  119584. set beforeRender(callback: Nullable<() => void>);
  119585. /**
  119586. * An event triggered after rendering the scene
  119587. */
  119588. onAfterRenderObservable: Observable<Scene>;
  119589. /**
  119590. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  119591. */
  119592. onAfterRenderCameraObservable: Observable<Camera>;
  119593. private _onAfterRenderObserver;
  119594. /** Sets a function to be executed after rendering this scene */
  119595. set afterRender(callback: Nullable<() => void>);
  119596. /**
  119597. * An event triggered before animating the scene
  119598. */
  119599. onBeforeAnimationsObservable: Observable<Scene>;
  119600. /**
  119601. * An event triggered after animations processing
  119602. */
  119603. onAfterAnimationsObservable: Observable<Scene>;
  119604. /**
  119605. * An event triggered before draw calls are ready to be sent
  119606. */
  119607. onBeforeDrawPhaseObservable: Observable<Scene>;
  119608. /**
  119609. * An event triggered after draw calls have been sent
  119610. */
  119611. onAfterDrawPhaseObservable: Observable<Scene>;
  119612. /**
  119613. * An event triggered when the scene is ready
  119614. */
  119615. onReadyObservable: Observable<Scene>;
  119616. /**
  119617. * An event triggered before rendering a camera
  119618. */
  119619. onBeforeCameraRenderObservable: Observable<Camera>;
  119620. private _onBeforeCameraRenderObserver;
  119621. /** Sets a function to be executed before rendering a camera*/
  119622. set beforeCameraRender(callback: () => void);
  119623. /**
  119624. * An event triggered after rendering a camera
  119625. */
  119626. onAfterCameraRenderObservable: Observable<Camera>;
  119627. private _onAfterCameraRenderObserver;
  119628. /** Sets a function to be executed after rendering a camera*/
  119629. set afterCameraRender(callback: () => void);
  119630. /**
  119631. * An event triggered when active meshes evaluation is about to start
  119632. */
  119633. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  119634. /**
  119635. * An event triggered when active meshes evaluation is done
  119636. */
  119637. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  119638. /**
  119639. * An event triggered when particles rendering is about to start
  119640. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  119641. */
  119642. onBeforeParticlesRenderingObservable: Observable<Scene>;
  119643. /**
  119644. * An event triggered when particles rendering is done
  119645. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  119646. */
  119647. onAfterParticlesRenderingObservable: Observable<Scene>;
  119648. /**
  119649. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  119650. */
  119651. onDataLoadedObservable: Observable<Scene>;
  119652. /**
  119653. * An event triggered when a camera is created
  119654. */
  119655. onNewCameraAddedObservable: Observable<Camera>;
  119656. /**
  119657. * An event triggered when a camera is removed
  119658. */
  119659. onCameraRemovedObservable: Observable<Camera>;
  119660. /**
  119661. * An event triggered when a light is created
  119662. */
  119663. onNewLightAddedObservable: Observable<Light>;
  119664. /**
  119665. * An event triggered when a light is removed
  119666. */
  119667. onLightRemovedObservable: Observable<Light>;
  119668. /**
  119669. * An event triggered when a geometry is created
  119670. */
  119671. onNewGeometryAddedObservable: Observable<Geometry>;
  119672. /**
  119673. * An event triggered when a geometry is removed
  119674. */
  119675. onGeometryRemovedObservable: Observable<Geometry>;
  119676. /**
  119677. * An event triggered when a transform node is created
  119678. */
  119679. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  119680. /**
  119681. * An event triggered when a transform node is removed
  119682. */
  119683. onTransformNodeRemovedObservable: Observable<TransformNode>;
  119684. /**
  119685. * An event triggered when a mesh is created
  119686. */
  119687. onNewMeshAddedObservable: Observable<AbstractMesh>;
  119688. /**
  119689. * An event triggered when a mesh is removed
  119690. */
  119691. onMeshRemovedObservable: Observable<AbstractMesh>;
  119692. /**
  119693. * An event triggered when a skeleton is created
  119694. */
  119695. onNewSkeletonAddedObservable: Observable<Skeleton>;
  119696. /**
  119697. * An event triggered when a skeleton is removed
  119698. */
  119699. onSkeletonRemovedObservable: Observable<Skeleton>;
  119700. /**
  119701. * An event triggered when a material is created
  119702. */
  119703. onNewMaterialAddedObservable: Observable<Material>;
  119704. /**
  119705. * An event triggered when a material is removed
  119706. */
  119707. onMaterialRemovedObservable: Observable<Material>;
  119708. /**
  119709. * An event triggered when a texture is created
  119710. */
  119711. onNewTextureAddedObservable: Observable<BaseTexture>;
  119712. /**
  119713. * An event triggered when a texture is removed
  119714. */
  119715. onTextureRemovedObservable: Observable<BaseTexture>;
  119716. /**
  119717. * An event triggered when render targets are about to be rendered
  119718. * Can happen multiple times per frame.
  119719. */
  119720. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  119721. /**
  119722. * An event triggered when render targets were rendered.
  119723. * Can happen multiple times per frame.
  119724. */
  119725. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  119726. /**
  119727. * An event triggered before calculating deterministic simulation step
  119728. */
  119729. onBeforeStepObservable: Observable<Scene>;
  119730. /**
  119731. * An event triggered after calculating deterministic simulation step
  119732. */
  119733. onAfterStepObservable: Observable<Scene>;
  119734. /**
  119735. * An event triggered when the activeCamera property is updated
  119736. */
  119737. onActiveCameraChanged: Observable<Scene>;
  119738. /**
  119739. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  119740. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  119741. * 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)
  119742. */
  119743. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  119744. /**
  119745. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  119746. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  119747. * 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)
  119748. */
  119749. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  119750. /**
  119751. * This Observable will when a mesh has been imported into the scene.
  119752. */
  119753. onMeshImportedObservable: Observable<AbstractMesh>;
  119754. /**
  119755. * This Observable will when an animation file has been imported into the scene.
  119756. */
  119757. onAnimationFileImportedObservable: Observable<Scene>;
  119758. /**
  119759. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  119760. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  119761. */
  119762. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  119763. /** @hidden */
  119764. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  119765. /**
  119766. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  119767. */
  119768. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  119769. /**
  119770. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  119771. */
  119772. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  119773. /**
  119774. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  119775. */
  119776. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  119777. /** Callback called when a pointer move is detected */
  119778. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  119779. /** Callback called when a pointer down is detected */
  119780. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  119781. /** Callback called when a pointer up is detected */
  119782. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  119783. /** Callback called when a pointer pick is detected */
  119784. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  119785. /**
  119786. * 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).
  119787. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  119788. */
  119789. onPrePointerObservable: Observable<PointerInfoPre>;
  119790. /**
  119791. * Observable event triggered each time an input event is received from the rendering canvas
  119792. */
  119793. onPointerObservable: Observable<PointerInfo>;
  119794. /**
  119795. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  119796. */
  119797. get unTranslatedPointer(): Vector2;
  119798. /**
  119799. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  119800. */
  119801. static get DragMovementThreshold(): number;
  119802. static set DragMovementThreshold(value: number);
  119803. /**
  119804. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  119805. */
  119806. static get LongPressDelay(): number;
  119807. static set LongPressDelay(value: number);
  119808. /**
  119809. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  119810. */
  119811. static get DoubleClickDelay(): number;
  119812. static set DoubleClickDelay(value: number);
  119813. /** If you need to check double click without raising a single click at first click, enable this flag */
  119814. static get ExclusiveDoubleClickMode(): boolean;
  119815. static set ExclusiveDoubleClickMode(value: boolean);
  119816. /** @hidden */
  119817. _mirroredCameraPosition: Nullable<Vector3>;
  119818. /**
  119819. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  119820. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  119821. */
  119822. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  119823. /**
  119824. * Observable event triggered each time an keyboard event is received from the hosting window
  119825. */
  119826. onKeyboardObservable: Observable<KeyboardInfo>;
  119827. private _useRightHandedSystem;
  119828. /**
  119829. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  119830. */
  119831. set useRightHandedSystem(value: boolean);
  119832. get useRightHandedSystem(): boolean;
  119833. private _timeAccumulator;
  119834. private _currentStepId;
  119835. private _currentInternalStep;
  119836. /**
  119837. * Sets the step Id used by deterministic lock step
  119838. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  119839. * @param newStepId defines the step Id
  119840. */
  119841. setStepId(newStepId: number): void;
  119842. /**
  119843. * Gets the step Id used by deterministic lock step
  119844. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  119845. * @returns the step Id
  119846. */
  119847. getStepId(): number;
  119848. /**
  119849. * Gets the internal step used by deterministic lock step
  119850. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  119851. * @returns the internal step
  119852. */
  119853. getInternalStep(): number;
  119854. private _fogEnabled;
  119855. /**
  119856. * Gets or sets a boolean indicating if fog is enabled on this scene
  119857. * @see https://doc.babylonjs.com/babylon101/environment#fog
  119858. * (Default is true)
  119859. */
  119860. set fogEnabled(value: boolean);
  119861. get fogEnabled(): boolean;
  119862. private _fogMode;
  119863. /**
  119864. * Gets or sets the fog mode to use
  119865. * @see https://doc.babylonjs.com/babylon101/environment#fog
  119866. * | mode | value |
  119867. * | --- | --- |
  119868. * | FOGMODE_NONE | 0 |
  119869. * | FOGMODE_EXP | 1 |
  119870. * | FOGMODE_EXP2 | 2 |
  119871. * | FOGMODE_LINEAR | 3 |
  119872. */
  119873. set fogMode(value: number);
  119874. get fogMode(): number;
  119875. /**
  119876. * Gets or sets the fog color to use
  119877. * @see https://doc.babylonjs.com/babylon101/environment#fog
  119878. * (Default is Color3(0.2, 0.2, 0.3))
  119879. */
  119880. fogColor: Color3;
  119881. /**
  119882. * Gets or sets the fog density to use
  119883. * @see https://doc.babylonjs.com/babylon101/environment#fog
  119884. * (Default is 0.1)
  119885. */
  119886. fogDensity: number;
  119887. /**
  119888. * Gets or sets the fog start distance to use
  119889. * @see https://doc.babylonjs.com/babylon101/environment#fog
  119890. * (Default is 0)
  119891. */
  119892. fogStart: number;
  119893. /**
  119894. * Gets or sets the fog end distance to use
  119895. * @see https://doc.babylonjs.com/babylon101/environment#fog
  119896. * (Default is 1000)
  119897. */
  119898. fogEnd: number;
  119899. /**
  119900. * Flag indicating that the frame buffer binding is handled by another component
  119901. */
  119902. prePass: boolean;
  119903. private _shadowsEnabled;
  119904. /**
  119905. * Gets or sets a boolean indicating if shadows are enabled on this scene
  119906. */
  119907. set shadowsEnabled(value: boolean);
  119908. get shadowsEnabled(): boolean;
  119909. private _lightsEnabled;
  119910. /**
  119911. * Gets or sets a boolean indicating if lights are enabled on this scene
  119912. */
  119913. set lightsEnabled(value: boolean);
  119914. get lightsEnabled(): boolean;
  119915. /** All of the active cameras added to this scene. */
  119916. activeCameras: Camera[];
  119917. /** @hidden */
  119918. _activeCamera: Nullable<Camera>;
  119919. /** Gets or sets the current active camera */
  119920. get activeCamera(): Nullable<Camera>;
  119921. set activeCamera(value: Nullable<Camera>);
  119922. private _defaultMaterial;
  119923. /** The default material used on meshes when no material is affected */
  119924. get defaultMaterial(): Material;
  119925. /** The default material used on meshes when no material is affected */
  119926. set defaultMaterial(value: Material);
  119927. private _texturesEnabled;
  119928. /**
  119929. * Gets or sets a boolean indicating if textures are enabled on this scene
  119930. */
  119931. set texturesEnabled(value: boolean);
  119932. get texturesEnabled(): boolean;
  119933. /**
  119934. * Gets or sets a boolean indicating if physic engines are enabled on this scene
  119935. */
  119936. physicsEnabled: boolean;
  119937. /**
  119938. * Gets or sets a boolean indicating if particles are enabled on this scene
  119939. */
  119940. particlesEnabled: boolean;
  119941. /**
  119942. * Gets or sets a boolean indicating if sprites are enabled on this scene
  119943. */
  119944. spritesEnabled: boolean;
  119945. private _skeletonsEnabled;
  119946. /**
  119947. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  119948. */
  119949. set skeletonsEnabled(value: boolean);
  119950. get skeletonsEnabled(): boolean;
  119951. /**
  119952. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  119953. */
  119954. lensFlaresEnabled: boolean;
  119955. /**
  119956. * Gets or sets a boolean indicating if collisions are enabled on this scene
  119957. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  119958. */
  119959. collisionsEnabled: boolean;
  119960. private _collisionCoordinator;
  119961. /** @hidden */
  119962. get collisionCoordinator(): ICollisionCoordinator;
  119963. /**
  119964. * Defines the gravity applied to this scene (used only for collisions)
  119965. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  119966. */
  119967. gravity: Vector3;
  119968. /**
  119969. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  119970. */
  119971. postProcessesEnabled: boolean;
  119972. /**
  119973. * Gets the current postprocess manager
  119974. */
  119975. postProcessManager: PostProcessManager;
  119976. /**
  119977. * Gets or sets a boolean indicating if render targets are enabled on this scene
  119978. */
  119979. renderTargetsEnabled: boolean;
  119980. /**
  119981. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  119982. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  119983. */
  119984. dumpNextRenderTargets: boolean;
  119985. /**
  119986. * The list of user defined render targets added to the scene
  119987. */
  119988. customRenderTargets: RenderTargetTexture[];
  119989. /**
  119990. * Defines if texture loading must be delayed
  119991. * If true, textures will only be loaded when they need to be rendered
  119992. */
  119993. useDelayedTextureLoading: boolean;
  119994. /**
  119995. * Gets the list of meshes imported to the scene through SceneLoader
  119996. */
  119997. importedMeshesFiles: String[];
  119998. /**
  119999. * Gets or sets a boolean indicating if probes are enabled on this scene
  120000. */
  120001. probesEnabled: boolean;
  120002. /**
  120003. * Gets or sets the current offline provider to use to store scene data
  120004. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  120005. */
  120006. offlineProvider: IOfflineProvider;
  120007. /**
  120008. * Gets or sets the action manager associated with the scene
  120009. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  120010. */
  120011. actionManager: AbstractActionManager;
  120012. private _meshesForIntersections;
  120013. /**
  120014. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  120015. */
  120016. proceduralTexturesEnabled: boolean;
  120017. private _engine;
  120018. private _totalVertices;
  120019. /** @hidden */
  120020. _activeIndices: PerfCounter;
  120021. /** @hidden */
  120022. _activeParticles: PerfCounter;
  120023. /** @hidden */
  120024. _activeBones: PerfCounter;
  120025. private _animationRatio;
  120026. /** @hidden */
  120027. _animationTimeLast: number;
  120028. /** @hidden */
  120029. _animationTime: number;
  120030. /**
  120031. * Gets or sets a general scale for animation speed
  120032. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  120033. */
  120034. animationTimeScale: number;
  120035. /** @hidden */
  120036. _cachedMaterial: Nullable<Material>;
  120037. /** @hidden */
  120038. _cachedEffect: Nullable<Effect>;
  120039. /** @hidden */
  120040. _cachedVisibility: Nullable<number>;
  120041. private _renderId;
  120042. private _frameId;
  120043. private _executeWhenReadyTimeoutId;
  120044. private _intermediateRendering;
  120045. private _viewUpdateFlag;
  120046. private _projectionUpdateFlag;
  120047. /** @hidden */
  120048. _toBeDisposed: Nullable<IDisposable>[];
  120049. private _activeRequests;
  120050. /** @hidden */
  120051. _pendingData: any[];
  120052. private _isDisposed;
  120053. /**
  120054. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  120055. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  120056. */
  120057. dispatchAllSubMeshesOfActiveMeshes: boolean;
  120058. private _activeMeshes;
  120059. private _processedMaterials;
  120060. private _renderTargets;
  120061. /** @hidden */
  120062. _activeParticleSystems: SmartArray<IParticleSystem>;
  120063. private _activeSkeletons;
  120064. private _softwareSkinnedMeshes;
  120065. private _renderingManager;
  120066. /** @hidden */
  120067. _activeAnimatables: Animatable[];
  120068. private _transformMatrix;
  120069. private _sceneUbo;
  120070. /** @hidden */
  120071. _viewMatrix: Matrix;
  120072. private _projectionMatrix;
  120073. /** @hidden */
  120074. _forcedViewPosition: Nullable<Vector3>;
  120075. /** @hidden */
  120076. _frustumPlanes: Plane[];
  120077. /**
  120078. * Gets the list of frustum planes (built from the active camera)
  120079. */
  120080. get frustumPlanes(): Plane[];
  120081. /**
  120082. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  120083. * This is useful if there are more lights that the maximum simulteanous authorized
  120084. */
  120085. requireLightSorting: boolean;
  120086. /** @hidden */
  120087. readonly useMaterialMeshMap: boolean;
  120088. /** @hidden */
  120089. readonly useClonedMeshMap: boolean;
  120090. private _externalData;
  120091. private _uid;
  120092. /**
  120093. * @hidden
  120094. * Backing store of defined scene components.
  120095. */
  120096. _components: ISceneComponent[];
  120097. /**
  120098. * @hidden
  120099. * Backing store of defined scene components.
  120100. */
  120101. _serializableComponents: ISceneSerializableComponent[];
  120102. /**
  120103. * List of components to register on the next registration step.
  120104. */
  120105. private _transientComponents;
  120106. /**
  120107. * Registers the transient components if needed.
  120108. */
  120109. private _registerTransientComponents;
  120110. /**
  120111. * @hidden
  120112. * Add a component to the scene.
  120113. * Note that the ccomponent could be registered on th next frame if this is called after
  120114. * the register component stage.
  120115. * @param component Defines the component to add to the scene
  120116. */
  120117. _addComponent(component: ISceneComponent): void;
  120118. /**
  120119. * @hidden
  120120. * Gets a component from the scene.
  120121. * @param name defines the name of the component to retrieve
  120122. * @returns the component or null if not present
  120123. */
  120124. _getComponent(name: string): Nullable<ISceneComponent>;
  120125. /**
  120126. * @hidden
  120127. * Defines the actions happening before camera updates.
  120128. */
  120129. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  120130. /**
  120131. * @hidden
  120132. * Defines the actions happening before clear the canvas.
  120133. */
  120134. _beforeClearStage: Stage<SimpleStageAction>;
  120135. /**
  120136. * @hidden
  120137. * Defines the actions when collecting render targets for the frame.
  120138. */
  120139. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  120140. /**
  120141. * @hidden
  120142. * Defines the actions happening for one camera in the frame.
  120143. */
  120144. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  120145. /**
  120146. * @hidden
  120147. * Defines the actions happening during the per mesh ready checks.
  120148. */
  120149. _isReadyForMeshStage: Stage<MeshStageAction>;
  120150. /**
  120151. * @hidden
  120152. * Defines the actions happening before evaluate active mesh checks.
  120153. */
  120154. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  120155. /**
  120156. * @hidden
  120157. * Defines the actions happening during the evaluate sub mesh checks.
  120158. */
  120159. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  120160. /**
  120161. * @hidden
  120162. * Defines the actions happening during the active mesh stage.
  120163. */
  120164. _activeMeshStage: Stage<ActiveMeshStageAction>;
  120165. /**
  120166. * @hidden
  120167. * Defines the actions happening during the per camera render target step.
  120168. */
  120169. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  120170. /**
  120171. * @hidden
  120172. * Defines the actions happening just before the active camera is drawing.
  120173. */
  120174. _beforeCameraDrawStage: Stage<CameraStageAction>;
  120175. /**
  120176. * @hidden
  120177. * Defines the actions happening just before a render target is drawing.
  120178. */
  120179. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  120180. /**
  120181. * @hidden
  120182. * Defines the actions happening just before a rendering group is drawing.
  120183. */
  120184. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  120185. /**
  120186. * @hidden
  120187. * Defines the actions happening just before a mesh is drawing.
  120188. */
  120189. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  120190. /**
  120191. * @hidden
  120192. * Defines the actions happening just after a mesh has been drawn.
  120193. */
  120194. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  120195. /**
  120196. * @hidden
  120197. * Defines the actions happening just after a rendering group has been drawn.
  120198. */
  120199. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  120200. /**
  120201. * @hidden
  120202. * Defines the actions happening just after the active camera has been drawn.
  120203. */
  120204. _afterCameraDrawStage: Stage<CameraStageAction>;
  120205. /**
  120206. * @hidden
  120207. * Defines the actions happening just after a render target has been drawn.
  120208. */
  120209. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  120210. /**
  120211. * @hidden
  120212. * Defines the actions happening just after rendering all cameras and computing intersections.
  120213. */
  120214. _afterRenderStage: Stage<SimpleStageAction>;
  120215. /**
  120216. * @hidden
  120217. * Defines the actions happening when a pointer move event happens.
  120218. */
  120219. _pointerMoveStage: Stage<PointerMoveStageAction>;
  120220. /**
  120221. * @hidden
  120222. * Defines the actions happening when a pointer down event happens.
  120223. */
  120224. _pointerDownStage: Stage<PointerUpDownStageAction>;
  120225. /**
  120226. * @hidden
  120227. * Defines the actions happening when a pointer up event happens.
  120228. */
  120229. _pointerUpStage: Stage<PointerUpDownStageAction>;
  120230. /**
  120231. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  120232. */
  120233. private geometriesByUniqueId;
  120234. /**
  120235. * Creates a new Scene
  120236. * @param engine defines the engine to use to render this scene
  120237. * @param options defines the scene options
  120238. */
  120239. constructor(engine: Engine, options?: SceneOptions);
  120240. /**
  120241. * Gets a string identifying the name of the class
  120242. * @returns "Scene" string
  120243. */
  120244. getClassName(): string;
  120245. private _defaultMeshCandidates;
  120246. /**
  120247. * @hidden
  120248. */
  120249. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  120250. private _defaultSubMeshCandidates;
  120251. /**
  120252. * @hidden
  120253. */
  120254. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  120255. /**
  120256. * Sets the default candidate providers for the scene.
  120257. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  120258. * and getCollidingSubMeshCandidates to their default function
  120259. */
  120260. setDefaultCandidateProviders(): void;
  120261. /**
  120262. * Gets the mesh that is currently under the pointer
  120263. */
  120264. get meshUnderPointer(): Nullable<AbstractMesh>;
  120265. /**
  120266. * Gets or sets the current on-screen X position of the pointer
  120267. */
  120268. get pointerX(): number;
  120269. set pointerX(value: number);
  120270. /**
  120271. * Gets or sets the current on-screen Y position of the pointer
  120272. */
  120273. get pointerY(): number;
  120274. set pointerY(value: number);
  120275. /**
  120276. * Gets the cached material (ie. the latest rendered one)
  120277. * @returns the cached material
  120278. */
  120279. getCachedMaterial(): Nullable<Material>;
  120280. /**
  120281. * Gets the cached effect (ie. the latest rendered one)
  120282. * @returns the cached effect
  120283. */
  120284. getCachedEffect(): Nullable<Effect>;
  120285. /**
  120286. * Gets the cached visibility state (ie. the latest rendered one)
  120287. * @returns the cached visibility state
  120288. */
  120289. getCachedVisibility(): Nullable<number>;
  120290. /**
  120291. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  120292. * @param material defines the current material
  120293. * @param effect defines the current effect
  120294. * @param visibility defines the current visibility state
  120295. * @returns true if one parameter is not cached
  120296. */
  120297. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  120298. /**
  120299. * Gets the engine associated with the scene
  120300. * @returns an Engine
  120301. */
  120302. getEngine(): Engine;
  120303. /**
  120304. * Gets the total number of vertices rendered per frame
  120305. * @returns the total number of vertices rendered per frame
  120306. */
  120307. getTotalVertices(): number;
  120308. /**
  120309. * Gets the performance counter for total vertices
  120310. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  120311. */
  120312. get totalVerticesPerfCounter(): PerfCounter;
  120313. /**
  120314. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  120315. * @returns the total number of active indices rendered per frame
  120316. */
  120317. getActiveIndices(): number;
  120318. /**
  120319. * Gets the performance counter for active indices
  120320. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  120321. */
  120322. get totalActiveIndicesPerfCounter(): PerfCounter;
  120323. /**
  120324. * Gets the total number of active particles rendered per frame
  120325. * @returns the total number of active particles rendered per frame
  120326. */
  120327. getActiveParticles(): number;
  120328. /**
  120329. * Gets the performance counter for active particles
  120330. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  120331. */
  120332. get activeParticlesPerfCounter(): PerfCounter;
  120333. /**
  120334. * Gets the total number of active bones rendered per frame
  120335. * @returns the total number of active bones rendered per frame
  120336. */
  120337. getActiveBones(): number;
  120338. /**
  120339. * Gets the performance counter for active bones
  120340. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  120341. */
  120342. get activeBonesPerfCounter(): PerfCounter;
  120343. /**
  120344. * Gets the array of active meshes
  120345. * @returns an array of AbstractMesh
  120346. */
  120347. getActiveMeshes(): SmartArray<AbstractMesh>;
  120348. /**
  120349. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  120350. * @returns a number
  120351. */
  120352. getAnimationRatio(): number;
  120353. /**
  120354. * Gets an unique Id for the current render phase
  120355. * @returns a number
  120356. */
  120357. getRenderId(): number;
  120358. /**
  120359. * Gets an unique Id for the current frame
  120360. * @returns a number
  120361. */
  120362. getFrameId(): number;
  120363. /** Call this function if you want to manually increment the render Id*/
  120364. incrementRenderId(): void;
  120365. private _createUbo;
  120366. /**
  120367. * Use this method to simulate a pointer move on a mesh
  120368. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  120369. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  120370. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  120371. * @returns the current scene
  120372. */
  120373. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  120374. /**
  120375. * Use this method to simulate a pointer down on a mesh
  120376. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  120377. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  120378. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  120379. * @returns the current scene
  120380. */
  120381. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  120382. /**
  120383. * Use this method to simulate a pointer up on a mesh
  120384. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  120385. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  120386. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  120387. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  120388. * @returns the current scene
  120389. */
  120390. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  120391. /**
  120392. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  120393. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  120394. * @returns true if the pointer was captured
  120395. */
  120396. isPointerCaptured(pointerId?: number): boolean;
  120397. /**
  120398. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  120399. * @param attachUp defines if you want to attach events to pointerup
  120400. * @param attachDown defines if you want to attach events to pointerdown
  120401. * @param attachMove defines if you want to attach events to pointermove
  120402. */
  120403. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  120404. /** Detaches all event handlers*/
  120405. detachControl(): void;
  120406. /**
  120407. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  120408. * Delay loaded resources are not taking in account
  120409. * @return true if all required resources are ready
  120410. */
  120411. isReady(): boolean;
  120412. /** Resets all cached information relative to material (including effect and visibility) */
  120413. resetCachedMaterial(): void;
  120414. /**
  120415. * Registers a function to be called before every frame render
  120416. * @param func defines the function to register
  120417. */
  120418. registerBeforeRender(func: () => void): void;
  120419. /**
  120420. * Unregisters a function called before every frame render
  120421. * @param func defines the function to unregister
  120422. */
  120423. unregisterBeforeRender(func: () => void): void;
  120424. /**
  120425. * Registers a function to be called after every frame render
  120426. * @param func defines the function to register
  120427. */
  120428. registerAfterRender(func: () => void): void;
  120429. /**
  120430. * Unregisters a function called after every frame render
  120431. * @param func defines the function to unregister
  120432. */
  120433. unregisterAfterRender(func: () => void): void;
  120434. private _executeOnceBeforeRender;
  120435. /**
  120436. * The provided function will run before render once and will be disposed afterwards.
  120437. * A timeout delay can be provided so that the function will be executed in N ms.
  120438. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  120439. * @param func The function to be executed.
  120440. * @param timeout optional delay in ms
  120441. */
  120442. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  120443. /** @hidden */
  120444. _addPendingData(data: any): void;
  120445. /** @hidden */
  120446. _removePendingData(data: any): void;
  120447. /**
  120448. * Returns the number of items waiting to be loaded
  120449. * @returns the number of items waiting to be loaded
  120450. */
  120451. getWaitingItemsCount(): number;
  120452. /**
  120453. * Returns a boolean indicating if the scene is still loading data
  120454. */
  120455. get isLoading(): boolean;
  120456. /**
  120457. * Registers a function to be executed when the scene is ready
  120458. * @param {Function} func - the function to be executed
  120459. */
  120460. executeWhenReady(func: () => void): void;
  120461. /**
  120462. * Returns a promise that resolves when the scene is ready
  120463. * @returns A promise that resolves when the scene is ready
  120464. */
  120465. whenReadyAsync(): Promise<void>;
  120466. /** @hidden */
  120467. _checkIsReady(): void;
  120468. /**
  120469. * Gets all animatable attached to the scene
  120470. */
  120471. get animatables(): Animatable[];
  120472. /**
  120473. * Resets the last animation time frame.
  120474. * Useful to override when animations start running when loading a scene for the first time.
  120475. */
  120476. resetLastAnimationTimeFrame(): void;
  120477. /**
  120478. * Gets the current view matrix
  120479. * @returns a Matrix
  120480. */
  120481. getViewMatrix(): Matrix;
  120482. /**
  120483. * Gets the current projection matrix
  120484. * @returns a Matrix
  120485. */
  120486. getProjectionMatrix(): Matrix;
  120487. /**
  120488. * Gets the current transform matrix
  120489. * @returns a Matrix made of View * Projection
  120490. */
  120491. getTransformMatrix(): Matrix;
  120492. /**
  120493. * Sets the current transform matrix
  120494. * @param viewL defines the View matrix to use
  120495. * @param projectionL defines the Projection matrix to use
  120496. * @param viewR defines the right View matrix to use (if provided)
  120497. * @param projectionR defines the right Projection matrix to use (if provided)
  120498. */
  120499. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  120500. /**
  120501. * Gets the uniform buffer used to store scene data
  120502. * @returns a UniformBuffer
  120503. */
  120504. getSceneUniformBuffer(): UniformBuffer;
  120505. /**
  120506. * Gets an unique (relatively to the current scene) Id
  120507. * @returns an unique number for the scene
  120508. */
  120509. getUniqueId(): number;
  120510. /**
  120511. * Add a mesh to the list of scene's meshes
  120512. * @param newMesh defines the mesh to add
  120513. * @param recursive if all child meshes should also be added to the scene
  120514. */
  120515. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  120516. /**
  120517. * Remove a mesh for the list of scene's meshes
  120518. * @param toRemove defines the mesh to remove
  120519. * @param recursive if all child meshes should also be removed from the scene
  120520. * @returns the index where the mesh was in the mesh list
  120521. */
  120522. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  120523. /**
  120524. * Add a transform node to the list of scene's transform nodes
  120525. * @param newTransformNode defines the transform node to add
  120526. */
  120527. addTransformNode(newTransformNode: TransformNode): void;
  120528. /**
  120529. * Remove a transform node for the list of scene's transform nodes
  120530. * @param toRemove defines the transform node to remove
  120531. * @returns the index where the transform node was in the transform node list
  120532. */
  120533. removeTransformNode(toRemove: TransformNode): number;
  120534. /**
  120535. * Remove a skeleton for the list of scene's skeletons
  120536. * @param toRemove defines the skeleton to remove
  120537. * @returns the index where the skeleton was in the skeleton list
  120538. */
  120539. removeSkeleton(toRemove: Skeleton): number;
  120540. /**
  120541. * Remove a morph target for the list of scene's morph targets
  120542. * @param toRemove defines the morph target to remove
  120543. * @returns the index where the morph target was in the morph target list
  120544. */
  120545. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  120546. /**
  120547. * Remove a light for the list of scene's lights
  120548. * @param toRemove defines the light to remove
  120549. * @returns the index where the light was in the light list
  120550. */
  120551. removeLight(toRemove: Light): number;
  120552. /**
  120553. * Remove a camera for the list of scene's cameras
  120554. * @param toRemove defines the camera to remove
  120555. * @returns the index where the camera was in the camera list
  120556. */
  120557. removeCamera(toRemove: Camera): number;
  120558. /**
  120559. * Remove a particle system for the list of scene's particle systems
  120560. * @param toRemove defines the particle system to remove
  120561. * @returns the index where the particle system was in the particle system list
  120562. */
  120563. removeParticleSystem(toRemove: IParticleSystem): number;
  120564. /**
  120565. * Remove a animation for the list of scene's animations
  120566. * @param toRemove defines the animation to remove
  120567. * @returns the index where the animation was in the animation list
  120568. */
  120569. removeAnimation(toRemove: Animation): number;
  120570. /**
  120571. * Will stop the animation of the given target
  120572. * @param target - the target
  120573. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  120574. * @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)
  120575. */
  120576. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  120577. /**
  120578. * Removes the given animation group from this scene.
  120579. * @param toRemove The animation group to remove
  120580. * @returns The index of the removed animation group
  120581. */
  120582. removeAnimationGroup(toRemove: AnimationGroup): number;
  120583. /**
  120584. * Removes the given multi-material from this scene.
  120585. * @param toRemove The multi-material to remove
  120586. * @returns The index of the removed multi-material
  120587. */
  120588. removeMultiMaterial(toRemove: MultiMaterial): number;
  120589. /**
  120590. * Removes the given material from this scene.
  120591. * @param toRemove The material to remove
  120592. * @returns The index of the removed material
  120593. */
  120594. removeMaterial(toRemove: Material): number;
  120595. /**
  120596. * Removes the given action manager from this scene.
  120597. * @param toRemove The action manager to remove
  120598. * @returns The index of the removed action manager
  120599. */
  120600. removeActionManager(toRemove: AbstractActionManager): number;
  120601. /**
  120602. * Removes the given texture from this scene.
  120603. * @param toRemove The texture to remove
  120604. * @returns The index of the removed texture
  120605. */
  120606. removeTexture(toRemove: BaseTexture): number;
  120607. /**
  120608. * Adds the given light to this scene
  120609. * @param newLight The light to add
  120610. */
  120611. addLight(newLight: Light): void;
  120612. /**
  120613. * Sorts the list list based on light priorities
  120614. */
  120615. sortLightsByPriority(): void;
  120616. /**
  120617. * Adds the given camera to this scene
  120618. * @param newCamera The camera to add
  120619. */
  120620. addCamera(newCamera: Camera): void;
  120621. /**
  120622. * Adds the given skeleton to this scene
  120623. * @param newSkeleton The skeleton to add
  120624. */
  120625. addSkeleton(newSkeleton: Skeleton): void;
  120626. /**
  120627. * Adds the given particle system to this scene
  120628. * @param newParticleSystem The particle system to add
  120629. */
  120630. addParticleSystem(newParticleSystem: IParticleSystem): void;
  120631. /**
  120632. * Adds the given animation to this scene
  120633. * @param newAnimation The animation to add
  120634. */
  120635. addAnimation(newAnimation: Animation): void;
  120636. /**
  120637. * Adds the given animation group to this scene.
  120638. * @param newAnimationGroup The animation group to add
  120639. */
  120640. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  120641. /**
  120642. * Adds the given multi-material to this scene
  120643. * @param newMultiMaterial The multi-material to add
  120644. */
  120645. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  120646. /**
  120647. * Adds the given material to this scene
  120648. * @param newMaterial The material to add
  120649. */
  120650. addMaterial(newMaterial: Material): void;
  120651. /**
  120652. * Adds the given morph target to this scene
  120653. * @param newMorphTargetManager The morph target to add
  120654. */
  120655. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  120656. /**
  120657. * Adds the given geometry to this scene
  120658. * @param newGeometry The geometry to add
  120659. */
  120660. addGeometry(newGeometry: Geometry): void;
  120661. /**
  120662. * Adds the given action manager to this scene
  120663. * @param newActionManager The action manager to add
  120664. */
  120665. addActionManager(newActionManager: AbstractActionManager): void;
  120666. /**
  120667. * Adds the given texture to this scene.
  120668. * @param newTexture The texture to add
  120669. */
  120670. addTexture(newTexture: BaseTexture): void;
  120671. /**
  120672. * Switch active camera
  120673. * @param newCamera defines the new active camera
  120674. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  120675. */
  120676. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  120677. /**
  120678. * sets the active camera of the scene using its ID
  120679. * @param id defines the camera's ID
  120680. * @return the new active camera or null if none found.
  120681. */
  120682. setActiveCameraByID(id: string): Nullable<Camera>;
  120683. /**
  120684. * sets the active camera of the scene using its name
  120685. * @param name defines the camera's name
  120686. * @returns the new active camera or null if none found.
  120687. */
  120688. setActiveCameraByName(name: string): Nullable<Camera>;
  120689. /**
  120690. * get an animation group using its name
  120691. * @param name defines the material's name
  120692. * @return the animation group or null if none found.
  120693. */
  120694. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  120695. /**
  120696. * Get a material using its unique id
  120697. * @param uniqueId defines the material's unique id
  120698. * @return the material or null if none found.
  120699. */
  120700. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  120701. /**
  120702. * get a material using its id
  120703. * @param id defines the material's ID
  120704. * @return the material or null if none found.
  120705. */
  120706. getMaterialByID(id: string): Nullable<Material>;
  120707. /**
  120708. * Gets a the last added material using a given id
  120709. * @param id defines the material's ID
  120710. * @return the last material with the given id or null if none found.
  120711. */
  120712. getLastMaterialByID(id: string): Nullable<Material>;
  120713. /**
  120714. * Gets a material using its name
  120715. * @param name defines the material's name
  120716. * @return the material or null if none found.
  120717. */
  120718. getMaterialByName(name: string): Nullable<Material>;
  120719. /**
  120720. * Get a texture using its unique id
  120721. * @param uniqueId defines the texture's unique id
  120722. * @return the texture or null if none found.
  120723. */
  120724. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  120725. /**
  120726. * Gets a camera using its id
  120727. * @param id defines the id to look for
  120728. * @returns the camera or null if not found
  120729. */
  120730. getCameraByID(id: string): Nullable<Camera>;
  120731. /**
  120732. * Gets a camera using its unique id
  120733. * @param uniqueId defines the unique id to look for
  120734. * @returns the camera or null if not found
  120735. */
  120736. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  120737. /**
  120738. * Gets a camera using its name
  120739. * @param name defines the camera's name
  120740. * @return the camera or null if none found.
  120741. */
  120742. getCameraByName(name: string): Nullable<Camera>;
  120743. /**
  120744. * Gets a bone using its id
  120745. * @param id defines the bone's id
  120746. * @return the bone or null if not found
  120747. */
  120748. getBoneByID(id: string): Nullable<Bone>;
  120749. /**
  120750. * Gets a bone using its id
  120751. * @param name defines the bone's name
  120752. * @return the bone or null if not found
  120753. */
  120754. getBoneByName(name: string): Nullable<Bone>;
  120755. /**
  120756. * Gets a light node using its name
  120757. * @param name defines the the light's name
  120758. * @return the light or null if none found.
  120759. */
  120760. getLightByName(name: string): Nullable<Light>;
  120761. /**
  120762. * Gets a light node using its id
  120763. * @param id defines the light's id
  120764. * @return the light or null if none found.
  120765. */
  120766. getLightByID(id: string): Nullable<Light>;
  120767. /**
  120768. * Gets a light node using its scene-generated unique ID
  120769. * @param uniqueId defines the light's unique id
  120770. * @return the light or null if none found.
  120771. */
  120772. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  120773. /**
  120774. * Gets a particle system by id
  120775. * @param id defines the particle system id
  120776. * @return the corresponding system or null if none found
  120777. */
  120778. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  120779. /**
  120780. * Gets a geometry using its ID
  120781. * @param id defines the geometry's id
  120782. * @return the geometry or null if none found.
  120783. */
  120784. getGeometryByID(id: string): Nullable<Geometry>;
  120785. private _getGeometryByUniqueID;
  120786. /**
  120787. * Add a new geometry to this scene
  120788. * @param geometry defines the geometry to be added to the scene.
  120789. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  120790. * @return a boolean defining if the geometry was added or not
  120791. */
  120792. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  120793. /**
  120794. * Removes an existing geometry
  120795. * @param geometry defines the geometry to be removed from the scene
  120796. * @return a boolean defining if the geometry was removed or not
  120797. */
  120798. removeGeometry(geometry: Geometry): boolean;
  120799. /**
  120800. * Gets the list of geometries attached to the scene
  120801. * @returns an array of Geometry
  120802. */
  120803. getGeometries(): Geometry[];
  120804. /**
  120805. * Gets the first added mesh found of a given ID
  120806. * @param id defines the id to search for
  120807. * @return the mesh found or null if not found at all
  120808. */
  120809. getMeshByID(id: string): Nullable<AbstractMesh>;
  120810. /**
  120811. * Gets a list of meshes using their id
  120812. * @param id defines the id to search for
  120813. * @returns a list of meshes
  120814. */
  120815. getMeshesByID(id: string): Array<AbstractMesh>;
  120816. /**
  120817. * Gets the first added transform node found of a given ID
  120818. * @param id defines the id to search for
  120819. * @return the found transform node or null if not found at all.
  120820. */
  120821. getTransformNodeByID(id: string): Nullable<TransformNode>;
  120822. /**
  120823. * Gets a transform node with its auto-generated unique id
  120824. * @param uniqueId efines the unique id to search for
  120825. * @return the found transform node or null if not found at all.
  120826. */
  120827. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  120828. /**
  120829. * Gets a list of transform nodes using their id
  120830. * @param id defines the id to search for
  120831. * @returns a list of transform nodes
  120832. */
  120833. getTransformNodesByID(id: string): Array<TransformNode>;
  120834. /**
  120835. * Gets a mesh with its auto-generated unique id
  120836. * @param uniqueId defines the unique id to search for
  120837. * @return the found mesh or null if not found at all.
  120838. */
  120839. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  120840. /**
  120841. * Gets a the last added mesh using a given id
  120842. * @param id defines the id to search for
  120843. * @return the found mesh or null if not found at all.
  120844. */
  120845. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  120846. /**
  120847. * Gets a the last added node (Mesh, Camera, Light) using a given id
  120848. * @param id defines the id to search for
  120849. * @return the found node or null if not found at all
  120850. */
  120851. getLastEntryByID(id: string): Nullable<Node>;
  120852. /**
  120853. * Gets a node (Mesh, Camera, Light) using a given id
  120854. * @param id defines the id to search for
  120855. * @return the found node or null if not found at all
  120856. */
  120857. getNodeByID(id: string): Nullable<Node>;
  120858. /**
  120859. * Gets a node (Mesh, Camera, Light) using a given name
  120860. * @param name defines the name to search for
  120861. * @return the found node or null if not found at all.
  120862. */
  120863. getNodeByName(name: string): Nullable<Node>;
  120864. /**
  120865. * Gets a mesh using a given name
  120866. * @param name defines the name to search for
  120867. * @return the found mesh or null if not found at all.
  120868. */
  120869. getMeshByName(name: string): Nullable<AbstractMesh>;
  120870. /**
  120871. * Gets a transform node using a given name
  120872. * @param name defines the name to search for
  120873. * @return the found transform node or null if not found at all.
  120874. */
  120875. getTransformNodeByName(name: string): Nullable<TransformNode>;
  120876. /**
  120877. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  120878. * @param id defines the id to search for
  120879. * @return the found skeleton or null if not found at all.
  120880. */
  120881. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  120882. /**
  120883. * Gets a skeleton using a given auto generated unique id
  120884. * @param uniqueId defines the unique id to search for
  120885. * @return the found skeleton or null if not found at all.
  120886. */
  120887. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  120888. /**
  120889. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  120890. * @param id defines the id to search for
  120891. * @return the found skeleton or null if not found at all.
  120892. */
  120893. getSkeletonById(id: string): Nullable<Skeleton>;
  120894. /**
  120895. * Gets a skeleton using a given name
  120896. * @param name defines the name to search for
  120897. * @return the found skeleton or null if not found at all.
  120898. */
  120899. getSkeletonByName(name: string): Nullable<Skeleton>;
  120900. /**
  120901. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  120902. * @param id defines the id to search for
  120903. * @return the found morph target manager or null if not found at all.
  120904. */
  120905. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  120906. /**
  120907. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  120908. * @param id defines the id to search for
  120909. * @return the found morph target or null if not found at all.
  120910. */
  120911. getMorphTargetById(id: string): Nullable<MorphTarget>;
  120912. /**
  120913. * Gets a morph target using a given name (if many are found, this function will pick the first one)
  120914. * @param name defines the name to search for
  120915. * @return the found morph target or null if not found at all.
  120916. */
  120917. getMorphTargetByName(name: string): Nullable<MorphTarget>;
  120918. /**
  120919. * Gets a post process using a given name (if many are found, this function will pick the first one)
  120920. * @param name defines the name to search for
  120921. * @return the found post process or null if not found at all.
  120922. */
  120923. getPostProcessByName(name: string): Nullable<PostProcess>;
  120924. /**
  120925. * Gets a boolean indicating if the given mesh is active
  120926. * @param mesh defines the mesh to look for
  120927. * @returns true if the mesh is in the active list
  120928. */
  120929. isActiveMesh(mesh: AbstractMesh): boolean;
  120930. /**
  120931. * Return a unique id as a string which can serve as an identifier for the scene
  120932. */
  120933. get uid(): string;
  120934. /**
  120935. * Add an externaly attached data from its key.
  120936. * This method call will fail and return false, if such key already exists.
  120937. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  120938. * @param key the unique key that identifies the data
  120939. * @param data the data object to associate to the key for this Engine instance
  120940. * @return true if no such key were already present and the data was added successfully, false otherwise
  120941. */
  120942. addExternalData<T>(key: string, data: T): boolean;
  120943. /**
  120944. * Get an externaly attached data from its key
  120945. * @param key the unique key that identifies the data
  120946. * @return the associated data, if present (can be null), or undefined if not present
  120947. */
  120948. getExternalData<T>(key: string): Nullable<T>;
  120949. /**
  120950. * Get an externaly attached data from its key, create it using a factory if it's not already present
  120951. * @param key the unique key that identifies the data
  120952. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  120953. * @return the associated data, can be null if the factory returned null.
  120954. */
  120955. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  120956. /**
  120957. * Remove an externaly attached data from the Engine instance
  120958. * @param key the unique key that identifies the data
  120959. * @return true if the data was successfully removed, false if it doesn't exist
  120960. */
  120961. removeExternalData(key: string): boolean;
  120962. private _evaluateSubMesh;
  120963. /**
  120964. * Clear the processed materials smart array preventing retention point in material dispose.
  120965. */
  120966. freeProcessedMaterials(): void;
  120967. private _preventFreeActiveMeshesAndRenderingGroups;
  120968. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  120969. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  120970. * when disposing several meshes in a row or a hierarchy of meshes.
  120971. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  120972. */
  120973. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  120974. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  120975. /**
  120976. * Clear the active meshes smart array preventing retention point in mesh dispose.
  120977. */
  120978. freeActiveMeshes(): void;
  120979. /**
  120980. * Clear the info related to rendering groups preventing retention points during dispose.
  120981. */
  120982. freeRenderingGroups(): void;
  120983. /** @hidden */
  120984. _isInIntermediateRendering(): boolean;
  120985. /**
  120986. * Lambda returning the list of potentially active meshes.
  120987. */
  120988. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  120989. /**
  120990. * Lambda returning the list of potentially active sub meshes.
  120991. */
  120992. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  120993. /**
  120994. * Lambda returning the list of potentially intersecting sub meshes.
  120995. */
  120996. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  120997. /**
  120998. * Lambda returning the list of potentially colliding sub meshes.
  120999. */
  121000. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  121001. private _activeMeshesFrozen;
  121002. private _skipEvaluateActiveMeshesCompletely;
  121003. /**
  121004. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  121005. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  121006. * @returns the current scene
  121007. */
  121008. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  121009. /**
  121010. * Use this function to restart evaluating active meshes on every frame
  121011. * @returns the current scene
  121012. */
  121013. unfreezeActiveMeshes(): Scene;
  121014. private _evaluateActiveMeshes;
  121015. private _activeMesh;
  121016. /**
  121017. * Update the transform matrix to update from the current active camera
  121018. * @param force defines a boolean used to force the update even if cache is up to date
  121019. */
  121020. updateTransformMatrix(force?: boolean): void;
  121021. private _bindFrameBuffer;
  121022. /** @hidden */
  121023. _allowPostProcessClearColor: boolean;
  121024. /** @hidden */
  121025. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  121026. private _processSubCameras;
  121027. private _checkIntersections;
  121028. /** @hidden */
  121029. _advancePhysicsEngineStep(step: number): void;
  121030. /**
  121031. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  121032. */
  121033. getDeterministicFrameTime: () => number;
  121034. /** @hidden */
  121035. _animate(): void;
  121036. /** Execute all animations (for a frame) */
  121037. animate(): void;
  121038. /**
  121039. * Render the scene
  121040. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  121041. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  121042. */
  121043. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  121044. /**
  121045. * Freeze all materials
  121046. * A frozen material will not be updatable but should be faster to render
  121047. */
  121048. freezeMaterials(): void;
  121049. /**
  121050. * Unfreeze all materials
  121051. * A frozen material will not be updatable but should be faster to render
  121052. */
  121053. unfreezeMaterials(): void;
  121054. /**
  121055. * Releases all held ressources
  121056. */
  121057. dispose(): void;
  121058. /**
  121059. * Gets if the scene is already disposed
  121060. */
  121061. get isDisposed(): boolean;
  121062. /**
  121063. * Call this function to reduce memory footprint of the scene.
  121064. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  121065. */
  121066. clearCachedVertexData(): void;
  121067. /**
  121068. * This function will remove the local cached buffer data from texture.
  121069. * It will save memory but will prevent the texture from being rebuilt
  121070. */
  121071. cleanCachedTextureBuffer(): void;
  121072. /**
  121073. * Get the world extend vectors with an optional filter
  121074. *
  121075. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  121076. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  121077. */
  121078. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  121079. min: Vector3;
  121080. max: Vector3;
  121081. };
  121082. /**
  121083. * Creates a ray that can be used to pick in the scene
  121084. * @param x defines the x coordinate of the origin (on-screen)
  121085. * @param y defines the y coordinate of the origin (on-screen)
  121086. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  121087. * @param camera defines the camera to use for the picking
  121088. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  121089. * @returns a Ray
  121090. */
  121091. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  121092. /**
  121093. * Creates a ray that can be used to pick in the scene
  121094. * @param x defines the x coordinate of the origin (on-screen)
  121095. * @param y defines the y coordinate of the origin (on-screen)
  121096. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  121097. * @param result defines the ray where to store the picking ray
  121098. * @param camera defines the camera to use for the picking
  121099. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  121100. * @returns the current scene
  121101. */
  121102. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  121103. /**
  121104. * Creates a ray that can be used to pick in the scene
  121105. * @param x defines the x coordinate of the origin (on-screen)
  121106. * @param y defines the y coordinate of the origin (on-screen)
  121107. * @param camera defines the camera to use for the picking
  121108. * @returns a Ray
  121109. */
  121110. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  121111. /**
  121112. * Creates a ray that can be used to pick in the scene
  121113. * @param x defines the x coordinate of the origin (on-screen)
  121114. * @param y defines the y coordinate of the origin (on-screen)
  121115. * @param result defines the ray where to store the picking ray
  121116. * @param camera defines the camera to use for the picking
  121117. * @returns the current scene
  121118. */
  121119. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  121120. /** Launch a ray to try to pick a mesh in the scene
  121121. * @param x position on screen
  121122. * @param y position on screen
  121123. * @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
  121124. * @param fastCheck defines if the first intersection will be used (and not the closest)
  121125. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  121126. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  121127. * @returns a PickingInfo
  121128. */
  121129. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  121130. /** Launch a ray to try to pick a mesh in the scene using only bounding information of the main mesh (not using submeshes)
  121131. * @param x position on screen
  121132. * @param y position on screen
  121133. * @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
  121134. * @param fastCheck defines if the first intersection will be used (and not the closest)
  121135. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  121136. * @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)
  121137. */
  121138. pickWithBoundingInfo(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  121139. /** Use the given ray to pick a mesh in the scene
  121140. * @param ray The ray to use to pick meshes
  121141. * @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
  121142. * @param fastCheck defines if the first intersection will be used (and not the closest)
  121143. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  121144. * @returns a PickingInfo
  121145. */
  121146. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  121147. /**
  121148. * Launch a ray to try to pick a mesh in the scene
  121149. * @param x X position on screen
  121150. * @param y Y position on screen
  121151. * @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
  121152. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  121153. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  121154. * @returns an array of PickingInfo
  121155. */
  121156. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  121157. /**
  121158. * Launch a ray to try to pick a mesh in the scene
  121159. * @param ray Ray to use
  121160. * @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
  121161. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  121162. * @returns an array of PickingInfo
  121163. */
  121164. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  121165. /**
  121166. * Force the value of meshUnderPointer
  121167. * @param mesh defines the mesh to use
  121168. * @param pointerId optional pointer id when using more than one pointer
  121169. */
  121170. setPointerOverMesh(mesh: Nullable<AbstractMesh>, pointerId?: number): void;
  121171. /**
  121172. * Gets the mesh under the pointer
  121173. * @returns a Mesh or null if no mesh is under the pointer
  121174. */
  121175. getPointerOverMesh(): Nullable<AbstractMesh>;
  121176. /** @hidden */
  121177. _rebuildGeometries(): void;
  121178. /** @hidden */
  121179. _rebuildTextures(): void;
  121180. private _getByTags;
  121181. /**
  121182. * Get a list of meshes by tags
  121183. * @param tagsQuery defines the tags query to use
  121184. * @param forEach defines a predicate used to filter results
  121185. * @returns an array of Mesh
  121186. */
  121187. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  121188. /**
  121189. * Get a list of cameras by tags
  121190. * @param tagsQuery defines the tags query to use
  121191. * @param forEach defines a predicate used to filter results
  121192. * @returns an array of Camera
  121193. */
  121194. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  121195. /**
  121196. * Get a list of lights by tags
  121197. * @param tagsQuery defines the tags query to use
  121198. * @param forEach defines a predicate used to filter results
  121199. * @returns an array of Light
  121200. */
  121201. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  121202. /**
  121203. * Get a list of materials by tags
  121204. * @param tagsQuery defines the tags query to use
  121205. * @param forEach defines a predicate used to filter results
  121206. * @returns an array of Material
  121207. */
  121208. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  121209. /**
  121210. * Get a list of transform nodes by tags
  121211. * @param tagsQuery defines the tags query to use
  121212. * @param forEach defines a predicate used to filter results
  121213. * @returns an array of TransformNode
  121214. */
  121215. getTransformNodesByTags(tagsQuery: string, forEach?: (transform: TransformNode) => void): TransformNode[];
  121216. /**
  121217. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  121218. * This allowed control for front to back rendering or reversly depending of the special needs.
  121219. *
  121220. * @param renderingGroupId The rendering group id corresponding to its index
  121221. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  121222. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  121223. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  121224. */
  121225. 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;
  121226. /**
  121227. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  121228. *
  121229. * @param renderingGroupId The rendering group id corresponding to its index
  121230. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  121231. * @param depth Automatically clears depth between groups if true and autoClear is true.
  121232. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  121233. */
  121234. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  121235. /**
  121236. * Gets the current auto clear configuration for one rendering group of the rendering
  121237. * manager.
  121238. * @param index the rendering group index to get the information for
  121239. * @returns The auto clear setup for the requested rendering group
  121240. */
  121241. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  121242. private _blockMaterialDirtyMechanism;
  121243. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  121244. get blockMaterialDirtyMechanism(): boolean;
  121245. set blockMaterialDirtyMechanism(value: boolean);
  121246. /**
  121247. * Will flag all materials as dirty to trigger new shader compilation
  121248. * @param flag defines the flag used to specify which material part must be marked as dirty
  121249. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  121250. */
  121251. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  121252. /** @hidden */
  121253. _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;
  121254. /** @hidden */
  121255. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  121256. /** @hidden */
  121257. _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;
  121258. /** @hidden */
  121259. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  121260. /** @hidden */
  121261. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  121262. /** @hidden */
  121263. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  121264. }
  121265. }
  121266. declare module BABYLON {
  121267. /**
  121268. * Set of assets to keep when moving a scene into an asset container.
  121269. */
  121270. export class KeepAssets extends AbstractScene {
  121271. }
  121272. /**
  121273. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  121274. */
  121275. export class InstantiatedEntries {
  121276. /**
  121277. * List of new root nodes (eg. nodes with no parent)
  121278. */
  121279. rootNodes: TransformNode[];
  121280. /**
  121281. * List of new skeletons
  121282. */
  121283. skeletons: Skeleton[];
  121284. /**
  121285. * List of new animation groups
  121286. */
  121287. animationGroups: AnimationGroup[];
  121288. }
  121289. /**
  121290. * Container with a set of assets that can be added or removed from a scene.
  121291. */
  121292. export class AssetContainer extends AbstractScene {
  121293. private _wasAddedToScene;
  121294. /**
  121295. * The scene the AssetContainer belongs to.
  121296. */
  121297. scene: Scene;
  121298. /**
  121299. * Instantiates an AssetContainer.
  121300. * @param scene The scene the AssetContainer belongs to.
  121301. */
  121302. constructor(scene: Scene);
  121303. /**
  121304. * Instantiate or clone all meshes and add the new ones to the scene.
  121305. * Skeletons and animation groups will all be cloned
  121306. * @param nameFunction defines an optional function used to get new names for clones
  121307. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  121308. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  121309. */
  121310. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  121311. /**
  121312. * Adds all the assets from the container to the scene.
  121313. */
  121314. addAllToScene(): void;
  121315. /**
  121316. * Removes all the assets in the container from the scene
  121317. */
  121318. removeAllFromScene(): void;
  121319. /**
  121320. * Disposes all the assets in the container
  121321. */
  121322. dispose(): void;
  121323. private _moveAssets;
  121324. /**
  121325. * Removes all the assets contained in the scene and adds them to the container.
  121326. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  121327. */
  121328. moveAllFromScene(keepAssets?: KeepAssets): void;
  121329. /**
  121330. * 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.
  121331. * @returns the root mesh
  121332. */
  121333. createRootMesh(): Mesh;
  121334. /**
  121335. * Merge animations (direct and animation groups) from this asset container into a scene
  121336. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  121337. * @param animatables set of animatables to retarget to a node from the scene
  121338. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  121339. * @returns an array of the new AnimationGroup added to the scene (empty array if none)
  121340. */
  121341. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): AnimationGroup[];
  121342. }
  121343. }
  121344. declare module BABYLON {
  121345. /**
  121346. * Defines how the parser contract is defined.
  121347. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  121348. */
  121349. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  121350. /**
  121351. * Defines how the individual parser contract is defined.
  121352. * These parser can parse an individual asset
  121353. */
  121354. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  121355. /**
  121356. * Base class of the scene acting as a container for the different elements composing a scene.
  121357. * This class is dynamically extended by the different components of the scene increasing
  121358. * flexibility and reducing coupling
  121359. */
  121360. export abstract class AbstractScene {
  121361. /**
  121362. * Stores the list of available parsers in the application.
  121363. */
  121364. private static _BabylonFileParsers;
  121365. /**
  121366. * Stores the list of available individual parsers in the application.
  121367. */
  121368. private static _IndividualBabylonFileParsers;
  121369. /**
  121370. * Adds a parser in the list of available ones
  121371. * @param name Defines the name of the parser
  121372. * @param parser Defines the parser to add
  121373. */
  121374. static AddParser(name: string, parser: BabylonFileParser): void;
  121375. /**
  121376. * Gets a general parser from the list of avaialble ones
  121377. * @param name Defines the name of the parser
  121378. * @returns the requested parser or null
  121379. */
  121380. static GetParser(name: string): Nullable<BabylonFileParser>;
  121381. /**
  121382. * Adds n individual parser in the list of available ones
  121383. * @param name Defines the name of the parser
  121384. * @param parser Defines the parser to add
  121385. */
  121386. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  121387. /**
  121388. * Gets an individual parser from the list of avaialble ones
  121389. * @param name Defines the name of the parser
  121390. * @returns the requested parser or null
  121391. */
  121392. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  121393. /**
  121394. * Parser json data and populate both a scene and its associated container object
  121395. * @param jsonData Defines the data to parse
  121396. * @param scene Defines the scene to parse the data for
  121397. * @param container Defines the container attached to the parsing sequence
  121398. * @param rootUrl Defines the root url of the data
  121399. */
  121400. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  121401. /**
  121402. * Gets the list of root nodes (ie. nodes with no parent)
  121403. */
  121404. rootNodes: Node[];
  121405. /** All of the cameras added to this scene
  121406. * @see https://doc.babylonjs.com/babylon101/cameras
  121407. */
  121408. cameras: Camera[];
  121409. /**
  121410. * All of the lights added to this scene
  121411. * @see https://doc.babylonjs.com/babylon101/lights
  121412. */
  121413. lights: Light[];
  121414. /**
  121415. * All of the (abstract) meshes added to this scene
  121416. */
  121417. meshes: AbstractMesh[];
  121418. /**
  121419. * The list of skeletons added to the scene
  121420. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  121421. */
  121422. skeletons: Skeleton[];
  121423. /**
  121424. * All of the particle systems added to this scene
  121425. * @see https://doc.babylonjs.com/babylon101/particles
  121426. */
  121427. particleSystems: IParticleSystem[];
  121428. /**
  121429. * Gets a list of Animations associated with the scene
  121430. */
  121431. animations: Animation[];
  121432. /**
  121433. * All of the animation groups added to this scene
  121434. * @see https://doc.babylonjs.com/how_to/group
  121435. */
  121436. animationGroups: AnimationGroup[];
  121437. /**
  121438. * All of the multi-materials added to this scene
  121439. * @see https://doc.babylonjs.com/how_to/multi_materials
  121440. */
  121441. multiMaterials: MultiMaterial[];
  121442. /**
  121443. * All of the materials added to this scene
  121444. * In the context of a Scene, it is not supposed to be modified manually.
  121445. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  121446. * Note also that the order of the Material within the array is not significant and might change.
  121447. * @see https://doc.babylonjs.com/babylon101/materials
  121448. */
  121449. materials: Material[];
  121450. /**
  121451. * The list of morph target managers added to the scene
  121452. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  121453. */
  121454. morphTargetManagers: MorphTargetManager[];
  121455. /**
  121456. * The list of geometries used in the scene.
  121457. */
  121458. geometries: Geometry[];
  121459. /**
  121460. * All of the tranform nodes added to this scene
  121461. * In the context of a Scene, it is not supposed to be modified manually.
  121462. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  121463. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  121464. * @see https://doc.babylonjs.com/how_to/transformnode
  121465. */
  121466. transformNodes: TransformNode[];
  121467. /**
  121468. * ActionManagers available on the scene.
  121469. */
  121470. actionManagers: AbstractActionManager[];
  121471. /**
  121472. * Textures to keep.
  121473. */
  121474. textures: BaseTexture[];
  121475. /** @hidden */
  121476. protected _environmentTexture: Nullable<BaseTexture>;
  121477. /**
  121478. * Texture used in all pbr material as the reflection texture.
  121479. * As in the majority of the scene they are the same (exception for multi room and so on),
  121480. * this is easier to reference from here than from all the materials.
  121481. */
  121482. get environmentTexture(): Nullable<BaseTexture>;
  121483. set environmentTexture(value: Nullable<BaseTexture>);
  121484. /**
  121485. * The list of postprocesses added to the scene
  121486. */
  121487. postProcesses: PostProcess[];
  121488. /**
  121489. * @returns all meshes, lights, cameras, transformNodes and bones
  121490. */
  121491. getNodes(): Array<Node>;
  121492. }
  121493. }
  121494. declare module BABYLON {
  121495. /**
  121496. * Interface used to define options for Sound class
  121497. */
  121498. export interface ISoundOptions {
  121499. /**
  121500. * Does the sound autoplay once loaded.
  121501. */
  121502. autoplay?: boolean;
  121503. /**
  121504. * Does the sound loop after it finishes playing once.
  121505. */
  121506. loop?: boolean;
  121507. /**
  121508. * Sound's volume
  121509. */
  121510. volume?: number;
  121511. /**
  121512. * Is it a spatial sound?
  121513. */
  121514. spatialSound?: boolean;
  121515. /**
  121516. * Maximum distance to hear that sound
  121517. */
  121518. maxDistance?: number;
  121519. /**
  121520. * Uses user defined attenuation function
  121521. */
  121522. useCustomAttenuation?: boolean;
  121523. /**
  121524. * Define the roll off factor of spatial sounds.
  121525. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  121526. */
  121527. rolloffFactor?: number;
  121528. /**
  121529. * Define the reference distance the sound should be heard perfectly.
  121530. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  121531. */
  121532. refDistance?: number;
  121533. /**
  121534. * Define the distance attenuation model the sound will follow.
  121535. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  121536. */
  121537. distanceModel?: string;
  121538. /**
  121539. * Defines the playback speed (1 by default)
  121540. */
  121541. playbackRate?: number;
  121542. /**
  121543. * Defines if the sound is from a streaming source
  121544. */
  121545. streaming?: boolean;
  121546. /**
  121547. * Defines an optional length (in seconds) inside the sound file
  121548. */
  121549. length?: number;
  121550. /**
  121551. * Defines an optional offset (in seconds) inside the sound file
  121552. */
  121553. offset?: number;
  121554. /**
  121555. * If true, URLs will not be required to state the audio file codec to use.
  121556. */
  121557. skipCodecCheck?: boolean;
  121558. }
  121559. /**
  121560. * Defines a sound that can be played in the application.
  121561. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  121562. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  121563. */
  121564. export class Sound {
  121565. /**
  121566. * The name of the sound in the scene.
  121567. */
  121568. name: string;
  121569. /**
  121570. * Does the sound autoplay once loaded.
  121571. */
  121572. autoplay: boolean;
  121573. /**
  121574. * Does the sound loop after it finishes playing once.
  121575. */
  121576. loop: boolean;
  121577. /**
  121578. * Does the sound use a custom attenuation curve to simulate the falloff
  121579. * happening when the source gets further away from the camera.
  121580. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  121581. */
  121582. useCustomAttenuation: boolean;
  121583. /**
  121584. * The sound track id this sound belongs to.
  121585. */
  121586. soundTrackId: number;
  121587. /**
  121588. * Is this sound currently played.
  121589. */
  121590. isPlaying: boolean;
  121591. /**
  121592. * Is this sound currently paused.
  121593. */
  121594. isPaused: boolean;
  121595. /**
  121596. * Does this sound enables spatial sound.
  121597. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  121598. */
  121599. spatialSound: boolean;
  121600. /**
  121601. * Define the reference distance the sound should be heard perfectly.
  121602. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  121603. */
  121604. refDistance: number;
  121605. /**
  121606. * Define the roll off factor of spatial sounds.
  121607. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  121608. */
  121609. rolloffFactor: number;
  121610. /**
  121611. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  121612. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  121613. */
  121614. maxDistance: number;
  121615. /**
  121616. * Define the distance attenuation model the sound will follow.
  121617. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  121618. */
  121619. distanceModel: string;
  121620. /**
  121621. * @hidden
  121622. * Back Compat
  121623. **/
  121624. onended: () => any;
  121625. /**
  121626. * Gets or sets an object used to store user defined information for the sound.
  121627. */
  121628. metadata: any;
  121629. /**
  121630. * Observable event when the current playing sound finishes.
  121631. */
  121632. onEndedObservable: Observable<Sound>;
  121633. private _panningModel;
  121634. private _playbackRate;
  121635. private _streaming;
  121636. private _startTime;
  121637. private _startOffset;
  121638. private _position;
  121639. /** @hidden */
  121640. _positionInEmitterSpace: boolean;
  121641. private _localDirection;
  121642. private _volume;
  121643. private _isReadyToPlay;
  121644. private _isDirectional;
  121645. private _readyToPlayCallback;
  121646. private _audioBuffer;
  121647. private _soundSource;
  121648. private _streamingSource;
  121649. private _soundPanner;
  121650. private _soundGain;
  121651. private _inputAudioNode;
  121652. private _outputAudioNode;
  121653. private _coneInnerAngle;
  121654. private _coneOuterAngle;
  121655. private _coneOuterGain;
  121656. private _scene;
  121657. private _connectedTransformNode;
  121658. private _customAttenuationFunction;
  121659. private _registerFunc;
  121660. private _isOutputConnected;
  121661. private _htmlAudioElement;
  121662. private _urlType;
  121663. private _length?;
  121664. private _offset?;
  121665. /** @hidden */
  121666. static _SceneComponentInitialization: (scene: Scene) => void;
  121667. /**
  121668. * Create a sound and attach it to a scene
  121669. * @param name Name of your sound
  121670. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  121671. * @param scene defines the scene the sound belongs to
  121672. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  121673. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  121674. */
  121675. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  121676. /**
  121677. * Release the sound and its associated resources
  121678. */
  121679. dispose(): void;
  121680. /**
  121681. * Gets if the sounds is ready to be played or not.
  121682. * @returns true if ready, otherwise false
  121683. */
  121684. isReady(): boolean;
  121685. private _soundLoaded;
  121686. /**
  121687. * Sets the data of the sound from an audiobuffer
  121688. * @param audioBuffer The audioBuffer containing the data
  121689. */
  121690. setAudioBuffer(audioBuffer: AudioBuffer): void;
  121691. /**
  121692. * Updates the current sounds options such as maxdistance, loop...
  121693. * @param options A JSON object containing values named as the object properties
  121694. */
  121695. updateOptions(options: ISoundOptions): void;
  121696. private _createSpatialParameters;
  121697. private _updateSpatialParameters;
  121698. /**
  121699. * Switch the panning model to HRTF:
  121700. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  121701. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  121702. */
  121703. switchPanningModelToHRTF(): void;
  121704. /**
  121705. * Switch the panning model to Equal Power:
  121706. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  121707. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  121708. */
  121709. switchPanningModelToEqualPower(): void;
  121710. private _switchPanningModel;
  121711. /**
  121712. * Connect this sound to a sound track audio node like gain...
  121713. * @param soundTrackAudioNode the sound track audio node to connect to
  121714. */
  121715. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  121716. /**
  121717. * Transform this sound into a directional source
  121718. * @param coneInnerAngle Size of the inner cone in degree
  121719. * @param coneOuterAngle Size of the outer cone in degree
  121720. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  121721. */
  121722. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  121723. /**
  121724. * Gets or sets the inner angle for the directional cone.
  121725. */
  121726. get directionalConeInnerAngle(): number;
  121727. /**
  121728. * Gets or sets the inner angle for the directional cone.
  121729. */
  121730. set directionalConeInnerAngle(value: number);
  121731. /**
  121732. * Gets or sets the outer angle for the directional cone.
  121733. */
  121734. get directionalConeOuterAngle(): number;
  121735. /**
  121736. * Gets or sets the outer angle for the directional cone.
  121737. */
  121738. set directionalConeOuterAngle(value: number);
  121739. /**
  121740. * Sets the position of the emitter if spatial sound is enabled
  121741. * @param newPosition Defines the new posisiton
  121742. */
  121743. setPosition(newPosition: Vector3): void;
  121744. /**
  121745. * Sets the local direction of the emitter if spatial sound is enabled
  121746. * @param newLocalDirection Defines the new local direction
  121747. */
  121748. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  121749. private _updateDirection;
  121750. /** @hidden */
  121751. updateDistanceFromListener(): void;
  121752. /**
  121753. * Sets a new custom attenuation function for the sound.
  121754. * @param callback Defines the function used for the attenuation
  121755. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  121756. */
  121757. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  121758. /**
  121759. * Play the sound
  121760. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  121761. * @param offset (optional) Start the sound at a specific time in seconds
  121762. * @param length (optional) Sound duration (in seconds)
  121763. */
  121764. play(time?: number, offset?: number, length?: number): void;
  121765. private _onended;
  121766. /**
  121767. * Stop the sound
  121768. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  121769. */
  121770. stop(time?: number): void;
  121771. /**
  121772. * Put the sound in pause
  121773. */
  121774. pause(): void;
  121775. /**
  121776. * Sets a dedicated volume for this sounds
  121777. * @param newVolume Define the new volume of the sound
  121778. * @param time Define time for gradual change to new volume
  121779. */
  121780. setVolume(newVolume: number, time?: number): void;
  121781. /**
  121782. * Set the sound play back rate
  121783. * @param newPlaybackRate Define the playback rate the sound should be played at
  121784. */
  121785. setPlaybackRate(newPlaybackRate: number): void;
  121786. /**
  121787. * Gets the volume of the sound.
  121788. * @returns the volume of the sound
  121789. */
  121790. getVolume(): number;
  121791. /**
  121792. * Attach the sound to a dedicated mesh
  121793. * @param transformNode The transform node to connect the sound with
  121794. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  121795. */
  121796. attachToMesh(transformNode: TransformNode): void;
  121797. /**
  121798. * Detach the sound from the previously attached mesh
  121799. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  121800. */
  121801. detachFromMesh(): void;
  121802. private _onRegisterAfterWorldMatrixUpdate;
  121803. /**
  121804. * Clone the current sound in the scene.
  121805. * @returns the new sound clone
  121806. */
  121807. clone(): Nullable<Sound>;
  121808. /**
  121809. * Gets the current underlying audio buffer containing the data
  121810. * @returns the audio buffer
  121811. */
  121812. getAudioBuffer(): Nullable<AudioBuffer>;
  121813. /**
  121814. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  121815. * @returns the source node
  121816. */
  121817. getSoundSource(): Nullable<AudioBufferSourceNode>;
  121818. /**
  121819. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  121820. * @returns the gain node
  121821. */
  121822. getSoundGain(): Nullable<GainNode>;
  121823. /**
  121824. * Serializes the Sound in a JSON representation
  121825. * @returns the JSON representation of the sound
  121826. */
  121827. serialize(): any;
  121828. /**
  121829. * Parse a JSON representation of a sound to innstantiate in a given scene
  121830. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  121831. * @param scene Define the scene the new parsed sound should be created in
  121832. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  121833. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  121834. * @returns the newly parsed sound
  121835. */
  121836. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  121837. }
  121838. }
  121839. declare module BABYLON {
  121840. /**
  121841. * This defines an action helpful to play a defined sound on a triggered action.
  121842. */
  121843. export class PlaySoundAction extends Action {
  121844. private _sound;
  121845. /**
  121846. * Instantiate the action
  121847. * @param triggerOptions defines the trigger options
  121848. * @param sound defines the sound to play
  121849. * @param condition defines the trigger related conditions
  121850. */
  121851. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  121852. /** @hidden */
  121853. _prepare(): void;
  121854. /**
  121855. * Execute the action and play the sound.
  121856. */
  121857. execute(): void;
  121858. /**
  121859. * Serializes the actions and its related information.
  121860. * @param parent defines the object to serialize in
  121861. * @returns the serialized object
  121862. */
  121863. serialize(parent: any): any;
  121864. }
  121865. /**
  121866. * This defines an action helpful to stop a defined sound on a triggered action.
  121867. */
  121868. export class StopSoundAction extends Action {
  121869. private _sound;
  121870. /**
  121871. * Instantiate the action
  121872. * @param triggerOptions defines the trigger options
  121873. * @param sound defines the sound to stop
  121874. * @param condition defines the trigger related conditions
  121875. */
  121876. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  121877. /** @hidden */
  121878. _prepare(): void;
  121879. /**
  121880. * Execute the action and stop the sound.
  121881. */
  121882. execute(): void;
  121883. /**
  121884. * Serializes the actions and its related information.
  121885. * @param parent defines the object to serialize in
  121886. * @returns the serialized object
  121887. */
  121888. serialize(parent: any): any;
  121889. }
  121890. }
  121891. declare module BABYLON {
  121892. /**
  121893. * This defines an action responsible to change the value of a property
  121894. * by interpolating between its current value and the newly set one once triggered.
  121895. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  121896. */
  121897. export class InterpolateValueAction extends Action {
  121898. /**
  121899. * Defines the path of the property where the value should be interpolated
  121900. */
  121901. propertyPath: string;
  121902. /**
  121903. * Defines the target value at the end of the interpolation.
  121904. */
  121905. value: any;
  121906. /**
  121907. * Defines the time it will take for the property to interpolate to the value.
  121908. */
  121909. duration: number;
  121910. /**
  121911. * Defines if the other scene animations should be stopped when the action has been triggered
  121912. */
  121913. stopOtherAnimations?: boolean;
  121914. /**
  121915. * Defines a callback raised once the interpolation animation has been done.
  121916. */
  121917. onInterpolationDone?: () => void;
  121918. /**
  121919. * Observable triggered once the interpolation animation has been done.
  121920. */
  121921. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  121922. private _target;
  121923. private _effectiveTarget;
  121924. private _property;
  121925. /**
  121926. * Instantiate the action
  121927. * @param triggerOptions defines the trigger options
  121928. * @param target defines the object containing the value to interpolate
  121929. * @param propertyPath defines the path to the property in the target object
  121930. * @param value defines the target value at the end of the interpolation
  121931. * @param duration deines the time it will take for the property to interpolate to the value.
  121932. * @param condition defines the trigger related conditions
  121933. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  121934. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  121935. */
  121936. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  121937. /** @hidden */
  121938. _prepare(): void;
  121939. /**
  121940. * Execute the action starts the value interpolation.
  121941. */
  121942. execute(): void;
  121943. /**
  121944. * Serializes the actions and its related information.
  121945. * @param parent defines the object to serialize in
  121946. * @returns the serialized object
  121947. */
  121948. serialize(parent: any): any;
  121949. }
  121950. }
  121951. declare module BABYLON {
  121952. /**
  121953. * Options allowed during the creation of a sound track.
  121954. */
  121955. export interface ISoundTrackOptions {
  121956. /**
  121957. * The volume the sound track should take during creation
  121958. */
  121959. volume?: number;
  121960. /**
  121961. * Define if the sound track is the main sound track of the scene
  121962. */
  121963. mainTrack?: boolean;
  121964. }
  121965. /**
  121966. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  121967. * It will be also used in a future release to apply effects on a specific track.
  121968. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  121969. */
  121970. export class SoundTrack {
  121971. /**
  121972. * The unique identifier of the sound track in the scene.
  121973. */
  121974. id: number;
  121975. /**
  121976. * The list of sounds included in the sound track.
  121977. */
  121978. soundCollection: Array<Sound>;
  121979. private _outputAudioNode;
  121980. private _scene;
  121981. private _connectedAnalyser;
  121982. private _options;
  121983. private _isInitialized;
  121984. /**
  121985. * Creates a new sound track.
  121986. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  121987. * @param scene Define the scene the sound track belongs to
  121988. * @param options
  121989. */
  121990. constructor(scene: Scene, options?: ISoundTrackOptions);
  121991. private _initializeSoundTrackAudioGraph;
  121992. /**
  121993. * Release the sound track and its associated resources
  121994. */
  121995. dispose(): void;
  121996. /**
  121997. * Adds a sound to this sound track
  121998. * @param sound define the cound to add
  121999. * @ignoreNaming
  122000. */
  122001. AddSound(sound: Sound): void;
  122002. /**
  122003. * Removes a sound to this sound track
  122004. * @param sound define the cound to remove
  122005. * @ignoreNaming
  122006. */
  122007. RemoveSound(sound: Sound): void;
  122008. /**
  122009. * Set a global volume for the full sound track.
  122010. * @param newVolume Define the new volume of the sound track
  122011. */
  122012. setVolume(newVolume: number): void;
  122013. /**
  122014. * Switch the panning model to HRTF:
  122015. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  122016. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  122017. */
  122018. switchPanningModelToHRTF(): void;
  122019. /**
  122020. * Switch the panning model to Equal Power:
  122021. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  122022. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  122023. */
  122024. switchPanningModelToEqualPower(): void;
  122025. /**
  122026. * Connect the sound track to an audio analyser allowing some amazing
  122027. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  122028. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  122029. * @param analyser The analyser to connect to the engine
  122030. */
  122031. connectToAnalyser(analyser: Analyser): void;
  122032. }
  122033. }
  122034. declare module BABYLON {
  122035. interface AbstractScene {
  122036. /**
  122037. * The list of sounds used in the scene.
  122038. */
  122039. sounds: Nullable<Array<Sound>>;
  122040. }
  122041. interface Scene {
  122042. /**
  122043. * @hidden
  122044. * Backing field
  122045. */
  122046. _mainSoundTrack: SoundTrack;
  122047. /**
  122048. * The main sound track played by the scene.
  122049. * It cotains your primary collection of sounds.
  122050. */
  122051. mainSoundTrack: SoundTrack;
  122052. /**
  122053. * The list of sound tracks added to the scene
  122054. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  122055. */
  122056. soundTracks: Nullable<Array<SoundTrack>>;
  122057. /**
  122058. * Gets a sound using a given name
  122059. * @param name defines the name to search for
  122060. * @return the found sound or null if not found at all.
  122061. */
  122062. getSoundByName(name: string): Nullable<Sound>;
  122063. /**
  122064. * Gets or sets if audio support is enabled
  122065. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  122066. */
  122067. audioEnabled: boolean;
  122068. /**
  122069. * Gets or sets if audio will be output to headphones
  122070. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  122071. */
  122072. headphone: boolean;
  122073. /**
  122074. * Gets or sets custom audio listener position provider
  122075. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  122076. */
  122077. audioListenerPositionProvider: Nullable<() => Vector3>;
  122078. /**
  122079. * Gets or sets a refresh rate when using 3D audio positioning
  122080. */
  122081. audioPositioningRefreshRate: number;
  122082. }
  122083. /**
  122084. * Defines the sound scene component responsible to manage any sounds
  122085. * in a given scene.
  122086. */
  122087. export class AudioSceneComponent implements ISceneSerializableComponent {
  122088. private static _CameraDirectionLH;
  122089. private static _CameraDirectionRH;
  122090. /**
  122091. * The component name helpfull to identify the component in the list of scene components.
  122092. */
  122093. readonly name: string;
  122094. /**
  122095. * The scene the component belongs to.
  122096. */
  122097. scene: Scene;
  122098. private _audioEnabled;
  122099. /**
  122100. * Gets whether audio is enabled or not.
  122101. * Please use related enable/disable method to switch state.
  122102. */
  122103. get audioEnabled(): boolean;
  122104. private _headphone;
  122105. /**
  122106. * Gets whether audio is outputing to headphone or not.
  122107. * Please use the according Switch methods to change output.
  122108. */
  122109. get headphone(): boolean;
  122110. /**
  122111. * Gets or sets a refresh rate when using 3D audio positioning
  122112. */
  122113. audioPositioningRefreshRate: number;
  122114. private _audioListenerPositionProvider;
  122115. /**
  122116. * Gets the current audio listener position provider
  122117. */
  122118. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  122119. /**
  122120. * Sets a custom listener position for all sounds in the scene
  122121. * By default, this is the position of the first active camera
  122122. */
  122123. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  122124. /**
  122125. * Creates a new instance of the component for the given scene
  122126. * @param scene Defines the scene to register the component in
  122127. */
  122128. constructor(scene: Scene);
  122129. /**
  122130. * Registers the component in a given scene
  122131. */
  122132. register(): void;
  122133. /**
  122134. * Rebuilds the elements related to this component in case of
  122135. * context lost for instance.
  122136. */
  122137. rebuild(): void;
  122138. /**
  122139. * Serializes the component data to the specified json object
  122140. * @param serializationObject The object to serialize to
  122141. */
  122142. serialize(serializationObject: any): void;
  122143. /**
  122144. * Adds all the elements from the container to the scene
  122145. * @param container the container holding the elements
  122146. */
  122147. addFromContainer(container: AbstractScene): void;
  122148. /**
  122149. * Removes all the elements in the container from the scene
  122150. * @param container contains the elements to remove
  122151. * @param dispose if the removed element should be disposed (default: false)
  122152. */
  122153. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  122154. /**
  122155. * Disposes the component and the associated ressources.
  122156. */
  122157. dispose(): void;
  122158. /**
  122159. * Disables audio in the associated scene.
  122160. */
  122161. disableAudio(): void;
  122162. /**
  122163. * Enables audio in the associated scene.
  122164. */
  122165. enableAudio(): void;
  122166. /**
  122167. * Switch audio to headphone output.
  122168. */
  122169. switchAudioModeForHeadphones(): void;
  122170. /**
  122171. * Switch audio to normal speakers.
  122172. */
  122173. switchAudioModeForNormalSpeakers(): void;
  122174. private _cachedCameraDirection;
  122175. private _cachedCameraPosition;
  122176. private _lastCheck;
  122177. private _afterRender;
  122178. }
  122179. }
  122180. declare module BABYLON {
  122181. /**
  122182. * Wraps one or more Sound objects and selects one with random weight for playback.
  122183. */
  122184. export class WeightedSound {
  122185. /** When true a Sound will be selected and played when the current playing Sound completes. */
  122186. loop: boolean;
  122187. private _coneInnerAngle;
  122188. private _coneOuterAngle;
  122189. private _volume;
  122190. /** A Sound is currently playing. */
  122191. isPlaying: boolean;
  122192. /** A Sound is currently paused. */
  122193. isPaused: boolean;
  122194. private _sounds;
  122195. private _weights;
  122196. private _currentIndex?;
  122197. /**
  122198. * Creates a new WeightedSound from the list of sounds given.
  122199. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  122200. * @param sounds Array of Sounds that will be selected from.
  122201. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  122202. */
  122203. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  122204. /**
  122205. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  122206. */
  122207. get directionalConeInnerAngle(): number;
  122208. /**
  122209. * The size of cone in degress for a directional sound in which there will be no attenuation.
  122210. */
  122211. set directionalConeInnerAngle(value: number);
  122212. /**
  122213. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  122214. * Listener angles between innerAngle and outerAngle will falloff linearly.
  122215. */
  122216. get directionalConeOuterAngle(): number;
  122217. /**
  122218. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  122219. * Listener angles between innerAngle and outerAngle will falloff linearly.
  122220. */
  122221. set directionalConeOuterAngle(value: number);
  122222. /**
  122223. * Playback volume.
  122224. */
  122225. get volume(): number;
  122226. /**
  122227. * Playback volume.
  122228. */
  122229. set volume(value: number);
  122230. private _onended;
  122231. /**
  122232. * Suspend playback
  122233. */
  122234. pause(): void;
  122235. /**
  122236. * Stop playback
  122237. */
  122238. stop(): void;
  122239. /**
  122240. * Start playback.
  122241. * @param startOffset Position the clip head at a specific time in seconds.
  122242. */
  122243. play(startOffset?: number): void;
  122244. }
  122245. }
  122246. declare module BABYLON {
  122247. /**
  122248. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  122249. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  122250. */
  122251. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  122252. /**
  122253. * Gets the name of the behavior.
  122254. */
  122255. get name(): string;
  122256. /**
  122257. * The easing function used by animations
  122258. */
  122259. static EasingFunction: BackEase;
  122260. /**
  122261. * The easing mode used by animations
  122262. */
  122263. static EasingMode: number;
  122264. /**
  122265. * The duration of the animation, in milliseconds
  122266. */
  122267. transitionDuration: number;
  122268. /**
  122269. * Length of the distance animated by the transition when lower radius is reached
  122270. */
  122271. lowerRadiusTransitionRange: number;
  122272. /**
  122273. * Length of the distance animated by the transition when upper radius is reached
  122274. */
  122275. upperRadiusTransitionRange: number;
  122276. private _autoTransitionRange;
  122277. /**
  122278. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  122279. */
  122280. get autoTransitionRange(): boolean;
  122281. /**
  122282. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  122283. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  122284. */
  122285. set autoTransitionRange(value: boolean);
  122286. private _attachedCamera;
  122287. private _onAfterCheckInputsObserver;
  122288. private _onMeshTargetChangedObserver;
  122289. /**
  122290. * Initializes the behavior.
  122291. */
  122292. init(): void;
  122293. /**
  122294. * Attaches the behavior to its arc rotate camera.
  122295. * @param camera Defines the camera to attach the behavior to
  122296. */
  122297. attach(camera: ArcRotateCamera): void;
  122298. /**
  122299. * Detaches the behavior from its current arc rotate camera.
  122300. */
  122301. detach(): void;
  122302. private _radiusIsAnimating;
  122303. private _radiusBounceTransition;
  122304. private _animatables;
  122305. private _cachedWheelPrecision;
  122306. /**
  122307. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  122308. * @param radiusLimit The limit to check against.
  122309. * @return Bool to indicate if at limit.
  122310. */
  122311. private _isRadiusAtLimit;
  122312. /**
  122313. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  122314. * @param radiusDelta The delta by which to animate to. Can be negative.
  122315. */
  122316. private _applyBoundRadiusAnimation;
  122317. /**
  122318. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  122319. */
  122320. protected _clearAnimationLocks(): void;
  122321. /**
  122322. * Stops and removes all animations that have been applied to the camera
  122323. */
  122324. stopAllAnimations(): void;
  122325. }
  122326. }
  122327. declare module BABYLON {
  122328. /**
  122329. * 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.
  122330. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  122331. */
  122332. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  122333. /**
  122334. * Gets the name of the behavior.
  122335. */
  122336. get name(): string;
  122337. private _mode;
  122338. private _radiusScale;
  122339. private _positionScale;
  122340. private _defaultElevation;
  122341. private _elevationReturnTime;
  122342. private _elevationReturnWaitTime;
  122343. private _zoomStopsAnimation;
  122344. private _framingTime;
  122345. /**
  122346. * The easing function used by animations
  122347. */
  122348. static EasingFunction: ExponentialEase;
  122349. /**
  122350. * The easing mode used by animations
  122351. */
  122352. static EasingMode: number;
  122353. /**
  122354. * Sets the current mode used by the behavior
  122355. */
  122356. set mode(mode: number);
  122357. /**
  122358. * Gets current mode used by the behavior.
  122359. */
  122360. get mode(): number;
  122361. /**
  122362. * Sets the scale applied to the radius (1 by default)
  122363. */
  122364. set radiusScale(radius: number);
  122365. /**
  122366. * Gets the scale applied to the radius
  122367. */
  122368. get radiusScale(): number;
  122369. /**
  122370. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  122371. */
  122372. set positionScale(scale: number);
  122373. /**
  122374. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  122375. */
  122376. get positionScale(): number;
  122377. /**
  122378. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  122379. * behaviour is triggered, in radians.
  122380. */
  122381. set defaultElevation(elevation: number);
  122382. /**
  122383. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  122384. * behaviour is triggered, in radians.
  122385. */
  122386. get defaultElevation(): number;
  122387. /**
  122388. * Sets the time (in milliseconds) taken to return to the default beta position.
  122389. * Negative value indicates camera should not return to default.
  122390. */
  122391. set elevationReturnTime(speed: number);
  122392. /**
  122393. * Gets the time (in milliseconds) taken to return to the default beta position.
  122394. * Negative value indicates camera should not return to default.
  122395. */
  122396. get elevationReturnTime(): number;
  122397. /**
  122398. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  122399. */
  122400. set elevationReturnWaitTime(time: number);
  122401. /**
  122402. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  122403. */
  122404. get elevationReturnWaitTime(): number;
  122405. /**
  122406. * Sets the flag that indicates if user zooming should stop animation.
  122407. */
  122408. set zoomStopsAnimation(flag: boolean);
  122409. /**
  122410. * Gets the flag that indicates if user zooming should stop animation.
  122411. */
  122412. get zoomStopsAnimation(): boolean;
  122413. /**
  122414. * Sets the transition time when framing the mesh, in milliseconds
  122415. */
  122416. set framingTime(time: number);
  122417. /**
  122418. * Gets the transition time when framing the mesh, in milliseconds
  122419. */
  122420. get framingTime(): number;
  122421. /**
  122422. * Define if the behavior should automatically change the configured
  122423. * camera limits and sensibilities.
  122424. */
  122425. autoCorrectCameraLimitsAndSensibility: boolean;
  122426. private _onPrePointerObservableObserver;
  122427. private _onAfterCheckInputsObserver;
  122428. private _onMeshTargetChangedObserver;
  122429. private _attachedCamera;
  122430. private _isPointerDown;
  122431. private _lastInteractionTime;
  122432. /**
  122433. * Initializes the behavior.
  122434. */
  122435. init(): void;
  122436. /**
  122437. * Attaches the behavior to its arc rotate camera.
  122438. * @param camera Defines the camera to attach the behavior to
  122439. */
  122440. attach(camera: ArcRotateCamera): void;
  122441. /**
  122442. * Detaches the behavior from its current arc rotate camera.
  122443. */
  122444. detach(): void;
  122445. private _animatables;
  122446. private _betaIsAnimating;
  122447. private _betaTransition;
  122448. private _radiusTransition;
  122449. private _vectorTransition;
  122450. /**
  122451. * Targets the given mesh and updates zoom level accordingly.
  122452. * @param mesh The mesh to target.
  122453. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  122454. * @param onAnimationEnd Callback triggered at the end of the framing animation
  122455. */
  122456. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  122457. /**
  122458. * Targets the given mesh with its children and updates zoom level accordingly.
  122459. * @param mesh The mesh to target.
  122460. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  122461. * @param onAnimationEnd Callback triggered at the end of the framing animation
  122462. */
  122463. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  122464. /**
  122465. * Targets the given meshes with their children and updates zoom level accordingly.
  122466. * @param meshes The mesh to target.
  122467. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  122468. * @param onAnimationEnd Callback triggered at the end of the framing animation
  122469. */
  122470. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  122471. /**
  122472. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  122473. * @param minimumWorld Determines the smaller position of the bounding box extend
  122474. * @param maximumWorld Determines the bigger position of the bounding box extend
  122475. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  122476. * @param onAnimationEnd Callback triggered at the end of the framing animation
  122477. */
  122478. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  122479. /**
  122480. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  122481. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  122482. * frustum width.
  122483. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  122484. * to fully enclose the mesh in the viewing frustum.
  122485. */
  122486. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  122487. /**
  122488. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  122489. * is automatically returned to its default position (expected to be above ground plane).
  122490. */
  122491. private _maintainCameraAboveGround;
  122492. /**
  122493. * Returns the frustum slope based on the canvas ratio and camera FOV
  122494. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  122495. */
  122496. private _getFrustumSlope;
  122497. /**
  122498. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  122499. */
  122500. private _clearAnimationLocks;
  122501. /**
  122502. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  122503. */
  122504. private _applyUserInteraction;
  122505. /**
  122506. * Stops and removes all animations that have been applied to the camera
  122507. */
  122508. stopAllAnimations(): void;
  122509. /**
  122510. * Gets a value indicating if the user is moving the camera
  122511. */
  122512. get isUserIsMoving(): boolean;
  122513. /**
  122514. * The camera can move all the way towards the mesh.
  122515. */
  122516. static IgnoreBoundsSizeMode: number;
  122517. /**
  122518. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  122519. */
  122520. static FitFrustumSidesMode: number;
  122521. }
  122522. }
  122523. declare module BABYLON {
  122524. /**
  122525. * Base class for Camera Pointer Inputs.
  122526. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  122527. * for example usage.
  122528. */
  122529. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  122530. /**
  122531. * Defines the camera the input is attached to.
  122532. */
  122533. abstract camera: Camera;
  122534. /**
  122535. * Whether keyboard modifier keys are pressed at time of last mouse event.
  122536. */
  122537. protected _altKey: boolean;
  122538. protected _ctrlKey: boolean;
  122539. protected _metaKey: boolean;
  122540. protected _shiftKey: boolean;
  122541. /**
  122542. * Which mouse buttons were pressed at time of last mouse event.
  122543. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  122544. */
  122545. protected _buttonsPressed: number;
  122546. /**
  122547. * Defines the buttons associated with the input to handle camera move.
  122548. */
  122549. buttons: number[];
  122550. /**
  122551. * Attach the input controls to a specific dom element to get the input from.
  122552. * @param element Defines the element the controls should be listened from
  122553. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  122554. */
  122555. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  122556. /**
  122557. * Detach the current controls from the specified dom element.
  122558. * @param element Defines the element to stop listening the inputs from
  122559. */
  122560. detachControl(element: Nullable<HTMLElement>): void;
  122561. /**
  122562. * Gets the class name of the current input.
  122563. * @returns the class name
  122564. */
  122565. getClassName(): string;
  122566. /**
  122567. * Get the friendly name associated with the input class.
  122568. * @returns the input friendly name
  122569. */
  122570. getSimpleName(): string;
  122571. /**
  122572. * Called on pointer POINTERDOUBLETAP event.
  122573. * Override this method to provide functionality on POINTERDOUBLETAP event.
  122574. */
  122575. protected onDoubleTap(type: string): void;
  122576. /**
  122577. * Called on pointer POINTERMOVE event if only a single touch is active.
  122578. * Override this method to provide functionality.
  122579. */
  122580. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  122581. /**
  122582. * Called on pointer POINTERMOVE event if multiple touches are active.
  122583. * Override this method to provide functionality.
  122584. */
  122585. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  122586. /**
  122587. * Called on JS contextmenu event.
  122588. * Override this method to provide functionality.
  122589. */
  122590. protected onContextMenu(evt: PointerEvent): void;
  122591. /**
  122592. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  122593. * press.
  122594. * Override this method to provide functionality.
  122595. */
  122596. protected onButtonDown(evt: PointerEvent): void;
  122597. /**
  122598. * Called each time a new POINTERUP event occurs. Ie, for each button
  122599. * release.
  122600. * Override this method to provide functionality.
  122601. */
  122602. protected onButtonUp(evt: PointerEvent): void;
  122603. /**
  122604. * Called when window becomes inactive.
  122605. * Override this method to provide functionality.
  122606. */
  122607. protected onLostFocus(): void;
  122608. private _pointerInput;
  122609. private _observer;
  122610. private _onLostFocus;
  122611. private pointA;
  122612. private pointB;
  122613. }
  122614. }
  122615. declare module BABYLON {
  122616. /**
  122617. * Manage the pointers inputs to control an arc rotate camera.
  122618. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  122619. */
  122620. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  122621. /**
  122622. * Defines the camera the input is attached to.
  122623. */
  122624. camera: ArcRotateCamera;
  122625. /**
  122626. * Gets the class name of the current input.
  122627. * @returns the class name
  122628. */
  122629. getClassName(): string;
  122630. /**
  122631. * Defines the buttons associated with the input to handle camera move.
  122632. */
  122633. buttons: number[];
  122634. /**
  122635. * Defines the pointer angular sensibility along the X axis or how fast is
  122636. * the camera rotating.
  122637. */
  122638. angularSensibilityX: number;
  122639. /**
  122640. * Defines the pointer angular sensibility along the Y axis or how fast is
  122641. * the camera rotating.
  122642. */
  122643. angularSensibilityY: number;
  122644. /**
  122645. * Defines the pointer pinch precision or how fast is the camera zooming.
  122646. */
  122647. pinchPrecision: number;
  122648. /**
  122649. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  122650. * from 0.
  122651. * It defines the percentage of current camera.radius to use as delta when
  122652. * pinch zoom is used.
  122653. */
  122654. pinchDeltaPercentage: number;
  122655. /**
  122656. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  122657. * that any object in the plane at the camera's target point will scale
  122658. * perfectly with finger motion.
  122659. * Overrides pinchDeltaPercentage and pinchPrecision.
  122660. */
  122661. useNaturalPinchZoom: boolean;
  122662. /**
  122663. * Defines the pointer panning sensibility or how fast is the camera moving.
  122664. */
  122665. panningSensibility: number;
  122666. /**
  122667. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  122668. */
  122669. multiTouchPanning: boolean;
  122670. /**
  122671. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  122672. * zoom (pinch) through multitouch.
  122673. */
  122674. multiTouchPanAndZoom: boolean;
  122675. /**
  122676. * Revers pinch action direction.
  122677. */
  122678. pinchInwards: boolean;
  122679. private _isPanClick;
  122680. private _twoFingerActivityCount;
  122681. private _isPinching;
  122682. /**
  122683. * Called on pointer POINTERMOVE event if only a single touch is active.
  122684. */
  122685. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  122686. /**
  122687. * Called on pointer POINTERDOUBLETAP event.
  122688. */
  122689. protected onDoubleTap(type: string): void;
  122690. /**
  122691. * Called on pointer POINTERMOVE event if multiple touches are active.
  122692. */
  122693. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  122694. /**
  122695. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  122696. * press.
  122697. */
  122698. protected onButtonDown(evt: PointerEvent): void;
  122699. /**
  122700. * Called each time a new POINTERUP event occurs. Ie, for each button
  122701. * release.
  122702. */
  122703. protected onButtonUp(evt: PointerEvent): void;
  122704. /**
  122705. * Called when window becomes inactive.
  122706. */
  122707. protected onLostFocus(): void;
  122708. }
  122709. }
  122710. declare module BABYLON {
  122711. /**
  122712. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  122713. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  122714. */
  122715. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  122716. /**
  122717. * Defines the camera the input is attached to.
  122718. */
  122719. camera: ArcRotateCamera;
  122720. /**
  122721. * Defines the list of key codes associated with the up action (increase alpha)
  122722. */
  122723. keysUp: number[];
  122724. /**
  122725. * Defines the list of key codes associated with the down action (decrease alpha)
  122726. */
  122727. keysDown: number[];
  122728. /**
  122729. * Defines the list of key codes associated with the left action (increase beta)
  122730. */
  122731. keysLeft: number[];
  122732. /**
  122733. * Defines the list of key codes associated with the right action (decrease beta)
  122734. */
  122735. keysRight: number[];
  122736. /**
  122737. * Defines the list of key codes associated with the reset action.
  122738. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  122739. */
  122740. keysReset: number[];
  122741. /**
  122742. * Defines the panning sensibility of the inputs.
  122743. * (How fast is the camera panning)
  122744. */
  122745. panningSensibility: number;
  122746. /**
  122747. * Defines the zooming sensibility of the inputs.
  122748. * (How fast is the camera zooming)
  122749. */
  122750. zoomingSensibility: number;
  122751. /**
  122752. * Defines whether maintaining the alt key down switch the movement mode from
  122753. * orientation to zoom.
  122754. */
  122755. useAltToZoom: boolean;
  122756. /**
  122757. * Rotation speed of the camera
  122758. */
  122759. angularSpeed: number;
  122760. private _keys;
  122761. private _ctrlPressed;
  122762. private _altPressed;
  122763. private _onCanvasBlurObserver;
  122764. private _onKeyboardObserver;
  122765. private _engine;
  122766. private _scene;
  122767. /**
  122768. * Attach the input controls to a specific dom element to get the input from.
  122769. * @param element Defines the element the controls should be listened from
  122770. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  122771. */
  122772. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  122773. /**
  122774. * Detach the current controls from the specified dom element.
  122775. * @param element Defines the element to stop listening the inputs from
  122776. */
  122777. detachControl(element: Nullable<HTMLElement>): void;
  122778. /**
  122779. * Update the current camera state depending on the inputs that have been used this frame.
  122780. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  122781. */
  122782. checkInputs(): void;
  122783. /**
  122784. * Gets the class name of the current intput.
  122785. * @returns the class name
  122786. */
  122787. getClassName(): string;
  122788. /**
  122789. * Get the friendly name associated with the input class.
  122790. * @returns the input friendly name
  122791. */
  122792. getSimpleName(): string;
  122793. }
  122794. }
  122795. declare module BABYLON {
  122796. /**
  122797. * Manage the mouse wheel inputs to control an arc rotate camera.
  122798. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  122799. */
  122800. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  122801. /**
  122802. * Defines the camera the input is attached to.
  122803. */
  122804. camera: ArcRotateCamera;
  122805. /**
  122806. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  122807. */
  122808. wheelPrecision: number;
  122809. /**
  122810. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  122811. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  122812. */
  122813. wheelDeltaPercentage: number;
  122814. private _wheel;
  122815. private _observer;
  122816. private computeDeltaFromMouseWheelLegacyEvent;
  122817. /**
  122818. * Attach the input controls to a specific dom element to get the input from.
  122819. * @param element Defines the element the controls should be listened from
  122820. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  122821. */
  122822. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  122823. /**
  122824. * Detach the current controls from the specified dom element.
  122825. * @param element Defines the element to stop listening the inputs from
  122826. */
  122827. detachControl(element: Nullable<HTMLElement>): void;
  122828. /**
  122829. * Gets the class name of the current intput.
  122830. * @returns the class name
  122831. */
  122832. getClassName(): string;
  122833. /**
  122834. * Get the friendly name associated with the input class.
  122835. * @returns the input friendly name
  122836. */
  122837. getSimpleName(): string;
  122838. }
  122839. }
  122840. declare module BABYLON {
  122841. /**
  122842. * Default Inputs manager for the ArcRotateCamera.
  122843. * It groups all the default supported inputs for ease of use.
  122844. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  122845. */
  122846. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  122847. /**
  122848. * Instantiates a new ArcRotateCameraInputsManager.
  122849. * @param camera Defines the camera the inputs belong to
  122850. */
  122851. constructor(camera: ArcRotateCamera);
  122852. /**
  122853. * Add mouse wheel input support to the input manager.
  122854. * @returns the current input manager
  122855. */
  122856. addMouseWheel(): ArcRotateCameraInputsManager;
  122857. /**
  122858. * Add pointers input support to the input manager.
  122859. * @returns the current input manager
  122860. */
  122861. addPointers(): ArcRotateCameraInputsManager;
  122862. /**
  122863. * Add keyboard input support to the input manager.
  122864. * @returns the current input manager
  122865. */
  122866. addKeyboard(): ArcRotateCameraInputsManager;
  122867. }
  122868. }
  122869. declare module BABYLON {
  122870. /**
  122871. * This represents an orbital type of camera.
  122872. *
  122873. * 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.
  122874. * 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.
  122875. * @see https://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  122876. */
  122877. export class ArcRotateCamera extends TargetCamera {
  122878. /**
  122879. * Defines the rotation angle of the camera along the longitudinal axis.
  122880. */
  122881. alpha: number;
  122882. /**
  122883. * Defines the rotation angle of the camera along the latitudinal axis.
  122884. */
  122885. beta: number;
  122886. /**
  122887. * Defines the radius of the camera from it s target point.
  122888. */
  122889. radius: number;
  122890. protected _target: Vector3;
  122891. protected _targetHost: Nullable<AbstractMesh>;
  122892. /**
  122893. * Defines the target point of the camera.
  122894. * The camera looks towards it form the radius distance.
  122895. * Please note that you can set the target to a mesh and thus the target will be copied from mesh.position
  122896. */
  122897. get target(): Vector3;
  122898. set target(value: Vector3);
  122899. /**
  122900. * Define the current local position of the camera in the scene
  122901. */
  122902. get position(): Vector3;
  122903. set position(newPosition: Vector3);
  122904. protected _upToYMatrix: Matrix;
  122905. protected _YToUpMatrix: Matrix;
  122906. /**
  122907. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  122908. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  122909. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  122910. */
  122911. set upVector(vec: Vector3);
  122912. get upVector(): Vector3;
  122913. /**
  122914. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  122915. */
  122916. setMatUp(): void;
  122917. /**
  122918. * Current inertia value on the longitudinal axis.
  122919. * The bigger this number the longer it will take for the camera to stop.
  122920. */
  122921. inertialAlphaOffset: number;
  122922. /**
  122923. * Current inertia value on the latitudinal axis.
  122924. * The bigger this number the longer it will take for the camera to stop.
  122925. */
  122926. inertialBetaOffset: number;
  122927. /**
  122928. * Current inertia value on the radius axis.
  122929. * The bigger this number the longer it will take for the camera to stop.
  122930. */
  122931. inertialRadiusOffset: number;
  122932. /**
  122933. * Minimum allowed angle on the longitudinal axis.
  122934. * This can help limiting how the Camera is able to move in the scene.
  122935. */
  122936. lowerAlphaLimit: Nullable<number>;
  122937. /**
  122938. * Maximum allowed angle on the longitudinal axis.
  122939. * This can help limiting how the Camera is able to move in the scene.
  122940. */
  122941. upperAlphaLimit: Nullable<number>;
  122942. /**
  122943. * Minimum allowed angle on the latitudinal axis.
  122944. * This can help limiting how the Camera is able to move in the scene.
  122945. */
  122946. lowerBetaLimit: number;
  122947. /**
  122948. * Maximum allowed angle on the latitudinal axis.
  122949. * This can help limiting how the Camera is able to move in the scene.
  122950. */
  122951. upperBetaLimit: number;
  122952. /**
  122953. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  122954. * This can help limiting how the Camera is able to move in the scene.
  122955. */
  122956. lowerRadiusLimit: Nullable<number>;
  122957. /**
  122958. * Maximum allowed distance of the camera to the target (The camera can not get further).
  122959. * This can help limiting how the Camera is able to move in the scene.
  122960. */
  122961. upperRadiusLimit: Nullable<number>;
  122962. /**
  122963. * Defines the current inertia value used during panning of the camera along the X axis.
  122964. */
  122965. inertialPanningX: number;
  122966. /**
  122967. * Defines the current inertia value used during panning of the camera along the Y axis.
  122968. */
  122969. inertialPanningY: number;
  122970. /**
  122971. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  122972. * Basically if your fingers moves away from more than this distance you will be considered
  122973. * in pinch mode.
  122974. */
  122975. pinchToPanMaxDistance: number;
  122976. /**
  122977. * Defines the maximum distance the camera can pan.
  122978. * This could help keeping the cammera always in your scene.
  122979. */
  122980. panningDistanceLimit: Nullable<number>;
  122981. /**
  122982. * Defines the target of the camera before paning.
  122983. */
  122984. panningOriginTarget: Vector3;
  122985. /**
  122986. * Defines the value of the inertia used during panning.
  122987. * 0 would mean stop inertia and one would mean no decelleration at all.
  122988. */
  122989. panningInertia: number;
  122990. /**
  122991. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  122992. */
  122993. get angularSensibilityX(): number;
  122994. set angularSensibilityX(value: number);
  122995. /**
  122996. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  122997. */
  122998. get angularSensibilityY(): number;
  122999. set angularSensibilityY(value: number);
  123000. /**
  123001. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  123002. */
  123003. get pinchPrecision(): number;
  123004. set pinchPrecision(value: number);
  123005. /**
  123006. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  123007. * It will be used instead of pinchDeltaPrecision if different from 0.
  123008. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  123009. */
  123010. get pinchDeltaPercentage(): number;
  123011. set pinchDeltaPercentage(value: number);
  123012. /**
  123013. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  123014. * and pinch delta percentage.
  123015. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  123016. * that any object in the plane at the camera's target point will scale
  123017. * perfectly with finger motion.
  123018. */
  123019. get useNaturalPinchZoom(): boolean;
  123020. set useNaturalPinchZoom(value: boolean);
  123021. /**
  123022. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  123023. */
  123024. get panningSensibility(): number;
  123025. set panningSensibility(value: number);
  123026. /**
  123027. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  123028. */
  123029. get keysUp(): number[];
  123030. set keysUp(value: number[]);
  123031. /**
  123032. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  123033. */
  123034. get keysDown(): number[];
  123035. set keysDown(value: number[]);
  123036. /**
  123037. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  123038. */
  123039. get keysLeft(): number[];
  123040. set keysLeft(value: number[]);
  123041. /**
  123042. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  123043. */
  123044. get keysRight(): number[];
  123045. set keysRight(value: number[]);
  123046. /**
  123047. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  123048. */
  123049. get wheelPrecision(): number;
  123050. set wheelPrecision(value: number);
  123051. /**
  123052. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  123053. * It will be used instead of pinchDeltaPrecision if different from 0.
  123054. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  123055. */
  123056. get wheelDeltaPercentage(): number;
  123057. set wheelDeltaPercentage(value: number);
  123058. /**
  123059. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  123060. */
  123061. zoomOnFactor: number;
  123062. /**
  123063. * Defines a screen offset for the camera position.
  123064. */
  123065. targetScreenOffset: Vector2;
  123066. /**
  123067. * Allows the camera to be completely reversed.
  123068. * If false the camera can not arrive upside down.
  123069. */
  123070. allowUpsideDown: boolean;
  123071. /**
  123072. * Define if double tap/click is used to restore the previously saved state of the camera.
  123073. */
  123074. useInputToRestoreState: boolean;
  123075. /** @hidden */
  123076. _viewMatrix: Matrix;
  123077. /** @hidden */
  123078. _useCtrlForPanning: boolean;
  123079. /** @hidden */
  123080. _panningMouseButton: number;
  123081. /**
  123082. * Defines the input associated to the camera.
  123083. */
  123084. inputs: ArcRotateCameraInputsManager;
  123085. /** @hidden */
  123086. _reset: () => void;
  123087. /**
  123088. * Defines the allowed panning axis.
  123089. */
  123090. panningAxis: Vector3;
  123091. protected _localDirection: Vector3;
  123092. protected _transformedDirection: Vector3;
  123093. private _bouncingBehavior;
  123094. /**
  123095. * Gets the bouncing behavior of the camera if it has been enabled.
  123096. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  123097. */
  123098. get bouncingBehavior(): Nullable<BouncingBehavior>;
  123099. /**
  123100. * Defines if the bouncing behavior of the camera is enabled on the camera.
  123101. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  123102. */
  123103. get useBouncingBehavior(): boolean;
  123104. set useBouncingBehavior(value: boolean);
  123105. private _framingBehavior;
  123106. /**
  123107. * Gets the framing behavior of the camera if it has been enabled.
  123108. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  123109. */
  123110. get framingBehavior(): Nullable<FramingBehavior>;
  123111. /**
  123112. * Defines if the framing behavior of the camera is enabled on the camera.
  123113. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  123114. */
  123115. get useFramingBehavior(): boolean;
  123116. set useFramingBehavior(value: boolean);
  123117. private _autoRotationBehavior;
  123118. /**
  123119. * Gets the auto rotation behavior of the camera if it has been enabled.
  123120. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  123121. */
  123122. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  123123. /**
  123124. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  123125. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  123126. */
  123127. get useAutoRotationBehavior(): boolean;
  123128. set useAutoRotationBehavior(value: boolean);
  123129. /**
  123130. * Observable triggered when the mesh target has been changed on the camera.
  123131. */
  123132. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  123133. /**
  123134. * Event raised when the camera is colliding with a mesh.
  123135. */
  123136. onCollide: (collidedMesh: AbstractMesh) => void;
  123137. /**
  123138. * Defines whether the camera should check collision with the objects oh the scene.
  123139. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  123140. */
  123141. checkCollisions: boolean;
  123142. /**
  123143. * Defines the collision radius of the camera.
  123144. * This simulates a sphere around the camera.
  123145. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  123146. */
  123147. collisionRadius: Vector3;
  123148. protected _collider: Collider;
  123149. protected _previousPosition: Vector3;
  123150. protected _collisionVelocity: Vector3;
  123151. protected _newPosition: Vector3;
  123152. protected _previousAlpha: number;
  123153. protected _previousBeta: number;
  123154. protected _previousRadius: number;
  123155. protected _collisionTriggered: boolean;
  123156. protected _targetBoundingCenter: Nullable<Vector3>;
  123157. private _computationVector;
  123158. /**
  123159. * Instantiates a new ArcRotateCamera in a given scene
  123160. * @param name Defines the name of the camera
  123161. * @param alpha Defines the camera rotation along the logitudinal axis
  123162. * @param beta Defines the camera rotation along the latitudinal axis
  123163. * @param radius Defines the camera distance from its target
  123164. * @param target Defines the camera target
  123165. * @param scene Defines the scene the camera belongs to
  123166. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  123167. */
  123168. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  123169. /** @hidden */
  123170. _initCache(): void;
  123171. /** @hidden */
  123172. _updateCache(ignoreParentClass?: boolean): void;
  123173. protected _getTargetPosition(): Vector3;
  123174. private _storedAlpha;
  123175. private _storedBeta;
  123176. private _storedRadius;
  123177. private _storedTarget;
  123178. private _storedTargetScreenOffset;
  123179. /**
  123180. * Stores the current state of the camera (alpha, beta, radius and target)
  123181. * @returns the camera itself
  123182. */
  123183. storeState(): Camera;
  123184. /**
  123185. * @hidden
  123186. * Restored camera state. You must call storeState() first
  123187. */
  123188. _restoreStateValues(): boolean;
  123189. /** @hidden */
  123190. _isSynchronizedViewMatrix(): boolean;
  123191. /**
  123192. * Attached controls to the current camera.
  123193. * @param element Defines the element the controls should be listened from
  123194. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  123195. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  123196. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  123197. */
  123198. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  123199. /**
  123200. * Detach the current controls from the camera.
  123201. * The camera will stop reacting to inputs.
  123202. * @param element Defines the element to stop listening the inputs from
  123203. */
  123204. detachControl(element: HTMLElement): void;
  123205. /** @hidden */
  123206. _checkInputs(): void;
  123207. protected _checkLimits(): void;
  123208. /**
  123209. * Rebuilds angles (alpha, beta) and radius from the give position and target
  123210. */
  123211. rebuildAnglesAndRadius(): void;
  123212. /**
  123213. * Use a position to define the current camera related information like alpha, beta and radius
  123214. * @param position Defines the position to set the camera at
  123215. */
  123216. setPosition(position: Vector3): void;
  123217. /**
  123218. * Defines the target the camera should look at.
  123219. * This will automatically adapt alpha beta and radius to fit within the new target.
  123220. * @param target Defines the new target as a Vector or a mesh
  123221. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  123222. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  123223. */
  123224. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  123225. /** @hidden */
  123226. _getViewMatrix(): Matrix;
  123227. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  123228. /**
  123229. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  123230. * @param meshes Defines the mesh to zoom on
  123231. * @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)
  123232. */
  123233. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  123234. /**
  123235. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  123236. * The target will be changed but the radius
  123237. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  123238. * @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)
  123239. */
  123240. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  123241. min: Vector3;
  123242. max: Vector3;
  123243. distance: number;
  123244. }, doNotUpdateMaxZ?: boolean): void;
  123245. /**
  123246. * @override
  123247. * Override Camera.createRigCamera
  123248. */
  123249. createRigCamera(name: string, cameraIndex: number): Camera;
  123250. /**
  123251. * @hidden
  123252. * @override
  123253. * Override Camera._updateRigCameras
  123254. */
  123255. _updateRigCameras(): void;
  123256. /**
  123257. * Destroy the camera and release the current resources hold by it.
  123258. */
  123259. dispose(): void;
  123260. /**
  123261. * Gets the current object class name.
  123262. * @return the class name
  123263. */
  123264. getClassName(): string;
  123265. }
  123266. }
  123267. declare module BABYLON {
  123268. /**
  123269. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  123270. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  123271. */
  123272. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  123273. /**
  123274. * Gets the name of the behavior.
  123275. */
  123276. get name(): string;
  123277. private _zoomStopsAnimation;
  123278. private _idleRotationSpeed;
  123279. private _idleRotationWaitTime;
  123280. private _idleRotationSpinupTime;
  123281. /**
  123282. * Sets the flag that indicates if user zooming should stop animation.
  123283. */
  123284. set zoomStopsAnimation(flag: boolean);
  123285. /**
  123286. * Gets the flag that indicates if user zooming should stop animation.
  123287. */
  123288. get zoomStopsAnimation(): boolean;
  123289. /**
  123290. * Sets the default speed at which the camera rotates around the model.
  123291. */
  123292. set idleRotationSpeed(speed: number);
  123293. /**
  123294. * Gets the default speed at which the camera rotates around the model.
  123295. */
  123296. get idleRotationSpeed(): number;
  123297. /**
  123298. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  123299. */
  123300. set idleRotationWaitTime(time: number);
  123301. /**
  123302. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  123303. */
  123304. get idleRotationWaitTime(): number;
  123305. /**
  123306. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  123307. */
  123308. set idleRotationSpinupTime(time: number);
  123309. /**
  123310. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  123311. */
  123312. get idleRotationSpinupTime(): number;
  123313. /**
  123314. * Gets a value indicating if the camera is currently rotating because of this behavior
  123315. */
  123316. get rotationInProgress(): boolean;
  123317. private _onPrePointerObservableObserver;
  123318. private _onAfterCheckInputsObserver;
  123319. private _attachedCamera;
  123320. private _isPointerDown;
  123321. private _lastFrameTime;
  123322. private _lastInteractionTime;
  123323. private _cameraRotationSpeed;
  123324. /**
  123325. * Initializes the behavior.
  123326. */
  123327. init(): void;
  123328. /**
  123329. * Attaches the behavior to its arc rotate camera.
  123330. * @param camera Defines the camera to attach the behavior to
  123331. */
  123332. attach(camera: ArcRotateCamera): void;
  123333. /**
  123334. * Detaches the behavior from its current arc rotate camera.
  123335. */
  123336. detach(): void;
  123337. /**
  123338. * Returns true if user is scrolling.
  123339. * @return true if user is scrolling.
  123340. */
  123341. private _userIsZooming;
  123342. private _lastFrameRadius;
  123343. private _shouldAnimationStopForInteraction;
  123344. /**
  123345. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  123346. */
  123347. private _applyUserInteraction;
  123348. private _userIsMoving;
  123349. }
  123350. }
  123351. declare module BABYLON {
  123352. /**
  123353. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  123354. */
  123355. export class AttachToBoxBehavior implements Behavior<Mesh> {
  123356. private ui;
  123357. /**
  123358. * The name of the behavior
  123359. */
  123360. name: string;
  123361. /**
  123362. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  123363. */
  123364. distanceAwayFromFace: number;
  123365. /**
  123366. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  123367. */
  123368. distanceAwayFromBottomOfFace: number;
  123369. private _faceVectors;
  123370. private _target;
  123371. private _scene;
  123372. private _onRenderObserver;
  123373. private _tmpMatrix;
  123374. private _tmpVector;
  123375. /**
  123376. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  123377. * @param ui The transform node that should be attched to the mesh
  123378. */
  123379. constructor(ui: TransformNode);
  123380. /**
  123381. * Initializes the behavior
  123382. */
  123383. init(): void;
  123384. private _closestFace;
  123385. private _zeroVector;
  123386. private _lookAtTmpMatrix;
  123387. private _lookAtToRef;
  123388. /**
  123389. * Attaches the AttachToBoxBehavior to the passed in mesh
  123390. * @param target The mesh that the specified node will be attached to
  123391. */
  123392. attach(target: Mesh): void;
  123393. /**
  123394. * Detaches the behavior from the mesh
  123395. */
  123396. detach(): void;
  123397. }
  123398. }
  123399. declare module BABYLON {
  123400. /**
  123401. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  123402. */
  123403. export class FadeInOutBehavior implements Behavior<Mesh> {
  123404. /**
  123405. * Time in milliseconds to delay before fading in (Default: 0)
  123406. */
  123407. delay: number;
  123408. /**
  123409. * Time in milliseconds for the mesh to fade in (Default: 300)
  123410. */
  123411. fadeInTime: number;
  123412. private _millisecondsPerFrame;
  123413. private _hovered;
  123414. private _hoverValue;
  123415. private _ownerNode;
  123416. /**
  123417. * Instatiates the FadeInOutBehavior
  123418. */
  123419. constructor();
  123420. /**
  123421. * The name of the behavior
  123422. */
  123423. get name(): string;
  123424. /**
  123425. * Initializes the behavior
  123426. */
  123427. init(): void;
  123428. /**
  123429. * Attaches the fade behavior on the passed in mesh
  123430. * @param ownerNode The mesh that will be faded in/out once attached
  123431. */
  123432. attach(ownerNode: Mesh): void;
  123433. /**
  123434. * Detaches the behavior from the mesh
  123435. */
  123436. detach(): void;
  123437. /**
  123438. * Triggers the mesh to begin fading in or out
  123439. * @param value if the object should fade in or out (true to fade in)
  123440. */
  123441. fadeIn(value: boolean): void;
  123442. private _update;
  123443. private _setAllVisibility;
  123444. }
  123445. }
  123446. declare module BABYLON {
  123447. /**
  123448. * Class containing a set of static utilities functions for managing Pivots
  123449. * @hidden
  123450. */
  123451. export class PivotTools {
  123452. private static _PivotCached;
  123453. private static _OldPivotPoint;
  123454. private static _PivotTranslation;
  123455. private static _PivotTmpVector;
  123456. private static _PivotPostMultiplyPivotMatrix;
  123457. /** @hidden */
  123458. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  123459. /** @hidden */
  123460. static _RestorePivotPoint(mesh: AbstractMesh): void;
  123461. }
  123462. }
  123463. declare module BABYLON {
  123464. /**
  123465. * Class containing static functions to help procedurally build meshes
  123466. */
  123467. export class PlaneBuilder {
  123468. /**
  123469. * Creates a plane mesh
  123470. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  123471. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  123472. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  123473. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123474. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  123475. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123476. * @param name defines the name of the mesh
  123477. * @param options defines the options used to create the mesh
  123478. * @param scene defines the hosting scene
  123479. * @returns the plane mesh
  123480. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  123481. */
  123482. static CreatePlane(name: string, options: {
  123483. size?: number;
  123484. width?: number;
  123485. height?: number;
  123486. sideOrientation?: number;
  123487. frontUVs?: Vector4;
  123488. backUVs?: Vector4;
  123489. updatable?: boolean;
  123490. sourcePlane?: Plane;
  123491. }, scene?: Nullable<Scene>): Mesh;
  123492. }
  123493. }
  123494. declare module BABYLON {
  123495. /**
  123496. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  123497. */
  123498. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  123499. private static _AnyMouseID;
  123500. /**
  123501. * Abstract mesh the behavior is set on
  123502. */
  123503. attachedNode: AbstractMesh;
  123504. private _dragPlane;
  123505. private _scene;
  123506. private _pointerObserver;
  123507. private _beforeRenderObserver;
  123508. private static _planeScene;
  123509. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  123510. /**
  123511. * 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)
  123512. */
  123513. maxDragAngle: number;
  123514. /**
  123515. * @hidden
  123516. */
  123517. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  123518. /**
  123519. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  123520. */
  123521. currentDraggingPointerID: number;
  123522. /**
  123523. * The last position where the pointer hit the drag plane in world space
  123524. */
  123525. lastDragPosition: Vector3;
  123526. /**
  123527. * If the behavior is currently in a dragging state
  123528. */
  123529. dragging: boolean;
  123530. /**
  123531. * 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)
  123532. */
  123533. dragDeltaRatio: number;
  123534. /**
  123535. * If the drag plane orientation should be updated during the dragging (Default: true)
  123536. */
  123537. updateDragPlane: boolean;
  123538. private _debugMode;
  123539. private _moving;
  123540. /**
  123541. * Fires each time the attached mesh is dragged with the pointer
  123542. * * delta between last drag position and current drag position in world space
  123543. * * dragDistance along the drag axis
  123544. * * dragPlaneNormal normal of the current drag plane used during the drag
  123545. * * dragPlanePoint in world space where the drag intersects the drag plane
  123546. */
  123547. onDragObservable: Observable<{
  123548. delta: Vector3;
  123549. dragPlanePoint: Vector3;
  123550. dragPlaneNormal: Vector3;
  123551. dragDistance: number;
  123552. pointerId: number;
  123553. }>;
  123554. /**
  123555. * Fires each time a drag begins (eg. mouse down on mesh)
  123556. */
  123557. onDragStartObservable: Observable<{
  123558. dragPlanePoint: Vector3;
  123559. pointerId: number;
  123560. }>;
  123561. /**
  123562. * Fires each time a drag ends (eg. mouse release after drag)
  123563. */
  123564. onDragEndObservable: Observable<{
  123565. dragPlanePoint: Vector3;
  123566. pointerId: number;
  123567. }>;
  123568. /**
  123569. * If the attached mesh should be moved when dragged
  123570. */
  123571. moveAttached: boolean;
  123572. /**
  123573. * If the drag behavior will react to drag events (Default: true)
  123574. */
  123575. enabled: boolean;
  123576. /**
  123577. * If pointer events should start and release the drag (Default: true)
  123578. */
  123579. startAndReleaseDragOnPointerEvents: boolean;
  123580. /**
  123581. * If camera controls should be detached during the drag
  123582. */
  123583. detachCameraControls: boolean;
  123584. /**
  123585. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  123586. */
  123587. useObjectOrientationForDragging: boolean;
  123588. private _options;
  123589. /**
  123590. * Gets the options used by the behavior
  123591. */
  123592. get options(): {
  123593. dragAxis?: Vector3;
  123594. dragPlaneNormal?: Vector3;
  123595. };
  123596. /**
  123597. * Sets the options used by the behavior
  123598. */
  123599. set options(options: {
  123600. dragAxis?: Vector3;
  123601. dragPlaneNormal?: Vector3;
  123602. });
  123603. /**
  123604. * Creates a pointer drag behavior that can be attached to a mesh
  123605. * @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)
  123606. */
  123607. constructor(options?: {
  123608. dragAxis?: Vector3;
  123609. dragPlaneNormal?: Vector3;
  123610. });
  123611. /**
  123612. * Predicate to determine if it is valid to move the object to a new position when it is moved
  123613. */
  123614. validateDrag: (targetPosition: Vector3) => boolean;
  123615. /**
  123616. * The name of the behavior
  123617. */
  123618. get name(): string;
  123619. /**
  123620. * Initializes the behavior
  123621. */
  123622. init(): void;
  123623. private _tmpVector;
  123624. private _alternatePickedPoint;
  123625. private _worldDragAxis;
  123626. private _targetPosition;
  123627. private _attachedElement;
  123628. /**
  123629. * Attaches the drag behavior the passed in mesh
  123630. * @param ownerNode The mesh that will be dragged around once attached
  123631. * @param predicate Predicate to use for pick filtering
  123632. */
  123633. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  123634. /**
  123635. * Force relase the drag action by code.
  123636. */
  123637. releaseDrag(): void;
  123638. private _startDragRay;
  123639. private _lastPointerRay;
  123640. /**
  123641. * Simulates the start of a pointer drag event on the behavior
  123642. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  123643. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  123644. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  123645. */
  123646. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  123647. protected _startDrag(pointerId: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  123648. private _dragDelta;
  123649. protected _moveDrag(ray: Ray): void;
  123650. private _pickWithRayOnDragPlane;
  123651. private _pointA;
  123652. private _pointC;
  123653. private _localAxis;
  123654. private _lookAt;
  123655. private _updateDragPlanePosition;
  123656. /**
  123657. * Detaches the behavior from the mesh
  123658. */
  123659. detach(): void;
  123660. }
  123661. }
  123662. declare module BABYLON {
  123663. /**
  123664. * A behavior that when attached to a mesh will allow the mesh to be scaled
  123665. */
  123666. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  123667. private _dragBehaviorA;
  123668. private _dragBehaviorB;
  123669. private _startDistance;
  123670. private _initialScale;
  123671. private _targetScale;
  123672. private _ownerNode;
  123673. private _sceneRenderObserver;
  123674. /**
  123675. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  123676. */
  123677. constructor();
  123678. /**
  123679. * The name of the behavior
  123680. */
  123681. get name(): string;
  123682. /**
  123683. * Initializes the behavior
  123684. */
  123685. init(): void;
  123686. private _getCurrentDistance;
  123687. /**
  123688. * Attaches the scale behavior the passed in mesh
  123689. * @param ownerNode The mesh that will be scaled around once attached
  123690. */
  123691. attach(ownerNode: Mesh): void;
  123692. /**
  123693. * Detaches the behavior from the mesh
  123694. */
  123695. detach(): void;
  123696. }
  123697. }
  123698. declare module BABYLON {
  123699. /**
  123700. * 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
  123701. */
  123702. export class SixDofDragBehavior implements Behavior<Mesh> {
  123703. private static _virtualScene;
  123704. private _ownerNode;
  123705. private _sceneRenderObserver;
  123706. private _scene;
  123707. private _targetPosition;
  123708. private _virtualOriginMesh;
  123709. private _virtualDragMesh;
  123710. private _pointerObserver;
  123711. private _moving;
  123712. private _startingOrientation;
  123713. private _attachedElement;
  123714. /**
  123715. * 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)
  123716. */
  123717. private zDragFactor;
  123718. /**
  123719. * If the object should rotate to face the drag origin
  123720. */
  123721. rotateDraggedObject: boolean;
  123722. /**
  123723. * If the behavior is currently in a dragging state
  123724. */
  123725. dragging: boolean;
  123726. /**
  123727. * 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)
  123728. */
  123729. dragDeltaRatio: number;
  123730. /**
  123731. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  123732. */
  123733. currentDraggingPointerID: number;
  123734. /**
  123735. * If camera controls should be detached during the drag
  123736. */
  123737. detachCameraControls: boolean;
  123738. /**
  123739. * Fires each time a drag starts
  123740. */
  123741. onDragStartObservable: Observable<{}>;
  123742. /**
  123743. * Fires each time a drag ends (eg. mouse release after drag)
  123744. */
  123745. onDragEndObservable: Observable<{}>;
  123746. /**
  123747. * 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
  123748. */
  123749. constructor();
  123750. /**
  123751. * The name of the behavior
  123752. */
  123753. get name(): string;
  123754. /**
  123755. * Initializes the behavior
  123756. */
  123757. init(): void;
  123758. /**
  123759. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  123760. */
  123761. private get _pointerCamera();
  123762. /**
  123763. * Attaches the scale behavior the passed in mesh
  123764. * @param ownerNode The mesh that will be scaled around once attached
  123765. */
  123766. attach(ownerNode: Mesh): void;
  123767. /**
  123768. * Detaches the behavior from the mesh
  123769. */
  123770. detach(): void;
  123771. }
  123772. }
  123773. declare module BABYLON {
  123774. /**
  123775. * Class used to apply inverse kinematics to bones
  123776. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  123777. */
  123778. export class BoneIKController {
  123779. private static _tmpVecs;
  123780. private static _tmpQuat;
  123781. private static _tmpMats;
  123782. /**
  123783. * Gets or sets the target mesh
  123784. */
  123785. targetMesh: AbstractMesh;
  123786. /** Gets or sets the mesh used as pole */
  123787. poleTargetMesh: AbstractMesh;
  123788. /**
  123789. * Gets or sets the bone used as pole
  123790. */
  123791. poleTargetBone: Nullable<Bone>;
  123792. /**
  123793. * Gets or sets the target position
  123794. */
  123795. targetPosition: Vector3;
  123796. /**
  123797. * Gets or sets the pole target position
  123798. */
  123799. poleTargetPosition: Vector3;
  123800. /**
  123801. * Gets or sets the pole target local offset
  123802. */
  123803. poleTargetLocalOffset: Vector3;
  123804. /**
  123805. * Gets or sets the pole angle
  123806. */
  123807. poleAngle: number;
  123808. /**
  123809. * Gets or sets the mesh associated with the controller
  123810. */
  123811. mesh: AbstractMesh;
  123812. /**
  123813. * 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)
  123814. */
  123815. slerpAmount: number;
  123816. private _bone1Quat;
  123817. private _bone1Mat;
  123818. private _bone2Ang;
  123819. private _bone1;
  123820. private _bone2;
  123821. private _bone1Length;
  123822. private _bone2Length;
  123823. private _maxAngle;
  123824. private _maxReach;
  123825. private _rightHandedSystem;
  123826. private _bendAxis;
  123827. private _slerping;
  123828. private _adjustRoll;
  123829. /**
  123830. * Gets or sets maximum allowed angle
  123831. */
  123832. get maxAngle(): number;
  123833. set maxAngle(value: number);
  123834. /**
  123835. * Creates a new BoneIKController
  123836. * @param mesh defines the mesh to control
  123837. * @param bone defines the bone to control
  123838. * @param options defines options to set up the controller
  123839. */
  123840. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  123841. targetMesh?: AbstractMesh;
  123842. poleTargetMesh?: AbstractMesh;
  123843. poleTargetBone?: Bone;
  123844. poleTargetLocalOffset?: Vector3;
  123845. poleAngle?: number;
  123846. bendAxis?: Vector3;
  123847. maxAngle?: number;
  123848. slerpAmount?: number;
  123849. });
  123850. private _setMaxAngle;
  123851. /**
  123852. * Force the controller to update the bones
  123853. */
  123854. update(): void;
  123855. }
  123856. }
  123857. declare module BABYLON {
  123858. /**
  123859. * Class used to make a bone look toward a point in space
  123860. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  123861. */
  123862. export class BoneLookController {
  123863. private static _tmpVecs;
  123864. private static _tmpQuat;
  123865. private static _tmpMats;
  123866. /**
  123867. * The target Vector3 that the bone will look at
  123868. */
  123869. target: Vector3;
  123870. /**
  123871. * The mesh that the bone is attached to
  123872. */
  123873. mesh: AbstractMesh;
  123874. /**
  123875. * The bone that will be looking to the target
  123876. */
  123877. bone: Bone;
  123878. /**
  123879. * The up axis of the coordinate system that is used when the bone is rotated
  123880. */
  123881. upAxis: Vector3;
  123882. /**
  123883. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  123884. */
  123885. upAxisSpace: Space;
  123886. /**
  123887. * Used to make an adjustment to the yaw of the bone
  123888. */
  123889. adjustYaw: number;
  123890. /**
  123891. * Used to make an adjustment to the pitch of the bone
  123892. */
  123893. adjustPitch: number;
  123894. /**
  123895. * Used to make an adjustment to the roll of the bone
  123896. */
  123897. adjustRoll: number;
  123898. /**
  123899. * 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)
  123900. */
  123901. slerpAmount: number;
  123902. private _minYaw;
  123903. private _maxYaw;
  123904. private _minPitch;
  123905. private _maxPitch;
  123906. private _minYawSin;
  123907. private _minYawCos;
  123908. private _maxYawSin;
  123909. private _maxYawCos;
  123910. private _midYawConstraint;
  123911. private _minPitchTan;
  123912. private _maxPitchTan;
  123913. private _boneQuat;
  123914. private _slerping;
  123915. private _transformYawPitch;
  123916. private _transformYawPitchInv;
  123917. private _firstFrameSkipped;
  123918. private _yawRange;
  123919. private _fowardAxis;
  123920. /**
  123921. * Gets or sets the minimum yaw angle that the bone can look to
  123922. */
  123923. get minYaw(): number;
  123924. set minYaw(value: number);
  123925. /**
  123926. * Gets or sets the maximum yaw angle that the bone can look to
  123927. */
  123928. get maxYaw(): number;
  123929. set maxYaw(value: number);
  123930. /**
  123931. * Gets or sets the minimum pitch angle that the bone can look to
  123932. */
  123933. get minPitch(): number;
  123934. set minPitch(value: number);
  123935. /**
  123936. * Gets or sets the maximum pitch angle that the bone can look to
  123937. */
  123938. get maxPitch(): number;
  123939. set maxPitch(value: number);
  123940. /**
  123941. * Create a BoneLookController
  123942. * @param mesh the mesh that the bone belongs to
  123943. * @param bone the bone that will be looking to the target
  123944. * @param target the target Vector3 to look at
  123945. * @param options optional settings:
  123946. * * maxYaw: the maximum angle the bone will yaw to
  123947. * * minYaw: the minimum angle the bone will yaw to
  123948. * * maxPitch: the maximum angle the bone will pitch to
  123949. * * minPitch: the minimum angle the bone will yaw to
  123950. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  123951. * * upAxis: the up axis of the coordinate system
  123952. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  123953. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  123954. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  123955. * * adjustYaw: used to make an adjustment to the yaw of the bone
  123956. * * adjustPitch: used to make an adjustment to the pitch of the bone
  123957. * * adjustRoll: used to make an adjustment to the roll of the bone
  123958. **/
  123959. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  123960. maxYaw?: number;
  123961. minYaw?: number;
  123962. maxPitch?: number;
  123963. minPitch?: number;
  123964. slerpAmount?: number;
  123965. upAxis?: Vector3;
  123966. upAxisSpace?: Space;
  123967. yawAxis?: Vector3;
  123968. pitchAxis?: Vector3;
  123969. adjustYaw?: number;
  123970. adjustPitch?: number;
  123971. adjustRoll?: number;
  123972. });
  123973. /**
  123974. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  123975. */
  123976. update(): void;
  123977. private _getAngleDiff;
  123978. private _getAngleBetween;
  123979. private _isAngleBetween;
  123980. }
  123981. }
  123982. declare module BABYLON {
  123983. /**
  123984. * Manage the gamepad inputs to control an arc rotate camera.
  123985. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  123986. */
  123987. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  123988. /**
  123989. * Defines the camera the input is attached to.
  123990. */
  123991. camera: ArcRotateCamera;
  123992. /**
  123993. * Defines the gamepad the input is gathering event from.
  123994. */
  123995. gamepad: Nullable<Gamepad>;
  123996. /**
  123997. * Defines the gamepad rotation sensiblity.
  123998. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  123999. */
  124000. gamepadRotationSensibility: number;
  124001. /**
  124002. * Defines the gamepad move sensiblity.
  124003. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  124004. */
  124005. gamepadMoveSensibility: number;
  124006. private _yAxisScale;
  124007. /**
  124008. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  124009. */
  124010. get invertYAxis(): boolean;
  124011. set invertYAxis(value: boolean);
  124012. private _onGamepadConnectedObserver;
  124013. private _onGamepadDisconnectedObserver;
  124014. /**
  124015. * Attach the input controls to a specific dom element to get the input from.
  124016. * @param element Defines the element the controls should be listened from
  124017. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  124018. */
  124019. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  124020. /**
  124021. * Detach the current controls from the specified dom element.
  124022. * @param element Defines the element to stop listening the inputs from
  124023. */
  124024. detachControl(element: Nullable<HTMLElement>): void;
  124025. /**
  124026. * Update the current camera state depending on the inputs that have been used this frame.
  124027. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  124028. */
  124029. checkInputs(): void;
  124030. /**
  124031. * Gets the class name of the current intput.
  124032. * @returns the class name
  124033. */
  124034. getClassName(): string;
  124035. /**
  124036. * Get the friendly name associated with the input class.
  124037. * @returns the input friendly name
  124038. */
  124039. getSimpleName(): string;
  124040. }
  124041. }
  124042. declare module BABYLON {
  124043. interface ArcRotateCameraInputsManager {
  124044. /**
  124045. * Add orientation input support to the input manager.
  124046. * @returns the current input manager
  124047. */
  124048. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  124049. }
  124050. /**
  124051. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  124052. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  124053. */
  124054. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  124055. /**
  124056. * Defines the camera the input is attached to.
  124057. */
  124058. camera: ArcRotateCamera;
  124059. /**
  124060. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  124061. */
  124062. alphaCorrection: number;
  124063. /**
  124064. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  124065. */
  124066. gammaCorrection: number;
  124067. private _alpha;
  124068. private _gamma;
  124069. private _dirty;
  124070. private _deviceOrientationHandler;
  124071. /**
  124072. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  124073. */
  124074. constructor();
  124075. /**
  124076. * Attach the input controls to a specific dom element to get the input from.
  124077. * @param element Defines the element the controls should be listened from
  124078. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  124079. */
  124080. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  124081. /** @hidden */
  124082. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  124083. /**
  124084. * Update the current camera state depending on the inputs that have been used this frame.
  124085. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  124086. */
  124087. checkInputs(): void;
  124088. /**
  124089. * Detach the current controls from the specified dom element.
  124090. * @param element Defines the element to stop listening the inputs from
  124091. */
  124092. detachControl(element: Nullable<HTMLElement>): void;
  124093. /**
  124094. * Gets the class name of the current intput.
  124095. * @returns the class name
  124096. */
  124097. getClassName(): string;
  124098. /**
  124099. * Get the friendly name associated with the input class.
  124100. * @returns the input friendly name
  124101. */
  124102. getSimpleName(): string;
  124103. }
  124104. }
  124105. declare module BABYLON {
  124106. /**
  124107. * Listen to mouse events to control the camera.
  124108. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  124109. */
  124110. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  124111. /**
  124112. * Defines the camera the input is attached to.
  124113. */
  124114. camera: FlyCamera;
  124115. /**
  124116. * Defines if touch is enabled. (Default is true.)
  124117. */
  124118. touchEnabled: boolean;
  124119. /**
  124120. * Defines the buttons associated with the input to handle camera rotation.
  124121. */
  124122. buttons: number[];
  124123. /**
  124124. * Assign buttons for Yaw control.
  124125. */
  124126. buttonsYaw: number[];
  124127. /**
  124128. * Assign buttons for Pitch control.
  124129. */
  124130. buttonsPitch: number[];
  124131. /**
  124132. * Assign buttons for Roll control.
  124133. */
  124134. buttonsRoll: number[];
  124135. /**
  124136. * Detect if any button is being pressed while mouse is moved.
  124137. * -1 = Mouse locked.
  124138. * 0 = Left button.
  124139. * 1 = Middle Button.
  124140. * 2 = Right Button.
  124141. */
  124142. activeButton: number;
  124143. /**
  124144. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  124145. * Higher values reduce its sensitivity.
  124146. */
  124147. angularSensibility: number;
  124148. private _mousemoveCallback;
  124149. private _observer;
  124150. private _rollObserver;
  124151. private previousPosition;
  124152. private noPreventDefault;
  124153. private element;
  124154. /**
  124155. * Listen to mouse events to control the camera.
  124156. * @param touchEnabled Define if touch is enabled. (Default is true.)
  124157. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  124158. */
  124159. constructor(touchEnabled?: boolean);
  124160. /**
  124161. * Attach the mouse control to the HTML DOM element.
  124162. * @param element Defines the element that listens to the input events.
  124163. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  124164. */
  124165. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  124166. /**
  124167. * Detach the current controls from the specified dom element.
  124168. * @param element Defines the element to stop listening the inputs from
  124169. */
  124170. detachControl(element: Nullable<HTMLElement>): void;
  124171. /**
  124172. * Gets the class name of the current input.
  124173. * @returns the class name.
  124174. */
  124175. getClassName(): string;
  124176. /**
  124177. * Get the friendly name associated with the input class.
  124178. * @returns the input's friendly name.
  124179. */
  124180. getSimpleName(): string;
  124181. private _pointerInput;
  124182. private _onMouseMove;
  124183. /**
  124184. * Rotate camera by mouse offset.
  124185. */
  124186. private rotateCamera;
  124187. }
  124188. }
  124189. declare module BABYLON {
  124190. /**
  124191. * Default Inputs manager for the FlyCamera.
  124192. * It groups all the default supported inputs for ease of use.
  124193. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  124194. */
  124195. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  124196. /**
  124197. * Instantiates a new FlyCameraInputsManager.
  124198. * @param camera Defines the camera the inputs belong to.
  124199. */
  124200. constructor(camera: FlyCamera);
  124201. /**
  124202. * Add keyboard input support to the input manager.
  124203. * @returns the new FlyCameraKeyboardMoveInput().
  124204. */
  124205. addKeyboard(): FlyCameraInputsManager;
  124206. /**
  124207. * Add mouse input support to the input manager.
  124208. * @param touchEnabled Enable touch screen support.
  124209. * @returns the new FlyCameraMouseInput().
  124210. */
  124211. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  124212. }
  124213. }
  124214. declare module BABYLON {
  124215. /**
  124216. * This is a flying camera, designed for 3D movement and rotation in all directions,
  124217. * such as in a 3D Space Shooter or a Flight Simulator.
  124218. */
  124219. export class FlyCamera extends TargetCamera {
  124220. /**
  124221. * Define the collision ellipsoid of the camera.
  124222. * This is helpful for simulating a camera body, like a player's body.
  124223. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  124224. */
  124225. ellipsoid: Vector3;
  124226. /**
  124227. * Define an offset for the position of the ellipsoid around the camera.
  124228. * This can be helpful if the camera is attached away from the player's body center,
  124229. * such as at its head.
  124230. */
  124231. ellipsoidOffset: Vector3;
  124232. /**
  124233. * Enable or disable collisions of the camera with the rest of the scene objects.
  124234. */
  124235. checkCollisions: boolean;
  124236. /**
  124237. * Enable or disable gravity on the camera.
  124238. */
  124239. applyGravity: boolean;
  124240. /**
  124241. * Define the current direction the camera is moving to.
  124242. */
  124243. cameraDirection: Vector3;
  124244. /**
  124245. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  124246. * This overrides and empties cameraRotation.
  124247. */
  124248. rotationQuaternion: Quaternion;
  124249. /**
  124250. * Track Roll to maintain the wanted Rolling when looking around.
  124251. */
  124252. _trackRoll: number;
  124253. /**
  124254. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  124255. */
  124256. rollCorrect: number;
  124257. /**
  124258. * Mimic a banked turn, Rolling the camera when Yawing.
  124259. * It's recommended to use rollCorrect = 10 for faster banking correction.
  124260. */
  124261. bankedTurn: boolean;
  124262. /**
  124263. * Limit in radians for how much Roll banking will add. (Default: 90°)
  124264. */
  124265. bankedTurnLimit: number;
  124266. /**
  124267. * Value of 0 disables the banked Roll.
  124268. * Value of 1 is equal to the Yaw angle in radians.
  124269. */
  124270. bankedTurnMultiplier: number;
  124271. /**
  124272. * The inputs manager loads all the input sources, such as keyboard and mouse.
  124273. */
  124274. inputs: FlyCameraInputsManager;
  124275. /**
  124276. * Gets the input sensibility for mouse input.
  124277. * Higher values reduce sensitivity.
  124278. */
  124279. get angularSensibility(): number;
  124280. /**
  124281. * Sets the input sensibility for a mouse input.
  124282. * Higher values reduce sensitivity.
  124283. */
  124284. set angularSensibility(value: number);
  124285. /**
  124286. * Get the keys for camera movement forward.
  124287. */
  124288. get keysForward(): number[];
  124289. /**
  124290. * Set the keys for camera movement forward.
  124291. */
  124292. set keysForward(value: number[]);
  124293. /**
  124294. * Get the keys for camera movement backward.
  124295. */
  124296. get keysBackward(): number[];
  124297. set keysBackward(value: number[]);
  124298. /**
  124299. * Get the keys for camera movement up.
  124300. */
  124301. get keysUp(): number[];
  124302. /**
  124303. * Set the keys for camera movement up.
  124304. */
  124305. set keysUp(value: number[]);
  124306. /**
  124307. * Get the keys for camera movement down.
  124308. */
  124309. get keysDown(): number[];
  124310. /**
  124311. * Set the keys for camera movement down.
  124312. */
  124313. set keysDown(value: number[]);
  124314. /**
  124315. * Get the keys for camera movement left.
  124316. */
  124317. get keysLeft(): number[];
  124318. /**
  124319. * Set the keys for camera movement left.
  124320. */
  124321. set keysLeft(value: number[]);
  124322. /**
  124323. * Set the keys for camera movement right.
  124324. */
  124325. get keysRight(): number[];
  124326. /**
  124327. * Set the keys for camera movement right.
  124328. */
  124329. set keysRight(value: number[]);
  124330. /**
  124331. * Event raised when the camera collides with a mesh in the scene.
  124332. */
  124333. onCollide: (collidedMesh: AbstractMesh) => void;
  124334. private _collider;
  124335. private _needMoveForGravity;
  124336. private _oldPosition;
  124337. private _diffPosition;
  124338. private _newPosition;
  124339. /** @hidden */
  124340. _localDirection: Vector3;
  124341. /** @hidden */
  124342. _transformedDirection: Vector3;
  124343. /**
  124344. * Instantiates a FlyCamera.
  124345. * This is a flying camera, designed for 3D movement and rotation in all directions,
  124346. * such as in a 3D Space Shooter or a Flight Simulator.
  124347. * @param name Define the name of the camera in the scene.
  124348. * @param position Define the starting position of the camera in the scene.
  124349. * @param scene Define the scene the camera belongs to.
  124350. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  124351. */
  124352. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  124353. /**
  124354. * Attach a control to the HTML DOM element.
  124355. * @param element Defines the element that listens to the input events.
  124356. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  124357. */
  124358. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  124359. /**
  124360. * Detach a control from the HTML DOM element.
  124361. * The camera will stop reacting to that input.
  124362. * @param element Defines the element that listens to the input events.
  124363. */
  124364. detachControl(element: HTMLElement): void;
  124365. private _collisionMask;
  124366. /**
  124367. * Get the mask that the camera ignores in collision events.
  124368. */
  124369. get collisionMask(): number;
  124370. /**
  124371. * Set the mask that the camera ignores in collision events.
  124372. */
  124373. set collisionMask(mask: number);
  124374. /** @hidden */
  124375. _collideWithWorld(displacement: Vector3): void;
  124376. /** @hidden */
  124377. private _onCollisionPositionChange;
  124378. /** @hidden */
  124379. _checkInputs(): void;
  124380. /** @hidden */
  124381. _decideIfNeedsToMove(): boolean;
  124382. /** @hidden */
  124383. _updatePosition(): void;
  124384. /**
  124385. * Restore the Roll to its target value at the rate specified.
  124386. * @param rate - Higher means slower restoring.
  124387. * @hidden
  124388. */
  124389. restoreRoll(rate: number): void;
  124390. /**
  124391. * Destroy the camera and release the current resources held by it.
  124392. */
  124393. dispose(): void;
  124394. /**
  124395. * Get the current object class name.
  124396. * @returns the class name.
  124397. */
  124398. getClassName(): string;
  124399. }
  124400. }
  124401. declare module BABYLON {
  124402. /**
  124403. * Listen to keyboard events to control the camera.
  124404. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  124405. */
  124406. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  124407. /**
  124408. * Defines the camera the input is attached to.
  124409. */
  124410. camera: FlyCamera;
  124411. /**
  124412. * The list of keyboard keys used to control the forward move of the camera.
  124413. */
  124414. keysForward: number[];
  124415. /**
  124416. * The list of keyboard keys used to control the backward move of the camera.
  124417. */
  124418. keysBackward: number[];
  124419. /**
  124420. * The list of keyboard keys used to control the forward move of the camera.
  124421. */
  124422. keysUp: number[];
  124423. /**
  124424. * The list of keyboard keys used to control the backward move of the camera.
  124425. */
  124426. keysDown: number[];
  124427. /**
  124428. * The list of keyboard keys used to control the right strafe move of the camera.
  124429. */
  124430. keysRight: number[];
  124431. /**
  124432. * The list of keyboard keys used to control the left strafe move of the camera.
  124433. */
  124434. keysLeft: number[];
  124435. private _keys;
  124436. private _onCanvasBlurObserver;
  124437. private _onKeyboardObserver;
  124438. private _engine;
  124439. private _scene;
  124440. /**
  124441. * Attach the input controls to a specific dom element to get the input from.
  124442. * @param element Defines the element the controls should be listened from
  124443. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  124444. */
  124445. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  124446. /**
  124447. * Detach the current controls from the specified dom element.
  124448. * @param element Defines the element to stop listening the inputs from
  124449. */
  124450. detachControl(element: Nullable<HTMLElement>): void;
  124451. /**
  124452. * Gets the class name of the current intput.
  124453. * @returns the class name
  124454. */
  124455. getClassName(): string;
  124456. /** @hidden */
  124457. _onLostFocus(e: FocusEvent): void;
  124458. /**
  124459. * Get the friendly name associated with the input class.
  124460. * @returns the input friendly name
  124461. */
  124462. getSimpleName(): string;
  124463. /**
  124464. * Update the current camera state depending on the inputs that have been used this frame.
  124465. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  124466. */
  124467. checkInputs(): void;
  124468. }
  124469. }
  124470. declare module BABYLON {
  124471. /**
  124472. * Manage the mouse wheel inputs to control a follow camera.
  124473. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  124474. */
  124475. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  124476. /**
  124477. * Defines the camera the input is attached to.
  124478. */
  124479. camera: FollowCamera;
  124480. /**
  124481. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  124482. */
  124483. axisControlRadius: boolean;
  124484. /**
  124485. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  124486. */
  124487. axisControlHeight: boolean;
  124488. /**
  124489. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  124490. */
  124491. axisControlRotation: boolean;
  124492. /**
  124493. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  124494. * relation to mouseWheel events.
  124495. */
  124496. wheelPrecision: number;
  124497. /**
  124498. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  124499. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  124500. */
  124501. wheelDeltaPercentage: number;
  124502. private _wheel;
  124503. private _observer;
  124504. /**
  124505. * Attach the input controls to a specific dom element to get the input from.
  124506. * @param element Defines the element the controls should be listened from
  124507. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  124508. */
  124509. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  124510. /**
  124511. * Detach the current controls from the specified dom element.
  124512. * @param element Defines the element to stop listening the inputs from
  124513. */
  124514. detachControl(element: Nullable<HTMLElement>): void;
  124515. /**
  124516. * Gets the class name of the current intput.
  124517. * @returns the class name
  124518. */
  124519. getClassName(): string;
  124520. /**
  124521. * Get the friendly name associated with the input class.
  124522. * @returns the input friendly name
  124523. */
  124524. getSimpleName(): string;
  124525. }
  124526. }
  124527. declare module BABYLON {
  124528. /**
  124529. * Manage the pointers inputs to control an follow camera.
  124530. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  124531. */
  124532. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  124533. /**
  124534. * Defines the camera the input is attached to.
  124535. */
  124536. camera: FollowCamera;
  124537. /**
  124538. * Gets the class name of the current input.
  124539. * @returns the class name
  124540. */
  124541. getClassName(): string;
  124542. /**
  124543. * Defines the pointer angular sensibility along the X axis or how fast is
  124544. * the camera rotating.
  124545. * A negative number will reverse the axis direction.
  124546. */
  124547. angularSensibilityX: number;
  124548. /**
  124549. * Defines the pointer angular sensibility along the Y axis or how fast is
  124550. * the camera rotating.
  124551. * A negative number will reverse the axis direction.
  124552. */
  124553. angularSensibilityY: number;
  124554. /**
  124555. * Defines the pointer pinch precision or how fast is the camera zooming.
  124556. * A negative number will reverse the axis direction.
  124557. */
  124558. pinchPrecision: number;
  124559. /**
  124560. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  124561. * from 0.
  124562. * It defines the percentage of current camera.radius to use as delta when
  124563. * pinch zoom is used.
  124564. */
  124565. pinchDeltaPercentage: number;
  124566. /**
  124567. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  124568. */
  124569. axisXControlRadius: boolean;
  124570. /**
  124571. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  124572. */
  124573. axisXControlHeight: boolean;
  124574. /**
  124575. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  124576. */
  124577. axisXControlRotation: boolean;
  124578. /**
  124579. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  124580. */
  124581. axisYControlRadius: boolean;
  124582. /**
  124583. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  124584. */
  124585. axisYControlHeight: boolean;
  124586. /**
  124587. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  124588. */
  124589. axisYControlRotation: boolean;
  124590. /**
  124591. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  124592. */
  124593. axisPinchControlRadius: boolean;
  124594. /**
  124595. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  124596. */
  124597. axisPinchControlHeight: boolean;
  124598. /**
  124599. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  124600. */
  124601. axisPinchControlRotation: boolean;
  124602. /**
  124603. * Log error messages if basic misconfiguration has occurred.
  124604. */
  124605. warningEnable: boolean;
  124606. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  124607. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  124608. private _warningCounter;
  124609. private _warning;
  124610. }
  124611. }
  124612. declare module BABYLON {
  124613. /**
  124614. * Default Inputs manager for the FollowCamera.
  124615. * It groups all the default supported inputs for ease of use.
  124616. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  124617. */
  124618. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  124619. /**
  124620. * Instantiates a new FollowCameraInputsManager.
  124621. * @param camera Defines the camera the inputs belong to
  124622. */
  124623. constructor(camera: FollowCamera);
  124624. /**
  124625. * Add keyboard input support to the input manager.
  124626. * @returns the current input manager
  124627. */
  124628. addKeyboard(): FollowCameraInputsManager;
  124629. /**
  124630. * Add mouse wheel input support to the input manager.
  124631. * @returns the current input manager
  124632. */
  124633. addMouseWheel(): FollowCameraInputsManager;
  124634. /**
  124635. * Add pointers input support to the input manager.
  124636. * @returns the current input manager
  124637. */
  124638. addPointers(): FollowCameraInputsManager;
  124639. /**
  124640. * Add orientation input support to the input manager.
  124641. * @returns the current input manager
  124642. */
  124643. addVRDeviceOrientation(): FollowCameraInputsManager;
  124644. }
  124645. }
  124646. declare module BABYLON {
  124647. /**
  124648. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  124649. * an arc rotate version arcFollowCamera are available.
  124650. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  124651. */
  124652. export class FollowCamera extends TargetCamera {
  124653. /**
  124654. * Distance the follow camera should follow an object at
  124655. */
  124656. radius: number;
  124657. /**
  124658. * Minimum allowed distance of the camera to the axis of rotation
  124659. * (The camera can not get closer).
  124660. * This can help limiting how the Camera is able to move in the scene.
  124661. */
  124662. lowerRadiusLimit: Nullable<number>;
  124663. /**
  124664. * Maximum allowed distance of the camera to the axis of rotation
  124665. * (The camera can not get further).
  124666. * This can help limiting how the Camera is able to move in the scene.
  124667. */
  124668. upperRadiusLimit: Nullable<number>;
  124669. /**
  124670. * Define a rotation offset between the camera and the object it follows
  124671. */
  124672. rotationOffset: number;
  124673. /**
  124674. * Minimum allowed angle to camera position relative to target object.
  124675. * This can help limiting how the Camera is able to move in the scene.
  124676. */
  124677. lowerRotationOffsetLimit: Nullable<number>;
  124678. /**
  124679. * Maximum allowed angle to camera position relative to target object.
  124680. * This can help limiting how the Camera is able to move in the scene.
  124681. */
  124682. upperRotationOffsetLimit: Nullable<number>;
  124683. /**
  124684. * Define a height offset between the camera and the object it follows.
  124685. * It can help following an object from the top (like a car chaing a plane)
  124686. */
  124687. heightOffset: number;
  124688. /**
  124689. * Minimum allowed height of camera position relative to target object.
  124690. * This can help limiting how the Camera is able to move in the scene.
  124691. */
  124692. lowerHeightOffsetLimit: Nullable<number>;
  124693. /**
  124694. * Maximum allowed height of camera position relative to target object.
  124695. * This can help limiting how the Camera is able to move in the scene.
  124696. */
  124697. upperHeightOffsetLimit: Nullable<number>;
  124698. /**
  124699. * Define how fast the camera can accelerate to follow it s target.
  124700. */
  124701. cameraAcceleration: number;
  124702. /**
  124703. * Define the speed limit of the camera following an object.
  124704. */
  124705. maxCameraSpeed: number;
  124706. /**
  124707. * Define the target of the camera.
  124708. */
  124709. lockedTarget: Nullable<AbstractMesh>;
  124710. /**
  124711. * Defines the input associated with the camera.
  124712. */
  124713. inputs: FollowCameraInputsManager;
  124714. /**
  124715. * Instantiates the follow camera.
  124716. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  124717. * @param name Define the name of the camera in the scene
  124718. * @param position Define the position of the camera
  124719. * @param scene Define the scene the camera belong to
  124720. * @param lockedTarget Define the target of the camera
  124721. */
  124722. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  124723. private _follow;
  124724. /**
  124725. * Attached controls to the current camera.
  124726. * @param element Defines the element the controls should be listened from
  124727. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  124728. */
  124729. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  124730. /**
  124731. * Detach the current controls from the camera.
  124732. * The camera will stop reacting to inputs.
  124733. * @param element Defines the element to stop listening the inputs from
  124734. */
  124735. detachControl(element: HTMLElement): void;
  124736. /** @hidden */
  124737. _checkInputs(): void;
  124738. private _checkLimits;
  124739. /**
  124740. * Gets the camera class name.
  124741. * @returns the class name
  124742. */
  124743. getClassName(): string;
  124744. }
  124745. /**
  124746. * Arc Rotate version of the follow camera.
  124747. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  124748. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  124749. */
  124750. export class ArcFollowCamera extends TargetCamera {
  124751. /** The longitudinal angle of the camera */
  124752. alpha: number;
  124753. /** The latitudinal angle of the camera */
  124754. beta: number;
  124755. /** The radius of the camera from its target */
  124756. radius: number;
  124757. private _cartesianCoordinates;
  124758. /** Define the camera target (the mesh it should follow) */
  124759. private _meshTarget;
  124760. /**
  124761. * Instantiates a new ArcFollowCamera
  124762. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  124763. * @param name Define the name of the camera
  124764. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  124765. * @param beta Define the rotation angle of the camera around the elevation axis
  124766. * @param radius Define the radius of the camera from its target point
  124767. * @param target Define the target of the camera
  124768. * @param scene Define the scene the camera belongs to
  124769. */
  124770. constructor(name: string,
  124771. /** The longitudinal angle of the camera */
  124772. alpha: number,
  124773. /** The latitudinal angle of the camera */
  124774. beta: number,
  124775. /** The radius of the camera from its target */
  124776. radius: number,
  124777. /** Define the camera target (the mesh it should follow) */
  124778. target: Nullable<AbstractMesh>, scene: Scene);
  124779. private _follow;
  124780. /** @hidden */
  124781. _checkInputs(): void;
  124782. /**
  124783. * Returns the class name of the object.
  124784. * It is mostly used internally for serialization purposes.
  124785. */
  124786. getClassName(): string;
  124787. }
  124788. }
  124789. declare module BABYLON {
  124790. /**
  124791. * Manage the keyboard inputs to control the movement of a follow camera.
  124792. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  124793. */
  124794. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  124795. /**
  124796. * Defines the camera the input is attached to.
  124797. */
  124798. camera: FollowCamera;
  124799. /**
  124800. * Defines the list of key codes associated with the up action (increase heightOffset)
  124801. */
  124802. keysHeightOffsetIncr: number[];
  124803. /**
  124804. * Defines the list of key codes associated with the down action (decrease heightOffset)
  124805. */
  124806. keysHeightOffsetDecr: number[];
  124807. /**
  124808. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  124809. */
  124810. keysHeightOffsetModifierAlt: boolean;
  124811. /**
  124812. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  124813. */
  124814. keysHeightOffsetModifierCtrl: boolean;
  124815. /**
  124816. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  124817. */
  124818. keysHeightOffsetModifierShift: boolean;
  124819. /**
  124820. * Defines the list of key codes associated with the left action (increase rotationOffset)
  124821. */
  124822. keysRotationOffsetIncr: number[];
  124823. /**
  124824. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  124825. */
  124826. keysRotationOffsetDecr: number[];
  124827. /**
  124828. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  124829. */
  124830. keysRotationOffsetModifierAlt: boolean;
  124831. /**
  124832. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  124833. */
  124834. keysRotationOffsetModifierCtrl: boolean;
  124835. /**
  124836. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  124837. */
  124838. keysRotationOffsetModifierShift: boolean;
  124839. /**
  124840. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  124841. */
  124842. keysRadiusIncr: number[];
  124843. /**
  124844. * Defines the list of key codes associated with the zoom-out action (increase radius)
  124845. */
  124846. keysRadiusDecr: number[];
  124847. /**
  124848. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  124849. */
  124850. keysRadiusModifierAlt: boolean;
  124851. /**
  124852. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  124853. */
  124854. keysRadiusModifierCtrl: boolean;
  124855. /**
  124856. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  124857. */
  124858. keysRadiusModifierShift: boolean;
  124859. /**
  124860. * Defines the rate of change of heightOffset.
  124861. */
  124862. heightSensibility: number;
  124863. /**
  124864. * Defines the rate of change of rotationOffset.
  124865. */
  124866. rotationSensibility: number;
  124867. /**
  124868. * Defines the rate of change of radius.
  124869. */
  124870. radiusSensibility: number;
  124871. private _keys;
  124872. private _ctrlPressed;
  124873. private _altPressed;
  124874. private _shiftPressed;
  124875. private _onCanvasBlurObserver;
  124876. private _onKeyboardObserver;
  124877. private _engine;
  124878. private _scene;
  124879. /**
  124880. * Attach the input controls to a specific dom element to get the input from.
  124881. * @param element Defines the element the controls should be listened from
  124882. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  124883. */
  124884. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  124885. /**
  124886. * Detach the current controls from the specified dom element.
  124887. * @param element Defines the element to stop listening the inputs from
  124888. */
  124889. detachControl(element: Nullable<HTMLElement>): void;
  124890. /**
  124891. * Update the current camera state depending on the inputs that have been used this frame.
  124892. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  124893. */
  124894. checkInputs(): void;
  124895. /**
  124896. * Gets the class name of the current input.
  124897. * @returns the class name
  124898. */
  124899. getClassName(): string;
  124900. /**
  124901. * Get the friendly name associated with the input class.
  124902. * @returns the input friendly name
  124903. */
  124904. getSimpleName(): string;
  124905. /**
  124906. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  124907. * allow modification of the heightOffset value.
  124908. */
  124909. private _modifierHeightOffset;
  124910. /**
  124911. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  124912. * allow modification of the rotationOffset value.
  124913. */
  124914. private _modifierRotationOffset;
  124915. /**
  124916. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  124917. * allow modification of the radius value.
  124918. */
  124919. private _modifierRadius;
  124920. }
  124921. }
  124922. declare module BABYLON {
  124923. interface FreeCameraInputsManager {
  124924. /**
  124925. * @hidden
  124926. */
  124927. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  124928. /**
  124929. * Add orientation input support to the input manager.
  124930. * @returns the current input manager
  124931. */
  124932. addDeviceOrientation(): FreeCameraInputsManager;
  124933. }
  124934. /**
  124935. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  124936. * Screen rotation is taken into account.
  124937. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  124938. */
  124939. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  124940. private _camera;
  124941. private _screenOrientationAngle;
  124942. private _constantTranform;
  124943. private _screenQuaternion;
  124944. private _alpha;
  124945. private _beta;
  124946. private _gamma;
  124947. /**
  124948. * Can be used to detect if a device orientation sensor is available on a device
  124949. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  124950. * @returns a promise that will resolve on orientation change
  124951. */
  124952. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  124953. /**
  124954. * @hidden
  124955. */
  124956. _onDeviceOrientationChangedObservable: Observable<void>;
  124957. /**
  124958. * Instantiates a new input
  124959. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  124960. */
  124961. constructor();
  124962. /**
  124963. * Define the camera controlled by the input.
  124964. */
  124965. get camera(): FreeCamera;
  124966. set camera(camera: FreeCamera);
  124967. /**
  124968. * Attach the input controls to a specific dom element to get the input from.
  124969. * @param element Defines the element the controls should be listened from
  124970. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  124971. */
  124972. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  124973. private _orientationChanged;
  124974. private _deviceOrientation;
  124975. /**
  124976. * Detach the current controls from the specified dom element.
  124977. * @param element Defines the element to stop listening the inputs from
  124978. */
  124979. detachControl(element: Nullable<HTMLElement>): void;
  124980. /**
  124981. * Update the current camera state depending on the inputs that have been used this frame.
  124982. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  124983. */
  124984. checkInputs(): void;
  124985. /**
  124986. * Gets the class name of the current intput.
  124987. * @returns the class name
  124988. */
  124989. getClassName(): string;
  124990. /**
  124991. * Get the friendly name associated with the input class.
  124992. * @returns the input friendly name
  124993. */
  124994. getSimpleName(): string;
  124995. }
  124996. }
  124997. declare module BABYLON {
  124998. /**
  124999. * Manage the gamepad inputs to control a free camera.
  125000. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  125001. */
  125002. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  125003. /**
  125004. * Define the camera the input is attached to.
  125005. */
  125006. camera: FreeCamera;
  125007. /**
  125008. * Define the Gamepad controlling the input
  125009. */
  125010. gamepad: Nullable<Gamepad>;
  125011. /**
  125012. * Defines the gamepad rotation sensiblity.
  125013. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  125014. */
  125015. gamepadAngularSensibility: number;
  125016. /**
  125017. * Defines the gamepad move sensiblity.
  125018. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  125019. */
  125020. gamepadMoveSensibility: number;
  125021. private _yAxisScale;
  125022. /**
  125023. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  125024. */
  125025. get invertYAxis(): boolean;
  125026. set invertYAxis(value: boolean);
  125027. private _onGamepadConnectedObserver;
  125028. private _onGamepadDisconnectedObserver;
  125029. private _cameraTransform;
  125030. private _deltaTransform;
  125031. private _vector3;
  125032. private _vector2;
  125033. /**
  125034. * Attach the input controls to a specific dom element to get the input from.
  125035. * @param element Defines the element the controls should be listened from
  125036. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  125037. */
  125038. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  125039. /**
  125040. * Detach the current controls from the specified dom element.
  125041. * @param element Defines the element to stop listening the inputs from
  125042. */
  125043. detachControl(element: Nullable<HTMLElement>): void;
  125044. /**
  125045. * Update the current camera state depending on the inputs that have been used this frame.
  125046. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  125047. */
  125048. checkInputs(): void;
  125049. /**
  125050. * Gets the class name of the current intput.
  125051. * @returns the class name
  125052. */
  125053. getClassName(): string;
  125054. /**
  125055. * Get the friendly name associated with the input class.
  125056. * @returns the input friendly name
  125057. */
  125058. getSimpleName(): string;
  125059. }
  125060. }
  125061. declare module BABYLON {
  125062. /**
  125063. * Defines the potential axis of a Joystick
  125064. */
  125065. export enum JoystickAxis {
  125066. /** X axis */
  125067. X = 0,
  125068. /** Y axis */
  125069. Y = 1,
  125070. /** Z axis */
  125071. Z = 2
  125072. }
  125073. /**
  125074. * Represents the different customization options available
  125075. * for VirtualJoystick
  125076. */
  125077. interface VirtualJoystickCustomizations {
  125078. /**
  125079. * Size of the joystick's puck
  125080. */
  125081. puckSize: number;
  125082. /**
  125083. * Size of the joystick's container
  125084. */
  125085. containerSize: number;
  125086. /**
  125087. * Color of the joystick && puck
  125088. */
  125089. color: string;
  125090. /**
  125091. * Image URL for the joystick's puck
  125092. */
  125093. puckImage?: string;
  125094. /**
  125095. * Image URL for the joystick's container
  125096. */
  125097. containerImage?: string;
  125098. /**
  125099. * Defines the unmoving position of the joystick container
  125100. */
  125101. position?: {
  125102. x: number;
  125103. y: number;
  125104. };
  125105. /**
  125106. * Defines whether or not the joystick container is always visible
  125107. */
  125108. alwaysVisible: boolean;
  125109. /**
  125110. * Defines whether or not to limit the movement of the puck to the joystick's container
  125111. */
  125112. limitToContainer: boolean;
  125113. }
  125114. /**
  125115. * Class used to define virtual joystick (used in touch mode)
  125116. */
  125117. export class VirtualJoystick {
  125118. /**
  125119. * Gets or sets a boolean indicating that left and right values must be inverted
  125120. */
  125121. reverseLeftRight: boolean;
  125122. /**
  125123. * Gets or sets a boolean indicating that up and down values must be inverted
  125124. */
  125125. reverseUpDown: boolean;
  125126. /**
  125127. * Gets the offset value for the position (ie. the change of the position value)
  125128. */
  125129. deltaPosition: Vector3;
  125130. /**
  125131. * Gets a boolean indicating if the virtual joystick was pressed
  125132. */
  125133. pressed: boolean;
  125134. /**
  125135. * Canvas the virtual joystick will render onto, default z-index of this is 5
  125136. */
  125137. static Canvas: Nullable<HTMLCanvasElement>;
  125138. /**
  125139. * boolean indicating whether or not the joystick's puck's movement should be limited to the joystick's container area
  125140. */
  125141. limitToContainer: boolean;
  125142. private static _globalJoystickIndex;
  125143. private static _alwaysVisibleSticks;
  125144. private static vjCanvasContext;
  125145. private static vjCanvasWidth;
  125146. private static vjCanvasHeight;
  125147. private static halfWidth;
  125148. private static _GetDefaultOptions;
  125149. private _action;
  125150. private _axisTargetedByLeftAndRight;
  125151. private _axisTargetedByUpAndDown;
  125152. private _joystickSensibility;
  125153. private _inversedSensibility;
  125154. private _joystickPointerID;
  125155. private _joystickColor;
  125156. private _joystickPointerPos;
  125157. private _joystickPreviousPointerPos;
  125158. private _joystickPointerStartPos;
  125159. private _deltaJoystickVector;
  125160. private _leftJoystick;
  125161. private _touches;
  125162. private _joystickPosition;
  125163. private _alwaysVisible;
  125164. private _puckImage;
  125165. private _containerImage;
  125166. private _joystickPuckSize;
  125167. private _joystickContainerSize;
  125168. private _clearPuckSize;
  125169. private _clearContainerSize;
  125170. private _clearPuckSizeOffset;
  125171. private _clearContainerSizeOffset;
  125172. private _onPointerDownHandlerRef;
  125173. private _onPointerMoveHandlerRef;
  125174. private _onPointerUpHandlerRef;
  125175. private _onResize;
  125176. /**
  125177. * Creates a new virtual joystick
  125178. * @param leftJoystick defines that the joystick is for left hand (false by default)
  125179. * @param customizations Defines the options we want to customize the VirtualJoystick
  125180. */
  125181. constructor(leftJoystick?: boolean, customizations?: Partial<VirtualJoystickCustomizations>);
  125182. /**
  125183. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  125184. * @param newJoystickSensibility defines the new sensibility
  125185. */
  125186. setJoystickSensibility(newJoystickSensibility: number): void;
  125187. private _onPointerDown;
  125188. private _onPointerMove;
  125189. private _onPointerUp;
  125190. /**
  125191. * Change the color of the virtual joystick
  125192. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  125193. */
  125194. setJoystickColor(newColor: string): void;
  125195. /**
  125196. * Size of the joystick's container
  125197. */
  125198. set containerSize(newSize: number);
  125199. get containerSize(): number;
  125200. /**
  125201. * Size of the joystick's puck
  125202. */
  125203. set puckSize(newSize: number);
  125204. get puckSize(): number;
  125205. /**
  125206. * Clears the set position of the joystick
  125207. */
  125208. clearPosition(): void;
  125209. /**
  125210. * Defines whether or not the joystick container is always visible
  125211. */
  125212. set alwaysVisible(value: boolean);
  125213. get alwaysVisible(): boolean;
  125214. /**
  125215. * Sets the constant position of the Joystick container
  125216. * @param x X axis coordinate
  125217. * @param y Y axis coordinate
  125218. */
  125219. setPosition(x: number, y: number): void;
  125220. /**
  125221. * Defines a callback to call when the joystick is touched
  125222. * @param action defines the callback
  125223. */
  125224. setActionOnTouch(action: () => any): void;
  125225. /**
  125226. * Defines which axis you'd like to control for left & right
  125227. * @param axis defines the axis to use
  125228. */
  125229. setAxisForLeftRight(axis: JoystickAxis): void;
  125230. /**
  125231. * Defines which axis you'd like to control for up & down
  125232. * @param axis defines the axis to use
  125233. */
  125234. setAxisForUpDown(axis: JoystickAxis): void;
  125235. /**
  125236. * Clears the canvas from the previous puck / container draw
  125237. */
  125238. private _clearPreviousDraw;
  125239. /**
  125240. * Loads `urlPath` to be used for the container's image
  125241. * @param urlPath defines the urlPath of an image to use
  125242. */
  125243. setContainerImage(urlPath: string): void;
  125244. /**
  125245. * Loads `urlPath` to be used for the puck's image
  125246. * @param urlPath defines the urlPath of an image to use
  125247. */
  125248. setPuckImage(urlPath: string): void;
  125249. /**
  125250. * Draws the Virtual Joystick's container
  125251. */
  125252. private _drawContainer;
  125253. /**
  125254. * Draws the Virtual Joystick's puck
  125255. */
  125256. private _drawPuck;
  125257. private _drawVirtualJoystick;
  125258. /**
  125259. * Release internal HTML canvas
  125260. */
  125261. releaseCanvas(): void;
  125262. }
  125263. }
  125264. declare module BABYLON {
  125265. interface FreeCameraInputsManager {
  125266. /**
  125267. * Add virtual joystick input support to the input manager.
  125268. * @returns the current input manager
  125269. */
  125270. addVirtualJoystick(): FreeCameraInputsManager;
  125271. }
  125272. /**
  125273. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  125274. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  125275. */
  125276. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  125277. /**
  125278. * Defines the camera the input is attached to.
  125279. */
  125280. camera: FreeCamera;
  125281. private _leftjoystick;
  125282. private _rightjoystick;
  125283. /**
  125284. * Gets the left stick of the virtual joystick.
  125285. * @returns The virtual Joystick
  125286. */
  125287. getLeftJoystick(): VirtualJoystick;
  125288. /**
  125289. * Gets the right stick of the virtual joystick.
  125290. * @returns The virtual Joystick
  125291. */
  125292. getRightJoystick(): VirtualJoystick;
  125293. /**
  125294. * Update the current camera state depending on the inputs that have been used this frame.
  125295. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  125296. */
  125297. checkInputs(): void;
  125298. /**
  125299. * Attach the input controls to a specific dom element to get the input from.
  125300. * @param element Defines the element the controls should be listened from
  125301. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  125302. */
  125303. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  125304. /**
  125305. * Detach the current controls from the specified dom element.
  125306. * @param element Defines the element to stop listening the inputs from
  125307. */
  125308. detachControl(element: Nullable<HTMLElement>): void;
  125309. /**
  125310. * Gets the class name of the current intput.
  125311. * @returns the class name
  125312. */
  125313. getClassName(): string;
  125314. /**
  125315. * Get the friendly name associated with the input class.
  125316. * @returns the input friendly name
  125317. */
  125318. getSimpleName(): string;
  125319. }
  125320. }
  125321. declare module BABYLON {
  125322. /**
  125323. * This represents a FPS type of camera controlled by touch.
  125324. * This is like a universal camera minus the Gamepad controls.
  125325. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  125326. */
  125327. export class TouchCamera extends FreeCamera {
  125328. /**
  125329. * Defines the touch sensibility for rotation.
  125330. * The higher the faster.
  125331. */
  125332. get touchAngularSensibility(): number;
  125333. set touchAngularSensibility(value: number);
  125334. /**
  125335. * Defines the touch sensibility for move.
  125336. * The higher the faster.
  125337. */
  125338. get touchMoveSensibility(): number;
  125339. set touchMoveSensibility(value: number);
  125340. /**
  125341. * Instantiates a new touch camera.
  125342. * This represents a FPS type of camera controlled by touch.
  125343. * This is like a universal camera minus the Gamepad controls.
  125344. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  125345. * @param name Define the name of the camera in the scene
  125346. * @param position Define the start position of the camera in the scene
  125347. * @param scene Define the scene the camera belongs to
  125348. */
  125349. constructor(name: string, position: Vector3, scene: Scene);
  125350. /**
  125351. * Gets the current object class name.
  125352. * @return the class name
  125353. */
  125354. getClassName(): string;
  125355. /** @hidden */
  125356. _setupInputs(): void;
  125357. }
  125358. }
  125359. declare module BABYLON {
  125360. /**
  125361. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  125362. * being tilted forward or back and left or right.
  125363. */
  125364. export class DeviceOrientationCamera extends FreeCamera {
  125365. private _initialQuaternion;
  125366. private _quaternionCache;
  125367. private _tmpDragQuaternion;
  125368. private _disablePointerInputWhenUsingDeviceOrientation;
  125369. /**
  125370. * Creates a new device orientation camera
  125371. * @param name The name of the camera
  125372. * @param position The start position camera
  125373. * @param scene The scene the camera belongs to
  125374. */
  125375. constructor(name: string, position: Vector3, scene: Scene);
  125376. /**
  125377. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  125378. */
  125379. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  125380. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  125381. private _dragFactor;
  125382. /**
  125383. * Enabled turning on the y axis when the orientation sensor is active
  125384. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  125385. */
  125386. enableHorizontalDragging(dragFactor?: number): void;
  125387. /**
  125388. * Gets the current instance class name ("DeviceOrientationCamera").
  125389. * This helps avoiding instanceof at run time.
  125390. * @returns the class name
  125391. */
  125392. getClassName(): string;
  125393. /**
  125394. * @hidden
  125395. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  125396. */
  125397. _checkInputs(): void;
  125398. /**
  125399. * Reset the camera to its default orientation on the specified axis only.
  125400. * @param axis The axis to reset
  125401. */
  125402. resetToCurrentRotation(axis?: Axis): void;
  125403. }
  125404. }
  125405. declare module BABYLON {
  125406. /**
  125407. * Defines supported buttons for XBox360 compatible gamepads
  125408. */
  125409. export enum Xbox360Button {
  125410. /** A */
  125411. A = 0,
  125412. /** B */
  125413. B = 1,
  125414. /** X */
  125415. X = 2,
  125416. /** Y */
  125417. Y = 3,
  125418. /** Left button */
  125419. LB = 4,
  125420. /** Right button */
  125421. RB = 5,
  125422. /** Back */
  125423. Back = 8,
  125424. /** Start */
  125425. Start = 9,
  125426. /** Left stick */
  125427. LeftStick = 10,
  125428. /** Right stick */
  125429. RightStick = 11
  125430. }
  125431. /** Defines values for XBox360 DPad */
  125432. export enum Xbox360Dpad {
  125433. /** Up */
  125434. Up = 12,
  125435. /** Down */
  125436. Down = 13,
  125437. /** Left */
  125438. Left = 14,
  125439. /** Right */
  125440. Right = 15
  125441. }
  125442. /**
  125443. * Defines a XBox360 gamepad
  125444. */
  125445. export class Xbox360Pad extends Gamepad {
  125446. private _leftTrigger;
  125447. private _rightTrigger;
  125448. private _onlefttriggerchanged;
  125449. private _onrighttriggerchanged;
  125450. private _onbuttondown;
  125451. private _onbuttonup;
  125452. private _ondpaddown;
  125453. private _ondpadup;
  125454. /** Observable raised when a button is pressed */
  125455. onButtonDownObservable: Observable<Xbox360Button>;
  125456. /** Observable raised when a button is released */
  125457. onButtonUpObservable: Observable<Xbox360Button>;
  125458. /** Observable raised when a pad is pressed */
  125459. onPadDownObservable: Observable<Xbox360Dpad>;
  125460. /** Observable raised when a pad is released */
  125461. onPadUpObservable: Observable<Xbox360Dpad>;
  125462. private _buttonA;
  125463. private _buttonB;
  125464. private _buttonX;
  125465. private _buttonY;
  125466. private _buttonBack;
  125467. private _buttonStart;
  125468. private _buttonLB;
  125469. private _buttonRB;
  125470. private _buttonLeftStick;
  125471. private _buttonRightStick;
  125472. private _dPadUp;
  125473. private _dPadDown;
  125474. private _dPadLeft;
  125475. private _dPadRight;
  125476. private _isXboxOnePad;
  125477. /**
  125478. * Creates a new XBox360 gamepad object
  125479. * @param id defines the id of this gamepad
  125480. * @param index defines its index
  125481. * @param gamepad defines the internal HTML gamepad object
  125482. * @param xboxOne defines if it is a XBox One gamepad
  125483. */
  125484. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  125485. /**
  125486. * Defines the callback to call when left trigger is pressed
  125487. * @param callback defines the callback to use
  125488. */
  125489. onlefttriggerchanged(callback: (value: number) => void): void;
  125490. /**
  125491. * Defines the callback to call when right trigger is pressed
  125492. * @param callback defines the callback to use
  125493. */
  125494. onrighttriggerchanged(callback: (value: number) => void): void;
  125495. /**
  125496. * Gets the left trigger value
  125497. */
  125498. get leftTrigger(): number;
  125499. /**
  125500. * Sets the left trigger value
  125501. */
  125502. set leftTrigger(newValue: number);
  125503. /**
  125504. * Gets the right trigger value
  125505. */
  125506. get rightTrigger(): number;
  125507. /**
  125508. * Sets the right trigger value
  125509. */
  125510. set rightTrigger(newValue: number);
  125511. /**
  125512. * Defines the callback to call when a button is pressed
  125513. * @param callback defines the callback to use
  125514. */
  125515. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  125516. /**
  125517. * Defines the callback to call when a button is released
  125518. * @param callback defines the callback to use
  125519. */
  125520. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  125521. /**
  125522. * Defines the callback to call when a pad is pressed
  125523. * @param callback defines the callback to use
  125524. */
  125525. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  125526. /**
  125527. * Defines the callback to call when a pad is released
  125528. * @param callback defines the callback to use
  125529. */
  125530. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  125531. private _setButtonValue;
  125532. private _setDPadValue;
  125533. /**
  125534. * Gets the value of the `A` button
  125535. */
  125536. get buttonA(): number;
  125537. /**
  125538. * Sets the value of the `A` button
  125539. */
  125540. set buttonA(value: number);
  125541. /**
  125542. * Gets the value of the `B` button
  125543. */
  125544. get buttonB(): number;
  125545. /**
  125546. * Sets the value of the `B` button
  125547. */
  125548. set buttonB(value: number);
  125549. /**
  125550. * Gets the value of the `X` button
  125551. */
  125552. get buttonX(): number;
  125553. /**
  125554. * Sets the value of the `X` button
  125555. */
  125556. set buttonX(value: number);
  125557. /**
  125558. * Gets the value of the `Y` button
  125559. */
  125560. get buttonY(): number;
  125561. /**
  125562. * Sets the value of the `Y` button
  125563. */
  125564. set buttonY(value: number);
  125565. /**
  125566. * Gets the value of the `Start` button
  125567. */
  125568. get buttonStart(): number;
  125569. /**
  125570. * Sets the value of the `Start` button
  125571. */
  125572. set buttonStart(value: number);
  125573. /**
  125574. * Gets the value of the `Back` button
  125575. */
  125576. get buttonBack(): number;
  125577. /**
  125578. * Sets the value of the `Back` button
  125579. */
  125580. set buttonBack(value: number);
  125581. /**
  125582. * Gets the value of the `Left` button
  125583. */
  125584. get buttonLB(): number;
  125585. /**
  125586. * Sets the value of the `Left` button
  125587. */
  125588. set buttonLB(value: number);
  125589. /**
  125590. * Gets the value of the `Right` button
  125591. */
  125592. get buttonRB(): number;
  125593. /**
  125594. * Sets the value of the `Right` button
  125595. */
  125596. set buttonRB(value: number);
  125597. /**
  125598. * Gets the value of the Left joystick
  125599. */
  125600. get buttonLeftStick(): number;
  125601. /**
  125602. * Sets the value of the Left joystick
  125603. */
  125604. set buttonLeftStick(value: number);
  125605. /**
  125606. * Gets the value of the Right joystick
  125607. */
  125608. get buttonRightStick(): number;
  125609. /**
  125610. * Sets the value of the Right joystick
  125611. */
  125612. set buttonRightStick(value: number);
  125613. /**
  125614. * Gets the value of D-pad up
  125615. */
  125616. get dPadUp(): number;
  125617. /**
  125618. * Sets the value of D-pad up
  125619. */
  125620. set dPadUp(value: number);
  125621. /**
  125622. * Gets the value of D-pad down
  125623. */
  125624. get dPadDown(): number;
  125625. /**
  125626. * Sets the value of D-pad down
  125627. */
  125628. set dPadDown(value: number);
  125629. /**
  125630. * Gets the value of D-pad left
  125631. */
  125632. get dPadLeft(): number;
  125633. /**
  125634. * Sets the value of D-pad left
  125635. */
  125636. set dPadLeft(value: number);
  125637. /**
  125638. * Gets the value of D-pad right
  125639. */
  125640. get dPadRight(): number;
  125641. /**
  125642. * Sets the value of D-pad right
  125643. */
  125644. set dPadRight(value: number);
  125645. /**
  125646. * Force the gamepad to synchronize with device values
  125647. */
  125648. update(): void;
  125649. /**
  125650. * Disposes the gamepad
  125651. */
  125652. dispose(): void;
  125653. }
  125654. }
  125655. declare module BABYLON {
  125656. /**
  125657. * Defines supported buttons for DualShock compatible gamepads
  125658. */
  125659. export enum DualShockButton {
  125660. /** Cross */
  125661. Cross = 0,
  125662. /** Circle */
  125663. Circle = 1,
  125664. /** Square */
  125665. Square = 2,
  125666. /** Triangle */
  125667. Triangle = 3,
  125668. /** L1 */
  125669. L1 = 4,
  125670. /** R1 */
  125671. R1 = 5,
  125672. /** Share */
  125673. Share = 8,
  125674. /** Options */
  125675. Options = 9,
  125676. /** Left stick */
  125677. LeftStick = 10,
  125678. /** Right stick */
  125679. RightStick = 11
  125680. }
  125681. /** Defines values for DualShock DPad */
  125682. export enum DualShockDpad {
  125683. /** Up */
  125684. Up = 12,
  125685. /** Down */
  125686. Down = 13,
  125687. /** Left */
  125688. Left = 14,
  125689. /** Right */
  125690. Right = 15
  125691. }
  125692. /**
  125693. * Defines a DualShock gamepad
  125694. */
  125695. export class DualShockPad extends Gamepad {
  125696. private _leftTrigger;
  125697. private _rightTrigger;
  125698. private _onlefttriggerchanged;
  125699. private _onrighttriggerchanged;
  125700. private _onbuttondown;
  125701. private _onbuttonup;
  125702. private _ondpaddown;
  125703. private _ondpadup;
  125704. /** Observable raised when a button is pressed */
  125705. onButtonDownObservable: Observable<DualShockButton>;
  125706. /** Observable raised when a button is released */
  125707. onButtonUpObservable: Observable<DualShockButton>;
  125708. /** Observable raised when a pad is pressed */
  125709. onPadDownObservable: Observable<DualShockDpad>;
  125710. /** Observable raised when a pad is released */
  125711. onPadUpObservable: Observable<DualShockDpad>;
  125712. private _buttonCross;
  125713. private _buttonCircle;
  125714. private _buttonSquare;
  125715. private _buttonTriangle;
  125716. private _buttonShare;
  125717. private _buttonOptions;
  125718. private _buttonL1;
  125719. private _buttonR1;
  125720. private _buttonLeftStick;
  125721. private _buttonRightStick;
  125722. private _dPadUp;
  125723. private _dPadDown;
  125724. private _dPadLeft;
  125725. private _dPadRight;
  125726. /**
  125727. * Creates a new DualShock gamepad object
  125728. * @param id defines the id of this gamepad
  125729. * @param index defines its index
  125730. * @param gamepad defines the internal HTML gamepad object
  125731. */
  125732. constructor(id: string, index: number, gamepad: any);
  125733. /**
  125734. * Defines the callback to call when left trigger is pressed
  125735. * @param callback defines the callback to use
  125736. */
  125737. onlefttriggerchanged(callback: (value: number) => void): void;
  125738. /**
  125739. * Defines the callback to call when right trigger is pressed
  125740. * @param callback defines the callback to use
  125741. */
  125742. onrighttriggerchanged(callback: (value: number) => void): void;
  125743. /**
  125744. * Gets the left trigger value
  125745. */
  125746. get leftTrigger(): number;
  125747. /**
  125748. * Sets the left trigger value
  125749. */
  125750. set leftTrigger(newValue: number);
  125751. /**
  125752. * Gets the right trigger value
  125753. */
  125754. get rightTrigger(): number;
  125755. /**
  125756. * Sets the right trigger value
  125757. */
  125758. set rightTrigger(newValue: number);
  125759. /**
  125760. * Defines the callback to call when a button is pressed
  125761. * @param callback defines the callback to use
  125762. */
  125763. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  125764. /**
  125765. * Defines the callback to call when a button is released
  125766. * @param callback defines the callback to use
  125767. */
  125768. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  125769. /**
  125770. * Defines the callback to call when a pad is pressed
  125771. * @param callback defines the callback to use
  125772. */
  125773. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  125774. /**
  125775. * Defines the callback to call when a pad is released
  125776. * @param callback defines the callback to use
  125777. */
  125778. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  125779. private _setButtonValue;
  125780. private _setDPadValue;
  125781. /**
  125782. * Gets the value of the `Cross` button
  125783. */
  125784. get buttonCross(): number;
  125785. /**
  125786. * Sets the value of the `Cross` button
  125787. */
  125788. set buttonCross(value: number);
  125789. /**
  125790. * Gets the value of the `Circle` button
  125791. */
  125792. get buttonCircle(): number;
  125793. /**
  125794. * Sets the value of the `Circle` button
  125795. */
  125796. set buttonCircle(value: number);
  125797. /**
  125798. * Gets the value of the `Square` button
  125799. */
  125800. get buttonSquare(): number;
  125801. /**
  125802. * Sets the value of the `Square` button
  125803. */
  125804. set buttonSquare(value: number);
  125805. /**
  125806. * Gets the value of the `Triangle` button
  125807. */
  125808. get buttonTriangle(): number;
  125809. /**
  125810. * Sets the value of the `Triangle` button
  125811. */
  125812. set buttonTriangle(value: number);
  125813. /**
  125814. * Gets the value of the `Options` button
  125815. */
  125816. get buttonOptions(): number;
  125817. /**
  125818. * Sets the value of the `Options` button
  125819. */
  125820. set buttonOptions(value: number);
  125821. /**
  125822. * Gets the value of the `Share` button
  125823. */
  125824. get buttonShare(): number;
  125825. /**
  125826. * Sets the value of the `Share` button
  125827. */
  125828. set buttonShare(value: number);
  125829. /**
  125830. * Gets the value of the `L1` button
  125831. */
  125832. get buttonL1(): number;
  125833. /**
  125834. * Sets the value of the `L1` button
  125835. */
  125836. set buttonL1(value: number);
  125837. /**
  125838. * Gets the value of the `R1` button
  125839. */
  125840. get buttonR1(): number;
  125841. /**
  125842. * Sets the value of the `R1` button
  125843. */
  125844. set buttonR1(value: number);
  125845. /**
  125846. * Gets the value of the Left joystick
  125847. */
  125848. get buttonLeftStick(): number;
  125849. /**
  125850. * Sets the value of the Left joystick
  125851. */
  125852. set buttonLeftStick(value: number);
  125853. /**
  125854. * Gets the value of the Right joystick
  125855. */
  125856. get buttonRightStick(): number;
  125857. /**
  125858. * Sets the value of the Right joystick
  125859. */
  125860. set buttonRightStick(value: number);
  125861. /**
  125862. * Gets the value of D-pad up
  125863. */
  125864. get dPadUp(): number;
  125865. /**
  125866. * Sets the value of D-pad up
  125867. */
  125868. set dPadUp(value: number);
  125869. /**
  125870. * Gets the value of D-pad down
  125871. */
  125872. get dPadDown(): number;
  125873. /**
  125874. * Sets the value of D-pad down
  125875. */
  125876. set dPadDown(value: number);
  125877. /**
  125878. * Gets the value of D-pad left
  125879. */
  125880. get dPadLeft(): number;
  125881. /**
  125882. * Sets the value of D-pad left
  125883. */
  125884. set dPadLeft(value: number);
  125885. /**
  125886. * Gets the value of D-pad right
  125887. */
  125888. get dPadRight(): number;
  125889. /**
  125890. * Sets the value of D-pad right
  125891. */
  125892. set dPadRight(value: number);
  125893. /**
  125894. * Force the gamepad to synchronize with device values
  125895. */
  125896. update(): void;
  125897. /**
  125898. * Disposes the gamepad
  125899. */
  125900. dispose(): void;
  125901. }
  125902. }
  125903. declare module BABYLON {
  125904. /**
  125905. * Manager for handling gamepads
  125906. */
  125907. export class GamepadManager {
  125908. private _scene?;
  125909. private _babylonGamepads;
  125910. private _oneGamepadConnected;
  125911. /** @hidden */
  125912. _isMonitoring: boolean;
  125913. private _gamepadEventSupported;
  125914. private _gamepadSupport?;
  125915. /**
  125916. * observable to be triggered when the gamepad controller has been connected
  125917. */
  125918. onGamepadConnectedObservable: Observable<Gamepad>;
  125919. /**
  125920. * observable to be triggered when the gamepad controller has been disconnected
  125921. */
  125922. onGamepadDisconnectedObservable: Observable<Gamepad>;
  125923. private _onGamepadConnectedEvent;
  125924. private _onGamepadDisconnectedEvent;
  125925. /**
  125926. * Initializes the gamepad manager
  125927. * @param _scene BabylonJS scene
  125928. */
  125929. constructor(_scene?: Scene | undefined);
  125930. /**
  125931. * The gamepads in the game pad manager
  125932. */
  125933. get gamepads(): Gamepad[];
  125934. /**
  125935. * Get the gamepad controllers based on type
  125936. * @param type The type of gamepad controller
  125937. * @returns Nullable gamepad
  125938. */
  125939. getGamepadByType(type?: number): Nullable<Gamepad>;
  125940. /**
  125941. * Disposes the gamepad manager
  125942. */
  125943. dispose(): void;
  125944. private _addNewGamepad;
  125945. private _startMonitoringGamepads;
  125946. private _stopMonitoringGamepads;
  125947. /** @hidden */
  125948. _checkGamepadsStatus(): void;
  125949. private _updateGamepadObjects;
  125950. }
  125951. }
  125952. declare module BABYLON {
  125953. interface Scene {
  125954. /** @hidden */
  125955. _gamepadManager: Nullable<GamepadManager>;
  125956. /**
  125957. * Gets the gamepad manager associated with the scene
  125958. * @see https://doc.babylonjs.com/how_to/how_to_use_gamepads
  125959. */
  125960. gamepadManager: GamepadManager;
  125961. }
  125962. /**
  125963. * Interface representing a free camera inputs manager
  125964. */
  125965. interface FreeCameraInputsManager {
  125966. /**
  125967. * Adds gamepad input support to the FreeCameraInputsManager.
  125968. * @returns the FreeCameraInputsManager
  125969. */
  125970. addGamepad(): FreeCameraInputsManager;
  125971. }
  125972. /**
  125973. * Interface representing an arc rotate camera inputs manager
  125974. */
  125975. interface ArcRotateCameraInputsManager {
  125976. /**
  125977. * Adds gamepad input support to the ArcRotateCamera InputManager.
  125978. * @returns the camera inputs manager
  125979. */
  125980. addGamepad(): ArcRotateCameraInputsManager;
  125981. }
  125982. /**
  125983. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  125984. */
  125985. export class GamepadSystemSceneComponent implements ISceneComponent {
  125986. /**
  125987. * The component name helpfull to identify the component in the list of scene components.
  125988. */
  125989. readonly name: string;
  125990. /**
  125991. * The scene the component belongs to.
  125992. */
  125993. scene: Scene;
  125994. /**
  125995. * Creates a new instance of the component for the given scene
  125996. * @param scene Defines the scene to register the component in
  125997. */
  125998. constructor(scene: Scene);
  125999. /**
  126000. * Registers the component in a given scene
  126001. */
  126002. register(): void;
  126003. /**
  126004. * Rebuilds the elements related to this component in case of
  126005. * context lost for instance.
  126006. */
  126007. rebuild(): void;
  126008. /**
  126009. * Disposes the component and the associated ressources
  126010. */
  126011. dispose(): void;
  126012. private _beforeCameraUpdate;
  126013. }
  126014. }
  126015. declare module BABYLON {
  126016. /**
  126017. * 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,
  126018. * which still works and will still be found in many Playgrounds.
  126019. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  126020. */
  126021. export class UniversalCamera extends TouchCamera {
  126022. /**
  126023. * Defines the gamepad rotation sensiblity.
  126024. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  126025. */
  126026. get gamepadAngularSensibility(): number;
  126027. set gamepadAngularSensibility(value: number);
  126028. /**
  126029. * Defines the gamepad move sensiblity.
  126030. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  126031. */
  126032. get gamepadMoveSensibility(): number;
  126033. set gamepadMoveSensibility(value: number);
  126034. /**
  126035. * 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,
  126036. * which still works and will still be found in many Playgrounds.
  126037. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  126038. * @param name Define the name of the camera in the scene
  126039. * @param position Define the start position of the camera in the scene
  126040. * @param scene Define the scene the camera belongs to
  126041. */
  126042. constructor(name: string, position: Vector3, scene: Scene);
  126043. /**
  126044. * Gets the current object class name.
  126045. * @return the class name
  126046. */
  126047. getClassName(): string;
  126048. }
  126049. }
  126050. declare module BABYLON {
  126051. /**
  126052. * This represents a FPS type of camera. This is only here for back compat purpose.
  126053. * Please use the UniversalCamera instead as both are identical.
  126054. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  126055. */
  126056. export class GamepadCamera extends UniversalCamera {
  126057. /**
  126058. * Instantiates a new Gamepad Camera
  126059. * This represents a FPS type of camera. This is only here for back compat purpose.
  126060. * Please use the UniversalCamera instead as both are identical.
  126061. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  126062. * @param name Define the name of the camera in the scene
  126063. * @param position Define the start position of the camera in the scene
  126064. * @param scene Define the scene the camera belongs to
  126065. */
  126066. constructor(name: string, position: Vector3, scene: Scene);
  126067. /**
  126068. * Gets the current object class name.
  126069. * @return the class name
  126070. */
  126071. getClassName(): string;
  126072. }
  126073. }
  126074. declare module BABYLON {
  126075. /** @hidden */
  126076. export var passPixelShader: {
  126077. name: string;
  126078. shader: string;
  126079. };
  126080. }
  126081. declare module BABYLON {
  126082. /** @hidden */
  126083. export var passCubePixelShader: {
  126084. name: string;
  126085. shader: string;
  126086. };
  126087. }
  126088. declare module BABYLON {
  126089. /**
  126090. * PassPostProcess which produces an output the same as it's input
  126091. */
  126092. export class PassPostProcess extends PostProcess {
  126093. /**
  126094. * Gets a string identifying the name of the class
  126095. * @returns "PassPostProcess" string
  126096. */
  126097. getClassName(): string;
  126098. /**
  126099. * Creates the PassPostProcess
  126100. * @param name The name of the effect.
  126101. * @param options The required width/height ratio to downsize to before computing the render pass.
  126102. * @param camera The camera to apply the render pass to.
  126103. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  126104. * @param engine The engine which the post process will be applied. (default: current engine)
  126105. * @param reusable If the post process can be reused on the same frame. (default: false)
  126106. * @param textureType The type of texture to be used when performing the post processing.
  126107. * @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)
  126108. */
  126109. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  126110. /** @hidden */
  126111. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassPostProcess;
  126112. }
  126113. /**
  126114. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  126115. */
  126116. export class PassCubePostProcess extends PostProcess {
  126117. private _face;
  126118. /**
  126119. * Gets or sets the cube face to display.
  126120. * * 0 is +X
  126121. * * 1 is -X
  126122. * * 2 is +Y
  126123. * * 3 is -Y
  126124. * * 4 is +Z
  126125. * * 5 is -Z
  126126. */
  126127. get face(): number;
  126128. set face(value: number);
  126129. /**
  126130. * Gets a string identifying the name of the class
  126131. * @returns "PassCubePostProcess" string
  126132. */
  126133. getClassName(): string;
  126134. /**
  126135. * Creates the PassCubePostProcess
  126136. * @param name The name of the effect.
  126137. * @param options The required width/height ratio to downsize to before computing the render pass.
  126138. * @param camera The camera to apply the render pass to.
  126139. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  126140. * @param engine The engine which the post process will be applied. (default: current engine)
  126141. * @param reusable If the post process can be reused on the same frame. (default: false)
  126142. * @param textureType The type of texture to be used when performing the post processing.
  126143. * @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)
  126144. */
  126145. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  126146. /** @hidden */
  126147. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassCubePostProcess;
  126148. }
  126149. }
  126150. declare module BABYLON {
  126151. /** @hidden */
  126152. export var anaglyphPixelShader: {
  126153. name: string;
  126154. shader: string;
  126155. };
  126156. }
  126157. declare module BABYLON {
  126158. /**
  126159. * Postprocess used to generate anaglyphic rendering
  126160. */
  126161. export class AnaglyphPostProcess extends PostProcess {
  126162. private _passedProcess;
  126163. /**
  126164. * Gets a string identifying the name of the class
  126165. * @returns "AnaglyphPostProcess" string
  126166. */
  126167. getClassName(): string;
  126168. /**
  126169. * Creates a new AnaglyphPostProcess
  126170. * @param name defines postprocess name
  126171. * @param options defines creation options or target ratio scale
  126172. * @param rigCameras defines cameras using this postprocess
  126173. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  126174. * @param engine defines hosting engine
  126175. * @param reusable defines if the postprocess will be reused multiple times per frame
  126176. */
  126177. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  126178. }
  126179. }
  126180. declare module BABYLON {
  126181. /**
  126182. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  126183. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  126184. */
  126185. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  126186. /**
  126187. * Creates a new AnaglyphArcRotateCamera
  126188. * @param name defines camera name
  126189. * @param alpha defines alpha angle (in radians)
  126190. * @param beta defines beta angle (in radians)
  126191. * @param radius defines radius
  126192. * @param target defines camera target
  126193. * @param interaxialDistance defines distance between each color axis
  126194. * @param scene defines the hosting scene
  126195. */
  126196. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  126197. /**
  126198. * Gets camera class name
  126199. * @returns AnaglyphArcRotateCamera
  126200. */
  126201. getClassName(): string;
  126202. }
  126203. }
  126204. declare module BABYLON {
  126205. /**
  126206. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  126207. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  126208. */
  126209. export class AnaglyphFreeCamera extends FreeCamera {
  126210. /**
  126211. * Creates a new AnaglyphFreeCamera
  126212. * @param name defines camera name
  126213. * @param position defines initial position
  126214. * @param interaxialDistance defines distance between each color axis
  126215. * @param scene defines the hosting scene
  126216. */
  126217. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  126218. /**
  126219. * Gets camera class name
  126220. * @returns AnaglyphFreeCamera
  126221. */
  126222. getClassName(): string;
  126223. }
  126224. }
  126225. declare module BABYLON {
  126226. /**
  126227. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  126228. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  126229. */
  126230. export class AnaglyphGamepadCamera extends GamepadCamera {
  126231. /**
  126232. * Creates a new AnaglyphGamepadCamera
  126233. * @param name defines camera name
  126234. * @param position defines initial position
  126235. * @param interaxialDistance defines distance between each color axis
  126236. * @param scene defines the hosting scene
  126237. */
  126238. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  126239. /**
  126240. * Gets camera class name
  126241. * @returns AnaglyphGamepadCamera
  126242. */
  126243. getClassName(): string;
  126244. }
  126245. }
  126246. declare module BABYLON {
  126247. /**
  126248. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  126249. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  126250. */
  126251. export class AnaglyphUniversalCamera extends UniversalCamera {
  126252. /**
  126253. * Creates a new AnaglyphUniversalCamera
  126254. * @param name defines camera name
  126255. * @param position defines initial position
  126256. * @param interaxialDistance defines distance between each color axis
  126257. * @param scene defines the hosting scene
  126258. */
  126259. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  126260. /**
  126261. * Gets camera class name
  126262. * @returns AnaglyphUniversalCamera
  126263. */
  126264. getClassName(): string;
  126265. }
  126266. }
  126267. declare module BABYLON {
  126268. /**
  126269. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  126270. * @see https://doc.babylonjs.com/features/cameras
  126271. */
  126272. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  126273. /**
  126274. * Creates a new StereoscopicArcRotateCamera
  126275. * @param name defines camera name
  126276. * @param alpha defines alpha angle (in radians)
  126277. * @param beta defines beta angle (in radians)
  126278. * @param radius defines radius
  126279. * @param target defines camera target
  126280. * @param interaxialDistance defines distance between each color axis
  126281. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  126282. * @param scene defines the hosting scene
  126283. */
  126284. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  126285. /**
  126286. * Gets camera class name
  126287. * @returns StereoscopicArcRotateCamera
  126288. */
  126289. getClassName(): string;
  126290. }
  126291. }
  126292. declare module BABYLON {
  126293. /**
  126294. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  126295. * @see https://doc.babylonjs.com/features/cameras
  126296. */
  126297. export class StereoscopicFreeCamera extends FreeCamera {
  126298. /**
  126299. * Creates a new StereoscopicFreeCamera
  126300. * @param name defines camera name
  126301. * @param position defines initial position
  126302. * @param interaxialDistance defines distance between each color axis
  126303. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  126304. * @param scene defines the hosting scene
  126305. */
  126306. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  126307. /**
  126308. * Gets camera class name
  126309. * @returns StereoscopicFreeCamera
  126310. */
  126311. getClassName(): string;
  126312. }
  126313. }
  126314. declare module BABYLON {
  126315. /**
  126316. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  126317. * @see https://doc.babylonjs.com/features/cameras
  126318. */
  126319. export class StereoscopicGamepadCamera extends GamepadCamera {
  126320. /**
  126321. * Creates a new StereoscopicGamepadCamera
  126322. * @param name defines camera name
  126323. * @param position defines initial position
  126324. * @param interaxialDistance defines distance between each color axis
  126325. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  126326. * @param scene defines the hosting scene
  126327. */
  126328. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  126329. /**
  126330. * Gets camera class name
  126331. * @returns StereoscopicGamepadCamera
  126332. */
  126333. getClassName(): string;
  126334. }
  126335. }
  126336. declare module BABYLON {
  126337. /**
  126338. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  126339. * @see https://doc.babylonjs.com/features/cameras
  126340. */
  126341. export class StereoscopicUniversalCamera extends UniversalCamera {
  126342. /**
  126343. * Creates a new StereoscopicUniversalCamera
  126344. * @param name defines camera name
  126345. * @param position defines initial position
  126346. * @param interaxialDistance defines distance between each color axis
  126347. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  126348. * @param scene defines the hosting scene
  126349. */
  126350. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  126351. /**
  126352. * Gets camera class name
  126353. * @returns StereoscopicUniversalCamera
  126354. */
  126355. getClassName(): string;
  126356. }
  126357. }
  126358. declare module BABYLON {
  126359. /**
  126360. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  126361. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  126362. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  126363. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  126364. */
  126365. export class VirtualJoysticksCamera extends FreeCamera {
  126366. /**
  126367. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  126368. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  126369. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  126370. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  126371. * @param name Define the name of the camera in the scene
  126372. * @param position Define the start position of the camera in the scene
  126373. * @param scene Define the scene the camera belongs to
  126374. */
  126375. constructor(name: string, position: Vector3, scene: Scene);
  126376. /**
  126377. * Gets the current object class name.
  126378. * @return the class name
  126379. */
  126380. getClassName(): string;
  126381. }
  126382. }
  126383. declare module BABYLON {
  126384. /**
  126385. * This represents all the required metrics to create a VR camera.
  126386. * @see https://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  126387. */
  126388. export class VRCameraMetrics {
  126389. /**
  126390. * Define the horizontal resolution off the screen.
  126391. */
  126392. hResolution: number;
  126393. /**
  126394. * Define the vertical resolution off the screen.
  126395. */
  126396. vResolution: number;
  126397. /**
  126398. * Define the horizontal screen size.
  126399. */
  126400. hScreenSize: number;
  126401. /**
  126402. * Define the vertical screen size.
  126403. */
  126404. vScreenSize: number;
  126405. /**
  126406. * Define the vertical screen center position.
  126407. */
  126408. vScreenCenter: number;
  126409. /**
  126410. * Define the distance of the eyes to the screen.
  126411. */
  126412. eyeToScreenDistance: number;
  126413. /**
  126414. * Define the distance between both lenses
  126415. */
  126416. lensSeparationDistance: number;
  126417. /**
  126418. * Define the distance between both viewer's eyes.
  126419. */
  126420. interpupillaryDistance: number;
  126421. /**
  126422. * Define the distortion factor of the VR postprocess.
  126423. * Please, touch with care.
  126424. */
  126425. distortionK: number[];
  126426. /**
  126427. * Define the chromatic aberration correction factors for the VR post process.
  126428. */
  126429. chromaAbCorrection: number[];
  126430. /**
  126431. * Define the scale factor of the post process.
  126432. * The smaller the better but the slower.
  126433. */
  126434. postProcessScaleFactor: number;
  126435. /**
  126436. * Define an offset for the lens center.
  126437. */
  126438. lensCenterOffset: number;
  126439. /**
  126440. * Define if the current vr camera should compensate the distortion of the lense or not.
  126441. */
  126442. compensateDistortion: boolean;
  126443. /**
  126444. * Defines if multiview should be enabled when rendering (Default: false)
  126445. */
  126446. multiviewEnabled: boolean;
  126447. /**
  126448. * Gets the rendering aspect ratio based on the provided resolutions.
  126449. */
  126450. get aspectRatio(): number;
  126451. /**
  126452. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  126453. */
  126454. get aspectRatioFov(): number;
  126455. /**
  126456. * @hidden
  126457. */
  126458. get leftHMatrix(): Matrix;
  126459. /**
  126460. * @hidden
  126461. */
  126462. get rightHMatrix(): Matrix;
  126463. /**
  126464. * @hidden
  126465. */
  126466. get leftPreViewMatrix(): Matrix;
  126467. /**
  126468. * @hidden
  126469. */
  126470. get rightPreViewMatrix(): Matrix;
  126471. /**
  126472. * Get the default VRMetrics based on the most generic setup.
  126473. * @returns the default vr metrics
  126474. */
  126475. static GetDefault(): VRCameraMetrics;
  126476. }
  126477. }
  126478. declare module BABYLON {
  126479. /** @hidden */
  126480. export var vrDistortionCorrectionPixelShader: {
  126481. name: string;
  126482. shader: string;
  126483. };
  126484. }
  126485. declare module BABYLON {
  126486. /**
  126487. * VRDistortionCorrectionPostProcess used for mobile VR
  126488. */
  126489. export class VRDistortionCorrectionPostProcess extends PostProcess {
  126490. private _isRightEye;
  126491. private _distortionFactors;
  126492. private _postProcessScaleFactor;
  126493. private _lensCenterOffset;
  126494. private _scaleIn;
  126495. private _scaleFactor;
  126496. private _lensCenter;
  126497. /**
  126498. * Gets a string identifying the name of the class
  126499. * @returns "VRDistortionCorrectionPostProcess" string
  126500. */
  126501. getClassName(): string;
  126502. /**
  126503. * Initializes the VRDistortionCorrectionPostProcess
  126504. * @param name The name of the effect.
  126505. * @param camera The camera to apply the render pass to.
  126506. * @param isRightEye If this is for the right eye distortion
  126507. * @param vrMetrics All the required metrics for the VR camera
  126508. */
  126509. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  126510. }
  126511. }
  126512. declare module BABYLON {
  126513. /**
  126514. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  126515. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  126516. */
  126517. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  126518. /**
  126519. * Creates a new VRDeviceOrientationArcRotateCamera
  126520. * @param name defines camera name
  126521. * @param alpha defines the camera rotation along the logitudinal axis
  126522. * @param beta defines the camera rotation along the latitudinal axis
  126523. * @param radius defines the camera distance from its target
  126524. * @param target defines the camera target
  126525. * @param scene defines the scene the camera belongs to
  126526. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  126527. * @param vrCameraMetrics defines the vr metrics associated to the camera
  126528. */
  126529. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  126530. /**
  126531. * Gets camera class name
  126532. * @returns VRDeviceOrientationArcRotateCamera
  126533. */
  126534. getClassName(): string;
  126535. }
  126536. }
  126537. declare module BABYLON {
  126538. /**
  126539. * Camera used to simulate VR rendering (based on FreeCamera)
  126540. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  126541. */
  126542. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  126543. /**
  126544. * Creates a new VRDeviceOrientationFreeCamera
  126545. * @param name defines camera name
  126546. * @param position defines the start position of the camera
  126547. * @param scene defines the scene the camera belongs to
  126548. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  126549. * @param vrCameraMetrics defines the vr metrics associated to the camera
  126550. */
  126551. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  126552. /**
  126553. * Gets camera class name
  126554. * @returns VRDeviceOrientationFreeCamera
  126555. */
  126556. getClassName(): string;
  126557. }
  126558. }
  126559. declare module BABYLON {
  126560. /**
  126561. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  126562. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  126563. */
  126564. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  126565. /**
  126566. * Creates a new VRDeviceOrientationGamepadCamera
  126567. * @param name defines camera name
  126568. * @param position defines the start position of the camera
  126569. * @param scene defines the scene the camera belongs to
  126570. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  126571. * @param vrCameraMetrics defines the vr metrics associated to the camera
  126572. */
  126573. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  126574. /**
  126575. * Gets camera class name
  126576. * @returns VRDeviceOrientationGamepadCamera
  126577. */
  126578. getClassName(): string;
  126579. }
  126580. }
  126581. declare module BABYLON {
  126582. /**
  126583. * A class extending Texture allowing drawing on a texture
  126584. * @see https://doc.babylonjs.com/how_to/dynamictexture
  126585. */
  126586. export class DynamicTexture extends Texture {
  126587. private _generateMipMaps;
  126588. private _canvas;
  126589. private _context;
  126590. /**
  126591. * Creates a DynamicTexture
  126592. * @param name defines the name of the texture
  126593. * @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
  126594. * @param scene defines the scene where you want the texture
  126595. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  126596. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  126597. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  126598. */
  126599. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  126600. /**
  126601. * Get the current class name of the texture useful for serialization or dynamic coding.
  126602. * @returns "DynamicTexture"
  126603. */
  126604. getClassName(): string;
  126605. /**
  126606. * Gets the current state of canRescale
  126607. */
  126608. get canRescale(): boolean;
  126609. private _recreate;
  126610. /**
  126611. * Scales the texture
  126612. * @param ratio the scale factor to apply to both width and height
  126613. */
  126614. scale(ratio: number): void;
  126615. /**
  126616. * Resizes the texture
  126617. * @param width the new width
  126618. * @param height the new height
  126619. */
  126620. scaleTo(width: number, height: number): void;
  126621. /**
  126622. * Gets the context of the canvas used by the texture
  126623. * @returns the canvas context of the dynamic texture
  126624. */
  126625. getContext(): CanvasRenderingContext2D;
  126626. /**
  126627. * Clears the texture
  126628. */
  126629. clear(): void;
  126630. /**
  126631. * Updates the texture
  126632. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  126633. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  126634. */
  126635. update(invertY?: boolean, premulAlpha?: boolean): void;
  126636. /**
  126637. * Draws text onto the texture
  126638. * @param text defines the text to be drawn
  126639. * @param x defines the placement of the text from the left
  126640. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  126641. * @param font defines the font to be used with font-style, font-size, font-name
  126642. * @param color defines the color used for the text
  126643. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  126644. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  126645. * @param update defines whether texture is immediately update (default is true)
  126646. */
  126647. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string | null, clearColor: string, invertY?: boolean, update?: boolean): void;
  126648. /**
  126649. * Clones the texture
  126650. * @returns the clone of the texture.
  126651. */
  126652. clone(): DynamicTexture;
  126653. /**
  126654. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  126655. * @returns a serialized dynamic texture object
  126656. */
  126657. serialize(): any;
  126658. private _IsCanvasElement;
  126659. /** @hidden */
  126660. _rebuild(): void;
  126661. }
  126662. }
  126663. declare module BABYLON {
  126664. /**
  126665. * Class containing static functions to help procedurally build meshes
  126666. */
  126667. export class GroundBuilder {
  126668. /**
  126669. * Creates a ground mesh
  126670. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  126671. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  126672. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  126673. * @param name defines the name of the mesh
  126674. * @param options defines the options used to create the mesh
  126675. * @param scene defines the hosting scene
  126676. * @returns the ground mesh
  126677. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  126678. */
  126679. static CreateGround(name: string, options: {
  126680. width?: number;
  126681. height?: number;
  126682. subdivisions?: number;
  126683. subdivisionsX?: number;
  126684. subdivisionsY?: number;
  126685. updatable?: boolean;
  126686. }, scene: any): Mesh;
  126687. /**
  126688. * Creates a tiled ground mesh
  126689. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  126690. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  126691. * * 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
  126692. * * 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
  126693. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  126694. * @param name defines the name of the mesh
  126695. * @param options defines the options used to create the mesh
  126696. * @param scene defines the hosting scene
  126697. * @returns the tiled ground mesh
  126698. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  126699. */
  126700. static CreateTiledGround(name: string, options: {
  126701. xmin: number;
  126702. zmin: number;
  126703. xmax: number;
  126704. zmax: number;
  126705. subdivisions?: {
  126706. w: number;
  126707. h: number;
  126708. };
  126709. precision?: {
  126710. w: number;
  126711. h: number;
  126712. };
  126713. updatable?: boolean;
  126714. }, scene?: Nullable<Scene>): Mesh;
  126715. /**
  126716. * Creates a ground mesh from a height map
  126717. * * The parameter `url` sets the URL of the height map image resource.
  126718. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  126719. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  126720. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  126721. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  126722. * * 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.
  126723. * * 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).
  126724. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  126725. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  126726. * @param name defines the name of the mesh
  126727. * @param url defines the url to the height map
  126728. * @param options defines the options used to create the mesh
  126729. * @param scene defines the hosting scene
  126730. * @returns the ground mesh
  126731. * @see https://doc.babylonjs.com/babylon101/height_map
  126732. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  126733. */
  126734. static CreateGroundFromHeightMap(name: string, url: string, options: {
  126735. width?: number;
  126736. height?: number;
  126737. subdivisions?: number;
  126738. minHeight?: number;
  126739. maxHeight?: number;
  126740. colorFilter?: Color3;
  126741. alphaFilter?: number;
  126742. updatable?: boolean;
  126743. onReady?: (mesh: GroundMesh) => void;
  126744. }, scene?: Nullable<Scene>): GroundMesh;
  126745. }
  126746. }
  126747. declare module BABYLON {
  126748. /**
  126749. * Class containing static functions to help procedurally build meshes
  126750. */
  126751. export class TorusBuilder {
  126752. /**
  126753. * Creates a torus mesh
  126754. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  126755. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  126756. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  126757. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  126758. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  126759. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  126760. * @param name defines the name of the mesh
  126761. * @param options defines the options used to create the mesh
  126762. * @param scene defines the hosting scene
  126763. * @returns the torus mesh
  126764. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  126765. */
  126766. static CreateTorus(name: string, options: {
  126767. diameter?: number;
  126768. thickness?: number;
  126769. tessellation?: number;
  126770. updatable?: boolean;
  126771. sideOrientation?: number;
  126772. frontUVs?: Vector4;
  126773. backUVs?: Vector4;
  126774. }, scene: any): Mesh;
  126775. }
  126776. }
  126777. declare module BABYLON {
  126778. /**
  126779. * Class containing static functions to help procedurally build meshes
  126780. */
  126781. export class CylinderBuilder {
  126782. /**
  126783. * Creates a cylinder or a cone mesh
  126784. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  126785. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  126786. * * 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.
  126787. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  126788. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  126789. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  126790. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  126791. * * 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).
  126792. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  126793. * * 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).
  126794. * * 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
  126795. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  126796. * * 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
  126797. * * 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.
  126798. * * If `enclose` is false, a ring surface is one element.
  126799. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  126800. * * 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
  126801. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  126802. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  126803. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  126804. * @param name defines the name of the mesh
  126805. * @param options defines the options used to create the mesh
  126806. * @param scene defines the hosting scene
  126807. * @returns the cylinder mesh
  126808. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  126809. */
  126810. static CreateCylinder(name: string, options: {
  126811. height?: number;
  126812. diameterTop?: number;
  126813. diameterBottom?: number;
  126814. diameter?: number;
  126815. tessellation?: number;
  126816. subdivisions?: number;
  126817. arc?: number;
  126818. faceColors?: Color4[];
  126819. faceUV?: Vector4[];
  126820. updatable?: boolean;
  126821. hasRings?: boolean;
  126822. enclose?: boolean;
  126823. cap?: number;
  126824. sideOrientation?: number;
  126825. frontUVs?: Vector4;
  126826. backUVs?: Vector4;
  126827. }, scene: any): Mesh;
  126828. }
  126829. }
  126830. declare module BABYLON {
  126831. /**
  126832. * States of the webXR experience
  126833. */
  126834. export enum WebXRState {
  126835. /**
  126836. * Transitioning to being in XR mode
  126837. */
  126838. ENTERING_XR = 0,
  126839. /**
  126840. * Transitioning to non XR mode
  126841. */
  126842. EXITING_XR = 1,
  126843. /**
  126844. * In XR mode and presenting
  126845. */
  126846. IN_XR = 2,
  126847. /**
  126848. * Not entered XR mode
  126849. */
  126850. NOT_IN_XR = 3
  126851. }
  126852. /**
  126853. * Abstraction of the XR render target
  126854. */
  126855. export interface WebXRRenderTarget extends IDisposable {
  126856. /**
  126857. * xrpresent context of the canvas which can be used to display/mirror xr content
  126858. */
  126859. canvasContext: WebGLRenderingContext;
  126860. /**
  126861. * xr layer for the canvas
  126862. */
  126863. xrLayer: Nullable<XRWebGLLayer>;
  126864. /**
  126865. * Initializes the xr layer for the session
  126866. * @param xrSession xr session
  126867. * @returns a promise that will resolve once the XR Layer has been created
  126868. */
  126869. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  126870. }
  126871. }
  126872. declare module BABYLON {
  126873. /**
  126874. * COnfiguration object for WebXR output canvas
  126875. */
  126876. export class WebXRManagedOutputCanvasOptions {
  126877. /**
  126878. * An optional canvas in case you wish to create it yourself and provide it here.
  126879. * If not provided, a new canvas will be created
  126880. */
  126881. canvasElement?: HTMLCanvasElement;
  126882. /**
  126883. * Options for this XR Layer output
  126884. */
  126885. canvasOptions?: XRWebGLLayerOptions;
  126886. /**
  126887. * CSS styling for a newly created canvas (if not provided)
  126888. */
  126889. newCanvasCssStyle?: string;
  126890. /**
  126891. * Get the default values of the configuration object
  126892. * @param engine defines the engine to use (can be null)
  126893. * @returns default values of this configuration object
  126894. */
  126895. static GetDefaults(engine?: ThinEngine): WebXRManagedOutputCanvasOptions;
  126896. }
  126897. /**
  126898. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  126899. */
  126900. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  126901. private _options;
  126902. private _canvas;
  126903. private _engine;
  126904. private _originalCanvasSize;
  126905. /**
  126906. * Rendering context of the canvas which can be used to display/mirror xr content
  126907. */
  126908. canvasContext: WebGLRenderingContext;
  126909. /**
  126910. * xr layer for the canvas
  126911. */
  126912. xrLayer: Nullable<XRWebGLLayer>;
  126913. /**
  126914. * Obseervers registered here will be triggered when the xr layer was initialized
  126915. */
  126916. onXRLayerInitObservable: Observable<XRWebGLLayer>;
  126917. /**
  126918. * Initializes the canvas to be added/removed upon entering/exiting xr
  126919. * @param _xrSessionManager The XR Session manager
  126920. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  126921. */
  126922. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  126923. /**
  126924. * Disposes of the object
  126925. */
  126926. dispose(): void;
  126927. /**
  126928. * Initializes the xr layer for the session
  126929. * @param xrSession xr session
  126930. * @returns a promise that will resolve once the XR Layer has been created
  126931. */
  126932. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  126933. private _addCanvas;
  126934. private _removeCanvas;
  126935. private _setCanvasSize;
  126936. private _setManagedOutputCanvas;
  126937. }
  126938. }
  126939. declare module BABYLON {
  126940. /**
  126941. * Manages an XRSession to work with Babylon's engine
  126942. * @see https://doc.babylonjs.com/how_to/webxr_session_manager
  126943. */
  126944. export class WebXRSessionManager implements IDisposable {
  126945. /** The scene which the session should be created for */
  126946. scene: Scene;
  126947. private _referenceSpace;
  126948. private _rttProvider;
  126949. private _sessionEnded;
  126950. private _xrNavigator;
  126951. private baseLayer;
  126952. /**
  126953. * The base reference space from which the session started. good if you want to reset your
  126954. * reference space
  126955. */
  126956. baseReferenceSpace: XRReferenceSpace;
  126957. /**
  126958. * Current XR frame
  126959. */
  126960. currentFrame: Nullable<XRFrame>;
  126961. /** WebXR timestamp updated every frame */
  126962. currentTimestamp: number;
  126963. /**
  126964. * Used just in case of a failure to initialize an immersive session.
  126965. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  126966. */
  126967. defaultHeightCompensation: number;
  126968. /**
  126969. * Fires every time a new xrFrame arrives which can be used to update the camera
  126970. */
  126971. onXRFrameObservable: Observable<XRFrame>;
  126972. /**
  126973. * Fires when the reference space changed
  126974. */
  126975. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  126976. /**
  126977. * Fires when the xr session is ended either by the device or manually done
  126978. */
  126979. onXRSessionEnded: Observable<any>;
  126980. /**
  126981. * Fires when the xr session is ended either by the device or manually done
  126982. */
  126983. onXRSessionInit: Observable<XRSession>;
  126984. /**
  126985. * Underlying xr session
  126986. */
  126987. session: XRSession;
  126988. /**
  126989. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  126990. * or get the offset the player is currently at.
  126991. */
  126992. viewerReferenceSpace: XRReferenceSpace;
  126993. /**
  126994. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  126995. * @param scene The scene which the session should be created for
  126996. */
  126997. constructor(
  126998. /** The scene which the session should be created for */
  126999. scene: Scene);
  127000. /**
  127001. * The current reference space used in this session. This reference space can constantly change!
  127002. * It is mainly used to offset the camera's position.
  127003. */
  127004. get referenceSpace(): XRReferenceSpace;
  127005. /**
  127006. * Set a new reference space and triggers the observable
  127007. */
  127008. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  127009. /**
  127010. * Disposes of the session manager
  127011. */
  127012. dispose(): void;
  127013. /**
  127014. * Stops the xrSession and restores the render loop
  127015. * @returns Promise which resolves after it exits XR
  127016. */
  127017. exitXRAsync(): Promise<void>;
  127018. /**
  127019. * Gets the correct render target texture to be rendered this frame for this eye
  127020. * @param eye the eye for which to get the render target
  127021. * @returns the render target for the specified eye
  127022. */
  127023. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  127024. /**
  127025. * Creates a WebXRRenderTarget object for the XR session
  127026. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  127027. * @param options optional options to provide when creating a new render target
  127028. * @returns a WebXR render target to which the session can render
  127029. */
  127030. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  127031. /**
  127032. * Initializes the manager
  127033. * After initialization enterXR can be called to start an XR session
  127034. * @returns Promise which resolves after it is initialized
  127035. */
  127036. initializeAsync(): Promise<void>;
  127037. /**
  127038. * Initializes an xr session
  127039. * @param xrSessionMode mode to initialize
  127040. * @param xrSessionInit defines optional and required values to pass to the session builder
  127041. * @returns a promise which will resolve once the session has been initialized
  127042. */
  127043. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  127044. /**
  127045. * Checks if a session would be supported for the creation options specified
  127046. * @param sessionMode session mode to check if supported eg. immersive-vr
  127047. * @returns A Promise that resolves to true if supported and false if not
  127048. */
  127049. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  127050. /**
  127051. * Resets the reference space to the one started the session
  127052. */
  127053. resetReferenceSpace(): void;
  127054. /**
  127055. * Starts rendering to the xr layer
  127056. */
  127057. runXRRenderLoop(): void;
  127058. /**
  127059. * Sets the reference space on the xr session
  127060. * @param referenceSpaceType space to set
  127061. * @returns a promise that will resolve once the reference space has been set
  127062. */
  127063. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  127064. /**
  127065. * Updates the render state of the session
  127066. * @param state state to set
  127067. * @returns a promise that resolves once the render state has been updated
  127068. */
  127069. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  127070. /**
  127071. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  127072. * @param sessionMode defines the session to test
  127073. * @returns a promise with boolean as final value
  127074. */
  127075. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  127076. private _createRenderTargetTexture;
  127077. }
  127078. }
  127079. declare module BABYLON {
  127080. /**
  127081. * WebXR Camera which holds the views for the xrSession
  127082. * @see https://doc.babylonjs.com/how_to/webxr_camera
  127083. */
  127084. export class WebXRCamera extends FreeCamera {
  127085. private _xrSessionManager;
  127086. private _firstFrame;
  127087. private _referenceQuaternion;
  127088. private _referencedPosition;
  127089. private _xrInvPositionCache;
  127090. private _xrInvQuaternionCache;
  127091. /**
  127092. * Observable raised before camera teleportation
  127093. */
  127094. onBeforeCameraTeleport: Observable<Vector3>;
  127095. /**
  127096. * Observable raised after camera teleportation
  127097. */
  127098. onAfterCameraTeleport: Observable<Vector3>;
  127099. /**
  127100. * Should position compensation execute on first frame.
  127101. * This is used when copying the position from a native (non XR) camera
  127102. */
  127103. compensateOnFirstFrame: boolean;
  127104. /**
  127105. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  127106. * @param name the name of the camera
  127107. * @param scene the scene to add the camera to
  127108. * @param _xrSessionManager a constructed xr session manager
  127109. */
  127110. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  127111. /**
  127112. * Return the user's height, unrelated to the current ground.
  127113. * This will be the y position of this camera, when ground level is 0.
  127114. */
  127115. get realWorldHeight(): number;
  127116. /** @hidden */
  127117. _updateForDualEyeDebugging(): void;
  127118. /**
  127119. * Sets this camera's transformation based on a non-vr camera
  127120. * @param otherCamera the non-vr camera to copy the transformation from
  127121. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  127122. */
  127123. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  127124. /**
  127125. * Gets the current instance class name ("WebXRCamera").
  127126. * @returns the class name
  127127. */
  127128. getClassName(): string;
  127129. private _rotate180;
  127130. private _updateFromXRSession;
  127131. private _updateNumberOfRigCameras;
  127132. private _updateReferenceSpace;
  127133. private _updateReferenceSpaceOffset;
  127134. }
  127135. }
  127136. declare module BABYLON {
  127137. /**
  127138. * Defining the interface required for a (webxr) feature
  127139. */
  127140. export interface IWebXRFeature extends IDisposable {
  127141. /**
  127142. * Is this feature attached
  127143. */
  127144. attached: boolean;
  127145. /**
  127146. * Should auto-attach be disabled?
  127147. */
  127148. disableAutoAttach: boolean;
  127149. /**
  127150. * Attach the feature to the session
  127151. * Will usually be called by the features manager
  127152. *
  127153. * @param force should attachment be forced (even when already attached)
  127154. * @returns true if successful.
  127155. */
  127156. attach(force?: boolean): boolean;
  127157. /**
  127158. * Detach the feature from the session
  127159. * Will usually be called by the features manager
  127160. *
  127161. * @returns true if successful.
  127162. */
  127163. detach(): boolean;
  127164. /**
  127165. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  127166. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  127167. *
  127168. * @returns whether or not the feature is compatible in this environment
  127169. */
  127170. isCompatible(): boolean;
  127171. /**
  127172. * Was this feature disposed;
  127173. */
  127174. isDisposed: boolean;
  127175. /**
  127176. * The name of the native xr feature name, if applicable (like anchor, hit-test, or hand-tracking)
  127177. */
  127178. xrNativeFeatureName?: string;
  127179. /**
  127180. * A list of (Babylon WebXR) features this feature depends on
  127181. */
  127182. dependsOn?: string[];
  127183. }
  127184. /**
  127185. * A list of the currently available features without referencing them
  127186. */
  127187. export class WebXRFeatureName {
  127188. /**
  127189. * The name of the anchor system feature
  127190. */
  127191. static readonly ANCHOR_SYSTEM: string;
  127192. /**
  127193. * The name of the background remover feature
  127194. */
  127195. static readonly BACKGROUND_REMOVER: string;
  127196. /**
  127197. * The name of the hit test feature
  127198. */
  127199. static readonly HIT_TEST: string;
  127200. /**
  127201. * physics impostors for xr controllers feature
  127202. */
  127203. static readonly PHYSICS_CONTROLLERS: string;
  127204. /**
  127205. * The name of the plane detection feature
  127206. */
  127207. static readonly PLANE_DETECTION: string;
  127208. /**
  127209. * The name of the pointer selection feature
  127210. */
  127211. static readonly POINTER_SELECTION: string;
  127212. /**
  127213. * The name of the teleportation feature
  127214. */
  127215. static readonly TELEPORTATION: string;
  127216. /**
  127217. * The name of the feature points feature.
  127218. */
  127219. static readonly FEATURE_POINTS: string;
  127220. /**
  127221. * The name of the hand tracking feature.
  127222. */
  127223. static readonly HAND_TRACKING: string;
  127224. }
  127225. /**
  127226. * Defining the constructor of a feature. Used to register the modules.
  127227. */
  127228. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => () => IWebXRFeature;
  127229. /**
  127230. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  127231. * It is mainly used in AR sessions.
  127232. *
  127233. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  127234. */
  127235. export class WebXRFeaturesManager implements IDisposable {
  127236. private _xrSessionManager;
  127237. private static readonly _AvailableFeatures;
  127238. private _features;
  127239. /**
  127240. * constructs a new features manages.
  127241. *
  127242. * @param _xrSessionManager an instance of WebXRSessionManager
  127243. */
  127244. constructor(_xrSessionManager: WebXRSessionManager);
  127245. /**
  127246. * Used to register a module. After calling this function a developer can use this feature in the scene.
  127247. * Mainly used internally.
  127248. *
  127249. * @param featureName the name of the feature to register
  127250. * @param constructorFunction the function used to construct the module
  127251. * @param version the (babylon) version of the module
  127252. * @param stable is that a stable version of this module
  127253. */
  127254. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  127255. /**
  127256. * Returns a constructor of a specific feature.
  127257. *
  127258. * @param featureName the name of the feature to construct
  127259. * @param version the version of the feature to load
  127260. * @param xrSessionManager the xrSessionManager. Used to construct the module
  127261. * @param options optional options provided to the module.
  127262. * @returns a function that, when called, will return a new instance of this feature
  127263. */
  127264. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): () => IWebXRFeature;
  127265. /**
  127266. * Can be used to return the list of features currently registered
  127267. *
  127268. * @returns an Array of available features
  127269. */
  127270. static GetAvailableFeatures(): string[];
  127271. /**
  127272. * Gets the versions available for a specific feature
  127273. * @param featureName the name of the feature
  127274. * @returns an array with the available versions
  127275. */
  127276. static GetAvailableVersions(featureName: string): string[];
  127277. /**
  127278. * Return the latest unstable version of this feature
  127279. * @param featureName the name of the feature to search
  127280. * @returns the version number. if not found will return -1
  127281. */
  127282. static GetLatestVersionOfFeature(featureName: string): number;
  127283. /**
  127284. * Return the latest stable version of this feature
  127285. * @param featureName the name of the feature to search
  127286. * @returns the version number. if not found will return -1
  127287. */
  127288. static GetStableVersionOfFeature(featureName: string): number;
  127289. /**
  127290. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  127291. * Can be used during a session to start a feature
  127292. * @param featureName the name of feature to attach
  127293. */
  127294. attachFeature(featureName: string): void;
  127295. /**
  127296. * Can be used inside a session or when the session ends to detach a specific feature
  127297. * @param featureName the name of the feature to detach
  127298. */
  127299. detachFeature(featureName: string): void;
  127300. /**
  127301. * Used to disable an already-enabled feature
  127302. * The feature will be disposed and will be recreated once enabled.
  127303. * @param featureName the feature to disable
  127304. * @returns true if disable was successful
  127305. */
  127306. disableFeature(featureName: string | {
  127307. Name: string;
  127308. }): boolean;
  127309. /**
  127310. * dispose this features manager
  127311. */
  127312. dispose(): void;
  127313. /**
  127314. * 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.
  127315. * 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.
  127316. *
  127317. * @param featureName the name of the feature to load or the class of the feature
  127318. * @param version optional version to load. if not provided the latest version will be enabled
  127319. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  127320. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  127321. * @param required is this feature required to the app. If set to true the session init will fail if the feature is not available.
  127322. * @returns a new constructed feature or throws an error if feature not found.
  127323. */
  127324. enableFeature(featureName: string | {
  127325. Name: string;
  127326. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean, required?: boolean): IWebXRFeature;
  127327. /**
  127328. * get the implementation of an enabled feature.
  127329. * @param featureName the name of the feature to load
  127330. * @returns the feature class, if found
  127331. */
  127332. getEnabledFeature(featureName: string): IWebXRFeature;
  127333. /**
  127334. * Get the list of enabled features
  127335. * @returns an array of enabled features
  127336. */
  127337. getEnabledFeatures(): string[];
  127338. /**
  127339. * This function will exten the session creation configuration object with enabled features.
  127340. * If, for example, the anchors feature is enabled, it will be automatically added to the optional or required features list,
  127341. * according to the defined "required" variable, provided during enableFeature call
  127342. * @param xrSessionInit the xr Session init object to extend
  127343. *
  127344. * @returns an extended XRSessionInit object
  127345. */
  127346. extendXRSessionInitObject(xrSessionInit: XRSessionInit): XRSessionInit;
  127347. }
  127348. }
  127349. declare module BABYLON {
  127350. /**
  127351. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  127352. * @see https://doc.babylonjs.com/how_to/webxr_experience_helpers
  127353. */
  127354. export class WebXRExperienceHelper implements IDisposable {
  127355. private scene;
  127356. private _nonVRCamera;
  127357. private _originalSceneAutoClear;
  127358. private _supported;
  127359. /**
  127360. * Camera used to render xr content
  127361. */
  127362. camera: WebXRCamera;
  127363. /** A features manager for this xr session */
  127364. featuresManager: WebXRFeaturesManager;
  127365. /**
  127366. * Observers registered here will be triggered after the camera's initial transformation is set
  127367. * This can be used to set a different ground level or an extra rotation.
  127368. *
  127369. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  127370. * to the position set after this observable is done executing.
  127371. */
  127372. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  127373. /**
  127374. * Fires when the state of the experience helper has changed
  127375. */
  127376. onStateChangedObservable: Observable<WebXRState>;
  127377. /** Session manager used to keep track of xr session */
  127378. sessionManager: WebXRSessionManager;
  127379. /**
  127380. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  127381. */
  127382. state: WebXRState;
  127383. /**
  127384. * Creates a WebXRExperienceHelper
  127385. * @param scene The scene the helper should be created in
  127386. */
  127387. private constructor();
  127388. /**
  127389. * Creates the experience helper
  127390. * @param scene the scene to attach the experience helper to
  127391. * @returns a promise for the experience helper
  127392. */
  127393. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  127394. /**
  127395. * Disposes of the experience helper
  127396. */
  127397. dispose(): void;
  127398. /**
  127399. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  127400. * @param sessionMode options for the XR session
  127401. * @param referenceSpaceType frame of reference of the XR session
  127402. * @param renderTarget the output canvas that will be used to enter XR mode
  127403. * @param sessionCreationOptions optional XRSessionInit object to init the session with
  127404. * @returns promise that resolves after xr mode has entered
  127405. */
  127406. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget, sessionCreationOptions?: XRSessionInit): Promise<WebXRSessionManager>;
  127407. /**
  127408. * Exits XR mode and returns the scene to its original state
  127409. * @returns promise that resolves after xr mode has exited
  127410. */
  127411. exitXRAsync(): Promise<void>;
  127412. private _nonXRToXRCamera;
  127413. private _setState;
  127414. }
  127415. }
  127416. declare module BABYLON {
  127417. /**
  127418. * X-Y values for axes in WebXR
  127419. */
  127420. export interface IWebXRMotionControllerAxesValue {
  127421. /**
  127422. * The value of the x axis
  127423. */
  127424. x: number;
  127425. /**
  127426. * The value of the y-axis
  127427. */
  127428. y: number;
  127429. }
  127430. /**
  127431. * changed / previous values for the values of this component
  127432. */
  127433. export interface IWebXRMotionControllerComponentChangesValues<T> {
  127434. /**
  127435. * current (this frame) value
  127436. */
  127437. current: T;
  127438. /**
  127439. * previous (last change) value
  127440. */
  127441. previous: T;
  127442. }
  127443. /**
  127444. * Represents changes in the component between current frame and last values recorded
  127445. */
  127446. export interface IWebXRMotionControllerComponentChanges {
  127447. /**
  127448. * will be populated with previous and current values if axes changed
  127449. */
  127450. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  127451. /**
  127452. * will be populated with previous and current values if pressed changed
  127453. */
  127454. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  127455. /**
  127456. * will be populated with previous and current values if touched changed
  127457. */
  127458. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  127459. /**
  127460. * will be populated with previous and current values if value changed
  127461. */
  127462. value?: IWebXRMotionControllerComponentChangesValues<number>;
  127463. }
  127464. /**
  127465. * This class represents a single component (for example button or thumbstick) of a motion controller
  127466. */
  127467. export class WebXRControllerComponent implements IDisposable {
  127468. /**
  127469. * the id of this component
  127470. */
  127471. id: string;
  127472. /**
  127473. * the type of the component
  127474. */
  127475. type: MotionControllerComponentType;
  127476. private _buttonIndex;
  127477. private _axesIndices;
  127478. private _axes;
  127479. private _changes;
  127480. private _currentValue;
  127481. private _hasChanges;
  127482. private _pressed;
  127483. private _touched;
  127484. /**
  127485. * button component type
  127486. */
  127487. static BUTTON_TYPE: MotionControllerComponentType;
  127488. /**
  127489. * squeeze component type
  127490. */
  127491. static SQUEEZE_TYPE: MotionControllerComponentType;
  127492. /**
  127493. * Thumbstick component type
  127494. */
  127495. static THUMBSTICK_TYPE: MotionControllerComponentType;
  127496. /**
  127497. * Touchpad component type
  127498. */
  127499. static TOUCHPAD_TYPE: MotionControllerComponentType;
  127500. /**
  127501. * trigger component type
  127502. */
  127503. static TRIGGER_TYPE: MotionControllerComponentType;
  127504. /**
  127505. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  127506. * the axes data changes
  127507. */
  127508. onAxisValueChangedObservable: Observable<{
  127509. x: number;
  127510. y: number;
  127511. }>;
  127512. /**
  127513. * Observers registered here will be triggered when the state of a button changes
  127514. * State change is either pressed / touched / value
  127515. */
  127516. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  127517. /**
  127518. * Creates a new component for a motion controller.
  127519. * It is created by the motion controller itself
  127520. *
  127521. * @param id the id of this component
  127522. * @param type the type of the component
  127523. * @param _buttonIndex index in the buttons array of the gamepad
  127524. * @param _axesIndices indices of the values in the axes array of the gamepad
  127525. */
  127526. constructor(
  127527. /**
  127528. * the id of this component
  127529. */
  127530. id: string,
  127531. /**
  127532. * the type of the component
  127533. */
  127534. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  127535. /**
  127536. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  127537. */
  127538. get axes(): IWebXRMotionControllerAxesValue;
  127539. /**
  127540. * Get the changes. Elements will be populated only if they changed with their previous and current value
  127541. */
  127542. get changes(): IWebXRMotionControllerComponentChanges;
  127543. /**
  127544. * Return whether or not the component changed the last frame
  127545. */
  127546. get hasChanges(): boolean;
  127547. /**
  127548. * is the button currently pressed
  127549. */
  127550. get pressed(): boolean;
  127551. /**
  127552. * is the button currently touched
  127553. */
  127554. get touched(): boolean;
  127555. /**
  127556. * Get the current value of this component
  127557. */
  127558. get value(): number;
  127559. /**
  127560. * Dispose this component
  127561. */
  127562. dispose(): void;
  127563. /**
  127564. * Are there axes correlating to this component
  127565. * @return true is axes data is available
  127566. */
  127567. isAxes(): boolean;
  127568. /**
  127569. * Is this component a button (hence - pressable)
  127570. * @returns true if can be pressed
  127571. */
  127572. isButton(): boolean;
  127573. /**
  127574. * update this component using the gamepad object it is in. Called on every frame
  127575. * @param nativeController the native gamepad controller object
  127576. */
  127577. update(nativeController: IMinimalMotionControllerObject): void;
  127578. }
  127579. }
  127580. declare module BABYLON {
  127581. /**
  127582. * Interface used to represent data loading progression
  127583. */
  127584. export interface ISceneLoaderProgressEvent {
  127585. /**
  127586. * Defines if data length to load can be evaluated
  127587. */
  127588. readonly lengthComputable: boolean;
  127589. /**
  127590. * Defines the loaded data length
  127591. */
  127592. readonly loaded: number;
  127593. /**
  127594. * Defines the data length to load
  127595. */
  127596. readonly total: number;
  127597. }
  127598. /**
  127599. * Interface used by SceneLoader plugins to define supported file extensions
  127600. */
  127601. export interface ISceneLoaderPluginExtensions {
  127602. /**
  127603. * Defines the list of supported extensions
  127604. */
  127605. [extension: string]: {
  127606. isBinary: boolean;
  127607. };
  127608. }
  127609. /**
  127610. * Interface used by SceneLoader plugin factory
  127611. */
  127612. export interface ISceneLoaderPluginFactory {
  127613. /**
  127614. * Defines the name of the factory
  127615. */
  127616. name: string;
  127617. /**
  127618. * Function called to create a new plugin
  127619. * @return the new plugin
  127620. */
  127621. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  127622. /**
  127623. * The callback that returns true if the data can be directly loaded.
  127624. * @param data string containing the file data
  127625. * @returns if the data can be loaded directly
  127626. */
  127627. canDirectLoad?(data: string): boolean;
  127628. }
  127629. /**
  127630. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  127631. */
  127632. export interface ISceneLoaderPluginBase {
  127633. /**
  127634. * The friendly name of this plugin.
  127635. */
  127636. name: string;
  127637. /**
  127638. * The file extensions supported by this plugin.
  127639. */
  127640. extensions: string | ISceneLoaderPluginExtensions;
  127641. /**
  127642. * The callback called when loading from a url.
  127643. * @param scene scene loading this url
  127644. * @param url url to load
  127645. * @param onSuccess callback called when the file successfully loads
  127646. * @param onProgress callback called while file is loading (if the server supports this mode)
  127647. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  127648. * @param onError callback called when the file fails to load
  127649. * @returns a file request object
  127650. */
  127651. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  127652. /**
  127653. * The callback called when loading from a file object.
  127654. * @param scene scene loading this file
  127655. * @param file defines the file to load
  127656. * @param onSuccess defines the callback to call when data is loaded
  127657. * @param onProgress defines the callback to call during loading process
  127658. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  127659. * @param onError defines the callback to call when an error occurs
  127660. * @returns a file request object
  127661. */
  127662. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  127663. /**
  127664. * The callback that returns true if the data can be directly loaded.
  127665. * @param data string containing the file data
  127666. * @returns if the data can be loaded directly
  127667. */
  127668. canDirectLoad?(data: string): boolean;
  127669. /**
  127670. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  127671. * @param scene scene loading this data
  127672. * @param data string containing the data
  127673. * @returns data to pass to the plugin
  127674. */
  127675. directLoad?(scene: Scene, data: string): any;
  127676. /**
  127677. * The callback that allows custom handling of the root url based on the response url.
  127678. * @param rootUrl the original root url
  127679. * @param responseURL the response url if available
  127680. * @returns the new root url
  127681. */
  127682. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  127683. }
  127684. /**
  127685. * Interface used to define a SceneLoader plugin
  127686. */
  127687. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  127688. /**
  127689. * Import meshes into a scene.
  127690. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  127691. * @param scene The scene to import into
  127692. * @param data The data to import
  127693. * @param rootUrl The root url for scene and resources
  127694. * @param meshes The meshes array to import into
  127695. * @param particleSystems The particle systems array to import into
  127696. * @param skeletons The skeletons array to import into
  127697. * @param onError The callback when import fails
  127698. * @returns True if successful or false otherwise
  127699. */
  127700. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  127701. /**
  127702. * Load into a scene.
  127703. * @param scene The scene to load into
  127704. * @param data The data to import
  127705. * @param rootUrl The root url for scene and resources
  127706. * @param onError The callback when import fails
  127707. * @returns True if successful or false otherwise
  127708. */
  127709. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  127710. /**
  127711. * Load into an asset container.
  127712. * @param scene The scene to load into
  127713. * @param data The data to import
  127714. * @param rootUrl The root url for scene and resources
  127715. * @param onError The callback when import fails
  127716. * @returns The loaded asset container
  127717. */
  127718. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  127719. }
  127720. /**
  127721. * Interface used to define an async SceneLoader plugin
  127722. */
  127723. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  127724. /**
  127725. * Import meshes into a scene.
  127726. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  127727. * @param scene The scene to import into
  127728. * @param data The data to import
  127729. * @param rootUrl The root url for scene and resources
  127730. * @param onProgress The callback when the load progresses
  127731. * @param fileName Defines the name of the file to load
  127732. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  127733. */
  127734. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  127735. meshes: AbstractMesh[];
  127736. particleSystems: IParticleSystem[];
  127737. skeletons: Skeleton[];
  127738. animationGroups: AnimationGroup[];
  127739. }>;
  127740. /**
  127741. * Load into a scene.
  127742. * @param scene The scene to load into
  127743. * @param data The data to import
  127744. * @param rootUrl The root url for scene and resources
  127745. * @param onProgress The callback when the load progresses
  127746. * @param fileName Defines the name of the file to load
  127747. * @returns Nothing
  127748. */
  127749. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  127750. /**
  127751. * Load into an asset container.
  127752. * @param scene The scene to load into
  127753. * @param data The data to import
  127754. * @param rootUrl The root url for scene and resources
  127755. * @param onProgress The callback when the load progresses
  127756. * @param fileName Defines the name of the file to load
  127757. * @returns The loaded asset container
  127758. */
  127759. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  127760. }
  127761. /**
  127762. * Mode that determines how to handle old animation groups before loading new ones.
  127763. */
  127764. export enum SceneLoaderAnimationGroupLoadingMode {
  127765. /**
  127766. * Reset all old animations to initial state then dispose them.
  127767. */
  127768. Clean = 0,
  127769. /**
  127770. * Stop all old animations.
  127771. */
  127772. Stop = 1,
  127773. /**
  127774. * Restart old animations from first frame.
  127775. */
  127776. Sync = 2,
  127777. /**
  127778. * Old animations remains untouched.
  127779. */
  127780. NoSync = 3
  127781. }
  127782. /**
  127783. * Defines a plugin registered by the SceneLoader
  127784. */
  127785. interface IRegisteredPlugin {
  127786. /**
  127787. * Defines the plugin to use
  127788. */
  127789. plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  127790. /**
  127791. * Defines if the plugin supports binary data
  127792. */
  127793. isBinary: boolean;
  127794. }
  127795. /**
  127796. * Class used to load scene from various file formats using registered plugins
  127797. * @see https://doc.babylonjs.com/how_to/load_from_any_file_type
  127798. */
  127799. export class SceneLoader {
  127800. /**
  127801. * No logging while loading
  127802. */
  127803. static readonly NO_LOGGING: number;
  127804. /**
  127805. * Minimal logging while loading
  127806. */
  127807. static readonly MINIMAL_LOGGING: number;
  127808. /**
  127809. * Summary logging while loading
  127810. */
  127811. static readonly SUMMARY_LOGGING: number;
  127812. /**
  127813. * Detailled logging while loading
  127814. */
  127815. static readonly DETAILED_LOGGING: number;
  127816. /**
  127817. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  127818. */
  127819. static get ForceFullSceneLoadingForIncremental(): boolean;
  127820. static set ForceFullSceneLoadingForIncremental(value: boolean);
  127821. /**
  127822. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  127823. */
  127824. static get ShowLoadingScreen(): boolean;
  127825. static set ShowLoadingScreen(value: boolean);
  127826. /**
  127827. * Defines the current logging level (while loading the scene)
  127828. * @ignorenaming
  127829. */
  127830. static get loggingLevel(): number;
  127831. static set loggingLevel(value: number);
  127832. /**
  127833. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  127834. */
  127835. static get CleanBoneMatrixWeights(): boolean;
  127836. static set CleanBoneMatrixWeights(value: boolean);
  127837. /**
  127838. * Event raised when a plugin is used to load a scene
  127839. */
  127840. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  127841. private static _registeredPlugins;
  127842. private static _showingLoadingScreen;
  127843. /**
  127844. * Gets the default plugin (used to load Babylon files)
  127845. * @returns the .babylon plugin
  127846. */
  127847. static GetDefaultPlugin(): IRegisteredPlugin;
  127848. private static _GetPluginForExtension;
  127849. private static _GetPluginForDirectLoad;
  127850. private static _GetPluginForFilename;
  127851. private static _GetDirectLoad;
  127852. private static _LoadData;
  127853. private static _GetFileInfo;
  127854. /**
  127855. * Gets a plugin that can load the given extension
  127856. * @param extension defines the extension to load
  127857. * @returns a plugin or null if none works
  127858. */
  127859. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  127860. /**
  127861. * Gets a boolean indicating that the given extension can be loaded
  127862. * @param extension defines the extension to load
  127863. * @returns true if the extension is supported
  127864. */
  127865. static IsPluginForExtensionAvailable(extension: string): boolean;
  127866. /**
  127867. * Adds a new plugin to the list of registered plugins
  127868. * @param plugin defines the plugin to add
  127869. */
  127870. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  127871. /**
  127872. * Import meshes into a scene
  127873. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  127874. * @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)
  127875. * @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)
  127876. * @param scene the instance of BABYLON.Scene to append to
  127877. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  127878. * @param onProgress a callback with a progress event for each file being loaded
  127879. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  127880. * @param pluginExtension the extension used to determine the plugin
  127881. * @returns The loaded plugin
  127882. */
  127883. 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>;
  127884. /**
  127885. * Import meshes into a scene
  127886. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  127887. * @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)
  127888. * @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)
  127889. * @param scene the instance of BABYLON.Scene to append to
  127890. * @param onProgress a callback with a progress event for each file being loaded
  127891. * @param pluginExtension the extension used to determine the plugin
  127892. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  127893. */
  127894. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  127895. meshes: AbstractMesh[];
  127896. particleSystems: IParticleSystem[];
  127897. skeletons: Skeleton[];
  127898. animationGroups: AnimationGroup[];
  127899. }>;
  127900. /**
  127901. * Load a scene
  127902. * @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)
  127903. * @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)
  127904. * @param engine is the instance of BABYLON.Engine to use to create the scene
  127905. * @param onSuccess a callback with the scene when import succeeds
  127906. * @param onProgress a callback with a progress event for each file being loaded
  127907. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  127908. * @param pluginExtension the extension used to determine the plugin
  127909. * @returns The loaded plugin
  127910. */
  127911. 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>;
  127912. /**
  127913. * Load a scene
  127914. * @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)
  127915. * @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)
  127916. * @param engine is the instance of BABYLON.Engine to use to create the scene
  127917. * @param onProgress a callback with a progress event for each file being loaded
  127918. * @param pluginExtension the extension used to determine the plugin
  127919. * @returns The loaded scene
  127920. */
  127921. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  127922. /**
  127923. * Append a scene
  127924. * @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)
  127925. * @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)
  127926. * @param scene is the instance of BABYLON.Scene to append to
  127927. * @param onSuccess a callback with the scene when import succeeds
  127928. * @param onProgress a callback with a progress event for each file being loaded
  127929. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  127930. * @param pluginExtension the extension used to determine the plugin
  127931. * @returns The loaded plugin
  127932. */
  127933. 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>;
  127934. /**
  127935. * Append a scene
  127936. * @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)
  127937. * @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)
  127938. * @param scene is the instance of BABYLON.Scene to append to
  127939. * @param onProgress a callback with a progress event for each file being loaded
  127940. * @param pluginExtension the extension used to determine the plugin
  127941. * @returns The given scene
  127942. */
  127943. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  127944. /**
  127945. * Load a scene into an asset container
  127946. * @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)
  127947. * @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)
  127948. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  127949. * @param onSuccess a callback with the scene when import succeeds
  127950. * @param onProgress a callback with a progress event for each file being loaded
  127951. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  127952. * @param pluginExtension the extension used to determine the plugin
  127953. * @returns The loaded plugin
  127954. */
  127955. 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>;
  127956. /**
  127957. * Load a scene into an asset container
  127958. * @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)
  127959. * @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)
  127960. * @param scene is the instance of Scene to append to
  127961. * @param onProgress a callback with a progress event for each file being loaded
  127962. * @param pluginExtension the extension used to determine the plugin
  127963. * @returns The loaded asset container
  127964. */
  127965. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  127966. /**
  127967. * Import animations from a file into a scene
  127968. * @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)
  127969. * @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)
  127970. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  127971. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  127972. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  127973. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  127974. * @param onSuccess a callback with the scene when import succeeds
  127975. * @param onProgress a callback with a progress event for each file being loaded
  127976. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  127977. * @param pluginExtension the extension used to determine the plugin
  127978. */
  127979. 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;
  127980. /**
  127981. * Import animations from a file into a scene
  127982. * @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)
  127983. * @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)
  127984. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  127985. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  127986. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  127987. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  127988. * @param onSuccess a callback with the scene when import succeeds
  127989. * @param onProgress a callback with a progress event for each file being loaded
  127990. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  127991. * @param pluginExtension the extension used to determine the plugin
  127992. * @returns the updated scene with imported animations
  127993. */
  127994. 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>;
  127995. }
  127996. }
  127997. declare module BABYLON {
  127998. /**
  127999. * Handedness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  128000. */
  128001. export type MotionControllerHandedness = "none" | "left" | "right";
  128002. /**
  128003. * The type of components available in motion controllers.
  128004. * This is not the name of the component.
  128005. */
  128006. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  128007. /**
  128008. * The state of a controller component
  128009. */
  128010. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  128011. /**
  128012. * The schema of motion controller layout.
  128013. * No object will be initialized using this interface
  128014. * This is used just to define the profile.
  128015. */
  128016. export interface IMotionControllerLayout {
  128017. /**
  128018. * Path to load the assets. Usually relative to the base path
  128019. */
  128020. assetPath: string;
  128021. /**
  128022. * Available components (unsorted)
  128023. */
  128024. components: {
  128025. /**
  128026. * A map of component Ids
  128027. */
  128028. [componentId: string]: {
  128029. /**
  128030. * The type of input the component outputs
  128031. */
  128032. type: MotionControllerComponentType;
  128033. /**
  128034. * The indices of this component in the gamepad object
  128035. */
  128036. gamepadIndices: {
  128037. /**
  128038. * Index of button
  128039. */
  128040. button?: number;
  128041. /**
  128042. * If available, index of x-axis
  128043. */
  128044. xAxis?: number;
  128045. /**
  128046. * If available, index of y-axis
  128047. */
  128048. yAxis?: number;
  128049. };
  128050. /**
  128051. * The mesh's root node name
  128052. */
  128053. rootNodeName: string;
  128054. /**
  128055. * Animation definitions for this model
  128056. */
  128057. visualResponses: {
  128058. [stateKey: string]: {
  128059. /**
  128060. * What property will be animated
  128061. */
  128062. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  128063. /**
  128064. * What states influence this visual response
  128065. */
  128066. states: MotionControllerComponentStateType[];
  128067. /**
  128068. * Type of animation - movement or visibility
  128069. */
  128070. valueNodeProperty: "transform" | "visibility";
  128071. /**
  128072. * Base node name to move. Its position will be calculated according to the min and max nodes
  128073. */
  128074. valueNodeName?: string;
  128075. /**
  128076. * Minimum movement node
  128077. */
  128078. minNodeName?: string;
  128079. /**
  128080. * Max movement node
  128081. */
  128082. maxNodeName?: string;
  128083. };
  128084. };
  128085. /**
  128086. * If touch enabled, what is the name of node to display user feedback
  128087. */
  128088. touchPointNodeName?: string;
  128089. };
  128090. };
  128091. /**
  128092. * Is it xr standard mapping or not
  128093. */
  128094. gamepadMapping: "" | "xr-standard";
  128095. /**
  128096. * Base root node of this entire model
  128097. */
  128098. rootNodeName: string;
  128099. /**
  128100. * Defines the main button component id
  128101. */
  128102. selectComponentId: string;
  128103. }
  128104. /**
  128105. * A definition for the layout map in the input profile
  128106. */
  128107. export interface IMotionControllerLayoutMap {
  128108. /**
  128109. * Layouts with handedness type as a key
  128110. */
  128111. [handedness: string]: IMotionControllerLayout;
  128112. }
  128113. /**
  128114. * The XR Input profile schema
  128115. * Profiles can be found here:
  128116. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  128117. */
  128118. export interface IMotionControllerProfile {
  128119. /**
  128120. * fallback profiles for this profileId
  128121. */
  128122. fallbackProfileIds: string[];
  128123. /**
  128124. * The layout map, with handedness as key
  128125. */
  128126. layouts: IMotionControllerLayoutMap;
  128127. /**
  128128. * The id of this profile
  128129. * correlates to the profile(s) in the xrInput.profiles array
  128130. */
  128131. profileId: string;
  128132. }
  128133. /**
  128134. * A helper-interface for the 3 meshes needed for controller button animation
  128135. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  128136. */
  128137. export interface IMotionControllerButtonMeshMap {
  128138. /**
  128139. * the mesh that defines the pressed value mesh position.
  128140. * This is used to find the max-position of this button
  128141. */
  128142. pressedMesh: AbstractMesh;
  128143. /**
  128144. * the mesh that defines the unpressed value mesh position.
  128145. * This is used to find the min (or initial) position of this button
  128146. */
  128147. unpressedMesh: AbstractMesh;
  128148. /**
  128149. * The mesh that will be changed when value changes
  128150. */
  128151. valueMesh: AbstractMesh;
  128152. }
  128153. /**
  128154. * A helper-interface for the 3 meshes needed for controller axis animation.
  128155. * This will be expanded when touchpad animations are fully supported
  128156. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  128157. */
  128158. export interface IMotionControllerMeshMap {
  128159. /**
  128160. * the mesh that defines the maximum value mesh position.
  128161. */
  128162. maxMesh?: AbstractMesh;
  128163. /**
  128164. * the mesh that defines the minimum value mesh position.
  128165. */
  128166. minMesh?: AbstractMesh;
  128167. /**
  128168. * The mesh that will be changed when axis value changes
  128169. */
  128170. valueMesh?: AbstractMesh;
  128171. }
  128172. /**
  128173. * The elements needed for change-detection of the gamepad objects in motion controllers
  128174. */
  128175. export interface IMinimalMotionControllerObject {
  128176. /**
  128177. * Available axes of this controller
  128178. */
  128179. axes: number[];
  128180. /**
  128181. * An array of available buttons
  128182. */
  128183. buttons: Array<{
  128184. /**
  128185. * Value of the button/trigger
  128186. */
  128187. value: number;
  128188. /**
  128189. * If the button/trigger is currently touched
  128190. */
  128191. touched: boolean;
  128192. /**
  128193. * If the button/trigger is currently pressed
  128194. */
  128195. pressed: boolean;
  128196. }>;
  128197. /**
  128198. * EXPERIMENTAL haptic support.
  128199. */
  128200. hapticActuators?: Array<{
  128201. pulse: (value: number, duration: number) => Promise<boolean>;
  128202. }>;
  128203. }
  128204. /**
  128205. * An Abstract Motion controller
  128206. * This class receives an xrInput and a profile layout and uses those to initialize the components
  128207. * Each component has an observable to check for changes in value and state
  128208. */
  128209. export abstract class WebXRAbstractMotionController implements IDisposable {
  128210. protected scene: Scene;
  128211. protected layout: IMotionControllerLayout;
  128212. /**
  128213. * The gamepad object correlating to this controller
  128214. */
  128215. gamepadObject: IMinimalMotionControllerObject;
  128216. /**
  128217. * handedness (left/right/none) of this controller
  128218. */
  128219. handedness: MotionControllerHandedness;
  128220. private _initComponent;
  128221. private _modelReady;
  128222. /**
  128223. * A map of components (WebXRControllerComponent) in this motion controller
  128224. * Components have a ComponentType and can also have both button and axis definitions
  128225. */
  128226. readonly components: {
  128227. [id: string]: WebXRControllerComponent;
  128228. };
  128229. /**
  128230. * Disable the model's animation. Can be set at any time.
  128231. */
  128232. disableAnimation: boolean;
  128233. /**
  128234. * Observers registered here will be triggered when the model of this controller is done loading
  128235. */
  128236. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  128237. /**
  128238. * The profile id of this motion controller
  128239. */
  128240. abstract profileId: string;
  128241. /**
  128242. * The root mesh of the model. It is null if the model was not yet initialized
  128243. */
  128244. rootMesh: Nullable<AbstractMesh>;
  128245. /**
  128246. * constructs a new abstract motion controller
  128247. * @param scene the scene to which the model of the controller will be added
  128248. * @param layout The profile layout to load
  128249. * @param gamepadObject The gamepad object correlating to this controller
  128250. * @param handedness handedness (left/right/none) of this controller
  128251. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  128252. */
  128253. constructor(scene: Scene, layout: IMotionControllerLayout,
  128254. /**
  128255. * The gamepad object correlating to this controller
  128256. */
  128257. gamepadObject: IMinimalMotionControllerObject,
  128258. /**
  128259. * handedness (left/right/none) of this controller
  128260. */
  128261. handedness: MotionControllerHandedness, _doNotLoadControllerMesh?: boolean);
  128262. /**
  128263. * Dispose this controller, the model mesh and all its components
  128264. */
  128265. dispose(): void;
  128266. /**
  128267. * Returns all components of specific type
  128268. * @param type the type to search for
  128269. * @return an array of components with this type
  128270. */
  128271. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  128272. /**
  128273. * get a component based an its component id as defined in layout.components
  128274. * @param id the id of the component
  128275. * @returns the component correlates to the id or undefined if not found
  128276. */
  128277. getComponent(id: string): WebXRControllerComponent;
  128278. /**
  128279. * Get the list of components available in this motion controller
  128280. * @returns an array of strings correlating to available components
  128281. */
  128282. getComponentIds(): string[];
  128283. /**
  128284. * Get the first component of specific type
  128285. * @param type type of component to find
  128286. * @return a controller component or null if not found
  128287. */
  128288. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  128289. /**
  128290. * Get the main (Select) component of this controller as defined in the layout
  128291. * @returns the main component of this controller
  128292. */
  128293. getMainComponent(): WebXRControllerComponent;
  128294. /**
  128295. * Loads the model correlating to this controller
  128296. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  128297. * @returns A promise fulfilled with the result of the model loading
  128298. */
  128299. loadModel(): Promise<boolean>;
  128300. /**
  128301. * Update this model using the current XRFrame
  128302. * @param xrFrame the current xr frame to use and update the model
  128303. */
  128304. updateFromXRFrame(xrFrame: XRFrame): void;
  128305. /**
  128306. * Backwards compatibility due to a deeply-integrated typo
  128307. */
  128308. get handness(): XREye;
  128309. /**
  128310. * Pulse (vibrate) this controller
  128311. * If the controller does not support pulses, this function will fail silently and return Promise<false> directly after called
  128312. * Consecutive calls to this function will cancel the last pulse call
  128313. *
  128314. * @param value the strength of the pulse in 0.0...1.0 range
  128315. * @param duration Duration of the pulse in milliseconds
  128316. * @param hapticActuatorIndex optional index of actuator (will usually be 0)
  128317. * @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
  128318. */
  128319. pulse(value: number, duration: number, hapticActuatorIndex?: number): Promise<boolean>;
  128320. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  128321. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  128322. /**
  128323. * Moves the axis on the controller mesh based on its current state
  128324. * @param axis the index of the axis
  128325. * @param axisValue the value of the axis which determines the meshes new position
  128326. * @hidden
  128327. */
  128328. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  128329. /**
  128330. * Update the model itself with the current frame data
  128331. * @param xrFrame the frame to use for updating the model mesh
  128332. */
  128333. protected updateModel(xrFrame: XRFrame): void;
  128334. /**
  128335. * Get the filename and path for this controller's model
  128336. * @returns a map of filename and path
  128337. */
  128338. protected abstract _getFilenameAndPath(): {
  128339. filename: string;
  128340. path: string;
  128341. };
  128342. /**
  128343. * This function is called before the mesh is loaded. It checks for loading constraints.
  128344. * For example, this function can check if the GLB loader is available
  128345. * If this function returns false, the generic controller will be loaded instead
  128346. * @returns Is the client ready to load the mesh
  128347. */
  128348. protected abstract _getModelLoadingConstraints(): boolean;
  128349. /**
  128350. * This function will be called after the model was successfully loaded and can be used
  128351. * for mesh transformations before it is available for the user
  128352. * @param meshes the loaded meshes
  128353. */
  128354. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  128355. /**
  128356. * Set the root mesh for this controller. Important for the WebXR controller class
  128357. * @param meshes the loaded meshes
  128358. */
  128359. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  128360. /**
  128361. * A function executed each frame that updates the mesh (if needed)
  128362. * @param xrFrame the current xrFrame
  128363. */
  128364. protected abstract _updateModel(xrFrame: XRFrame): void;
  128365. private _getGenericFilenameAndPath;
  128366. private _getGenericParentMesh;
  128367. }
  128368. }
  128369. declare module BABYLON {
  128370. /**
  128371. * A generic trigger-only motion controller for WebXR
  128372. */
  128373. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  128374. /**
  128375. * Static version of the profile id of this controller
  128376. */
  128377. static ProfileId: string;
  128378. profileId: string;
  128379. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  128380. protected _getFilenameAndPath(): {
  128381. filename: string;
  128382. path: string;
  128383. };
  128384. protected _getModelLoadingConstraints(): boolean;
  128385. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  128386. protected _setRootMesh(meshes: AbstractMesh[]): void;
  128387. protected _updateModel(): void;
  128388. }
  128389. }
  128390. declare module BABYLON {
  128391. /**
  128392. * Class containing static functions to help procedurally build meshes
  128393. */
  128394. export class SphereBuilder {
  128395. /**
  128396. * Creates a sphere mesh
  128397. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  128398. * * 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`)
  128399. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  128400. * * 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
  128401. * * 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)
  128402. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  128403. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  128404. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  128405. * @param name defines the name of the mesh
  128406. * @param options defines the options used to create the mesh
  128407. * @param scene defines the hosting scene
  128408. * @returns the sphere mesh
  128409. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  128410. */
  128411. static CreateSphere(name: string, options: {
  128412. segments?: number;
  128413. diameter?: number;
  128414. diameterX?: number;
  128415. diameterY?: number;
  128416. diameterZ?: number;
  128417. arc?: number;
  128418. slice?: number;
  128419. sideOrientation?: number;
  128420. frontUVs?: Vector4;
  128421. backUVs?: Vector4;
  128422. updatable?: boolean;
  128423. }, scene?: Nullable<Scene>): Mesh;
  128424. }
  128425. }
  128426. declare module BABYLON {
  128427. /**
  128428. * A profiled motion controller has its profile loaded from an online repository.
  128429. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  128430. */
  128431. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  128432. private _repositoryUrl;
  128433. private _buttonMeshMapping;
  128434. private _touchDots;
  128435. /**
  128436. * The profile ID of this controller. Will be populated when the controller initializes.
  128437. */
  128438. profileId: string;
  128439. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  128440. dispose(): void;
  128441. protected _getFilenameAndPath(): {
  128442. filename: string;
  128443. path: string;
  128444. };
  128445. protected _getModelLoadingConstraints(): boolean;
  128446. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  128447. protected _setRootMesh(meshes: AbstractMesh[]): void;
  128448. protected _updateModel(_xrFrame: XRFrame): void;
  128449. }
  128450. }
  128451. declare module BABYLON {
  128452. /**
  128453. * A construction function type to create a new controller based on an xrInput object
  128454. */
  128455. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  128456. /**
  128457. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  128458. *
  128459. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  128460. * it should be replaced with auto-loaded controllers.
  128461. *
  128462. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  128463. */
  128464. export class WebXRMotionControllerManager {
  128465. private static _AvailableControllers;
  128466. private static _Fallbacks;
  128467. private static _ProfileLoadingPromises;
  128468. private static _ProfilesList;
  128469. /**
  128470. * The base URL of the online controller repository. Can be changed at any time.
  128471. */
  128472. static BaseRepositoryUrl: string;
  128473. /**
  128474. * Which repository gets priority - local or online
  128475. */
  128476. static PrioritizeOnlineRepository: boolean;
  128477. /**
  128478. * Use the online repository, or use only locally-defined controllers
  128479. */
  128480. static UseOnlineRepository: boolean;
  128481. /**
  128482. * Clear the cache used for profile loading and reload when requested again
  128483. */
  128484. static ClearProfilesCache(): void;
  128485. /**
  128486. * Register the default fallbacks.
  128487. * This function is called automatically when this file is imported.
  128488. */
  128489. static DefaultFallbacks(): void;
  128490. /**
  128491. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  128492. * @param profileId the profile to which a fallback needs to be found
  128493. * @return an array with corresponding fallback profiles
  128494. */
  128495. static FindFallbackWithProfileId(profileId: string): string[];
  128496. /**
  128497. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  128498. * The order of search:
  128499. *
  128500. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  128501. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  128502. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  128503. * 4) return the generic trigger controller if none were found
  128504. *
  128505. * @param xrInput the xrInput to which a new controller is initialized
  128506. * @param scene the scene to which the model will be added
  128507. * @param forceProfile force a certain profile for this controller
  128508. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  128509. */
  128510. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  128511. /**
  128512. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  128513. *
  128514. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  128515. *
  128516. * @param type the profile type to register
  128517. * @param constructFunction the function to be called when loading this profile
  128518. */
  128519. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  128520. /**
  128521. * Register a fallback to a specific profile.
  128522. * @param profileId the profileId that will receive the fallbacks
  128523. * @param fallbacks A list of fallback profiles
  128524. */
  128525. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  128526. /**
  128527. * Will update the list of profiles available in the repository
  128528. * @return a promise that resolves to a map of profiles available online
  128529. */
  128530. static UpdateProfilesList(): Promise<{
  128531. [profile: string]: string;
  128532. }>;
  128533. private static _LoadProfileFromRepository;
  128534. private static _LoadProfilesFromAvailableControllers;
  128535. }
  128536. }
  128537. declare module BABYLON {
  128538. /**
  128539. * Configuration options for the WebXR controller creation
  128540. */
  128541. export interface IWebXRControllerOptions {
  128542. /**
  128543. * Should the controller mesh be animated when a user interacts with it
  128544. * The pressed buttons / thumbstick and touchpad animations will be disabled
  128545. */
  128546. disableMotionControllerAnimation?: boolean;
  128547. /**
  128548. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  128549. */
  128550. doNotLoadControllerMesh?: boolean;
  128551. /**
  128552. * Force a specific controller type for this controller.
  128553. * This can be used when creating your own profile or when testing different controllers
  128554. */
  128555. forceControllerProfile?: string;
  128556. /**
  128557. * Defines a rendering group ID for meshes that will be loaded.
  128558. * This is for the default controllers only.
  128559. */
  128560. renderingGroupId?: number;
  128561. }
  128562. /**
  128563. * Represents an XR controller
  128564. */
  128565. export class WebXRInputSource {
  128566. private _scene;
  128567. /** The underlying input source for the controller */
  128568. inputSource: XRInputSource;
  128569. private _options;
  128570. private _tmpVector;
  128571. private _uniqueId;
  128572. private _disposed;
  128573. /**
  128574. * 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
  128575. */
  128576. grip?: AbstractMesh;
  128577. /**
  128578. * If available, this is the gamepad object related to this controller.
  128579. * Using this object it is possible to get click events and trackpad changes of the
  128580. * webxr controller that is currently being used.
  128581. */
  128582. motionController?: WebXRAbstractMotionController;
  128583. /**
  128584. * Event that fires when the controller is removed/disposed.
  128585. * The object provided as event data is this controller, after associated assets were disposed.
  128586. * uniqueId is still available.
  128587. */
  128588. onDisposeObservable: Observable<WebXRInputSource>;
  128589. /**
  128590. * Will be triggered when the mesh associated with the motion controller is done loading.
  128591. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  128592. * A shortened version of controller -> motion controller -> on mesh loaded.
  128593. */
  128594. onMeshLoadedObservable: Observable<AbstractMesh>;
  128595. /**
  128596. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  128597. */
  128598. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  128599. /**
  128600. * Pointer which can be used to select objects or attach a visible laser to
  128601. */
  128602. pointer: AbstractMesh;
  128603. /**
  128604. * Creates the input source object
  128605. * @see https://doc.babylonjs.com/how_to/webxr_controllers_support
  128606. * @param _scene the scene which the controller should be associated to
  128607. * @param inputSource the underlying input source for the controller
  128608. * @param _options options for this controller creation
  128609. */
  128610. constructor(_scene: Scene,
  128611. /** The underlying input source for the controller */
  128612. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  128613. /**
  128614. * Get this controllers unique id
  128615. */
  128616. get uniqueId(): string;
  128617. /**
  128618. * Disposes of the object
  128619. */
  128620. dispose(): void;
  128621. /**
  128622. * Gets a world space ray coming from the pointer or grip
  128623. * @param result the resulting ray
  128624. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  128625. */
  128626. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  128627. /**
  128628. * Updates the controller pose based on the given XRFrame
  128629. * @param xrFrame xr frame to update the pose with
  128630. * @param referenceSpace reference space to use
  128631. */
  128632. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  128633. }
  128634. }
  128635. declare module BABYLON {
  128636. /**
  128637. * The schema for initialization options of the XR Input class
  128638. */
  128639. export interface IWebXRInputOptions {
  128640. /**
  128641. * If set to true no model will be automatically loaded
  128642. */
  128643. doNotLoadControllerMeshes?: boolean;
  128644. /**
  128645. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  128646. * If not found, the xr input profile data will be used.
  128647. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  128648. */
  128649. forceInputProfile?: string;
  128650. /**
  128651. * Do not send a request to the controller repository to load the profile.
  128652. *
  128653. * Instead, use the controllers available in babylon itself.
  128654. */
  128655. disableOnlineControllerRepository?: boolean;
  128656. /**
  128657. * A custom URL for the controllers repository
  128658. */
  128659. customControllersRepositoryURL?: string;
  128660. /**
  128661. * Should the controller model's components not move according to the user input
  128662. */
  128663. disableControllerAnimation?: boolean;
  128664. /**
  128665. * Optional options to pass to the controller. Will be overridden by the Input options where applicable
  128666. */
  128667. controllerOptions?: IWebXRControllerOptions;
  128668. }
  128669. /**
  128670. * XR input used to track XR inputs such as controllers/rays
  128671. */
  128672. export class WebXRInput implements IDisposable {
  128673. /**
  128674. * the xr session manager for this session
  128675. */
  128676. xrSessionManager: WebXRSessionManager;
  128677. /**
  128678. * the WebXR camera for this session. Mainly used for teleportation
  128679. */
  128680. xrCamera: WebXRCamera;
  128681. private readonly options;
  128682. /**
  128683. * XR controllers being tracked
  128684. */
  128685. controllers: Array<WebXRInputSource>;
  128686. private _frameObserver;
  128687. private _sessionEndedObserver;
  128688. private _sessionInitObserver;
  128689. /**
  128690. * Event when a controller has been connected/added
  128691. */
  128692. onControllerAddedObservable: Observable<WebXRInputSource>;
  128693. /**
  128694. * Event when a controller has been removed/disconnected
  128695. */
  128696. onControllerRemovedObservable: Observable<WebXRInputSource>;
  128697. /**
  128698. * Initializes the WebXRInput
  128699. * @param xrSessionManager the xr session manager for this session
  128700. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  128701. * @param options = initialization options for this xr input
  128702. */
  128703. constructor(
  128704. /**
  128705. * the xr session manager for this session
  128706. */
  128707. xrSessionManager: WebXRSessionManager,
  128708. /**
  128709. * the WebXR camera for this session. Mainly used for teleportation
  128710. */
  128711. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  128712. private _onInputSourcesChange;
  128713. private _addAndRemoveControllers;
  128714. /**
  128715. * Disposes of the object
  128716. */
  128717. dispose(): void;
  128718. }
  128719. }
  128720. declare module BABYLON {
  128721. /**
  128722. * This is the base class for all WebXR features.
  128723. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  128724. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  128725. */
  128726. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  128727. protected _xrSessionManager: WebXRSessionManager;
  128728. private _attached;
  128729. private _removeOnDetach;
  128730. /**
  128731. * Is this feature disposed?
  128732. */
  128733. isDisposed: boolean;
  128734. /**
  128735. * Should auto-attach be disabled?
  128736. */
  128737. disableAutoAttach: boolean;
  128738. /**
  128739. * The name of the native xr feature name (like anchor, hit-test, or hand-tracking)
  128740. */
  128741. xrNativeFeatureName: string;
  128742. /**
  128743. * Construct a new (abstract) WebXR feature
  128744. * @param _xrSessionManager the xr session manager for this feature
  128745. */
  128746. constructor(_xrSessionManager: WebXRSessionManager);
  128747. /**
  128748. * Is this feature attached
  128749. */
  128750. get attached(): boolean;
  128751. /**
  128752. * attach this feature
  128753. *
  128754. * @param force should attachment be forced (even when already attached)
  128755. * @returns true if successful, false is failed or already attached
  128756. */
  128757. attach(force?: boolean): boolean;
  128758. /**
  128759. * detach this feature.
  128760. *
  128761. * @returns true if successful, false if failed or already detached
  128762. */
  128763. detach(): boolean;
  128764. /**
  128765. * Dispose this feature and all of the resources attached
  128766. */
  128767. dispose(): void;
  128768. /**
  128769. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  128770. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  128771. *
  128772. * @returns whether or not the feature is compatible in this environment
  128773. */
  128774. isCompatible(): boolean;
  128775. /**
  128776. * This is used to register callbacks that will automatically be removed when detach is called.
  128777. * @param observable the observable to which the observer will be attached
  128778. * @param callback the callback to register
  128779. */
  128780. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  128781. /**
  128782. * Code in this function will be executed on each xrFrame received from the browser.
  128783. * This function will not execute after the feature is detached.
  128784. * @param _xrFrame the current frame
  128785. */
  128786. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  128787. }
  128788. }
  128789. declare module BABYLON {
  128790. /**
  128791. * Renders a layer on top of an existing scene
  128792. */
  128793. export class UtilityLayerRenderer implements IDisposable {
  128794. /** the original scene that will be rendered on top of */
  128795. originalScene: Scene;
  128796. private _pointerCaptures;
  128797. private _lastPointerEvents;
  128798. private static _DefaultUtilityLayer;
  128799. private static _DefaultKeepDepthUtilityLayer;
  128800. private _sharedGizmoLight;
  128801. private _renderCamera;
  128802. /**
  128803. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  128804. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  128805. * @returns the camera that is used when rendering the utility layer
  128806. */
  128807. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  128808. /**
  128809. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  128810. * @param cam the camera that should be used when rendering the utility layer
  128811. */
  128812. setRenderCamera(cam: Nullable<Camera>): void;
  128813. /**
  128814. * @hidden
  128815. * Light which used by gizmos to get light shading
  128816. */
  128817. _getSharedGizmoLight(): HemisphericLight;
  128818. /**
  128819. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  128820. */
  128821. pickUtilitySceneFirst: boolean;
  128822. /**
  128823. * 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)
  128824. */
  128825. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  128826. /**
  128827. * 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)
  128828. */
  128829. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  128830. /**
  128831. * The scene that is rendered on top of the original scene
  128832. */
  128833. utilityLayerScene: Scene;
  128834. /**
  128835. * If the utility layer should automatically be rendered on top of existing scene
  128836. */
  128837. shouldRender: boolean;
  128838. /**
  128839. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  128840. */
  128841. onlyCheckPointerDownEvents: boolean;
  128842. /**
  128843. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  128844. */
  128845. processAllEvents: boolean;
  128846. /**
  128847. * Observable raised when the pointer move from the utility layer scene to the main scene
  128848. */
  128849. onPointerOutObservable: Observable<number>;
  128850. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  128851. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  128852. private _afterRenderObserver;
  128853. private _sceneDisposeObserver;
  128854. private _originalPointerObserver;
  128855. /**
  128856. * Instantiates a UtilityLayerRenderer
  128857. * @param originalScene the original scene that will be rendered on top of
  128858. * @param handleEvents boolean indicating if the utility layer should handle events
  128859. */
  128860. constructor(
  128861. /** the original scene that will be rendered on top of */
  128862. originalScene: Scene, handleEvents?: boolean);
  128863. private _notifyObservers;
  128864. /**
  128865. * Renders the utility layers scene on top of the original scene
  128866. */
  128867. render(): void;
  128868. /**
  128869. * Disposes of the renderer
  128870. */
  128871. dispose(): void;
  128872. private _updateCamera;
  128873. }
  128874. }
  128875. declare module BABYLON {
  128876. /**
  128877. * Options interface for the pointer selection module
  128878. */
  128879. export interface IWebXRControllerPointerSelectionOptions {
  128880. /**
  128881. * if provided, this scene will be used to render meshes.
  128882. */
  128883. customUtilityLayerScene?: Scene;
  128884. /**
  128885. * 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)
  128886. * If not disabled, the last picked point will be used to execute a pointer up event
  128887. * If disabled, pointer up event will be triggered right after the pointer down event.
  128888. * Used in screen and gaze target ray mode only
  128889. */
  128890. disablePointerUpOnTouchOut: boolean;
  128891. /**
  128892. * For gaze mode for tracked-pointer / controllers (time to select instead of button press)
  128893. */
  128894. forceGazeMode: boolean;
  128895. /**
  128896. * 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
  128897. * to start a new countdown to the pointer down event.
  128898. * Defaults to 1.
  128899. */
  128900. gazeModePointerMovedFactor?: number;
  128901. /**
  128902. * Different button type to use instead of the main component
  128903. */
  128904. overrideButtonId?: string;
  128905. /**
  128906. * use this rendering group id for the meshes (optional)
  128907. */
  128908. renderingGroupId?: number;
  128909. /**
  128910. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  128911. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  128912. * 3000 means 3 seconds between pointing at something and selecting it
  128913. */
  128914. timeToSelect?: number;
  128915. /**
  128916. * Should meshes created here be added to a utility layer or the main scene
  128917. */
  128918. useUtilityLayer?: boolean;
  128919. /**
  128920. * Optional WebXR camera to be used for gaze selection
  128921. */
  128922. gazeCamera?: WebXRCamera;
  128923. /**
  128924. * the xr input to use with this pointer selection
  128925. */
  128926. xrInput: WebXRInput;
  128927. }
  128928. /**
  128929. * A module that will enable pointer selection for motion controllers of XR Input Sources
  128930. */
  128931. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  128932. private readonly _options;
  128933. private static _idCounter;
  128934. private _attachController;
  128935. private _controllers;
  128936. private _scene;
  128937. private _tmpVectorForPickCompare;
  128938. /**
  128939. * The module's name
  128940. */
  128941. static readonly Name: string;
  128942. /**
  128943. * The (Babylon) version of this module.
  128944. * This is an integer representing the implementation version.
  128945. * This number does not correspond to the WebXR specs version
  128946. */
  128947. static readonly Version: number;
  128948. /**
  128949. * Disable lighting on the laser pointer (so it will always be visible)
  128950. */
  128951. disablePointerLighting: boolean;
  128952. /**
  128953. * Disable lighting on the selection mesh (so it will always be visible)
  128954. */
  128955. disableSelectionMeshLighting: boolean;
  128956. /**
  128957. * Should the laser pointer be displayed
  128958. */
  128959. displayLaserPointer: boolean;
  128960. /**
  128961. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  128962. */
  128963. displaySelectionMesh: boolean;
  128964. /**
  128965. * This color will be set to the laser pointer when selection is triggered
  128966. */
  128967. laserPointerPickedColor: Color3;
  128968. /**
  128969. * Default color of the laser pointer
  128970. */
  128971. laserPointerDefaultColor: Color3;
  128972. /**
  128973. * default color of the selection ring
  128974. */
  128975. selectionMeshDefaultColor: Color3;
  128976. /**
  128977. * This color will be applied to the selection ring when selection is triggered
  128978. */
  128979. selectionMeshPickedColor: Color3;
  128980. /**
  128981. * Optional filter to be used for ray selection. This predicate shares behavior with
  128982. * scene.pointerMovePredicate which takes priority if it is also assigned.
  128983. */
  128984. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  128985. /**
  128986. * constructs a new background remover module
  128987. * @param _xrSessionManager the session manager for this module
  128988. * @param _options read-only options to be used in this module
  128989. */
  128990. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  128991. /**
  128992. * attach this feature
  128993. * Will usually be called by the features manager
  128994. *
  128995. * @returns true if successful.
  128996. */
  128997. attach(): boolean;
  128998. /**
  128999. * detach this feature.
  129000. * Will usually be called by the features manager
  129001. *
  129002. * @returns true if successful.
  129003. */
  129004. detach(): boolean;
  129005. /**
  129006. * Will get the mesh under a specific pointer.
  129007. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  129008. * @param controllerId the controllerId to check
  129009. * @returns The mesh under pointer or null if no mesh is under the pointer
  129010. */
  129011. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  129012. /**
  129013. * Get the xr controller that correlates to the pointer id in the pointer event
  129014. *
  129015. * @param id the pointer id to search for
  129016. * @returns the controller that correlates to this id or null if not found
  129017. */
  129018. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  129019. protected _onXRFrame(_xrFrame: XRFrame): void;
  129020. private _attachGazeMode;
  129021. private _attachScreenRayMode;
  129022. private _attachTrackedPointerRayMode;
  129023. private _convertNormalToDirectionOfRay;
  129024. private _detachController;
  129025. private _generateNewMeshPair;
  129026. private _pickingMoved;
  129027. private _updatePointerDistance;
  129028. /** @hidden */
  129029. get lasterPointerDefaultColor(): Color3;
  129030. }
  129031. }
  129032. declare module BABYLON {
  129033. /**
  129034. * Button which can be used to enter a different mode of XR
  129035. */
  129036. export class WebXREnterExitUIButton {
  129037. /** button element */
  129038. element: HTMLElement;
  129039. /** XR initialization options for the button */
  129040. sessionMode: XRSessionMode;
  129041. /** Reference space type */
  129042. referenceSpaceType: XRReferenceSpaceType;
  129043. /**
  129044. * Creates a WebXREnterExitUIButton
  129045. * @param element button element
  129046. * @param sessionMode XR initialization session mode
  129047. * @param referenceSpaceType the type of reference space to be used
  129048. */
  129049. constructor(
  129050. /** button element */
  129051. element: HTMLElement,
  129052. /** XR initialization options for the button */
  129053. sessionMode: XRSessionMode,
  129054. /** Reference space type */
  129055. referenceSpaceType: XRReferenceSpaceType);
  129056. /**
  129057. * Extendable function which can be used to update the button's visuals when the state changes
  129058. * @param activeButton the current active button in the UI
  129059. */
  129060. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  129061. }
  129062. /**
  129063. * Options to create the webXR UI
  129064. */
  129065. export class WebXREnterExitUIOptions {
  129066. /**
  129067. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  129068. */
  129069. customButtons?: Array<WebXREnterExitUIButton>;
  129070. /**
  129071. * A reference space type to use when creating the default button.
  129072. * Default is local-floor
  129073. */
  129074. referenceSpaceType?: XRReferenceSpaceType;
  129075. /**
  129076. * Context to enter xr with
  129077. */
  129078. renderTarget?: Nullable<WebXRRenderTarget>;
  129079. /**
  129080. * A session mode to use when creating the default button.
  129081. * Default is immersive-vr
  129082. */
  129083. sessionMode?: XRSessionMode;
  129084. /**
  129085. * A list of optional features to init the session with
  129086. */
  129087. optionalFeatures?: string[];
  129088. /**
  129089. * A list of optional features to init the session with
  129090. */
  129091. requiredFeatures?: string[];
  129092. }
  129093. /**
  129094. * UI to allow the user to enter/exit XR mode
  129095. */
  129096. export class WebXREnterExitUI implements IDisposable {
  129097. private scene;
  129098. /** version of the options passed to this UI */
  129099. options: WebXREnterExitUIOptions;
  129100. private _activeButton;
  129101. private _buttons;
  129102. /**
  129103. * The HTML Div Element to which buttons are added.
  129104. */
  129105. readonly overlay: HTMLDivElement;
  129106. /**
  129107. * Fired every time the active button is changed.
  129108. *
  129109. * When xr is entered via a button that launches xr that button will be the callback parameter
  129110. *
  129111. * When exiting xr the callback parameter will be null)
  129112. */
  129113. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  129114. /**
  129115. *
  129116. * @param scene babylon scene object to use
  129117. * @param options (read-only) version of the options passed to this UI
  129118. */
  129119. private constructor();
  129120. /**
  129121. * Creates UI to allow the user to enter/exit XR mode
  129122. * @param scene the scene to add the ui to
  129123. * @param helper the xr experience helper to enter/exit xr with
  129124. * @param options options to configure the UI
  129125. * @returns the created ui
  129126. */
  129127. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  129128. /**
  129129. * Disposes of the XR UI component
  129130. */
  129131. dispose(): void;
  129132. private _updateButtons;
  129133. }
  129134. }
  129135. declare module BABYLON {
  129136. /**
  129137. * Class containing static functions to help procedurally build meshes
  129138. */
  129139. export class LinesBuilder {
  129140. /**
  129141. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  129142. * * 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
  129143. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  129144. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  129145. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  129146. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  129147. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  129148. * * 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
  129149. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  129150. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  129151. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  129152. * @param name defines the name of the new line system
  129153. * @param options defines the options used to create the line system
  129154. * @param scene defines the hosting scene
  129155. * @returns a new line system mesh
  129156. */
  129157. static CreateLineSystem(name: string, options: {
  129158. lines: Vector3[][];
  129159. updatable?: boolean;
  129160. instance?: Nullable<LinesMesh>;
  129161. colors?: Nullable<Color4[][]>;
  129162. useVertexAlpha?: boolean;
  129163. }, scene: Nullable<Scene>): LinesMesh;
  129164. /**
  129165. * Creates a line mesh
  129166. * 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
  129167. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  129168. * * The parameter `points` is an array successive Vector3
  129169. * * 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
  129170. * * The optional parameter `colors` is an array of successive Color4, one per line point
  129171. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  129172. * * When updating an instance, remember that only point positions can change, not the number of points
  129173. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  129174. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  129175. * @param name defines the name of the new line system
  129176. * @param options defines the options used to create the line system
  129177. * @param scene defines the hosting scene
  129178. * @returns a new line mesh
  129179. */
  129180. static CreateLines(name: string, options: {
  129181. points: Vector3[];
  129182. updatable?: boolean;
  129183. instance?: Nullable<LinesMesh>;
  129184. colors?: Color4[];
  129185. useVertexAlpha?: boolean;
  129186. }, scene?: Nullable<Scene>): LinesMesh;
  129187. /**
  129188. * Creates a dashed line mesh
  129189. * * 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
  129190. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  129191. * * The parameter `points` is an array successive Vector3
  129192. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  129193. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  129194. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  129195. * * 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
  129196. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  129197. * * When updating an instance, remember that only point positions can change, not the number of points
  129198. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  129199. * @param name defines the name of the mesh
  129200. * @param options defines the options used to create the mesh
  129201. * @param scene defines the hosting scene
  129202. * @returns the dashed line mesh
  129203. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  129204. */
  129205. static CreateDashedLines(name: string, options: {
  129206. points: Vector3[];
  129207. dashSize?: number;
  129208. gapSize?: number;
  129209. dashNb?: number;
  129210. updatable?: boolean;
  129211. instance?: LinesMesh;
  129212. useVertexAlpha?: boolean;
  129213. }, scene?: Nullable<Scene>): LinesMesh;
  129214. }
  129215. }
  129216. declare module BABYLON {
  129217. /**
  129218. * Construction options for a timer
  129219. */
  129220. export interface ITimerOptions<T> {
  129221. /**
  129222. * Time-to-end
  129223. */
  129224. timeout: number;
  129225. /**
  129226. * The context observable is used to calculate time deltas and provides the context of the timer's callbacks. Will usually be OnBeforeRenderObservable.
  129227. * Countdown calculation is done ONLY when the observable is notifying its observers, meaning that if
  129228. * you choose an observable that doesn't trigger too often, the wait time might extend further than the requested max time
  129229. */
  129230. contextObservable: Observable<T>;
  129231. /**
  129232. * Optional parameters when adding an observer to the observable
  129233. */
  129234. observableParameters?: {
  129235. mask?: number;
  129236. insertFirst?: boolean;
  129237. scope?: any;
  129238. };
  129239. /**
  129240. * An optional break condition that will stop the times prematurely. In this case onEnded will not be triggered!
  129241. */
  129242. breakCondition?: (data?: ITimerData<T>) => boolean;
  129243. /**
  129244. * Will be triggered when the time condition has met
  129245. */
  129246. onEnded?: (data: ITimerData<any>) => void;
  129247. /**
  129248. * Will be triggered when the break condition has met (prematurely ended)
  129249. */
  129250. onAborted?: (data: ITimerData<any>) => void;
  129251. /**
  129252. * Optional function to execute on each tick (or count)
  129253. */
  129254. onTick?: (data: ITimerData<any>) => void;
  129255. }
  129256. /**
  129257. * An interface defining the data sent by the timer
  129258. */
  129259. export interface ITimerData<T> {
  129260. /**
  129261. * When did it start
  129262. */
  129263. startTime: number;
  129264. /**
  129265. * Time now
  129266. */
  129267. currentTime: number;
  129268. /**
  129269. * Time passed since started
  129270. */
  129271. deltaTime: number;
  129272. /**
  129273. * How much is completed, in [0.0...1.0].
  129274. * Note that this CAN be higher than 1 due to the fact that we don't actually measure time but delta between observable calls
  129275. */
  129276. completeRate: number;
  129277. /**
  129278. * What the registered observable sent in the last count
  129279. */
  129280. payload: T;
  129281. }
  129282. /**
  129283. * The current state of the timer
  129284. */
  129285. export enum TimerState {
  129286. /**
  129287. * Timer initialized, not yet started
  129288. */
  129289. INIT = 0,
  129290. /**
  129291. * Timer started and counting
  129292. */
  129293. STARTED = 1,
  129294. /**
  129295. * Timer ended (whether aborted or time reached)
  129296. */
  129297. ENDED = 2
  129298. }
  129299. /**
  129300. * A simple version of the timer. Will take options and start the timer immediately after calling it
  129301. *
  129302. * @param options options with which to initialize this timer
  129303. */
  129304. export function setAndStartTimer(options: ITimerOptions<any>): Nullable<Observer<any>>;
  129305. /**
  129306. * An advanced implementation of a timer class
  129307. */
  129308. export class AdvancedTimer<T = any> implements IDisposable {
  129309. /**
  129310. * Will notify each time the timer calculates the remaining time
  129311. */
  129312. onEachCountObservable: Observable<ITimerData<T>>;
  129313. /**
  129314. * Will trigger when the timer was aborted due to the break condition
  129315. */
  129316. onTimerAbortedObservable: Observable<ITimerData<T>>;
  129317. /**
  129318. * Will trigger when the timer ended successfully
  129319. */
  129320. onTimerEndedObservable: Observable<ITimerData<T>>;
  129321. /**
  129322. * Will trigger when the timer state has changed
  129323. */
  129324. onStateChangedObservable: Observable<TimerState>;
  129325. private _observer;
  129326. private _contextObservable;
  129327. private _observableParameters;
  129328. private _startTime;
  129329. private _timer;
  129330. private _state;
  129331. private _breakCondition;
  129332. private _timeToEnd;
  129333. private _breakOnNextTick;
  129334. /**
  129335. * Will construct a new advanced timer based on the options provided. Timer will not start until start() is called.
  129336. * @param options construction options for this advanced timer
  129337. */
  129338. constructor(options: ITimerOptions<T>);
  129339. /**
  129340. * set a breaking condition for this timer. Default is to never break during count
  129341. * @param predicate the new break condition. Returns true to break, false otherwise
  129342. */
  129343. set breakCondition(predicate: (data: ITimerData<T>) => boolean);
  129344. /**
  129345. * Reset ALL associated observables in this advanced timer
  129346. */
  129347. clearObservables(): void;
  129348. /**
  129349. * Will start a new iteration of this timer. Only one instance of this timer can run at a time.
  129350. *
  129351. * @param timeToEnd how much time to measure until timer ended
  129352. */
  129353. start(timeToEnd?: number): void;
  129354. /**
  129355. * Will force a stop on the next tick.
  129356. */
  129357. stop(): void;
  129358. /**
  129359. * Dispose this timer, clearing all resources
  129360. */
  129361. dispose(): void;
  129362. private _setState;
  129363. private _tick;
  129364. private _stop;
  129365. }
  129366. }
  129367. declare module BABYLON {
  129368. /**
  129369. * The options container for the teleportation module
  129370. */
  129371. export interface IWebXRTeleportationOptions {
  129372. /**
  129373. * if provided, this scene will be used to render meshes.
  129374. */
  129375. customUtilityLayerScene?: Scene;
  129376. /**
  129377. * Values to configure the default target mesh
  129378. */
  129379. defaultTargetMeshOptions?: {
  129380. /**
  129381. * Fill color of the teleportation area
  129382. */
  129383. teleportationFillColor?: string;
  129384. /**
  129385. * Border color for the teleportation area
  129386. */
  129387. teleportationBorderColor?: string;
  129388. /**
  129389. * Disable the mesh's animation sequence
  129390. */
  129391. disableAnimation?: boolean;
  129392. /**
  129393. * Disable lighting on the material or the ring and arrow
  129394. */
  129395. disableLighting?: boolean;
  129396. /**
  129397. * Override the default material of the torus and arrow
  129398. */
  129399. torusArrowMaterial?: Material;
  129400. };
  129401. /**
  129402. * A list of meshes to use as floor meshes.
  129403. * Meshes can be added and removed after initializing the feature using the
  129404. * addFloorMesh and removeFloorMesh functions
  129405. * If empty, rotation will still work
  129406. */
  129407. floorMeshes?: AbstractMesh[];
  129408. /**
  129409. * use this rendering group id for the meshes (optional)
  129410. */
  129411. renderingGroupId?: number;
  129412. /**
  129413. * Should teleportation move only to snap points
  129414. */
  129415. snapPointsOnly?: boolean;
  129416. /**
  129417. * An array of points to which the teleportation will snap to.
  129418. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  129419. */
  129420. snapPositions?: Vector3[];
  129421. /**
  129422. * How close should the teleportation ray be in order to snap to position.
  129423. * Default to 0.8 units (meters)
  129424. */
  129425. snapToPositionRadius?: number;
  129426. /**
  129427. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  129428. * If you want to support rotation, make sure your mesh has a direction indicator.
  129429. *
  129430. * When left untouched, the default mesh will be initialized.
  129431. */
  129432. teleportationTargetMesh?: AbstractMesh;
  129433. /**
  129434. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  129435. */
  129436. timeToTeleport?: number;
  129437. /**
  129438. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  129439. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  129440. */
  129441. useMainComponentOnly?: boolean;
  129442. /**
  129443. * Should meshes created here be added to a utility layer or the main scene
  129444. */
  129445. useUtilityLayer?: boolean;
  129446. /**
  129447. * Babylon XR Input class for controller
  129448. */
  129449. xrInput: WebXRInput;
  129450. /**
  129451. * Meshes that the teleportation ray cannot go through
  129452. */
  129453. pickBlockerMeshes?: AbstractMesh[];
  129454. }
  129455. /**
  129456. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  129457. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  129458. * the input of the attached controllers.
  129459. */
  129460. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  129461. private _options;
  129462. private _controllers;
  129463. private _currentTeleportationControllerId;
  129464. private _floorMeshes;
  129465. private _quadraticBezierCurve;
  129466. private _selectionFeature;
  129467. private _snapToPositions;
  129468. private _snappedToPoint;
  129469. private _teleportationRingMaterial?;
  129470. private _tmpRay;
  129471. private _tmpVector;
  129472. private _tmpQuaternion;
  129473. /**
  129474. * The module's name
  129475. */
  129476. static readonly Name: string;
  129477. /**
  129478. * The (Babylon) version of this module.
  129479. * This is an integer representing the implementation version.
  129480. * This number does not correspond to the webxr specs version
  129481. */
  129482. static readonly Version: number;
  129483. /**
  129484. * Is movement backwards enabled
  129485. */
  129486. backwardsMovementEnabled: boolean;
  129487. /**
  129488. * Distance to travel when moving backwards
  129489. */
  129490. backwardsTeleportationDistance: number;
  129491. /**
  129492. * The distance from the user to the inspection point in the direction of the controller
  129493. * A higher number will allow the user to move further
  129494. * defaults to 5 (meters, in xr units)
  129495. */
  129496. parabolicCheckRadius: number;
  129497. /**
  129498. * Should the module support parabolic ray on top of direct ray
  129499. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  129500. * Very helpful when moving between floors / different heights
  129501. */
  129502. parabolicRayEnabled: boolean;
  129503. /**
  129504. * How much rotation should be applied when rotating right and left
  129505. */
  129506. rotationAngle: number;
  129507. /**
  129508. * Is rotation enabled when moving forward?
  129509. * Disabling this feature will prevent the user from deciding the direction when teleporting
  129510. */
  129511. rotationEnabled: boolean;
  129512. /**
  129513. * constructs a new anchor system
  129514. * @param _xrSessionManager an instance of WebXRSessionManager
  129515. * @param _options configuration object for this feature
  129516. */
  129517. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  129518. /**
  129519. * Get the snapPointsOnly flag
  129520. */
  129521. get snapPointsOnly(): boolean;
  129522. /**
  129523. * Sets the snapPointsOnly flag
  129524. * @param snapToPoints should teleportation be exclusively to snap points
  129525. */
  129526. set snapPointsOnly(snapToPoints: boolean);
  129527. /**
  129528. * Add a new mesh to the floor meshes array
  129529. * @param mesh the mesh to use as floor mesh
  129530. */
  129531. addFloorMesh(mesh: AbstractMesh): void;
  129532. /**
  129533. * Add a new snap-to point to fix teleportation to this position
  129534. * @param newSnapPoint The new Snap-To point
  129535. */
  129536. addSnapPoint(newSnapPoint: Vector3): void;
  129537. attach(): boolean;
  129538. detach(): boolean;
  129539. dispose(): void;
  129540. /**
  129541. * Remove a mesh from the floor meshes array
  129542. * @param mesh the mesh to remove
  129543. */
  129544. removeFloorMesh(mesh: AbstractMesh): void;
  129545. /**
  129546. * Remove a mesh from the floor meshes array using its name
  129547. * @param name the mesh name to remove
  129548. */
  129549. removeFloorMeshByName(name: string): void;
  129550. /**
  129551. * 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
  129552. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  129553. * @returns was the point found and removed or not
  129554. */
  129555. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  129556. /**
  129557. * This function sets a selection feature that will be disabled when
  129558. * the forward ray is shown and will be reattached when hidden.
  129559. * This is used to remove the selection rays when moving.
  129560. * @param selectionFeature the feature to disable when forward movement is enabled
  129561. */
  129562. setSelectionFeature(selectionFeature: Nullable<IWebXRFeature>): void;
  129563. protected _onXRFrame(_xrFrame: XRFrame): void;
  129564. private _attachController;
  129565. private _createDefaultTargetMesh;
  129566. private _detachController;
  129567. private _findClosestSnapPointWithRadius;
  129568. private _setTargetMeshPosition;
  129569. private _setTargetMeshVisibility;
  129570. private _showParabolicPath;
  129571. private _teleportForward;
  129572. }
  129573. }
  129574. declare module BABYLON {
  129575. /**
  129576. * Options for the default xr helper
  129577. */
  129578. export class WebXRDefaultExperienceOptions {
  129579. /**
  129580. * Enable or disable default UI to enter XR
  129581. */
  129582. disableDefaultUI?: boolean;
  129583. /**
  129584. * Should teleportation not initialize. defaults to false.
  129585. */
  129586. disableTeleportation?: boolean;
  129587. /**
  129588. * Floor meshes that will be used for teleport
  129589. */
  129590. floorMeshes?: Array<AbstractMesh>;
  129591. /**
  129592. * If set to true, the first frame will not be used to reset position
  129593. * The first frame is mainly used when copying transformation from the old camera
  129594. * Mainly used in AR
  129595. */
  129596. ignoreNativeCameraTransformation?: boolean;
  129597. /**
  129598. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  129599. */
  129600. inputOptions?: IWebXRInputOptions;
  129601. /**
  129602. * optional configuration for the output canvas
  129603. */
  129604. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  129605. /**
  129606. * optional UI options. This can be used among other to change session mode and reference space type
  129607. */
  129608. uiOptions?: WebXREnterExitUIOptions;
  129609. /**
  129610. * When loading teleportation and pointer select, use stable versions instead of latest.
  129611. */
  129612. useStablePlugins?: boolean;
  129613. /**
  129614. * An optional rendering group id that will be set globally for teleportation, pointer selection and default controller meshes
  129615. */
  129616. renderingGroupId?: number;
  129617. /**
  129618. * A list of optional features to init the session with
  129619. * If set to true, all features we support will be added
  129620. */
  129621. optionalFeatures?: boolean | string[];
  129622. }
  129623. /**
  129624. * Default experience which provides a similar setup to the previous webVRExperience
  129625. */
  129626. export class WebXRDefaultExperience {
  129627. /**
  129628. * Base experience
  129629. */
  129630. baseExperience: WebXRExperienceHelper;
  129631. /**
  129632. * Enables ui for entering/exiting xr
  129633. */
  129634. enterExitUI: WebXREnterExitUI;
  129635. /**
  129636. * Input experience extension
  129637. */
  129638. input: WebXRInput;
  129639. /**
  129640. * Enables laser pointer and selection
  129641. */
  129642. pointerSelection: WebXRControllerPointerSelection;
  129643. /**
  129644. * Default target xr should render to
  129645. */
  129646. renderTarget: WebXRRenderTarget;
  129647. /**
  129648. * Enables teleportation
  129649. */
  129650. teleportation: WebXRMotionControllerTeleportation;
  129651. private constructor();
  129652. /**
  129653. * Creates the default xr experience
  129654. * @param scene scene
  129655. * @param options options for basic configuration
  129656. * @returns resulting WebXRDefaultExperience
  129657. */
  129658. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  129659. /**
  129660. * DIsposes of the experience helper
  129661. */
  129662. dispose(): void;
  129663. }
  129664. }
  129665. declare module BABYLON {
  129666. /**
  129667. * Options to modify the vr teleportation behavior.
  129668. */
  129669. export interface VRTeleportationOptions {
  129670. /**
  129671. * The name of the mesh which should be used as the teleportation floor. (default: null)
  129672. */
  129673. floorMeshName?: string;
  129674. /**
  129675. * A list of meshes to be used as the teleportation floor. (default: empty)
  129676. */
  129677. floorMeshes?: Mesh[];
  129678. /**
  129679. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  129680. */
  129681. teleportationMode?: number;
  129682. /**
  129683. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  129684. */
  129685. teleportationTime?: number;
  129686. /**
  129687. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  129688. */
  129689. teleportationSpeed?: number;
  129690. /**
  129691. * The easing function used in the animation or null for Linear. (default CircleEase)
  129692. */
  129693. easingFunction?: EasingFunction;
  129694. }
  129695. /**
  129696. * Options to modify the vr experience helper's behavior.
  129697. */
  129698. export interface VRExperienceHelperOptions extends WebVROptions {
  129699. /**
  129700. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  129701. */
  129702. createDeviceOrientationCamera?: boolean;
  129703. /**
  129704. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  129705. */
  129706. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  129707. /**
  129708. * Uses the main button on the controller to toggle the laser casted. (default: true)
  129709. */
  129710. laserToggle?: boolean;
  129711. /**
  129712. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  129713. */
  129714. floorMeshes?: Mesh[];
  129715. /**
  129716. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  129717. */
  129718. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  129719. /**
  129720. * Defines if WebXR should be used instead of WebVR (if available)
  129721. */
  129722. useXR?: boolean;
  129723. }
  129724. /**
  129725. * Event containing information after VR has been entered
  129726. */
  129727. export class OnAfterEnteringVRObservableEvent {
  129728. /**
  129729. * If entering vr was successful
  129730. */
  129731. success: boolean;
  129732. }
  129733. /**
  129734. * Helps to quickly add VR support to an existing scene.
  129735. * See https://doc.babylonjs.com/how_to/webvr_helper
  129736. */
  129737. export class VRExperienceHelper {
  129738. /** Options to modify the vr experience helper's behavior. */
  129739. webVROptions: VRExperienceHelperOptions;
  129740. private _scene;
  129741. private _position;
  129742. private _btnVR;
  129743. private _btnVRDisplayed;
  129744. private _webVRsupported;
  129745. private _webVRready;
  129746. private _webVRrequesting;
  129747. private _webVRpresenting;
  129748. private _hasEnteredVR;
  129749. private _fullscreenVRpresenting;
  129750. private _inputElement;
  129751. private _webVRCamera;
  129752. private _vrDeviceOrientationCamera;
  129753. private _deviceOrientationCamera;
  129754. private _existingCamera;
  129755. private _onKeyDown;
  129756. private _onVrDisplayPresentChange;
  129757. private _onVRDisplayChanged;
  129758. private _onVRRequestPresentStart;
  129759. private _onVRRequestPresentComplete;
  129760. /**
  129761. * 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)
  129762. */
  129763. enableGazeEvenWhenNoPointerLock: boolean;
  129764. /**
  129765. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  129766. */
  129767. exitVROnDoubleTap: boolean;
  129768. /**
  129769. * Observable raised right before entering VR.
  129770. */
  129771. onEnteringVRObservable: Observable<VRExperienceHelper>;
  129772. /**
  129773. * Observable raised when entering VR has completed.
  129774. */
  129775. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  129776. /**
  129777. * Observable raised when exiting VR.
  129778. */
  129779. onExitingVRObservable: Observable<VRExperienceHelper>;
  129780. /**
  129781. * Observable raised when controller mesh is loaded.
  129782. */
  129783. onControllerMeshLoadedObservable: Observable<WebVRController>;
  129784. /** Return this.onEnteringVRObservable
  129785. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  129786. */
  129787. get onEnteringVR(): Observable<VRExperienceHelper>;
  129788. /** Return this.onExitingVRObservable
  129789. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  129790. */
  129791. get onExitingVR(): Observable<VRExperienceHelper>;
  129792. /** Return this.onControllerMeshLoadedObservable
  129793. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  129794. */
  129795. get onControllerMeshLoaded(): Observable<WebVRController>;
  129796. private _rayLength;
  129797. private _useCustomVRButton;
  129798. private _teleportationRequested;
  129799. private _teleportActive;
  129800. private _floorMeshName;
  129801. private _floorMeshesCollection;
  129802. private _teleportationMode;
  129803. private _teleportationTime;
  129804. private _teleportationSpeed;
  129805. private _teleportationEasing;
  129806. private _rotationAllowed;
  129807. private _teleportBackwardsVector;
  129808. private _teleportationTarget;
  129809. private _isDefaultTeleportationTarget;
  129810. private _postProcessMove;
  129811. private _teleportationFillColor;
  129812. private _teleportationBorderColor;
  129813. private _rotationAngle;
  129814. private _haloCenter;
  129815. private _cameraGazer;
  129816. private _padSensibilityUp;
  129817. private _padSensibilityDown;
  129818. private _leftController;
  129819. private _rightController;
  129820. private _gazeColor;
  129821. private _laserColor;
  129822. private _pickedLaserColor;
  129823. private _pickedGazeColor;
  129824. /**
  129825. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  129826. */
  129827. onNewMeshSelected: Observable<AbstractMesh>;
  129828. /**
  129829. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  129830. * This observable will provide the mesh and the controller used to select the mesh
  129831. */
  129832. onMeshSelectedWithController: Observable<{
  129833. mesh: AbstractMesh;
  129834. controller: WebVRController;
  129835. }>;
  129836. /**
  129837. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  129838. */
  129839. onNewMeshPicked: Observable<PickingInfo>;
  129840. private _circleEase;
  129841. /**
  129842. * Observable raised before camera teleportation
  129843. */
  129844. onBeforeCameraTeleport: Observable<Vector3>;
  129845. /**
  129846. * Observable raised after camera teleportation
  129847. */
  129848. onAfterCameraTeleport: Observable<Vector3>;
  129849. /**
  129850. * Observable raised when current selected mesh gets unselected
  129851. */
  129852. onSelectedMeshUnselected: Observable<AbstractMesh>;
  129853. private _raySelectionPredicate;
  129854. /**
  129855. * To be optionaly changed by user to define custom ray selection
  129856. */
  129857. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  129858. /**
  129859. * To be optionaly changed by user to define custom selection logic (after ray selection)
  129860. */
  129861. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  129862. /**
  129863. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  129864. */
  129865. teleportationEnabled: boolean;
  129866. private _defaultHeight;
  129867. private _teleportationInitialized;
  129868. private _interactionsEnabled;
  129869. private _interactionsRequested;
  129870. private _displayGaze;
  129871. private _displayLaserPointer;
  129872. /**
  129873. * The mesh used to display where the user is going to teleport.
  129874. */
  129875. get teleportationTarget(): Mesh;
  129876. /**
  129877. * Sets the mesh to be used to display where the user is going to teleport.
  129878. */
  129879. set teleportationTarget(value: Mesh);
  129880. /**
  129881. * 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
  129882. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  129883. * See https://doc.babylonjs.com/resources/baking_transformations
  129884. */
  129885. get gazeTrackerMesh(): Mesh;
  129886. set gazeTrackerMesh(value: Mesh);
  129887. /**
  129888. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  129889. */
  129890. updateGazeTrackerScale: boolean;
  129891. /**
  129892. * If the gaze trackers color should be updated when selecting meshes
  129893. */
  129894. updateGazeTrackerColor: boolean;
  129895. /**
  129896. * If the controller laser color should be updated when selecting meshes
  129897. */
  129898. updateControllerLaserColor: boolean;
  129899. /**
  129900. * The gaze tracking mesh corresponding to the left controller
  129901. */
  129902. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  129903. /**
  129904. * The gaze tracking mesh corresponding to the right controller
  129905. */
  129906. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  129907. /**
  129908. * If the ray of the gaze should be displayed.
  129909. */
  129910. get displayGaze(): boolean;
  129911. /**
  129912. * Sets if the ray of the gaze should be displayed.
  129913. */
  129914. set displayGaze(value: boolean);
  129915. /**
  129916. * If the ray of the LaserPointer should be displayed.
  129917. */
  129918. get displayLaserPointer(): boolean;
  129919. /**
  129920. * Sets if the ray of the LaserPointer should be displayed.
  129921. */
  129922. set displayLaserPointer(value: boolean);
  129923. /**
  129924. * The deviceOrientationCamera used as the camera when not in VR.
  129925. */
  129926. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  129927. /**
  129928. * Based on the current WebVR support, returns the current VR camera used.
  129929. */
  129930. get currentVRCamera(): Nullable<Camera>;
  129931. /**
  129932. * The webVRCamera which is used when in VR.
  129933. */
  129934. get webVRCamera(): WebVRFreeCamera;
  129935. /**
  129936. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  129937. */
  129938. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  129939. /**
  129940. * The html button that is used to trigger entering into VR.
  129941. */
  129942. get vrButton(): Nullable<HTMLButtonElement>;
  129943. private get _teleportationRequestInitiated();
  129944. /**
  129945. * Defines whether or not Pointer lock should be requested when switching to
  129946. * full screen.
  129947. */
  129948. requestPointerLockOnFullScreen: boolean;
  129949. /**
  129950. * If asking to force XR, this will be populated with the default xr experience
  129951. */
  129952. xr: WebXRDefaultExperience;
  129953. /**
  129954. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  129955. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  129956. */
  129957. xrTestDone: boolean;
  129958. /**
  129959. * Instantiates a VRExperienceHelper.
  129960. * Helps to quickly add VR support to an existing scene.
  129961. * @param scene The scene the VRExperienceHelper belongs to.
  129962. * @param webVROptions Options to modify the vr experience helper's behavior.
  129963. */
  129964. constructor(scene: Scene,
  129965. /** Options to modify the vr experience helper's behavior. */
  129966. webVROptions?: VRExperienceHelperOptions);
  129967. private completeVRInit;
  129968. private _onDefaultMeshLoaded;
  129969. private _onResize;
  129970. private _onFullscreenChange;
  129971. /**
  129972. * Gets a value indicating if we are currently in VR mode.
  129973. */
  129974. get isInVRMode(): boolean;
  129975. private onVrDisplayPresentChange;
  129976. private onVRDisplayChanged;
  129977. private moveButtonToBottomRight;
  129978. private displayVRButton;
  129979. private updateButtonVisibility;
  129980. private _cachedAngularSensibility;
  129981. /**
  129982. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  129983. * Otherwise, will use the fullscreen API.
  129984. */
  129985. enterVR(): void;
  129986. /**
  129987. * Attempt to exit VR, or fullscreen.
  129988. */
  129989. exitVR(): void;
  129990. /**
  129991. * The position of the vr experience helper.
  129992. */
  129993. get position(): Vector3;
  129994. /**
  129995. * Sets the position of the vr experience helper.
  129996. */
  129997. set position(value: Vector3);
  129998. /**
  129999. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  130000. */
  130001. enableInteractions(): void;
  130002. private get _noControllerIsActive();
  130003. private beforeRender;
  130004. private _isTeleportationFloor;
  130005. /**
  130006. * Adds a floor mesh to be used for teleportation.
  130007. * @param floorMesh the mesh to be used for teleportation.
  130008. */
  130009. addFloorMesh(floorMesh: Mesh): void;
  130010. /**
  130011. * Removes a floor mesh from being used for teleportation.
  130012. * @param floorMesh the mesh to be removed.
  130013. */
  130014. removeFloorMesh(floorMesh: Mesh): void;
  130015. /**
  130016. * Enables interactions and teleportation using the VR controllers and gaze.
  130017. * @param vrTeleportationOptions options to modify teleportation behavior.
  130018. */
  130019. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  130020. private _onNewGamepadConnected;
  130021. private _tryEnableInteractionOnController;
  130022. private _onNewGamepadDisconnected;
  130023. private _enableInteractionOnController;
  130024. private _checkTeleportWithRay;
  130025. private _checkRotate;
  130026. private _checkTeleportBackwards;
  130027. private _enableTeleportationOnController;
  130028. private _createTeleportationCircles;
  130029. private _displayTeleportationTarget;
  130030. private _hideTeleportationTarget;
  130031. private _rotateCamera;
  130032. private _moveTeleportationSelectorTo;
  130033. private _workingVector;
  130034. private _workingQuaternion;
  130035. private _workingMatrix;
  130036. /**
  130037. * Time Constant Teleportation Mode
  130038. */
  130039. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  130040. /**
  130041. * Speed Constant Teleportation Mode
  130042. */
  130043. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  130044. /**
  130045. * Teleports the users feet to the desired location
  130046. * @param location The location where the user's feet should be placed
  130047. */
  130048. teleportCamera(location: Vector3): void;
  130049. private _convertNormalToDirectionOfRay;
  130050. private _castRayAndSelectObject;
  130051. private _notifySelectedMeshUnselected;
  130052. /**
  130053. * Permanently set new colors for the laser pointer
  130054. * @param color the new laser color
  130055. * @param pickedColor the new laser color when picked mesh detected
  130056. */
  130057. setLaserColor(color: Color3, pickedColor?: Color3): void;
  130058. /**
  130059. * Set lighting enabled / disabled on the laser pointer of both controllers
  130060. * @param enabled should the lighting be enabled on the laser pointer
  130061. */
  130062. setLaserLightingState(enabled?: boolean): void;
  130063. /**
  130064. * Permanently set new colors for the gaze pointer
  130065. * @param color the new gaze color
  130066. * @param pickedColor the new gaze color when picked mesh detected
  130067. */
  130068. setGazeColor(color: Color3, pickedColor?: Color3): void;
  130069. /**
  130070. * Sets the color of the laser ray from the vr controllers.
  130071. * @param color new color for the ray.
  130072. */
  130073. changeLaserColor(color: Color3): void;
  130074. /**
  130075. * Sets the color of the ray from the vr headsets gaze.
  130076. * @param color new color for the ray.
  130077. */
  130078. changeGazeColor(color: Color3): void;
  130079. /**
  130080. * Exits VR and disposes of the vr experience helper
  130081. */
  130082. dispose(): void;
  130083. /**
  130084. * Gets the name of the VRExperienceHelper class
  130085. * @returns "VRExperienceHelper"
  130086. */
  130087. getClassName(): string;
  130088. }
  130089. }
  130090. declare module BABYLON {
  130091. /**
  130092. * Contains an array of blocks representing the octree
  130093. */
  130094. export interface IOctreeContainer<T> {
  130095. /**
  130096. * Blocks within the octree
  130097. */
  130098. blocks: Array<OctreeBlock<T>>;
  130099. }
  130100. /**
  130101. * Class used to store a cell in an octree
  130102. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  130103. */
  130104. export class OctreeBlock<T> {
  130105. /**
  130106. * Gets the content of the current block
  130107. */
  130108. entries: T[];
  130109. /**
  130110. * Gets the list of block children
  130111. */
  130112. blocks: Array<OctreeBlock<T>>;
  130113. private _depth;
  130114. private _maxDepth;
  130115. private _capacity;
  130116. private _minPoint;
  130117. private _maxPoint;
  130118. private _boundingVectors;
  130119. private _creationFunc;
  130120. /**
  130121. * Creates a new block
  130122. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  130123. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  130124. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  130125. * @param depth defines the current depth of this block in the octree
  130126. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  130127. * @param creationFunc defines a callback to call when an element is added to the block
  130128. */
  130129. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  130130. /**
  130131. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  130132. */
  130133. get capacity(): number;
  130134. /**
  130135. * Gets the minimum vector (in world space) of the block's bounding box
  130136. */
  130137. get minPoint(): Vector3;
  130138. /**
  130139. * Gets the maximum vector (in world space) of the block's bounding box
  130140. */
  130141. get maxPoint(): Vector3;
  130142. /**
  130143. * Add a new element to this block
  130144. * @param entry defines the element to add
  130145. */
  130146. addEntry(entry: T): void;
  130147. /**
  130148. * Remove an element from this block
  130149. * @param entry defines the element to remove
  130150. */
  130151. removeEntry(entry: T): void;
  130152. /**
  130153. * Add an array of elements to this block
  130154. * @param entries defines the array of elements to add
  130155. */
  130156. addEntries(entries: T[]): void;
  130157. /**
  130158. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  130159. * @param frustumPlanes defines the frustum planes to test
  130160. * @param selection defines the array to store current content if selection is positive
  130161. * @param allowDuplicate defines if the selection array can contains duplicated entries
  130162. */
  130163. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  130164. /**
  130165. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  130166. * @param sphereCenter defines the bounding sphere center
  130167. * @param sphereRadius defines the bounding sphere radius
  130168. * @param selection defines the array to store current content if selection is positive
  130169. * @param allowDuplicate defines if the selection array can contains duplicated entries
  130170. */
  130171. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  130172. /**
  130173. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  130174. * @param ray defines the ray to test with
  130175. * @param selection defines the array to store current content if selection is positive
  130176. */
  130177. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  130178. /**
  130179. * Subdivide the content into child blocks (this block will then be empty)
  130180. */
  130181. createInnerBlocks(): void;
  130182. /**
  130183. * @hidden
  130184. */
  130185. 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;
  130186. }
  130187. }
  130188. declare module BABYLON {
  130189. /**
  130190. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  130191. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  130192. */
  130193. export class Octree<T> {
  130194. /** 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.) */
  130195. maxDepth: number;
  130196. /**
  130197. * Blocks within the octree containing objects
  130198. */
  130199. blocks: Array<OctreeBlock<T>>;
  130200. /**
  130201. * Content stored in the octree
  130202. */
  130203. dynamicContent: T[];
  130204. private _maxBlockCapacity;
  130205. private _selectionContent;
  130206. private _creationFunc;
  130207. /**
  130208. * Creates a octree
  130209. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  130210. * @param creationFunc function to be used to instatiate the octree
  130211. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  130212. * @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.)
  130213. */
  130214. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  130215. /** 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.) */
  130216. maxDepth?: number);
  130217. /**
  130218. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  130219. * @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);
  130220. * @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);
  130221. * @param entries meshes to be added to the octree blocks
  130222. */
  130223. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  130224. /**
  130225. * Adds a mesh to the octree
  130226. * @param entry Mesh to add to the octree
  130227. */
  130228. addMesh(entry: T): void;
  130229. /**
  130230. * Remove an element from the octree
  130231. * @param entry defines the element to remove
  130232. */
  130233. removeMesh(entry: T): void;
  130234. /**
  130235. * Selects an array of meshes within the frustum
  130236. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  130237. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  130238. * @returns array of meshes within the frustum
  130239. */
  130240. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  130241. /**
  130242. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  130243. * @param sphereCenter defines the bounding sphere center
  130244. * @param sphereRadius defines the bounding sphere radius
  130245. * @param allowDuplicate defines if the selection array can contains duplicated entries
  130246. * @returns an array of objects that intersect the sphere
  130247. */
  130248. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  130249. /**
  130250. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  130251. * @param ray defines the ray to test with
  130252. * @returns array of intersected objects
  130253. */
  130254. intersectsRay(ray: Ray): SmartArray<T>;
  130255. /**
  130256. * Adds a mesh into the octree block if it intersects the block
  130257. */
  130258. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  130259. /**
  130260. * Adds a submesh into the octree block if it intersects the block
  130261. */
  130262. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  130263. }
  130264. }
  130265. declare module BABYLON {
  130266. interface Scene {
  130267. /**
  130268. * @hidden
  130269. * Backing Filed
  130270. */
  130271. _selectionOctree: Octree<AbstractMesh>;
  130272. /**
  130273. * Gets the octree used to boost mesh selection (picking)
  130274. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  130275. */
  130276. selectionOctree: Octree<AbstractMesh>;
  130277. /**
  130278. * Creates or updates the octree used to boost selection (picking)
  130279. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  130280. * @param maxCapacity defines the maximum capacity per leaf
  130281. * @param maxDepth defines the maximum depth of the octree
  130282. * @returns an octree of AbstractMesh
  130283. */
  130284. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  130285. }
  130286. interface AbstractMesh {
  130287. /**
  130288. * @hidden
  130289. * Backing Field
  130290. */
  130291. _submeshesOctree: Octree<SubMesh>;
  130292. /**
  130293. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  130294. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  130295. * @param maxCapacity defines the maximum size of each block (64 by default)
  130296. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  130297. * @returns the new octree
  130298. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  130299. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  130300. */
  130301. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  130302. }
  130303. /**
  130304. * Defines the octree scene component responsible to manage any octrees
  130305. * in a given scene.
  130306. */
  130307. export class OctreeSceneComponent {
  130308. /**
  130309. * The component name help to identify the component in the list of scene components.
  130310. */
  130311. readonly name: string;
  130312. /**
  130313. * The scene the component belongs to.
  130314. */
  130315. scene: Scene;
  130316. /**
  130317. * Indicates if the meshes have been checked to make sure they are isEnabled()
  130318. */
  130319. readonly checksIsEnabled: boolean;
  130320. /**
  130321. * Creates a new instance of the component for the given scene
  130322. * @param scene Defines the scene to register the component in
  130323. */
  130324. constructor(scene: Scene);
  130325. /**
  130326. * Registers the component in a given scene
  130327. */
  130328. register(): void;
  130329. /**
  130330. * Return the list of active meshes
  130331. * @returns the list of active meshes
  130332. */
  130333. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  130334. /**
  130335. * Return the list of active sub meshes
  130336. * @param mesh The mesh to get the candidates sub meshes from
  130337. * @returns the list of active sub meshes
  130338. */
  130339. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  130340. private _tempRay;
  130341. /**
  130342. * Return the list of sub meshes intersecting with a given local ray
  130343. * @param mesh defines the mesh to find the submesh for
  130344. * @param localRay defines the ray in local space
  130345. * @returns the list of intersecting sub meshes
  130346. */
  130347. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  130348. /**
  130349. * Return the list of sub meshes colliding with a collider
  130350. * @param mesh defines the mesh to find the submesh for
  130351. * @param collider defines the collider to evaluate the collision against
  130352. * @returns the list of colliding sub meshes
  130353. */
  130354. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  130355. /**
  130356. * Rebuilds the elements related to this component in case of
  130357. * context lost for instance.
  130358. */
  130359. rebuild(): void;
  130360. /**
  130361. * Disposes the component and the associated ressources.
  130362. */
  130363. dispose(): void;
  130364. }
  130365. }
  130366. declare module BABYLON {
  130367. /**
  130368. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  130369. */
  130370. export class Gizmo implements IDisposable {
  130371. /** The utility layer the gizmo will be added to */
  130372. gizmoLayer: UtilityLayerRenderer;
  130373. /**
  130374. * The root mesh of the gizmo
  130375. */
  130376. _rootMesh: Mesh;
  130377. private _attachedMesh;
  130378. private _attachedNode;
  130379. /**
  130380. * Ratio for the scale of the gizmo (Default: 1)
  130381. */
  130382. protected _scaleRatio: number;
  130383. /**
  130384. * Ratio for the scale of the gizmo (Default: 1)
  130385. */
  130386. set scaleRatio(value: number);
  130387. get scaleRatio(): number;
  130388. /**
  130389. * If a custom mesh has been set (Default: false)
  130390. */
  130391. protected _customMeshSet: boolean;
  130392. /**
  130393. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  130394. * * When set, interactions will be enabled
  130395. */
  130396. get attachedMesh(): Nullable<AbstractMesh>;
  130397. set attachedMesh(value: Nullable<AbstractMesh>);
  130398. /**
  130399. * Node that the gizmo will be attached to. (eg. on a drag gizmo the mesh, bone or NodeTransform that will be dragged)
  130400. * * When set, interactions will be enabled
  130401. */
  130402. get attachedNode(): Nullable<Node>;
  130403. set attachedNode(value: Nullable<Node>);
  130404. /**
  130405. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  130406. * @param mesh The mesh to replace the default mesh of the gizmo
  130407. */
  130408. setCustomMesh(mesh: Mesh): void;
  130409. protected _updateGizmoRotationToMatchAttachedMesh: boolean;
  130410. /**
  130411. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  130412. */
  130413. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  130414. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  130415. /**
  130416. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  130417. */
  130418. updateGizmoPositionToMatchAttachedMesh: boolean;
  130419. /**
  130420. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  130421. */
  130422. updateScale: boolean;
  130423. protected _interactionsEnabled: boolean;
  130424. protected _attachedNodeChanged(value: Nullable<Node>): void;
  130425. private _beforeRenderObserver;
  130426. private _tempQuaternion;
  130427. private _tempVector;
  130428. private _tempVector2;
  130429. private _tempMatrix1;
  130430. private _tempMatrix2;
  130431. private _rightHandtoLeftHandMatrix;
  130432. /**
  130433. * Creates a gizmo
  130434. * @param gizmoLayer The utility layer the gizmo will be added to
  130435. */
  130436. constructor(
  130437. /** The utility layer the gizmo will be added to */
  130438. gizmoLayer?: UtilityLayerRenderer);
  130439. /**
  130440. * Updates the gizmo to match the attached mesh's position/rotation
  130441. */
  130442. protected _update(): void;
  130443. /**
  130444. * computes the rotation/scaling/position of the transform once the Node world matrix has changed.
  130445. * @param value Node, TransformNode or mesh
  130446. */
  130447. protected _matrixChanged(): void;
  130448. /**
  130449. * Disposes of the gizmo
  130450. */
  130451. dispose(): void;
  130452. }
  130453. }
  130454. declare module BABYLON {
  130455. /**
  130456. * Single plane drag gizmo
  130457. */
  130458. export class PlaneDragGizmo extends Gizmo {
  130459. /**
  130460. * Drag behavior responsible for the gizmos dragging interactions
  130461. */
  130462. dragBehavior: PointerDragBehavior;
  130463. private _pointerObserver;
  130464. /**
  130465. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  130466. */
  130467. snapDistance: number;
  130468. /**
  130469. * Event that fires each time the gizmo snaps to a new location.
  130470. * * snapDistance is the the change in distance
  130471. */
  130472. onSnapObservable: Observable<{
  130473. snapDistance: number;
  130474. }>;
  130475. private _plane;
  130476. private _coloredMaterial;
  130477. private _hoverMaterial;
  130478. private _isEnabled;
  130479. private _parent;
  130480. /** @hidden */
  130481. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  130482. /** @hidden */
  130483. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  130484. /**
  130485. * Creates a PlaneDragGizmo
  130486. * @param gizmoLayer The utility layer the gizmo will be added to
  130487. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  130488. * @param color The color of the gizmo
  130489. */
  130490. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  130491. protected _attachedNodeChanged(value: Nullable<Node>): void;
  130492. /**
  130493. * If the gizmo is enabled
  130494. */
  130495. set isEnabled(value: boolean);
  130496. get isEnabled(): boolean;
  130497. /**
  130498. * Disposes of the gizmo
  130499. */
  130500. dispose(): void;
  130501. }
  130502. }
  130503. declare module BABYLON {
  130504. /**
  130505. * Gizmo that enables dragging a mesh along 3 axis
  130506. */
  130507. export class PositionGizmo extends Gizmo {
  130508. /**
  130509. * Internal gizmo used for interactions on the x axis
  130510. */
  130511. xGizmo: AxisDragGizmo;
  130512. /**
  130513. * Internal gizmo used for interactions on the y axis
  130514. */
  130515. yGizmo: AxisDragGizmo;
  130516. /**
  130517. * Internal gizmo used for interactions on the z axis
  130518. */
  130519. zGizmo: AxisDragGizmo;
  130520. /**
  130521. * Internal gizmo used for interactions on the yz plane
  130522. */
  130523. xPlaneGizmo: PlaneDragGizmo;
  130524. /**
  130525. * Internal gizmo used for interactions on the xz plane
  130526. */
  130527. yPlaneGizmo: PlaneDragGizmo;
  130528. /**
  130529. * Internal gizmo used for interactions on the xy plane
  130530. */
  130531. zPlaneGizmo: PlaneDragGizmo;
  130532. /**
  130533. * private variables
  130534. */
  130535. private _meshAttached;
  130536. private _nodeAttached;
  130537. private _snapDistance;
  130538. /** Fires an event when any of it's sub gizmos are dragged */
  130539. onDragStartObservable: Observable<unknown>;
  130540. /** Fires an event when any of it's sub gizmos are released from dragging */
  130541. onDragEndObservable: Observable<unknown>;
  130542. /**
  130543. * If set to true, planar drag is enabled
  130544. */
  130545. private _planarGizmoEnabled;
  130546. get attachedMesh(): Nullable<AbstractMesh>;
  130547. set attachedMesh(mesh: Nullable<AbstractMesh>);
  130548. get attachedNode(): Nullable<Node>;
  130549. set attachedNode(node: Nullable<Node>);
  130550. /**
  130551. * Creates a PositionGizmo
  130552. * @param gizmoLayer The utility layer the gizmo will be added to
  130553. @param thickness display gizmo axis thickness
  130554. */
  130555. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number);
  130556. /**
  130557. * If the planar drag gizmo is enabled
  130558. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  130559. */
  130560. set planarGizmoEnabled(value: boolean);
  130561. get planarGizmoEnabled(): boolean;
  130562. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  130563. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  130564. /**
  130565. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  130566. */
  130567. set snapDistance(value: number);
  130568. get snapDistance(): number;
  130569. /**
  130570. * Ratio for the scale of the gizmo (Default: 1)
  130571. */
  130572. set scaleRatio(value: number);
  130573. get scaleRatio(): number;
  130574. /**
  130575. * Disposes of the gizmo
  130576. */
  130577. dispose(): void;
  130578. /**
  130579. * CustomMeshes are not supported by this gizmo
  130580. * @param mesh The mesh to replace the default mesh of the gizmo
  130581. */
  130582. setCustomMesh(mesh: Mesh): void;
  130583. }
  130584. }
  130585. declare module BABYLON {
  130586. /**
  130587. * Single axis drag gizmo
  130588. */
  130589. export class AxisDragGizmo extends Gizmo {
  130590. /**
  130591. * Drag behavior responsible for the gizmos dragging interactions
  130592. */
  130593. dragBehavior: PointerDragBehavior;
  130594. private _pointerObserver;
  130595. /**
  130596. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  130597. */
  130598. snapDistance: number;
  130599. /**
  130600. * Event that fires each time the gizmo snaps to a new location.
  130601. * * snapDistance is the the change in distance
  130602. */
  130603. onSnapObservable: Observable<{
  130604. snapDistance: number;
  130605. }>;
  130606. private _isEnabled;
  130607. private _parent;
  130608. private _arrow;
  130609. private _coloredMaterial;
  130610. private _hoverMaterial;
  130611. /** @hidden */
  130612. static _CreateArrow(scene: Scene, material: StandardMaterial, thickness?: number): TransformNode;
  130613. /** @hidden */
  130614. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  130615. /**
  130616. * Creates an AxisDragGizmo
  130617. * @param gizmoLayer The utility layer the gizmo will be added to
  130618. * @param dragAxis The axis which the gizmo will be able to drag on
  130619. * @param color The color of the gizmo
  130620. * @param thickness display gizmo axis thickness
  130621. */
  130622. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>, thickness?: number);
  130623. protected _attachedNodeChanged(value: Nullable<Node>): void;
  130624. /**
  130625. * If the gizmo is enabled
  130626. */
  130627. set isEnabled(value: boolean);
  130628. get isEnabled(): boolean;
  130629. /**
  130630. * Disposes of the gizmo
  130631. */
  130632. dispose(): void;
  130633. }
  130634. }
  130635. declare module BABYLON.Debug {
  130636. /**
  130637. * The Axes viewer will show 3 axes in a specific point in space
  130638. */
  130639. export class AxesViewer {
  130640. private _xAxis;
  130641. private _yAxis;
  130642. private _zAxis;
  130643. private _scaleLinesFactor;
  130644. private _instanced;
  130645. /**
  130646. * Gets the hosting scene
  130647. */
  130648. scene: Nullable<Scene>;
  130649. /**
  130650. * Gets or sets a number used to scale line length
  130651. */
  130652. scaleLines: number;
  130653. /** Gets the node hierarchy used to render x-axis */
  130654. get xAxis(): TransformNode;
  130655. /** Gets the node hierarchy used to render y-axis */
  130656. get yAxis(): TransformNode;
  130657. /** Gets the node hierarchy used to render z-axis */
  130658. get zAxis(): TransformNode;
  130659. /**
  130660. * Creates a new AxesViewer
  130661. * @param scene defines the hosting scene
  130662. * @param scaleLines defines a number used to scale line length (1 by default)
  130663. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  130664. * @param xAxis defines the node hierarchy used to render the x-axis
  130665. * @param yAxis defines the node hierarchy used to render the y-axis
  130666. * @param zAxis defines the node hierarchy used to render the z-axis
  130667. */
  130668. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  130669. /**
  130670. * Force the viewer to update
  130671. * @param position defines the position of the viewer
  130672. * @param xaxis defines the x axis of the viewer
  130673. * @param yaxis defines the y axis of the viewer
  130674. * @param zaxis defines the z axis of the viewer
  130675. */
  130676. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  130677. /**
  130678. * Creates an instance of this axes viewer.
  130679. * @returns a new axes viewer with instanced meshes
  130680. */
  130681. createInstance(): AxesViewer;
  130682. /** Releases resources */
  130683. dispose(): void;
  130684. private static _SetRenderingGroupId;
  130685. }
  130686. }
  130687. declare module BABYLON.Debug {
  130688. /**
  130689. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  130690. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  130691. */
  130692. export class BoneAxesViewer extends AxesViewer {
  130693. /**
  130694. * Gets or sets the target mesh where to display the axes viewer
  130695. */
  130696. mesh: Nullable<Mesh>;
  130697. /**
  130698. * Gets or sets the target bone where to display the axes viewer
  130699. */
  130700. bone: Nullable<Bone>;
  130701. /** Gets current position */
  130702. pos: Vector3;
  130703. /** Gets direction of X axis */
  130704. xaxis: Vector3;
  130705. /** Gets direction of Y axis */
  130706. yaxis: Vector3;
  130707. /** Gets direction of Z axis */
  130708. zaxis: Vector3;
  130709. /**
  130710. * Creates a new BoneAxesViewer
  130711. * @param scene defines the hosting scene
  130712. * @param bone defines the target bone
  130713. * @param mesh defines the target mesh
  130714. * @param scaleLines defines a scaling factor for line length (1 by default)
  130715. */
  130716. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  130717. /**
  130718. * Force the viewer to update
  130719. */
  130720. update(): void;
  130721. /** Releases resources */
  130722. dispose(): void;
  130723. }
  130724. }
  130725. declare module BABYLON {
  130726. /**
  130727. * Interface used to define scene explorer extensibility option
  130728. */
  130729. export interface IExplorerExtensibilityOption {
  130730. /**
  130731. * Define the option label
  130732. */
  130733. label: string;
  130734. /**
  130735. * Defines the action to execute on click
  130736. */
  130737. action: (entity: any) => void;
  130738. }
  130739. /**
  130740. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  130741. */
  130742. export interface IExplorerExtensibilityGroup {
  130743. /**
  130744. * Defines a predicate to test if a given type mut be extended
  130745. */
  130746. predicate: (entity: any) => boolean;
  130747. /**
  130748. * Gets the list of options added to a type
  130749. */
  130750. entries: IExplorerExtensibilityOption[];
  130751. }
  130752. /**
  130753. * Interface used to define the options to use to create the Inspector
  130754. */
  130755. export interface IInspectorOptions {
  130756. /**
  130757. * Display in overlay mode (default: false)
  130758. */
  130759. overlay?: boolean;
  130760. /**
  130761. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  130762. */
  130763. globalRoot?: HTMLElement;
  130764. /**
  130765. * Display the Scene explorer
  130766. */
  130767. showExplorer?: boolean;
  130768. /**
  130769. * Display the property inspector
  130770. */
  130771. showInspector?: boolean;
  130772. /**
  130773. * Display in embed mode (both panes on the right)
  130774. */
  130775. embedMode?: boolean;
  130776. /**
  130777. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  130778. */
  130779. handleResize?: boolean;
  130780. /**
  130781. * Allow the panes to popup (default: true)
  130782. */
  130783. enablePopup?: boolean;
  130784. /**
  130785. * Allow the panes to be closed by users (default: true)
  130786. */
  130787. enableClose?: boolean;
  130788. /**
  130789. * Optional list of extensibility entries
  130790. */
  130791. explorerExtensibility?: IExplorerExtensibilityGroup[];
  130792. /**
  130793. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  130794. */
  130795. inspectorURL?: string;
  130796. /**
  130797. * Optional initial tab (default to DebugLayerTab.Properties)
  130798. */
  130799. initialTab?: DebugLayerTab;
  130800. }
  130801. interface Scene {
  130802. /**
  130803. * @hidden
  130804. * Backing field
  130805. */
  130806. _debugLayer: DebugLayer;
  130807. /**
  130808. * Gets the debug layer (aka Inspector) associated with the scene
  130809. * @see https://doc.babylonjs.com/features/playground_debuglayer
  130810. */
  130811. debugLayer: DebugLayer;
  130812. }
  130813. /**
  130814. * Enum of inspector action tab
  130815. */
  130816. export enum DebugLayerTab {
  130817. /**
  130818. * Properties tag (default)
  130819. */
  130820. Properties = 0,
  130821. /**
  130822. * Debug tab
  130823. */
  130824. Debug = 1,
  130825. /**
  130826. * Statistics tab
  130827. */
  130828. Statistics = 2,
  130829. /**
  130830. * Tools tab
  130831. */
  130832. Tools = 3,
  130833. /**
  130834. * Settings tab
  130835. */
  130836. Settings = 4
  130837. }
  130838. /**
  130839. * The debug layer (aka Inspector) is the go to tool in order to better understand
  130840. * what is happening in your scene
  130841. * @see https://doc.babylonjs.com/features/playground_debuglayer
  130842. */
  130843. export class DebugLayer {
  130844. /**
  130845. * Define the url to get the inspector script from.
  130846. * By default it uses the babylonjs CDN.
  130847. * @ignoreNaming
  130848. */
  130849. static InspectorURL: string;
  130850. private _scene;
  130851. private BJSINSPECTOR;
  130852. private _onPropertyChangedObservable?;
  130853. /**
  130854. * Observable triggered when a property is changed through the inspector.
  130855. */
  130856. get onPropertyChangedObservable(): any;
  130857. /**
  130858. * Instantiates a new debug layer.
  130859. * The debug layer (aka Inspector) is the go to tool in order to better understand
  130860. * what is happening in your scene
  130861. * @see https://doc.babylonjs.com/features/playground_debuglayer
  130862. * @param scene Defines the scene to inspect
  130863. */
  130864. constructor(scene: Scene);
  130865. /** Creates the inspector window. */
  130866. private _createInspector;
  130867. /**
  130868. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  130869. * @param entity defines the entity to select
  130870. * @param lineContainerTitles defines the specific blocks to highlight (could be a string or an array of strings)
  130871. */
  130872. select(entity: any, lineContainerTitles?: string | string[]): void;
  130873. /** Get the inspector from bundle or global */
  130874. private _getGlobalInspector;
  130875. /**
  130876. * Get if the inspector is visible or not.
  130877. * @returns true if visible otherwise, false
  130878. */
  130879. isVisible(): boolean;
  130880. /**
  130881. * Hide the inspector and close its window.
  130882. */
  130883. hide(): void;
  130884. /**
  130885. * Update the scene in the inspector
  130886. */
  130887. setAsActiveScene(): void;
  130888. /**
  130889. * Launch the debugLayer.
  130890. * @param config Define the configuration of the inspector
  130891. * @return a promise fulfilled when the debug layer is visible
  130892. */
  130893. show(config?: IInspectorOptions): Promise<DebugLayer>;
  130894. }
  130895. }
  130896. declare module BABYLON {
  130897. /**
  130898. * Class containing static functions to help procedurally build meshes
  130899. */
  130900. export class BoxBuilder {
  130901. /**
  130902. * Creates a box mesh
  130903. * * The parameter `size` sets the size (float) of each box side (default 1)
  130904. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  130905. * * 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)
  130906. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  130907. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  130908. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  130909. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  130910. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  130911. * @param name defines the name of the mesh
  130912. * @param options defines the options used to create the mesh
  130913. * @param scene defines the hosting scene
  130914. * @returns the box mesh
  130915. */
  130916. static CreateBox(name: string, options: {
  130917. size?: number;
  130918. width?: number;
  130919. height?: number;
  130920. depth?: number;
  130921. faceUV?: Vector4[];
  130922. faceColors?: Color4[];
  130923. sideOrientation?: number;
  130924. frontUVs?: Vector4;
  130925. backUVs?: Vector4;
  130926. wrap?: boolean;
  130927. topBaseAt?: number;
  130928. bottomBaseAt?: number;
  130929. updatable?: boolean;
  130930. }, scene?: Nullable<Scene>): Mesh;
  130931. }
  130932. }
  130933. declare module BABYLON.Debug {
  130934. /**
  130935. * Used to show the physics impostor around the specific mesh
  130936. */
  130937. export class PhysicsViewer {
  130938. /** @hidden */
  130939. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  130940. /** @hidden */
  130941. protected _meshes: Array<Nullable<AbstractMesh>>;
  130942. /** @hidden */
  130943. protected _scene: Nullable<Scene>;
  130944. /** @hidden */
  130945. protected _numMeshes: number;
  130946. /** @hidden */
  130947. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  130948. private _renderFunction;
  130949. private _utilityLayer;
  130950. private _debugBoxMesh;
  130951. private _debugSphereMesh;
  130952. private _debugCylinderMesh;
  130953. private _debugMaterial;
  130954. private _debugMeshMeshes;
  130955. /**
  130956. * Creates a new PhysicsViewer
  130957. * @param scene defines the hosting scene
  130958. */
  130959. constructor(scene: Scene);
  130960. /** @hidden */
  130961. protected _updateDebugMeshes(): void;
  130962. /**
  130963. * Renders a specified physic impostor
  130964. * @param impostor defines the impostor to render
  130965. * @param targetMesh defines the mesh represented by the impostor
  130966. * @returns the new debug mesh used to render the impostor
  130967. */
  130968. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  130969. /**
  130970. * Hides a specified physic impostor
  130971. * @param impostor defines the impostor to hide
  130972. */
  130973. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  130974. private _getDebugMaterial;
  130975. private _getDebugBoxMesh;
  130976. private _getDebugSphereMesh;
  130977. private _getDebugCylinderMesh;
  130978. private _getDebugMeshMesh;
  130979. private _getDebugMesh;
  130980. /** Releases all resources */
  130981. dispose(): void;
  130982. }
  130983. }
  130984. declare module BABYLON {
  130985. /**
  130986. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  130987. * in order to better appreciate the issue one might have.
  130988. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  130989. */
  130990. export class RayHelper {
  130991. /**
  130992. * Defines the ray we are currently tryin to visualize.
  130993. */
  130994. ray: Nullable<Ray>;
  130995. private _renderPoints;
  130996. private _renderLine;
  130997. private _renderFunction;
  130998. private _scene;
  130999. private _onAfterRenderObserver;
  131000. private _onAfterStepObserver;
  131001. private _attachedToMesh;
  131002. private _meshSpaceDirection;
  131003. private _meshSpaceOrigin;
  131004. /**
  131005. * Helper function to create a colored helper in a scene in one line.
  131006. * @param ray Defines the ray we are currently tryin to visualize
  131007. * @param scene Defines the scene the ray is used in
  131008. * @param color Defines the color we want to see the ray in
  131009. * @returns The newly created ray helper.
  131010. */
  131011. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  131012. /**
  131013. * Instantiate a new ray helper.
  131014. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  131015. * in order to better appreciate the issue one might have.
  131016. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  131017. * @param ray Defines the ray we are currently tryin to visualize
  131018. */
  131019. constructor(ray: Ray);
  131020. /**
  131021. * Shows the ray we are willing to debug.
  131022. * @param scene Defines the scene the ray needs to be rendered in
  131023. * @param color Defines the color the ray needs to be rendered in
  131024. */
  131025. show(scene: Scene, color?: Color3): void;
  131026. /**
  131027. * Hides the ray we are debugging.
  131028. */
  131029. hide(): void;
  131030. private _render;
  131031. /**
  131032. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  131033. * @param mesh Defines the mesh we want the helper attached to
  131034. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  131035. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  131036. * @param length Defines the length of the ray
  131037. */
  131038. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  131039. /**
  131040. * Detach the ray helper from the mesh it has previously been attached to.
  131041. */
  131042. detachFromMesh(): void;
  131043. private _updateToMesh;
  131044. /**
  131045. * Dispose the helper and release its associated resources.
  131046. */
  131047. dispose(): void;
  131048. }
  131049. }
  131050. declare module BABYLON {
  131051. /**
  131052. * Defines the options associated with the creation of a SkeletonViewer.
  131053. */
  131054. export interface ISkeletonViewerOptions {
  131055. /** Should the system pause animations before building the Viewer? */
  131056. pauseAnimations: boolean;
  131057. /** Should the system return the skeleton to rest before building? */
  131058. returnToRest: boolean;
  131059. /** public Display Mode of the Viewer */
  131060. displayMode: number;
  131061. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  131062. displayOptions: ISkeletonViewerDisplayOptions;
  131063. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  131064. computeBonesUsingShaders: boolean;
  131065. /** Flag ignore non weighted bones */
  131066. useAllBones: boolean;
  131067. }
  131068. /**
  131069. * Defines how to display the various bone meshes for the viewer.
  131070. */
  131071. export interface ISkeletonViewerDisplayOptions {
  131072. /** How far down to start tapering the bone spurs */
  131073. midStep?: number;
  131074. /** How big is the midStep? */
  131075. midStepFactor?: number;
  131076. /** Base for the Sphere Size */
  131077. sphereBaseSize?: number;
  131078. /** The ratio of the sphere to the longest bone in units */
  131079. sphereScaleUnit?: number;
  131080. /** Ratio for the Sphere Size */
  131081. sphereFactor?: number;
  131082. }
  131083. /**
  131084. * Defines the constructor options for the BoneWeight Shader.
  131085. */
  131086. export interface IBoneWeightShaderOptions {
  131087. /** Skeleton to Map */
  131088. skeleton: Skeleton;
  131089. /** Colors for Uninfluenced bones */
  131090. colorBase?: Color3;
  131091. /** Colors for 0.0-0.25 Weight bones */
  131092. colorZero?: Color3;
  131093. /** Color for 0.25-0.5 Weight Influence */
  131094. colorQuarter?: Color3;
  131095. /** Color for 0.5-0.75 Weight Influence */
  131096. colorHalf?: Color3;
  131097. /** Color for 0.75-1 Weight Influence */
  131098. colorFull?: Color3;
  131099. /** Color for Zero Weight Influence */
  131100. targetBoneIndex?: number;
  131101. }
  131102. /**
  131103. * Simple structure of the gradient steps for the Color Map.
  131104. */
  131105. export interface ISkeletonMapShaderColorMapKnot {
  131106. /** Color of the Knot */
  131107. color: Color3;
  131108. /** Location of the Knot */
  131109. location: number;
  131110. }
  131111. /**
  131112. * Defines the constructor options for the SkeletonMap Shader.
  131113. */
  131114. export interface ISkeletonMapShaderOptions {
  131115. /** Skeleton to Map */
  131116. skeleton: Skeleton;
  131117. /** Array of ColorMapKnots that make the gradient must be ordered with knot[i].location < knot[i+1].location*/
  131118. colorMap?: ISkeletonMapShaderColorMapKnot[];
  131119. }
  131120. }
  131121. declare module BABYLON {
  131122. /**
  131123. * Class containing static functions to help procedurally build meshes
  131124. */
  131125. export class RibbonBuilder {
  131126. /**
  131127. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  131128. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  131129. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  131130. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  131131. * * 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
  131132. * * 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
  131133. * * 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
  131134. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  131135. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  131136. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  131137. * * 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
  131138. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  131139. * * 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
  131140. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  131141. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  131142. * @param name defines the name of the mesh
  131143. * @param options defines the options used to create the mesh
  131144. * @param scene defines the hosting scene
  131145. * @returns the ribbon mesh
  131146. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  131147. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  131148. */
  131149. static CreateRibbon(name: string, options: {
  131150. pathArray: Vector3[][];
  131151. closeArray?: boolean;
  131152. closePath?: boolean;
  131153. offset?: number;
  131154. updatable?: boolean;
  131155. sideOrientation?: number;
  131156. frontUVs?: Vector4;
  131157. backUVs?: Vector4;
  131158. instance?: Mesh;
  131159. invertUV?: boolean;
  131160. uvs?: Vector2[];
  131161. colors?: Color4[];
  131162. }, scene?: Nullable<Scene>): Mesh;
  131163. }
  131164. }
  131165. declare module BABYLON {
  131166. /**
  131167. * Class containing static functions to help procedurally build meshes
  131168. */
  131169. export class ShapeBuilder {
  131170. /**
  131171. * 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.
  131172. * * 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.
  131173. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  131174. * * 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.
  131175. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  131176. * * 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
  131177. * * 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
  131178. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  131179. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  131180. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  131181. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  131182. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  131183. * @param name defines the name of the mesh
  131184. * @param options defines the options used to create the mesh
  131185. * @param scene defines the hosting scene
  131186. * @returns the extruded shape mesh
  131187. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  131188. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  131189. */
  131190. static ExtrudeShape(name: string, options: {
  131191. shape: Vector3[];
  131192. path: Vector3[];
  131193. scale?: number;
  131194. rotation?: number;
  131195. cap?: number;
  131196. updatable?: boolean;
  131197. sideOrientation?: number;
  131198. frontUVs?: Vector4;
  131199. backUVs?: Vector4;
  131200. instance?: Mesh;
  131201. invertUV?: boolean;
  131202. }, scene?: Nullable<Scene>): Mesh;
  131203. /**
  131204. * Creates an custom extruded shape mesh.
  131205. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  131206. * * 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.
  131207. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  131208. * * 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
  131209. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  131210. * * 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
  131211. * * It must returns a float value that will be the scale value applied to the shape on each path point
  131212. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  131213. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  131214. * * 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
  131215. * * 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
  131216. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  131217. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  131218. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  131219. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  131220. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  131221. * @param name defines the name of the mesh
  131222. * @param options defines the options used to create the mesh
  131223. * @param scene defines the hosting scene
  131224. * @returns the custom extruded shape mesh
  131225. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  131226. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  131227. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  131228. */
  131229. static ExtrudeShapeCustom(name: string, options: {
  131230. shape: Vector3[];
  131231. path: Vector3[];
  131232. scaleFunction?: any;
  131233. rotationFunction?: any;
  131234. ribbonCloseArray?: boolean;
  131235. ribbonClosePath?: boolean;
  131236. cap?: number;
  131237. updatable?: boolean;
  131238. sideOrientation?: number;
  131239. frontUVs?: Vector4;
  131240. backUVs?: Vector4;
  131241. instance?: Mesh;
  131242. invertUV?: boolean;
  131243. }, scene?: Nullable<Scene>): Mesh;
  131244. private static _ExtrudeShapeGeneric;
  131245. }
  131246. }
  131247. declare module BABYLON.Debug {
  131248. /**
  131249. * Class used to render a debug view of a given skeleton
  131250. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  131251. */
  131252. export class SkeletonViewer {
  131253. /** defines the skeleton to render */
  131254. skeleton: Skeleton;
  131255. /** defines the mesh attached to the skeleton */
  131256. mesh: AbstractMesh;
  131257. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  131258. autoUpdateBonesMatrices: boolean;
  131259. /** defines the rendering group id to use with the viewer */
  131260. renderingGroupId: number;
  131261. /** is the options for the viewer */
  131262. options: Partial<ISkeletonViewerOptions>;
  131263. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_LINES */
  131264. static readonly DISPLAY_LINES: number;
  131265. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERES */
  131266. static readonly DISPLAY_SPHERES: number;
  131267. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERE_AND_SPURS */
  131268. static readonly DISPLAY_SPHERE_AND_SPURS: number;
  131269. /** public static method to create a BoneWeight Shader
  131270. * @param options The constructor options
  131271. * @param scene The scene that the shader is scoped to
  131272. * @returns The created ShaderMaterial
  131273. * @see http://www.babylonjs-playground.com/#1BZJVJ#395
  131274. */
  131275. static CreateBoneWeightShader(options: IBoneWeightShaderOptions, scene: Scene): ShaderMaterial;
  131276. /** public static method to create a BoneWeight Shader
  131277. * @param options The constructor options
  131278. * @param scene The scene that the shader is scoped to
  131279. * @returns The created ShaderMaterial
  131280. */
  131281. static CreateSkeletonMapShader(options: ISkeletonMapShaderOptions, scene: Scene): ShaderMaterial;
  131282. /** private static method to create a BoneWeight Shader
  131283. * @param size The size of the buffer to create (usually the bone count)
  131284. * @param colorMap The gradient data to generate
  131285. * @param scene The scene that the shader is scoped to
  131286. * @returns an Array of floats from the color gradient values
  131287. */
  131288. private static _CreateBoneMapColorBuffer;
  131289. /** If SkeletonViewer scene scope. */
  131290. private _scene;
  131291. /** Gets or sets the color used to render the skeleton */
  131292. color: Color3;
  131293. /** Array of the points of the skeleton fo the line view. */
  131294. private _debugLines;
  131295. /** The SkeletonViewers Mesh. */
  131296. private _debugMesh;
  131297. /** If SkeletonViewer is enabled. */
  131298. private _isEnabled;
  131299. /** If SkeletonViewer is ready. */
  131300. private _ready;
  131301. /** SkeletonViewer render observable. */
  131302. private _obs;
  131303. /** The Utility Layer to render the gizmos in. */
  131304. private _utilityLayer;
  131305. private _boneIndices;
  131306. /** Gets the Scene. */
  131307. get scene(): Scene;
  131308. /** Gets the utilityLayer. */
  131309. get utilityLayer(): Nullable<UtilityLayerRenderer>;
  131310. /** Checks Ready Status. */
  131311. get isReady(): Boolean;
  131312. /** Sets Ready Status. */
  131313. set ready(value: boolean);
  131314. /** Gets the debugMesh */
  131315. get debugMesh(): Nullable<AbstractMesh> | Nullable<LinesMesh>;
  131316. /** Sets the debugMesh */
  131317. set debugMesh(value: Nullable<AbstractMesh> | Nullable<LinesMesh>);
  131318. /** Gets the displayMode */
  131319. get displayMode(): number;
  131320. /** Sets the displayMode */
  131321. set displayMode(value: number);
  131322. /**
  131323. * Creates a new SkeletonViewer
  131324. * @param skeleton defines the skeleton to render
  131325. * @param mesh defines the mesh attached to the skeleton
  131326. * @param scene defines the hosting scene
  131327. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  131328. * @param renderingGroupId defines the rendering group id to use with the viewer
  131329. * @param options All of the extra constructor options for the SkeletonViewer
  131330. */
  131331. constructor(
  131332. /** defines the skeleton to render */
  131333. skeleton: Skeleton,
  131334. /** defines the mesh attached to the skeleton */
  131335. mesh: AbstractMesh,
  131336. /** The Scene scope*/
  131337. scene: Scene,
  131338. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  131339. autoUpdateBonesMatrices?: boolean,
  131340. /** defines the rendering group id to use with the viewer */
  131341. renderingGroupId?: number,
  131342. /** is the options for the viewer */
  131343. options?: Partial<ISkeletonViewerOptions>);
  131344. /** The Dynamic bindings for the update functions */
  131345. private _bindObs;
  131346. /** Update the viewer to sync with current skeleton state, only used to manually update. */
  131347. update(): void;
  131348. /** Gets or sets a boolean indicating if the viewer is enabled */
  131349. set isEnabled(value: boolean);
  131350. get isEnabled(): boolean;
  131351. private _getBonePosition;
  131352. private _getLinesForBonesWithLength;
  131353. private _getLinesForBonesNoLength;
  131354. /** function to revert the mesh and scene back to the initial state. */
  131355. private _revert;
  131356. /** function to build and bind sphere joint points and spur bone representations. */
  131357. private _buildSpheresAndSpurs;
  131358. /** Update the viewer to sync with current skeleton state, only used for the line display. */
  131359. private _displayLinesUpdate;
  131360. /** Changes the displayMode of the skeleton viewer
  131361. * @param mode The displayMode numerical value
  131362. */
  131363. changeDisplayMode(mode: number): void;
  131364. /** Changes the displayMode of the skeleton viewer
  131365. * @param option String of the option name
  131366. * @param value The numerical option value
  131367. */
  131368. changeDisplayOptions(option: string, value: number): void;
  131369. /** Release associated resources */
  131370. dispose(): void;
  131371. }
  131372. }
  131373. declare module BABYLON {
  131374. /**
  131375. * Enum for Device Types
  131376. */
  131377. export enum DeviceType {
  131378. /** Generic */
  131379. Generic = 0,
  131380. /** Keyboard */
  131381. Keyboard = 1,
  131382. /** Mouse */
  131383. Mouse = 2,
  131384. /** Touch Pointers */
  131385. Touch = 3,
  131386. /** PS4 Dual Shock */
  131387. DualShock = 4,
  131388. /** Xbox */
  131389. Xbox = 5,
  131390. /** Switch Controller */
  131391. Switch = 6
  131392. }
  131393. /**
  131394. * Enum for All Pointers (Touch/Mouse)
  131395. */
  131396. export enum PointerInput {
  131397. /** Horizontal Axis */
  131398. Horizontal = 0,
  131399. /** Vertical Axis */
  131400. Vertical = 1,
  131401. /** Left Click or Touch */
  131402. LeftClick = 2,
  131403. /** Middle Click */
  131404. MiddleClick = 3,
  131405. /** Right Click */
  131406. RightClick = 4,
  131407. /** Browser Back */
  131408. BrowserBack = 5,
  131409. /** Browser Forward */
  131410. BrowserForward = 6
  131411. }
  131412. /**
  131413. * Enum for Dual Shock Gamepad
  131414. */
  131415. export enum DualShockInput {
  131416. /** Cross */
  131417. Cross = 0,
  131418. /** Circle */
  131419. Circle = 1,
  131420. /** Square */
  131421. Square = 2,
  131422. /** Triangle */
  131423. Triangle = 3,
  131424. /** L1 */
  131425. L1 = 4,
  131426. /** R1 */
  131427. R1 = 5,
  131428. /** L2 */
  131429. L2 = 6,
  131430. /** R2 */
  131431. R2 = 7,
  131432. /** Share */
  131433. Share = 8,
  131434. /** Options */
  131435. Options = 9,
  131436. /** L3 */
  131437. L3 = 10,
  131438. /** R3 */
  131439. R3 = 11,
  131440. /** DPadUp */
  131441. DPadUp = 12,
  131442. /** DPadDown */
  131443. DPadDown = 13,
  131444. /** DPadLeft */
  131445. DPadLeft = 14,
  131446. /** DRight */
  131447. DPadRight = 15,
  131448. /** Home */
  131449. Home = 16,
  131450. /** TouchPad */
  131451. TouchPad = 17,
  131452. /** LStickXAxis */
  131453. LStickXAxis = 18,
  131454. /** LStickYAxis */
  131455. LStickYAxis = 19,
  131456. /** RStickXAxis */
  131457. RStickXAxis = 20,
  131458. /** RStickYAxis */
  131459. RStickYAxis = 21
  131460. }
  131461. /**
  131462. * Enum for Xbox Gamepad
  131463. */
  131464. export enum XboxInput {
  131465. /** A */
  131466. A = 0,
  131467. /** B */
  131468. B = 1,
  131469. /** X */
  131470. X = 2,
  131471. /** Y */
  131472. Y = 3,
  131473. /** LB */
  131474. LB = 4,
  131475. /** RB */
  131476. RB = 5,
  131477. /** LT */
  131478. LT = 6,
  131479. /** RT */
  131480. RT = 7,
  131481. /** Back */
  131482. Back = 8,
  131483. /** Start */
  131484. Start = 9,
  131485. /** LS */
  131486. LS = 10,
  131487. /** RS */
  131488. RS = 11,
  131489. /** DPadUp */
  131490. DPadUp = 12,
  131491. /** DPadDown */
  131492. DPadDown = 13,
  131493. /** DPadLeft */
  131494. DPadLeft = 14,
  131495. /** DRight */
  131496. DPadRight = 15,
  131497. /** Home */
  131498. Home = 16,
  131499. /** LStickXAxis */
  131500. LStickXAxis = 17,
  131501. /** LStickYAxis */
  131502. LStickYAxis = 18,
  131503. /** RStickXAxis */
  131504. RStickXAxis = 19,
  131505. /** RStickYAxis */
  131506. RStickYAxis = 20
  131507. }
  131508. /**
  131509. * Enum for Switch (Pro/JoyCon L+R) Gamepad
  131510. */
  131511. export enum SwitchInput {
  131512. /** B */
  131513. B = 0,
  131514. /** A */
  131515. A = 1,
  131516. /** Y */
  131517. Y = 2,
  131518. /** X */
  131519. X = 3,
  131520. /** L */
  131521. L = 4,
  131522. /** R */
  131523. R = 5,
  131524. /** ZL */
  131525. ZL = 6,
  131526. /** ZR */
  131527. ZR = 7,
  131528. /** Minus */
  131529. Minus = 8,
  131530. /** Plus */
  131531. Plus = 9,
  131532. /** LS */
  131533. LS = 10,
  131534. /** RS */
  131535. RS = 11,
  131536. /** DPadUp */
  131537. DPadUp = 12,
  131538. /** DPadDown */
  131539. DPadDown = 13,
  131540. /** DPadLeft */
  131541. DPadLeft = 14,
  131542. /** DRight */
  131543. DPadRight = 15,
  131544. /** Home */
  131545. Home = 16,
  131546. /** Capture */
  131547. Capture = 17,
  131548. /** LStickXAxis */
  131549. LStickXAxis = 18,
  131550. /** LStickYAxis */
  131551. LStickYAxis = 19,
  131552. /** RStickXAxis */
  131553. RStickXAxis = 20,
  131554. /** RStickYAxis */
  131555. RStickYAxis = 21
  131556. }
  131557. }
  131558. declare module BABYLON {
  131559. /**
  131560. * This class will take all inputs from Keyboard, Pointer, and
  131561. * any Gamepads and provide a polling system that all devices
  131562. * will use. This class assumes that there will only be one
  131563. * pointer device and one keyboard.
  131564. */
  131565. export class DeviceInputSystem implements IDisposable {
  131566. /**
  131567. * Callback to be triggered when a device is connected
  131568. */
  131569. onDeviceConnected: (deviceType: DeviceType, deviceSlot: number) => void;
  131570. /**
  131571. * Callback to be triggered when a device is disconnected
  131572. */
  131573. onDeviceDisconnected: (deviceType: DeviceType, deviceSlot: number) => void;
  131574. /**
  131575. * Callback to be triggered when event driven input is updated
  131576. */
  131577. onInputChanged: (deviceType: DeviceType, deviceSlot: number, inputIndex: number, previousState: Nullable<number>, currentState: Nullable<number>) => void;
  131578. private _inputs;
  131579. private _gamepads;
  131580. private _keyboardActive;
  131581. private _pointerActive;
  131582. private _elementToAttachTo;
  131583. private _keyboardDownEvent;
  131584. private _keyboardUpEvent;
  131585. private _pointerMoveEvent;
  131586. private _pointerDownEvent;
  131587. private _pointerUpEvent;
  131588. private _gamepadConnectedEvent;
  131589. private _gamepadDisconnectedEvent;
  131590. private static _MAX_KEYCODES;
  131591. private static _MAX_POINTER_INPUTS;
  131592. private constructor();
  131593. /**
  131594. * Creates a new DeviceInputSystem instance
  131595. * @param engine Engine to pull input element from
  131596. * @returns The new instance
  131597. */
  131598. static Create(engine: Engine): DeviceInputSystem;
  131599. /**
  131600. * Checks for current device input value, given an id and input index
  131601. * @param deviceName Id of connected device
  131602. * @param inputIndex Index of device input
  131603. * @returns Current value of input
  131604. */
  131605. /**
  131606. * Checks for current device input value, given an id and input index. Throws exception if requested device not initialized.
  131607. * @param deviceType Enum specifiying device type
  131608. * @param deviceSlot "Slot" or index that device is referenced in
  131609. * @param inputIndex Id of input to be checked
  131610. * @returns Current value of input
  131611. */
  131612. pollInput(deviceType: DeviceType, deviceSlot: number, inputIndex: number): number;
  131613. /**
  131614. * Dispose of all the eventlisteners
  131615. */
  131616. dispose(): void;
  131617. /**
  131618. * Add device and inputs to device array
  131619. * @param deviceType Enum specifiying device type
  131620. * @param deviceSlot "Slot" or index that device is referenced in
  131621. * @param numberOfInputs Number of input entries to create for given device
  131622. */
  131623. private _registerDevice;
  131624. /**
  131625. * Given a specific device name, remove that device from the device map
  131626. * @param deviceType Enum specifiying device type
  131627. * @param deviceSlot "Slot" or index that device is referenced in
  131628. */
  131629. private _unregisterDevice;
  131630. /**
  131631. * Handle all actions that come from keyboard interaction
  131632. */
  131633. private _handleKeyActions;
  131634. /**
  131635. * Handle all actions that come from pointer interaction
  131636. */
  131637. private _handlePointerActions;
  131638. /**
  131639. * Handle all actions that come from gamepad interaction
  131640. */
  131641. private _handleGamepadActions;
  131642. /**
  131643. * Update all non-event based devices with each frame
  131644. * @param deviceType Enum specifiying device type
  131645. * @param deviceSlot "Slot" or index that device is referenced in
  131646. * @param inputIndex Id of input to be checked
  131647. */
  131648. private _updateDevice;
  131649. /**
  131650. * Gets DeviceType from the device name
  131651. * @param deviceName Name of Device from DeviceInputSystem
  131652. * @returns DeviceType enum value
  131653. */
  131654. private _getGamepadDeviceType;
  131655. }
  131656. }
  131657. declare module BABYLON {
  131658. /**
  131659. * Type to handle enforcement of inputs
  131660. */
  131661. 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;
  131662. }
  131663. declare module BABYLON {
  131664. /**
  131665. * Class that handles all input for a specific device
  131666. */
  131667. export class DeviceSource<T extends DeviceType> {
  131668. /** Type of device */
  131669. readonly deviceType: DeviceType;
  131670. /** "Slot" or index that device is referenced in */
  131671. readonly deviceSlot: number;
  131672. /**
  131673. * Observable to handle device input changes per device
  131674. */
  131675. readonly onInputChangedObservable: Observable<{
  131676. inputIndex: DeviceInput<T>;
  131677. previousState: Nullable<number>;
  131678. currentState: Nullable<number>;
  131679. }>;
  131680. private readonly _deviceInputSystem;
  131681. /**
  131682. * Default Constructor
  131683. * @param deviceInputSystem Reference to DeviceInputSystem
  131684. * @param deviceType Type of device
  131685. * @param deviceSlot "Slot" or index that device is referenced in
  131686. */
  131687. constructor(deviceInputSystem: DeviceInputSystem,
  131688. /** Type of device */
  131689. deviceType: DeviceType,
  131690. /** "Slot" or index that device is referenced in */
  131691. deviceSlot?: number);
  131692. /**
  131693. * Get input for specific input
  131694. * @param inputIndex index of specific input on device
  131695. * @returns Input value from DeviceInputSystem
  131696. */
  131697. getInput(inputIndex: DeviceInput<T>): number;
  131698. }
  131699. /**
  131700. * Class to keep track of devices
  131701. */
  131702. export class DeviceSourceManager implements IDisposable {
  131703. /**
  131704. * Observable to be triggered when before a device is connected
  131705. */
  131706. readonly onBeforeDeviceConnectedObservable: Observable<{
  131707. deviceType: DeviceType;
  131708. deviceSlot: number;
  131709. }>;
  131710. /**
  131711. * Observable to be triggered when before a device is disconnected
  131712. */
  131713. readonly onBeforeDeviceDisconnectedObservable: Observable<{
  131714. deviceType: DeviceType;
  131715. deviceSlot: number;
  131716. }>;
  131717. /**
  131718. * Observable to be triggered when after a device is connected
  131719. */
  131720. readonly onAfterDeviceConnectedObservable: Observable<{
  131721. deviceType: DeviceType;
  131722. deviceSlot: number;
  131723. }>;
  131724. /**
  131725. * Observable to be triggered when after a device is disconnected
  131726. */
  131727. readonly onAfterDeviceDisconnectedObservable: Observable<{
  131728. deviceType: DeviceType;
  131729. deviceSlot: number;
  131730. }>;
  131731. private readonly _devices;
  131732. private readonly _firstDevice;
  131733. private readonly _deviceInputSystem;
  131734. /**
  131735. * Default Constructor
  131736. * @param engine engine to pull input element from
  131737. */
  131738. constructor(engine: Engine);
  131739. /**
  131740. * Gets a DeviceSource, given a type and slot
  131741. * @param deviceType Enum specifying device type
  131742. * @param deviceSlot "Slot" or index that device is referenced in
  131743. * @returns DeviceSource object
  131744. */
  131745. getDeviceSource<T extends DeviceType>(deviceType: T, deviceSlot?: number): Nullable<DeviceSource<T>>;
  131746. /**
  131747. * Gets an array of DeviceSource objects for a given device type
  131748. * @param deviceType Enum specifying device type
  131749. * @returns Array of DeviceSource objects
  131750. */
  131751. getDeviceSources<T extends DeviceType>(deviceType: T): ReadonlyArray<DeviceSource<T>>;
  131752. /**
  131753. * Dispose of DeviceInputSystem and other parts
  131754. */
  131755. dispose(): void;
  131756. /**
  131757. * Function to add device name to device list
  131758. * @param deviceType Enum specifying device type
  131759. * @param deviceSlot "Slot" or index that device is referenced in
  131760. */
  131761. private _addDevice;
  131762. /**
  131763. * Function to remove device name to device list
  131764. * @param deviceType Enum specifying device type
  131765. * @param deviceSlot "Slot" or index that device is referenced in
  131766. */
  131767. private _removeDevice;
  131768. /**
  131769. * Updates array storing first connected device of each type
  131770. * @param type Type of Device
  131771. */
  131772. private _updateFirstDevices;
  131773. }
  131774. }
  131775. declare module BABYLON {
  131776. /**
  131777. * Options to create the null engine
  131778. */
  131779. export class NullEngineOptions {
  131780. /**
  131781. * Render width (Default: 512)
  131782. */
  131783. renderWidth: number;
  131784. /**
  131785. * Render height (Default: 256)
  131786. */
  131787. renderHeight: number;
  131788. /**
  131789. * Texture size (Default: 512)
  131790. */
  131791. textureSize: number;
  131792. /**
  131793. * If delta time between frames should be constant
  131794. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  131795. */
  131796. deterministicLockstep: boolean;
  131797. /**
  131798. * Maximum about of steps between frames (Default: 4)
  131799. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  131800. */
  131801. lockstepMaxSteps: number;
  131802. /**
  131803. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  131804. */
  131805. useHighPrecisionMatrix?: boolean;
  131806. }
  131807. /**
  131808. * The null engine class provides support for headless version of babylon.js.
  131809. * This can be used in server side scenario or for testing purposes
  131810. */
  131811. export class NullEngine extends Engine {
  131812. private _options;
  131813. /**
  131814. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  131815. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  131816. * @returns true if engine is in deterministic lock step mode
  131817. */
  131818. isDeterministicLockStep(): boolean;
  131819. /**
  131820. * Gets the max steps when engine is running in deterministic lock step
  131821. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  131822. * @returns the max steps
  131823. */
  131824. getLockstepMaxSteps(): number;
  131825. /**
  131826. * Gets the current hardware scaling level.
  131827. * By default the hardware scaling level is computed from the window device ratio.
  131828. * 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.
  131829. * @returns a number indicating the current hardware scaling level
  131830. */
  131831. getHardwareScalingLevel(): number;
  131832. constructor(options?: NullEngineOptions);
  131833. /**
  131834. * Creates a vertex buffer
  131835. * @param vertices the data for the vertex buffer
  131836. * @returns the new WebGL static buffer
  131837. */
  131838. createVertexBuffer(vertices: FloatArray): DataBuffer;
  131839. /**
  131840. * Creates a new index buffer
  131841. * @param indices defines the content of the index buffer
  131842. * @param updatable defines if the index buffer must be updatable
  131843. * @returns a new webGL buffer
  131844. */
  131845. createIndexBuffer(indices: IndicesArray): DataBuffer;
  131846. /**
  131847. * Clear the current render buffer or the current render target (if any is set up)
  131848. * @param color defines the color to use
  131849. * @param backBuffer defines if the back buffer must be cleared
  131850. * @param depth defines if the depth buffer must be cleared
  131851. * @param stencil defines if the stencil buffer must be cleared
  131852. */
  131853. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  131854. /**
  131855. * Gets the current render width
  131856. * @param useScreen defines if screen size must be used (or the current render target if any)
  131857. * @returns a number defining the current render width
  131858. */
  131859. getRenderWidth(useScreen?: boolean): number;
  131860. /**
  131861. * Gets the current render height
  131862. * @param useScreen defines if screen size must be used (or the current render target if any)
  131863. * @returns a number defining the current render height
  131864. */
  131865. getRenderHeight(useScreen?: boolean): number;
  131866. /**
  131867. * Set the WebGL's viewport
  131868. * @param viewport defines the viewport element to be used
  131869. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  131870. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  131871. */
  131872. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  131873. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  131874. /**
  131875. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  131876. * @param pipelineContext defines the pipeline context to use
  131877. * @param uniformsNames defines the list of uniform names
  131878. * @returns an array of webGL uniform locations
  131879. */
  131880. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  131881. /**
  131882. * Gets the lsit of active attributes for a given webGL program
  131883. * @param pipelineContext defines the pipeline context to use
  131884. * @param attributesNames defines the list of attribute names to get
  131885. * @returns an array of indices indicating the offset of each attribute
  131886. */
  131887. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  131888. /**
  131889. * Binds an effect to the webGL context
  131890. * @param effect defines the effect to bind
  131891. */
  131892. bindSamplers(effect: Effect): void;
  131893. /**
  131894. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  131895. * @param effect defines the effect to activate
  131896. */
  131897. enableEffect(effect: Effect): void;
  131898. /**
  131899. * Set various states to the webGL context
  131900. * @param culling defines backface culling state
  131901. * @param zOffset defines the value to apply to zOffset (0 by default)
  131902. * @param force defines if states must be applied even if cache is up to date
  131903. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  131904. */
  131905. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  131906. /**
  131907. * Set the value of an uniform to an array of int32
  131908. * @param uniform defines the webGL uniform location where to store the value
  131909. * @param array defines the array of int32 to store
  131910. */
  131911. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  131912. /**
  131913. * Set the value of an uniform to an array of int32 (stored as vec2)
  131914. * @param uniform defines the webGL uniform location where to store the value
  131915. * @param array defines the array of int32 to store
  131916. */
  131917. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  131918. /**
  131919. * Set the value of an uniform to an array of int32 (stored as vec3)
  131920. * @param uniform defines the webGL uniform location where to store the value
  131921. * @param array defines the array of int32 to store
  131922. */
  131923. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  131924. /**
  131925. * Set the value of an uniform to an array of int32 (stored as vec4)
  131926. * @param uniform defines the webGL uniform location where to store the value
  131927. * @param array defines the array of int32 to store
  131928. */
  131929. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  131930. /**
  131931. * Set the value of an uniform to an array of float32
  131932. * @param uniform defines the webGL uniform location where to store the value
  131933. * @param array defines the array of float32 to store
  131934. */
  131935. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  131936. /**
  131937. * Set the value of an uniform to an array of float32 (stored as vec2)
  131938. * @param uniform defines the webGL uniform location where to store the value
  131939. * @param array defines the array of float32 to store
  131940. */
  131941. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  131942. /**
  131943. * Set the value of an uniform to an array of float32 (stored as vec3)
  131944. * @param uniform defines the webGL uniform location where to store the value
  131945. * @param array defines the array of float32 to store
  131946. */
  131947. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  131948. /**
  131949. * Set the value of an uniform to an array of float32 (stored as vec4)
  131950. * @param uniform defines the webGL uniform location where to store the value
  131951. * @param array defines the array of float32 to store
  131952. */
  131953. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  131954. /**
  131955. * Set the value of an uniform to an array of number
  131956. * @param uniform defines the webGL uniform location where to store the value
  131957. * @param array defines the array of number to store
  131958. */
  131959. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  131960. /**
  131961. * Set the value of an uniform to an array of number (stored as vec2)
  131962. * @param uniform defines the webGL uniform location where to store the value
  131963. * @param array defines the array of number to store
  131964. */
  131965. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  131966. /**
  131967. * Set the value of an uniform to an array of number (stored as vec3)
  131968. * @param uniform defines the webGL uniform location where to store the value
  131969. * @param array defines the array of number to store
  131970. */
  131971. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  131972. /**
  131973. * Set the value of an uniform to an array of number (stored as vec4)
  131974. * @param uniform defines the webGL uniform location where to store the value
  131975. * @param array defines the array of number to store
  131976. */
  131977. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  131978. /**
  131979. * Set the value of an uniform to an array of float32 (stored as matrices)
  131980. * @param uniform defines the webGL uniform location where to store the value
  131981. * @param matrices defines the array of float32 to store
  131982. */
  131983. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  131984. /**
  131985. * Set the value of an uniform to a matrix (3x3)
  131986. * @param uniform defines the webGL uniform location where to store the value
  131987. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  131988. */
  131989. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  131990. /**
  131991. * Set the value of an uniform to a matrix (2x2)
  131992. * @param uniform defines the webGL uniform location where to store the value
  131993. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  131994. */
  131995. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  131996. /**
  131997. * Set the value of an uniform to a number (float)
  131998. * @param uniform defines the webGL uniform location where to store the value
  131999. * @param value defines the float number to store
  132000. */
  132001. setFloat(uniform: WebGLUniformLocation, value: number): void;
  132002. /**
  132003. * Set the value of an uniform to a vec2
  132004. * @param uniform defines the webGL uniform location where to store the value
  132005. * @param x defines the 1st component of the value
  132006. * @param y defines the 2nd component of the value
  132007. */
  132008. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  132009. /**
  132010. * Set the value of an uniform to a vec3
  132011. * @param uniform defines the webGL uniform location where to store the value
  132012. * @param x defines the 1st component of the value
  132013. * @param y defines the 2nd component of the value
  132014. * @param z defines the 3rd component of the value
  132015. */
  132016. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  132017. /**
  132018. * Set the value of an uniform to a boolean
  132019. * @param uniform defines the webGL uniform location where to store the value
  132020. * @param bool defines the boolean to store
  132021. */
  132022. setBool(uniform: WebGLUniformLocation, bool: number): void;
  132023. /**
  132024. * Set the value of an uniform to a vec4
  132025. * @param uniform defines the webGL uniform location where to store the value
  132026. * @param x defines the 1st component of the value
  132027. * @param y defines the 2nd component of the value
  132028. * @param z defines the 3rd component of the value
  132029. * @param w defines the 4th component of the value
  132030. */
  132031. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  132032. /**
  132033. * Sets the current alpha mode
  132034. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  132035. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  132036. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  132037. */
  132038. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  132039. /**
  132040. * Bind webGl buffers directly to the webGL context
  132041. * @param vertexBuffers defines the vertex buffer to bind
  132042. * @param indexBuffer defines the index buffer to bind
  132043. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  132044. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  132045. * @param effect defines the effect associated with the vertex buffer
  132046. */
  132047. bindBuffers(vertexBuffers: {
  132048. [key: string]: VertexBuffer;
  132049. }, indexBuffer: DataBuffer, effect: Effect): void;
  132050. /**
  132051. * Force the entire cache to be cleared
  132052. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  132053. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  132054. */
  132055. wipeCaches(bruteForce?: boolean): void;
  132056. /**
  132057. * Send a draw order
  132058. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  132059. * @param indexStart defines the starting index
  132060. * @param indexCount defines the number of index to draw
  132061. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  132062. */
  132063. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  132064. /**
  132065. * Draw a list of indexed primitives
  132066. * @param fillMode defines the primitive to use
  132067. * @param indexStart defines the starting index
  132068. * @param indexCount defines the number of index to draw
  132069. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  132070. */
  132071. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  132072. /**
  132073. * Draw a list of unindexed primitives
  132074. * @param fillMode defines the primitive to use
  132075. * @param verticesStart defines the index of first vertex to draw
  132076. * @param verticesCount defines the count of vertices to draw
  132077. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  132078. */
  132079. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  132080. /** @hidden */
  132081. _createTexture(): WebGLTexture;
  132082. /** @hidden */
  132083. _releaseTexture(texture: InternalTexture): void;
  132084. /**
  132085. * Usually called from Texture.ts.
  132086. * Passed information to create a WebGLTexture
  132087. * @param urlArg defines a value which contains one of the following:
  132088. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  132089. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  132090. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  132091. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  132092. * @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)
  132093. * @param scene needed for loading to the correct scene
  132094. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  132095. * @param onLoad optional callback to be called upon successful completion
  132096. * @param onError optional callback to be called upon failure
  132097. * @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
  132098. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  132099. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  132100. * @param forcedExtension defines the extension to use to pick the right loader
  132101. * @param mimeType defines an optional mime type
  132102. * @returns a InternalTexture for assignment back into BABYLON.Texture
  132103. */
  132104. 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;
  132105. /**
  132106. * Creates a new render target texture
  132107. * @param size defines the size of the texture
  132108. * @param options defines the options used to create the texture
  132109. * @returns a new render target texture stored in an InternalTexture
  132110. */
  132111. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  132112. /**
  132113. * Update the sampling mode of a given texture
  132114. * @param samplingMode defines the required sampling mode
  132115. * @param texture defines the texture to update
  132116. */
  132117. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  132118. /**
  132119. * Binds the frame buffer to the specified texture.
  132120. * @param texture The texture to render to or null for the default canvas
  132121. * @param faceIndex The face of the texture to render to in case of cube texture
  132122. * @param requiredWidth The width of the target to render to
  132123. * @param requiredHeight The height of the target to render to
  132124. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  132125. * @param lodLevel defines le lod level to bind to the frame buffer
  132126. */
  132127. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  132128. /**
  132129. * Unbind the current render target texture from the webGL context
  132130. * @param texture defines the render target texture to unbind
  132131. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  132132. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  132133. */
  132134. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  132135. /**
  132136. * Creates a dynamic vertex buffer
  132137. * @param vertices the data for the dynamic vertex buffer
  132138. * @returns the new WebGL dynamic buffer
  132139. */
  132140. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  132141. /**
  132142. * Update the content of a dynamic texture
  132143. * @param texture defines the texture to update
  132144. * @param canvas defines the canvas containing the source
  132145. * @param invertY defines if data must be stored with Y axis inverted
  132146. * @param premulAlpha defines if alpha is stored as premultiplied
  132147. * @param format defines the format of the data
  132148. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  132149. */
  132150. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  132151. /**
  132152. * Gets a boolean indicating if all created effects are ready
  132153. * @returns true if all effects are ready
  132154. */
  132155. areAllEffectsReady(): boolean;
  132156. /**
  132157. * @hidden
  132158. * Get the current error code of the webGL context
  132159. * @returns the error code
  132160. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  132161. */
  132162. getError(): number;
  132163. /** @hidden */
  132164. _getUnpackAlignement(): number;
  132165. /** @hidden */
  132166. _unpackFlipY(value: boolean): void;
  132167. /**
  132168. * Update a dynamic index buffer
  132169. * @param indexBuffer defines the target index buffer
  132170. * @param indices defines the data to update
  132171. * @param offset defines the offset in the target index buffer where update should start
  132172. */
  132173. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  132174. /**
  132175. * Updates a dynamic vertex buffer.
  132176. * @param vertexBuffer the vertex buffer to update
  132177. * @param vertices the data used to update the vertex buffer
  132178. * @param byteOffset the byte offset of the data (optional)
  132179. * @param byteLength the byte length of the data (optional)
  132180. */
  132181. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  132182. /** @hidden */
  132183. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  132184. /** @hidden */
  132185. _bindTexture(channel: number, texture: InternalTexture): void;
  132186. protected _deleteBuffer(buffer: WebGLBuffer): void;
  132187. /**
  132188. * 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
  132189. */
  132190. releaseEffects(): void;
  132191. displayLoadingUI(): void;
  132192. hideLoadingUI(): void;
  132193. /** @hidden */
  132194. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  132195. /** @hidden */
  132196. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  132197. /** @hidden */
  132198. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  132199. /** @hidden */
  132200. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  132201. }
  132202. }
  132203. declare module BABYLON {
  132204. /**
  132205. * @hidden
  132206. **/
  132207. export class _TimeToken {
  132208. _startTimeQuery: Nullable<WebGLQuery>;
  132209. _endTimeQuery: Nullable<WebGLQuery>;
  132210. _timeElapsedQuery: Nullable<WebGLQuery>;
  132211. _timeElapsedQueryEnded: boolean;
  132212. }
  132213. }
  132214. declare module BABYLON {
  132215. /** @hidden */
  132216. export class _OcclusionDataStorage {
  132217. /** @hidden */
  132218. occlusionInternalRetryCounter: number;
  132219. /** @hidden */
  132220. isOcclusionQueryInProgress: boolean;
  132221. /** @hidden */
  132222. isOccluded: boolean;
  132223. /** @hidden */
  132224. occlusionRetryCount: number;
  132225. /** @hidden */
  132226. occlusionType: number;
  132227. /** @hidden */
  132228. occlusionQueryAlgorithmType: number;
  132229. }
  132230. interface Engine {
  132231. /**
  132232. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  132233. * @return the new query
  132234. */
  132235. createQuery(): WebGLQuery;
  132236. /**
  132237. * Delete and release a webGL query
  132238. * @param query defines the query to delete
  132239. * @return the current engine
  132240. */
  132241. deleteQuery(query: WebGLQuery): Engine;
  132242. /**
  132243. * Check if a given query has resolved and got its value
  132244. * @param query defines the query to check
  132245. * @returns true if the query got its value
  132246. */
  132247. isQueryResultAvailable(query: WebGLQuery): boolean;
  132248. /**
  132249. * Gets the value of a given query
  132250. * @param query defines the query to check
  132251. * @returns the value of the query
  132252. */
  132253. getQueryResult(query: WebGLQuery): number;
  132254. /**
  132255. * Initiates an occlusion query
  132256. * @param algorithmType defines the algorithm to use
  132257. * @param query defines the query to use
  132258. * @returns the current engine
  132259. * @see https://doc.babylonjs.com/features/occlusionquery
  132260. */
  132261. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  132262. /**
  132263. * Ends an occlusion query
  132264. * @see https://doc.babylonjs.com/features/occlusionquery
  132265. * @param algorithmType defines the algorithm to use
  132266. * @returns the current engine
  132267. */
  132268. endOcclusionQuery(algorithmType: number): Engine;
  132269. /**
  132270. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  132271. * Please note that only one query can be issued at a time
  132272. * @returns a time token used to track the time span
  132273. */
  132274. startTimeQuery(): Nullable<_TimeToken>;
  132275. /**
  132276. * Ends a time query
  132277. * @param token defines the token used to measure the time span
  132278. * @returns the time spent (in ns)
  132279. */
  132280. endTimeQuery(token: _TimeToken): int;
  132281. /** @hidden */
  132282. _currentNonTimestampToken: Nullable<_TimeToken>;
  132283. /** @hidden */
  132284. _createTimeQuery(): WebGLQuery;
  132285. /** @hidden */
  132286. _deleteTimeQuery(query: WebGLQuery): void;
  132287. /** @hidden */
  132288. _getGlAlgorithmType(algorithmType: number): number;
  132289. /** @hidden */
  132290. _getTimeQueryResult(query: WebGLQuery): any;
  132291. /** @hidden */
  132292. _getTimeQueryAvailability(query: WebGLQuery): any;
  132293. }
  132294. interface AbstractMesh {
  132295. /**
  132296. * Backing filed
  132297. * @hidden
  132298. */
  132299. __occlusionDataStorage: _OcclusionDataStorage;
  132300. /**
  132301. * Access property
  132302. * @hidden
  132303. */
  132304. _occlusionDataStorage: _OcclusionDataStorage;
  132305. /**
  132306. * 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.
  132307. * The default value is -1 which means don't break the query and wait till the result
  132308. * @see https://doc.babylonjs.com/features/occlusionquery
  132309. */
  132310. occlusionRetryCount: number;
  132311. /**
  132312. * 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:
  132313. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  132314. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  132315. * * 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.
  132316. * @see https://doc.babylonjs.com/features/occlusionquery
  132317. */
  132318. occlusionType: number;
  132319. /**
  132320. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  132321. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  132322. * * 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.
  132323. * @see https://doc.babylonjs.com/features/occlusionquery
  132324. */
  132325. occlusionQueryAlgorithmType: number;
  132326. /**
  132327. * 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
  132328. * @see https://doc.babylonjs.com/features/occlusionquery
  132329. */
  132330. isOccluded: boolean;
  132331. /**
  132332. * Flag to check the progress status of the query
  132333. * @see https://doc.babylonjs.com/features/occlusionquery
  132334. */
  132335. isOcclusionQueryInProgress: boolean;
  132336. }
  132337. }
  132338. declare module BABYLON {
  132339. /** @hidden */
  132340. export var _forceTransformFeedbackToBundle: boolean;
  132341. interface Engine {
  132342. /**
  132343. * Creates a webGL transform feedback object
  132344. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  132345. * @returns the webGL transform feedback object
  132346. */
  132347. createTransformFeedback(): WebGLTransformFeedback;
  132348. /**
  132349. * Delete a webGL transform feedback object
  132350. * @param value defines the webGL transform feedback object to delete
  132351. */
  132352. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  132353. /**
  132354. * Bind a webGL transform feedback object to the webgl context
  132355. * @param value defines the webGL transform feedback object to bind
  132356. */
  132357. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  132358. /**
  132359. * Begins a transform feedback operation
  132360. * @param usePoints defines if points or triangles must be used
  132361. */
  132362. beginTransformFeedback(usePoints: boolean): void;
  132363. /**
  132364. * Ends a transform feedback operation
  132365. */
  132366. endTransformFeedback(): void;
  132367. /**
  132368. * Specify the varyings to use with transform feedback
  132369. * @param program defines the associated webGL program
  132370. * @param value defines the list of strings representing the varying names
  132371. */
  132372. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  132373. /**
  132374. * Bind a webGL buffer for a transform feedback operation
  132375. * @param value defines the webGL buffer to bind
  132376. */
  132377. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  132378. }
  132379. }
  132380. declare module BABYLON {
  132381. /**
  132382. * Class used to define an additional view for the engine
  132383. * @see https://doc.babylonjs.com/how_to/multi_canvases
  132384. */
  132385. export class EngineView {
  132386. /** Defines the canvas where to render the view */
  132387. target: HTMLCanvasElement;
  132388. /** Defines an optional camera used to render the view (will use active camera else) */
  132389. camera?: Camera;
  132390. }
  132391. interface Engine {
  132392. /**
  132393. * Gets or sets the HTML element to use for attaching events
  132394. */
  132395. inputElement: Nullable<HTMLElement>;
  132396. /**
  132397. * Gets the current engine view
  132398. * @see https://doc.babylonjs.com/how_to/multi_canvases
  132399. */
  132400. activeView: Nullable<EngineView>;
  132401. /** Gets or sets the list of views */
  132402. views: EngineView[];
  132403. /**
  132404. * Register a new child canvas
  132405. * @param canvas defines the canvas to register
  132406. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  132407. * @returns the associated view
  132408. */
  132409. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  132410. /**
  132411. * Remove a registered child canvas
  132412. * @param canvas defines the canvas to remove
  132413. * @returns the current engine
  132414. */
  132415. unRegisterView(canvas: HTMLCanvasElement): Engine;
  132416. }
  132417. }
  132418. declare module BABYLON {
  132419. interface Engine {
  132420. /** @hidden */
  132421. _excludedCompressedTextures: string[];
  132422. /** @hidden */
  132423. _textureFormatInUse: string;
  132424. /**
  132425. * Gets the list of texture formats supported
  132426. */
  132427. readonly texturesSupported: Array<string>;
  132428. /**
  132429. * Gets the texture format in use
  132430. */
  132431. readonly textureFormatInUse: Nullable<string>;
  132432. /**
  132433. * Set the compressed texture extensions or file names to skip.
  132434. *
  132435. * @param skippedFiles defines the list of those texture files you want to skip
  132436. * Example: [".dds", ".env", "myfile.png"]
  132437. */
  132438. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  132439. /**
  132440. * Set the compressed texture format to use, based on the formats you have, and the formats
  132441. * supported by the hardware / browser.
  132442. *
  132443. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  132444. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  132445. * to API arguments needed to compressed textures. This puts the burden on the container
  132446. * generator to house the arcane code for determining these for current & future formats.
  132447. *
  132448. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  132449. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  132450. *
  132451. * Note: The result of this call is not taken into account when a texture is base64.
  132452. *
  132453. * @param formatsAvailable defines the list of those format families you have created
  132454. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  132455. *
  132456. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  132457. * @returns The extension selected.
  132458. */
  132459. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  132460. }
  132461. }
  132462. declare module BABYLON {
  132463. /**
  132464. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  132465. */
  132466. export interface CubeMapInfo {
  132467. /**
  132468. * The pixel array for the front face.
  132469. * This is stored in format, left to right, up to down format.
  132470. */
  132471. front: Nullable<ArrayBufferView>;
  132472. /**
  132473. * The pixel array for the back face.
  132474. * This is stored in format, left to right, up to down format.
  132475. */
  132476. back: Nullable<ArrayBufferView>;
  132477. /**
  132478. * The pixel array for the left face.
  132479. * This is stored in format, left to right, up to down format.
  132480. */
  132481. left: Nullable<ArrayBufferView>;
  132482. /**
  132483. * The pixel array for the right face.
  132484. * This is stored in format, left to right, up to down format.
  132485. */
  132486. right: Nullable<ArrayBufferView>;
  132487. /**
  132488. * The pixel array for the up face.
  132489. * This is stored in format, left to right, up to down format.
  132490. */
  132491. up: Nullable<ArrayBufferView>;
  132492. /**
  132493. * The pixel array for the down face.
  132494. * This is stored in format, left to right, up to down format.
  132495. */
  132496. down: Nullable<ArrayBufferView>;
  132497. /**
  132498. * The size of the cubemap stored.
  132499. *
  132500. * Each faces will be size * size pixels.
  132501. */
  132502. size: number;
  132503. /**
  132504. * The format of the texture.
  132505. *
  132506. * RGBA, RGB.
  132507. */
  132508. format: number;
  132509. /**
  132510. * The type of the texture data.
  132511. *
  132512. * UNSIGNED_INT, FLOAT.
  132513. */
  132514. type: number;
  132515. /**
  132516. * Specifies whether the texture is in gamma space.
  132517. */
  132518. gammaSpace: boolean;
  132519. }
  132520. /**
  132521. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  132522. */
  132523. export class PanoramaToCubeMapTools {
  132524. private static FACE_LEFT;
  132525. private static FACE_RIGHT;
  132526. private static FACE_FRONT;
  132527. private static FACE_BACK;
  132528. private static FACE_DOWN;
  132529. private static FACE_UP;
  132530. /**
  132531. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  132532. *
  132533. * @param float32Array The source data.
  132534. * @param inputWidth The width of the input panorama.
  132535. * @param inputHeight The height of the input panorama.
  132536. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  132537. * @return The cubemap data
  132538. */
  132539. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  132540. private static CreateCubemapTexture;
  132541. private static CalcProjectionSpherical;
  132542. }
  132543. }
  132544. declare module BABYLON {
  132545. /**
  132546. * Helper class dealing with the extraction of spherical polynomial dataArray
  132547. * from a cube map.
  132548. */
  132549. export class CubeMapToSphericalPolynomialTools {
  132550. private static FileFaces;
  132551. /**
  132552. * Converts a texture to the according Spherical Polynomial data.
  132553. * This extracts the first 3 orders only as they are the only one used in the lighting.
  132554. *
  132555. * @param texture The texture to extract the information from.
  132556. * @return The Spherical Polynomial data.
  132557. */
  132558. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  132559. /**
  132560. * Converts a cubemap to the according Spherical Polynomial data.
  132561. * This extracts the first 3 orders only as they are the only one used in the lighting.
  132562. *
  132563. * @param cubeInfo The Cube map to extract the information from.
  132564. * @return The Spherical Polynomial data.
  132565. */
  132566. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  132567. }
  132568. }
  132569. declare module BABYLON {
  132570. interface BaseTexture {
  132571. /**
  132572. * Get the polynomial representation of the texture data.
  132573. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  132574. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  132575. */
  132576. sphericalPolynomial: Nullable<SphericalPolynomial>;
  132577. }
  132578. }
  132579. declare module BABYLON {
  132580. /** @hidden */
  132581. export var rgbdEncodePixelShader: {
  132582. name: string;
  132583. shader: string;
  132584. };
  132585. }
  132586. declare module BABYLON {
  132587. /** @hidden */
  132588. export var rgbdDecodePixelShader: {
  132589. name: string;
  132590. shader: string;
  132591. };
  132592. }
  132593. declare module BABYLON {
  132594. /**
  132595. * Raw texture data and descriptor sufficient for WebGL texture upload
  132596. */
  132597. export interface EnvironmentTextureInfo {
  132598. /**
  132599. * Version of the environment map
  132600. */
  132601. version: number;
  132602. /**
  132603. * Width of image
  132604. */
  132605. width: number;
  132606. /**
  132607. * Irradiance information stored in the file.
  132608. */
  132609. irradiance: any;
  132610. /**
  132611. * Specular information stored in the file.
  132612. */
  132613. specular: any;
  132614. }
  132615. /**
  132616. * Defines One Image in the file. It requires only the position in the file
  132617. * as well as the length.
  132618. */
  132619. interface BufferImageData {
  132620. /**
  132621. * Length of the image data.
  132622. */
  132623. length: number;
  132624. /**
  132625. * Position of the data from the null terminator delimiting the end of the JSON.
  132626. */
  132627. position: number;
  132628. }
  132629. /**
  132630. * Defines the specular data enclosed in the file.
  132631. * This corresponds to the version 1 of the data.
  132632. */
  132633. export interface EnvironmentTextureSpecularInfoV1 {
  132634. /**
  132635. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  132636. */
  132637. specularDataPosition?: number;
  132638. /**
  132639. * This contains all the images data needed to reconstruct the cubemap.
  132640. */
  132641. mipmaps: Array<BufferImageData>;
  132642. /**
  132643. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  132644. */
  132645. lodGenerationScale: number;
  132646. }
  132647. /**
  132648. * Sets of helpers addressing the serialization and deserialization of environment texture
  132649. * stored in a BabylonJS env file.
  132650. * Those files are usually stored as .env files.
  132651. */
  132652. export class EnvironmentTextureTools {
  132653. /**
  132654. * Magic number identifying the env file.
  132655. */
  132656. private static _MagicBytes;
  132657. /**
  132658. * Gets the environment info from an env file.
  132659. * @param data The array buffer containing the .env bytes.
  132660. * @returns the environment file info (the json header) if successfully parsed.
  132661. */
  132662. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  132663. /**
  132664. * Creates an environment texture from a loaded cube texture.
  132665. * @param texture defines the cube texture to convert in env file
  132666. * @return a promise containing the environment data if succesfull.
  132667. */
  132668. static CreateEnvTextureAsync(texture: BaseTexture): Promise<ArrayBuffer>;
  132669. /**
  132670. * Creates a JSON representation of the spherical data.
  132671. * @param texture defines the texture containing the polynomials
  132672. * @return the JSON representation of the spherical info
  132673. */
  132674. private static _CreateEnvTextureIrradiance;
  132675. /**
  132676. * Creates the ArrayBufferViews used for initializing environment texture image data.
  132677. * @param data the image data
  132678. * @param info parameters that determine what views will be created for accessing the underlying buffer
  132679. * @return the views described by info providing access to the underlying buffer
  132680. */
  132681. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  132682. /**
  132683. * Uploads the texture info contained in the env file to the GPU.
  132684. * @param texture defines the internal texture to upload to
  132685. * @param data defines the data to load
  132686. * @param info defines the texture info retrieved through the GetEnvInfo method
  132687. * @returns a promise
  132688. */
  132689. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  132690. private static _OnImageReadyAsync;
  132691. /**
  132692. * Uploads the levels of image data to the GPU.
  132693. * @param texture defines the internal texture to upload to
  132694. * @param imageData defines the array buffer views of image data [mipmap][face]
  132695. * @returns a promise
  132696. */
  132697. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  132698. /**
  132699. * Uploads spherical polynomials information to the texture.
  132700. * @param texture defines the texture we are trying to upload the information to
  132701. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  132702. */
  132703. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  132704. /** @hidden */
  132705. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  132706. }
  132707. }
  132708. declare module BABYLON {
  132709. /**
  132710. * Class used to inline functions in shader code
  132711. */
  132712. export class ShaderCodeInliner {
  132713. private static readonly _RegexpFindFunctionNameAndType;
  132714. private _sourceCode;
  132715. private _functionDescr;
  132716. private _numMaxIterations;
  132717. /** Gets or sets the token used to mark the functions to inline */
  132718. inlineToken: string;
  132719. /** Gets or sets the debug mode */
  132720. debug: boolean;
  132721. /** Gets the code after the inlining process */
  132722. get code(): string;
  132723. /**
  132724. * Initializes the inliner
  132725. * @param sourceCode shader code source to inline
  132726. * @param numMaxIterations maximum number of iterations (used to detect recursive calls)
  132727. */
  132728. constructor(sourceCode: string, numMaxIterations?: number);
  132729. /**
  132730. * Start the processing of the shader code
  132731. */
  132732. processCode(): void;
  132733. private _collectFunctions;
  132734. private _processInlining;
  132735. private _extractBetweenMarkers;
  132736. private _skipWhitespaces;
  132737. private _removeComments;
  132738. private _replaceFunctionCallsByCode;
  132739. private _findBackward;
  132740. private _escapeRegExp;
  132741. private _replaceNames;
  132742. }
  132743. }
  132744. declare module BABYLON {
  132745. /**
  132746. * Container for accessors for natively-stored mesh data buffers.
  132747. */
  132748. class NativeDataBuffer extends DataBuffer {
  132749. /**
  132750. * Accessor value used to identify/retrieve a natively-stored index buffer.
  132751. */
  132752. nativeIndexBuffer?: any;
  132753. /**
  132754. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  132755. */
  132756. nativeVertexBuffer?: any;
  132757. }
  132758. /** @hidden */
  132759. class NativeTexture extends InternalTexture {
  132760. getInternalTexture(): InternalTexture;
  132761. getViewCount(): number;
  132762. }
  132763. /** @hidden */
  132764. export class NativeEngine extends Engine {
  132765. private readonly _native;
  132766. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  132767. private readonly INVALID_HANDLE;
  132768. private _boundBuffersVertexArray;
  132769. getHardwareScalingLevel(): number;
  132770. constructor();
  132771. dispose(): void;
  132772. /**
  132773. * Can be used to override the current requestAnimationFrame requester.
  132774. * @hidden
  132775. */
  132776. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  132777. /**
  132778. * Override default engine behavior.
  132779. * @param color
  132780. * @param backBuffer
  132781. * @param depth
  132782. * @param stencil
  132783. */
  132784. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  132785. /**
  132786. * Gets host document
  132787. * @returns the host document object
  132788. */
  132789. getHostDocument(): Nullable<Document>;
  132790. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  132791. createIndexBuffer(indices: IndicesArray, updateable?: boolean): NativeDataBuffer;
  132792. createVertexBuffer(data: DataArray, updateable?: boolean): NativeDataBuffer;
  132793. protected _recordVertexArrayObject(vertexArray: any, vertexBuffers: {
  132794. [key: string]: VertexBuffer;
  132795. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  132796. bindBuffers(vertexBuffers: {
  132797. [key: string]: VertexBuffer;
  132798. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  132799. recordVertexArrayObject(vertexBuffers: {
  132800. [key: string]: VertexBuffer;
  132801. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  132802. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  132803. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  132804. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  132805. /**
  132806. * Draw a list of indexed primitives
  132807. * @param fillMode defines the primitive to use
  132808. * @param indexStart defines the starting index
  132809. * @param indexCount defines the number of index to draw
  132810. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  132811. */
  132812. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  132813. /**
  132814. * Draw a list of unindexed primitives
  132815. * @param fillMode defines the primitive to use
  132816. * @param verticesStart defines the index of first vertex to draw
  132817. * @param verticesCount defines the count of vertices to draw
  132818. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  132819. */
  132820. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  132821. createPipelineContext(): IPipelineContext;
  132822. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  132823. /** @hidden */
  132824. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  132825. /** @hidden */
  132826. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  132827. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  132828. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  132829. protected _setProgram(program: WebGLProgram): void;
  132830. _releaseEffect(effect: Effect): void;
  132831. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  132832. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  132833. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  132834. bindSamplers(effect: Effect): void;
  132835. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  132836. getRenderWidth(useScreen?: boolean): number;
  132837. getRenderHeight(useScreen?: boolean): number;
  132838. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  132839. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  132840. /**
  132841. * Set the z offset to apply to current rendering
  132842. * @param value defines the offset to apply
  132843. */
  132844. setZOffset(value: number): void;
  132845. /**
  132846. * Gets the current value of the zOffset
  132847. * @returns the current zOffset state
  132848. */
  132849. getZOffset(): number;
  132850. /**
  132851. * Enable or disable depth buffering
  132852. * @param enable defines the state to set
  132853. */
  132854. setDepthBuffer(enable: boolean): void;
  132855. /**
  132856. * Gets a boolean indicating if depth writing is enabled
  132857. * @returns the current depth writing state
  132858. */
  132859. getDepthWrite(): boolean;
  132860. /**
  132861. * Enable or disable depth writing
  132862. * @param enable defines the state to set
  132863. */
  132864. setDepthWrite(enable: boolean): void;
  132865. /**
  132866. * Enable or disable color writing
  132867. * @param enable defines the state to set
  132868. */
  132869. setColorWrite(enable: boolean): void;
  132870. /**
  132871. * Gets a boolean indicating if color writing is enabled
  132872. * @returns the current color writing state
  132873. */
  132874. getColorWrite(): boolean;
  132875. /**
  132876. * Sets alpha constants used by some alpha blending modes
  132877. * @param r defines the red component
  132878. * @param g defines the green component
  132879. * @param b defines the blue component
  132880. * @param a defines the alpha component
  132881. */
  132882. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  132883. /**
  132884. * Sets the current alpha mode
  132885. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  132886. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  132887. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  132888. */
  132889. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  132890. /**
  132891. * Gets the current alpha mode
  132892. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  132893. * @returns the current alpha mode
  132894. */
  132895. getAlphaMode(): number;
  132896. setInt(uniform: WebGLUniformLocation, int: number): void;
  132897. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  132898. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  132899. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  132900. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  132901. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  132902. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  132903. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  132904. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  132905. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  132906. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  132907. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  132908. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  132909. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  132910. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  132911. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  132912. setFloat(uniform: WebGLUniformLocation, value: number): void;
  132913. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  132914. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  132915. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  132916. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  132917. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  132918. wipeCaches(bruteForce?: boolean): void;
  132919. _createTexture(): WebGLTexture;
  132920. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  132921. /**
  132922. * Usually called from Texture.ts.
  132923. * Passed information to create a WebGLTexture
  132924. * @param url defines a value which contains one of the following:
  132925. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  132926. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  132927. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  132928. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  132929. * @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)
  132930. * @param scene needed for loading to the correct scene
  132931. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  132932. * @param onLoad optional callback to be called upon successful completion
  132933. * @param onError optional callback to be called upon failure
  132934. * @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
  132935. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  132936. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  132937. * @param forcedExtension defines the extension to use to pick the right loader
  132938. * @param mimeType defines an optional mime type
  132939. * @returns a InternalTexture for assignment back into BABYLON.Texture
  132940. */
  132941. 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;
  132942. /**
  132943. * Creates a cube texture
  132944. * @param rootUrl defines the url where the files to load is located
  132945. * @param scene defines the current scene
  132946. * @param files defines the list of files to load (1 per face)
  132947. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  132948. * @param onLoad defines an optional callback raised when the texture is loaded
  132949. * @param onError defines an optional callback raised if there is an issue to load the texture
  132950. * @param format defines the format of the data
  132951. * @param forcedExtension defines the extension to use to pick the right loader
  132952. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  132953. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  132954. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  132955. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  132956. * @returns the cube texture as an InternalTexture
  132957. */
  132958. 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;
  132959. private _getSamplingFilter;
  132960. private static _GetNativeTextureFormat;
  132961. createRenderTargetTexture(size: number | {
  132962. width: number;
  132963. height: number;
  132964. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  132965. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  132966. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  132967. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  132968. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  132969. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  132970. /**
  132971. * Updates a dynamic vertex buffer.
  132972. * @param vertexBuffer the vertex buffer to update
  132973. * @param data the data used to update the vertex buffer
  132974. * @param byteOffset the byte offset of the data (optional)
  132975. * @param byteLength the byte length of the data (optional)
  132976. */
  132977. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  132978. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  132979. private _updateAnisotropicLevel;
  132980. private _getAddressMode;
  132981. /** @hidden */
  132982. _bindTexture(channel: number, texture: InternalTexture): void;
  132983. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  132984. releaseEffects(): void;
  132985. /** @hidden */
  132986. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  132987. /** @hidden */
  132988. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  132989. /** @hidden */
  132990. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  132991. /** @hidden */
  132992. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  132993. }
  132994. }
  132995. declare module BABYLON {
  132996. /**
  132997. * Gather the list of clipboard event types as constants.
  132998. */
  132999. export class ClipboardEventTypes {
  133000. /**
  133001. * The clipboard event is fired when a copy command is active (pressed).
  133002. */
  133003. static readonly COPY: number;
  133004. /**
  133005. * The clipboard event is fired when a cut command is active (pressed).
  133006. */
  133007. static readonly CUT: number;
  133008. /**
  133009. * The clipboard event is fired when a paste command is active (pressed).
  133010. */
  133011. static readonly PASTE: number;
  133012. }
  133013. /**
  133014. * This class is used to store clipboard related info for the onClipboardObservable event.
  133015. */
  133016. export class ClipboardInfo {
  133017. /**
  133018. * Defines the type of event (BABYLON.ClipboardEventTypes)
  133019. */
  133020. type: number;
  133021. /**
  133022. * Defines the related dom event
  133023. */
  133024. event: ClipboardEvent;
  133025. /**
  133026. *Creates an instance of ClipboardInfo.
  133027. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  133028. * @param event Defines the related dom event
  133029. */
  133030. constructor(
  133031. /**
  133032. * Defines the type of event (BABYLON.ClipboardEventTypes)
  133033. */
  133034. type: number,
  133035. /**
  133036. * Defines the related dom event
  133037. */
  133038. event: ClipboardEvent);
  133039. /**
  133040. * Get the clipboard event's type from the keycode.
  133041. * @param keyCode Defines the keyCode for the current keyboard event.
  133042. * @return {number}
  133043. */
  133044. static GetTypeFromCharacter(keyCode: number): number;
  133045. }
  133046. }
  133047. declare module BABYLON {
  133048. /**
  133049. * Google Daydream controller
  133050. */
  133051. export class DaydreamController extends WebVRController {
  133052. /**
  133053. * Base Url for the controller model.
  133054. */
  133055. static MODEL_BASE_URL: string;
  133056. /**
  133057. * File name for the controller model.
  133058. */
  133059. static MODEL_FILENAME: string;
  133060. /**
  133061. * Gamepad Id prefix used to identify Daydream Controller.
  133062. */
  133063. static readonly GAMEPAD_ID_PREFIX: string;
  133064. /**
  133065. * Creates a new DaydreamController from a gamepad
  133066. * @param vrGamepad the gamepad that the controller should be created from
  133067. */
  133068. constructor(vrGamepad: any);
  133069. /**
  133070. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  133071. * @param scene scene in which to add meshes
  133072. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  133073. */
  133074. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  133075. /**
  133076. * Called once for each button that changed state since the last frame
  133077. * @param buttonIdx Which button index changed
  133078. * @param state New state of the button
  133079. * @param changes Which properties on the state changed since last frame
  133080. */
  133081. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  133082. }
  133083. }
  133084. declare module BABYLON {
  133085. /**
  133086. * Gear VR Controller
  133087. */
  133088. export class GearVRController extends WebVRController {
  133089. /**
  133090. * Base Url for the controller model.
  133091. */
  133092. static MODEL_BASE_URL: string;
  133093. /**
  133094. * File name for the controller model.
  133095. */
  133096. static MODEL_FILENAME: string;
  133097. /**
  133098. * Gamepad Id prefix used to identify this controller.
  133099. */
  133100. static readonly GAMEPAD_ID_PREFIX: string;
  133101. private readonly _buttonIndexToObservableNameMap;
  133102. /**
  133103. * Creates a new GearVRController from a gamepad
  133104. * @param vrGamepad the gamepad that the controller should be created from
  133105. */
  133106. constructor(vrGamepad: any);
  133107. /**
  133108. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  133109. * @param scene scene in which to add meshes
  133110. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  133111. */
  133112. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  133113. /**
  133114. * Called once for each button that changed state since the last frame
  133115. * @param buttonIdx Which button index changed
  133116. * @param state New state of the button
  133117. * @param changes Which properties on the state changed since last frame
  133118. */
  133119. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  133120. }
  133121. }
  133122. declare module BABYLON {
  133123. /**
  133124. * Generic Controller
  133125. */
  133126. export class GenericController extends WebVRController {
  133127. /**
  133128. * Base Url for the controller model.
  133129. */
  133130. static readonly MODEL_BASE_URL: string;
  133131. /**
  133132. * File name for the controller model.
  133133. */
  133134. static readonly MODEL_FILENAME: string;
  133135. /**
  133136. * Creates a new GenericController from a gamepad
  133137. * @param vrGamepad the gamepad that the controller should be created from
  133138. */
  133139. constructor(vrGamepad: any);
  133140. /**
  133141. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  133142. * @param scene scene in which to add meshes
  133143. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  133144. */
  133145. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  133146. /**
  133147. * Called once for each button that changed state since the last frame
  133148. * @param buttonIdx Which button index changed
  133149. * @param state New state of the button
  133150. * @param changes Which properties on the state changed since last frame
  133151. */
  133152. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  133153. }
  133154. }
  133155. declare module BABYLON {
  133156. /**
  133157. * Oculus Touch Controller
  133158. */
  133159. export class OculusTouchController extends WebVRController {
  133160. /**
  133161. * Base Url for the controller model.
  133162. */
  133163. static MODEL_BASE_URL: string;
  133164. /**
  133165. * File name for the left controller model.
  133166. */
  133167. static MODEL_LEFT_FILENAME: string;
  133168. /**
  133169. * File name for the right controller model.
  133170. */
  133171. static MODEL_RIGHT_FILENAME: string;
  133172. /**
  133173. * Base Url for the Quest controller model.
  133174. */
  133175. static QUEST_MODEL_BASE_URL: string;
  133176. /**
  133177. * @hidden
  133178. * If the controllers are running on a device that needs the updated Quest controller models
  133179. */
  133180. static _IsQuest: boolean;
  133181. /**
  133182. * Fired when the secondary trigger on this controller is modified
  133183. */
  133184. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  133185. /**
  133186. * Fired when the thumb rest on this controller is modified
  133187. */
  133188. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  133189. /**
  133190. * Creates a new OculusTouchController from a gamepad
  133191. * @param vrGamepad the gamepad that the controller should be created from
  133192. */
  133193. constructor(vrGamepad: any);
  133194. /**
  133195. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  133196. * @param scene scene in which to add meshes
  133197. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  133198. */
  133199. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  133200. /**
  133201. * Fired when the A button on this controller is modified
  133202. */
  133203. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  133204. /**
  133205. * Fired when the B button on this controller is modified
  133206. */
  133207. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  133208. /**
  133209. * Fired when the X button on this controller is modified
  133210. */
  133211. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  133212. /**
  133213. * Fired when the Y button on this controller is modified
  133214. */
  133215. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  133216. /**
  133217. * Called once for each button that changed state since the last frame
  133218. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  133219. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  133220. * 2) secondary trigger (same)
  133221. * 3) A (right) X (left), touch, pressed = value
  133222. * 4) B / Y
  133223. * 5) thumb rest
  133224. * @param buttonIdx Which button index changed
  133225. * @param state New state of the button
  133226. * @param changes Which properties on the state changed since last frame
  133227. */
  133228. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  133229. }
  133230. }
  133231. declare module BABYLON {
  133232. /**
  133233. * Vive Controller
  133234. */
  133235. export class ViveController extends WebVRController {
  133236. /**
  133237. * Base Url for the controller model.
  133238. */
  133239. static MODEL_BASE_URL: string;
  133240. /**
  133241. * File name for the controller model.
  133242. */
  133243. static MODEL_FILENAME: string;
  133244. /**
  133245. * Creates a new ViveController from a gamepad
  133246. * @param vrGamepad the gamepad that the controller should be created from
  133247. */
  133248. constructor(vrGamepad: any);
  133249. /**
  133250. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  133251. * @param scene scene in which to add meshes
  133252. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  133253. */
  133254. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  133255. /**
  133256. * Fired when the left button on this controller is modified
  133257. */
  133258. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  133259. /**
  133260. * Fired when the right button on this controller is modified
  133261. */
  133262. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  133263. /**
  133264. * Fired when the menu button on this controller is modified
  133265. */
  133266. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  133267. /**
  133268. * Called once for each button that changed state since the last frame
  133269. * Vive mapping:
  133270. * 0: touchpad
  133271. * 1: trigger
  133272. * 2: left AND right buttons
  133273. * 3: menu button
  133274. * @param buttonIdx Which button index changed
  133275. * @param state New state of the button
  133276. * @param changes Which properties on the state changed since last frame
  133277. */
  133278. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  133279. }
  133280. }
  133281. declare module BABYLON {
  133282. /**
  133283. * Defines the WindowsMotionController object that the state of the windows motion controller
  133284. */
  133285. export class WindowsMotionController extends WebVRController {
  133286. /**
  133287. * The base url used to load the left and right controller models
  133288. */
  133289. static MODEL_BASE_URL: string;
  133290. /**
  133291. * The name of the left controller model file
  133292. */
  133293. static MODEL_LEFT_FILENAME: string;
  133294. /**
  133295. * The name of the right controller model file
  133296. */
  133297. static MODEL_RIGHT_FILENAME: string;
  133298. /**
  133299. * The controller name prefix for this controller type
  133300. */
  133301. static readonly GAMEPAD_ID_PREFIX: string;
  133302. /**
  133303. * The controller id pattern for this controller type
  133304. */
  133305. private static readonly GAMEPAD_ID_PATTERN;
  133306. private _loadedMeshInfo;
  133307. protected readonly _mapping: {
  133308. buttons: string[];
  133309. buttonMeshNames: {
  133310. trigger: string;
  133311. menu: string;
  133312. grip: string;
  133313. thumbstick: string;
  133314. trackpad: string;
  133315. };
  133316. buttonObservableNames: {
  133317. trigger: string;
  133318. menu: string;
  133319. grip: string;
  133320. thumbstick: string;
  133321. trackpad: string;
  133322. };
  133323. axisMeshNames: string[];
  133324. pointingPoseMeshName: string;
  133325. };
  133326. /**
  133327. * Fired when the trackpad on this controller is clicked
  133328. */
  133329. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  133330. /**
  133331. * Fired when the trackpad on this controller is modified
  133332. */
  133333. onTrackpadValuesChangedObservable: Observable<StickValues>;
  133334. /**
  133335. * The current x and y values of this controller's trackpad
  133336. */
  133337. trackpad: StickValues;
  133338. /**
  133339. * Creates a new WindowsMotionController from a gamepad
  133340. * @param vrGamepad the gamepad that the controller should be created from
  133341. */
  133342. constructor(vrGamepad: any);
  133343. /**
  133344. * Fired when the trigger on this controller is modified
  133345. */
  133346. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  133347. /**
  133348. * Fired when the menu button on this controller is modified
  133349. */
  133350. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  133351. /**
  133352. * Fired when the grip button on this controller is modified
  133353. */
  133354. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  133355. /**
  133356. * Fired when the thumbstick button on this controller is modified
  133357. */
  133358. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  133359. /**
  133360. * Fired when the touchpad button on this controller is modified
  133361. */
  133362. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  133363. /**
  133364. * Fired when the touchpad values on this controller are modified
  133365. */
  133366. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  133367. protected _updateTrackpad(): void;
  133368. /**
  133369. * Called once per frame by the engine.
  133370. */
  133371. update(): void;
  133372. /**
  133373. * Called once for each button that changed state since the last frame
  133374. * @param buttonIdx Which button index changed
  133375. * @param state New state of the button
  133376. * @param changes Which properties on the state changed since last frame
  133377. */
  133378. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  133379. /**
  133380. * Moves the buttons on the controller mesh based on their current state
  133381. * @param buttonName the name of the button to move
  133382. * @param buttonValue the value of the button which determines the buttons new position
  133383. */
  133384. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  133385. /**
  133386. * Moves the axis on the controller mesh based on its current state
  133387. * @param axis the index of the axis
  133388. * @param axisValue the value of the axis which determines the meshes new position
  133389. * @hidden
  133390. */
  133391. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  133392. /**
  133393. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  133394. * @param scene scene in which to add meshes
  133395. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  133396. */
  133397. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  133398. /**
  133399. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  133400. * can be transformed by button presses and axes values, based on this._mapping.
  133401. *
  133402. * @param scene scene in which the meshes exist
  133403. * @param meshes list of meshes that make up the controller model to process
  133404. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  133405. */
  133406. private processModel;
  133407. private createMeshInfo;
  133408. /**
  133409. * Gets the ray of the controller in the direction the controller is pointing
  133410. * @param length the length the resulting ray should be
  133411. * @returns a ray in the direction the controller is pointing
  133412. */
  133413. getForwardRay(length?: number): Ray;
  133414. /**
  133415. * Disposes of the controller
  133416. */
  133417. dispose(): void;
  133418. }
  133419. /**
  133420. * This class represents a new windows motion controller in XR.
  133421. */
  133422. export class XRWindowsMotionController extends WindowsMotionController {
  133423. /**
  133424. * Changing the original WIndowsMotionController mapping to fir the new mapping
  133425. */
  133426. protected readonly _mapping: {
  133427. buttons: string[];
  133428. buttonMeshNames: {
  133429. trigger: string;
  133430. menu: string;
  133431. grip: string;
  133432. thumbstick: string;
  133433. trackpad: string;
  133434. };
  133435. buttonObservableNames: {
  133436. trigger: string;
  133437. menu: string;
  133438. grip: string;
  133439. thumbstick: string;
  133440. trackpad: string;
  133441. };
  133442. axisMeshNames: string[];
  133443. pointingPoseMeshName: string;
  133444. };
  133445. /**
  133446. * Construct a new XR-Based windows motion controller
  133447. *
  133448. * @param gamepadInfo the gamepad object from the browser
  133449. */
  133450. constructor(gamepadInfo: any);
  133451. /**
  133452. * holds the thumbstick values (X,Y)
  133453. */
  133454. thumbstickValues: StickValues;
  133455. /**
  133456. * Fired when the thumbstick on this controller is clicked
  133457. */
  133458. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  133459. /**
  133460. * Fired when the thumbstick on this controller is modified
  133461. */
  133462. onThumbstickValuesChangedObservable: Observable<StickValues>;
  133463. /**
  133464. * Fired when the touchpad button on this controller is modified
  133465. */
  133466. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  133467. /**
  133468. * Fired when the touchpad values on this controller are modified
  133469. */
  133470. onTrackpadValuesChangedObservable: Observable<StickValues>;
  133471. /**
  133472. * Fired when the thumbstick button on this controller is modified
  133473. * here to prevent breaking changes
  133474. */
  133475. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  133476. /**
  133477. * updating the thumbstick(!) and not the trackpad.
  133478. * This is named this way due to the difference between WebVR and XR and to avoid
  133479. * changing the parent class.
  133480. */
  133481. protected _updateTrackpad(): void;
  133482. /**
  133483. * Disposes the class with joy
  133484. */
  133485. dispose(): void;
  133486. }
  133487. }
  133488. declare module BABYLON {
  133489. /**
  133490. * Class containing static functions to help procedurally build meshes
  133491. */
  133492. export class PolyhedronBuilder {
  133493. /**
  133494. * Creates a polyhedron mesh
  133495. * * 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
  133496. * * The parameter `size` (positive float, default 1) sets the polygon size
  133497. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  133498. * * 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`
  133499. * * 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
  133500. * * 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)`)
  133501. * * 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
  133502. * * 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
  133503. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  133504. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  133505. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  133506. * @param name defines the name of the mesh
  133507. * @param options defines the options used to create the mesh
  133508. * @param scene defines the hosting scene
  133509. * @returns the polyhedron mesh
  133510. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  133511. */
  133512. static CreatePolyhedron(name: string, options: {
  133513. type?: number;
  133514. size?: number;
  133515. sizeX?: number;
  133516. sizeY?: number;
  133517. sizeZ?: number;
  133518. custom?: any;
  133519. faceUV?: Vector4[];
  133520. faceColors?: Color4[];
  133521. flat?: boolean;
  133522. updatable?: boolean;
  133523. sideOrientation?: number;
  133524. frontUVs?: Vector4;
  133525. backUVs?: Vector4;
  133526. }, scene?: Nullable<Scene>): Mesh;
  133527. }
  133528. }
  133529. declare module BABYLON {
  133530. /**
  133531. * Gizmo that enables scaling a mesh along 3 axis
  133532. */
  133533. export class ScaleGizmo extends Gizmo {
  133534. /**
  133535. * Internal gizmo used for interactions on the x axis
  133536. */
  133537. xGizmo: AxisScaleGizmo;
  133538. /**
  133539. * Internal gizmo used for interactions on the y axis
  133540. */
  133541. yGizmo: AxisScaleGizmo;
  133542. /**
  133543. * Internal gizmo used for interactions on the z axis
  133544. */
  133545. zGizmo: AxisScaleGizmo;
  133546. /**
  133547. * Internal gizmo used to scale all axis equally
  133548. */
  133549. uniformScaleGizmo: AxisScaleGizmo;
  133550. private _meshAttached;
  133551. private _nodeAttached;
  133552. private _snapDistance;
  133553. private _uniformScalingMesh;
  133554. private _octahedron;
  133555. private _sensitivity;
  133556. /** Fires an event when any of it's sub gizmos are dragged */
  133557. onDragStartObservable: Observable<unknown>;
  133558. /** Fires an event when any of it's sub gizmos are released from dragging */
  133559. onDragEndObservable: Observable<unknown>;
  133560. get attachedMesh(): Nullable<AbstractMesh>;
  133561. set attachedMesh(mesh: Nullable<AbstractMesh>);
  133562. get attachedNode(): Nullable<Node>;
  133563. set attachedNode(node: Nullable<Node>);
  133564. /**
  133565. * Creates a ScaleGizmo
  133566. * @param gizmoLayer The utility layer the gizmo will be added to
  133567. * @param thickness display gizmo axis thickness
  133568. */
  133569. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number);
  133570. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  133571. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  133572. /**
  133573. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  133574. */
  133575. set snapDistance(value: number);
  133576. get snapDistance(): number;
  133577. /**
  133578. * Ratio for the scale of the gizmo (Default: 1)
  133579. */
  133580. set scaleRatio(value: number);
  133581. get scaleRatio(): number;
  133582. /**
  133583. * Sensitivity factor for dragging (Default: 1)
  133584. */
  133585. set sensitivity(value: number);
  133586. get sensitivity(): number;
  133587. /**
  133588. * Disposes of the gizmo
  133589. */
  133590. dispose(): void;
  133591. }
  133592. }
  133593. declare module BABYLON {
  133594. /**
  133595. * Single axis scale gizmo
  133596. */
  133597. export class AxisScaleGizmo extends Gizmo {
  133598. /**
  133599. * Drag behavior responsible for the gizmos dragging interactions
  133600. */
  133601. dragBehavior: PointerDragBehavior;
  133602. private _pointerObserver;
  133603. /**
  133604. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  133605. */
  133606. snapDistance: number;
  133607. /**
  133608. * Event that fires each time the gizmo snaps to a new location.
  133609. * * snapDistance is the the change in distance
  133610. */
  133611. onSnapObservable: Observable<{
  133612. snapDistance: number;
  133613. }>;
  133614. /**
  133615. * If the scaling operation should be done on all axis (default: false)
  133616. */
  133617. uniformScaling: boolean;
  133618. /**
  133619. * Custom sensitivity value for the drag strength
  133620. */
  133621. sensitivity: number;
  133622. private _isEnabled;
  133623. private _parent;
  133624. private _arrow;
  133625. private _coloredMaterial;
  133626. private _hoverMaterial;
  133627. /**
  133628. * Creates an AxisScaleGizmo
  133629. * @param gizmoLayer The utility layer the gizmo will be added to
  133630. * @param dragAxis The axis which the gizmo will be able to scale on
  133631. * @param color The color of the gizmo
  133632. * @param thickness display gizmo axis thickness
  133633. */
  133634. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>, thickness?: number);
  133635. protected _attachedNodeChanged(value: Nullable<Node>): void;
  133636. /**
  133637. * If the gizmo is enabled
  133638. */
  133639. set isEnabled(value: boolean);
  133640. get isEnabled(): boolean;
  133641. /**
  133642. * Disposes of the gizmo
  133643. */
  133644. dispose(): void;
  133645. /**
  133646. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  133647. * @param mesh The mesh to replace the default mesh of the gizmo
  133648. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  133649. */
  133650. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  133651. }
  133652. }
  133653. declare module BABYLON {
  133654. /**
  133655. * Bounding box gizmo
  133656. */
  133657. export class BoundingBoxGizmo extends Gizmo {
  133658. private _lineBoundingBox;
  133659. private _rotateSpheresParent;
  133660. private _scaleBoxesParent;
  133661. private _boundingDimensions;
  133662. private _renderObserver;
  133663. private _pointerObserver;
  133664. private _scaleDragSpeed;
  133665. private _tmpQuaternion;
  133666. private _tmpVector;
  133667. private _tmpRotationMatrix;
  133668. /**
  133669. * 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)
  133670. */
  133671. ignoreChildren: boolean;
  133672. /**
  133673. * 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)
  133674. */
  133675. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  133676. /**
  133677. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  133678. */
  133679. rotationSphereSize: number;
  133680. /**
  133681. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  133682. */
  133683. scaleBoxSize: number;
  133684. /**
  133685. * 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)
  133686. */
  133687. fixedDragMeshScreenSize: boolean;
  133688. /**
  133689. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  133690. */
  133691. fixedDragMeshScreenSizeDistanceFactor: number;
  133692. /**
  133693. * Fired when a rotation sphere or scale box is dragged
  133694. */
  133695. onDragStartObservable: Observable<{}>;
  133696. /**
  133697. * Fired when a scale box is dragged
  133698. */
  133699. onScaleBoxDragObservable: Observable<{}>;
  133700. /**
  133701. * Fired when a scale box drag is ended
  133702. */
  133703. onScaleBoxDragEndObservable: Observable<{}>;
  133704. /**
  133705. * Fired when a rotation sphere is dragged
  133706. */
  133707. onRotationSphereDragObservable: Observable<{}>;
  133708. /**
  133709. * Fired when a rotation sphere drag is ended
  133710. */
  133711. onRotationSphereDragEndObservable: Observable<{}>;
  133712. /**
  133713. * 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)
  133714. */
  133715. scalePivot: Nullable<Vector3>;
  133716. /**
  133717. * Mesh used as a pivot to rotate the attached node
  133718. */
  133719. private _anchorMesh;
  133720. private _existingMeshScale;
  133721. private _dragMesh;
  133722. private pointerDragBehavior;
  133723. private coloredMaterial;
  133724. private hoverColoredMaterial;
  133725. /**
  133726. * Sets the color of the bounding box gizmo
  133727. * @param color the color to set
  133728. */
  133729. setColor(color: Color3): void;
  133730. /**
  133731. * Creates an BoundingBoxGizmo
  133732. * @param gizmoLayer The utility layer the gizmo will be added to
  133733. * @param color The color of the gizmo
  133734. */
  133735. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  133736. protected _attachedNodeChanged(value: Nullable<AbstractMesh>): void;
  133737. private _selectNode;
  133738. /**
  133739. * Updates the bounding box information for the Gizmo
  133740. */
  133741. updateBoundingBox(): void;
  133742. private _updateRotationSpheres;
  133743. private _updateScaleBoxes;
  133744. /**
  133745. * Enables rotation on the specified axis and disables rotation on the others
  133746. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  133747. */
  133748. setEnabledRotationAxis(axis: string): void;
  133749. /**
  133750. * Enables/disables scaling
  133751. * @param enable if scaling should be enabled
  133752. * @param homogeneousScaling defines if scaling should only be homogeneous
  133753. */
  133754. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  133755. private _updateDummy;
  133756. /**
  133757. * Enables a pointer drag behavior on the bounding box of the gizmo
  133758. */
  133759. enableDragBehavior(): void;
  133760. /**
  133761. * Disposes of the gizmo
  133762. */
  133763. dispose(): void;
  133764. /**
  133765. * 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)
  133766. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  133767. * @returns the bounding box mesh with the passed in mesh as a child
  133768. */
  133769. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  133770. /**
  133771. * CustomMeshes are not supported by this gizmo
  133772. * @param mesh The mesh to replace the default mesh of the gizmo
  133773. */
  133774. setCustomMesh(mesh: Mesh): void;
  133775. }
  133776. }
  133777. declare module BABYLON {
  133778. /**
  133779. * Single plane rotation gizmo
  133780. */
  133781. export class PlaneRotationGizmo extends Gizmo {
  133782. /**
  133783. * Drag behavior responsible for the gizmos dragging interactions
  133784. */
  133785. dragBehavior: PointerDragBehavior;
  133786. private _pointerObserver;
  133787. /**
  133788. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  133789. */
  133790. snapDistance: number;
  133791. /**
  133792. * Event that fires each time the gizmo snaps to a new location.
  133793. * * snapDistance is the the change in distance
  133794. */
  133795. onSnapObservable: Observable<{
  133796. snapDistance: number;
  133797. }>;
  133798. private _isEnabled;
  133799. private _parent;
  133800. /**
  133801. * Creates a PlaneRotationGizmo
  133802. * @param gizmoLayer The utility layer the gizmo will be added to
  133803. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  133804. * @param color The color of the gizmo
  133805. * @param tessellation Amount of tessellation to be used when creating rotation circles
  133806. * @param useEulerRotation Use and update Euler angle instead of quaternion
  133807. * @param thickness display gizmo axis thickness
  133808. */
  133809. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean, thickness?: number);
  133810. protected _attachedNodeChanged(value: Nullable<Node>): void;
  133811. /**
  133812. * If the gizmo is enabled
  133813. */
  133814. set isEnabled(value: boolean);
  133815. get isEnabled(): boolean;
  133816. /**
  133817. * Disposes of the gizmo
  133818. */
  133819. dispose(): void;
  133820. }
  133821. }
  133822. declare module BABYLON {
  133823. /**
  133824. * Gizmo that enables rotating a mesh along 3 axis
  133825. */
  133826. export class RotationGizmo extends Gizmo {
  133827. /**
  133828. * Internal gizmo used for interactions on the x axis
  133829. */
  133830. xGizmo: PlaneRotationGizmo;
  133831. /**
  133832. * Internal gizmo used for interactions on the y axis
  133833. */
  133834. yGizmo: PlaneRotationGizmo;
  133835. /**
  133836. * Internal gizmo used for interactions on the z axis
  133837. */
  133838. zGizmo: PlaneRotationGizmo;
  133839. /** Fires an event when any of it's sub gizmos are dragged */
  133840. onDragStartObservable: Observable<unknown>;
  133841. /** Fires an event when any of it's sub gizmos are released from dragging */
  133842. onDragEndObservable: Observable<unknown>;
  133843. private _meshAttached;
  133844. private _nodeAttached;
  133845. get attachedMesh(): Nullable<AbstractMesh>;
  133846. set attachedMesh(mesh: Nullable<AbstractMesh>);
  133847. get attachedNode(): Nullable<Node>;
  133848. set attachedNode(node: Nullable<Node>);
  133849. /**
  133850. * Creates a RotationGizmo
  133851. * @param gizmoLayer The utility layer the gizmo will be added to
  133852. * @param tessellation Amount of tessellation to be used when creating rotation circles
  133853. * @param useEulerRotation Use and update Euler angle instead of quaternion
  133854. * @param thickness display gizmo axis thickness
  133855. */
  133856. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean, thickness?: number);
  133857. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  133858. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  133859. /**
  133860. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  133861. */
  133862. set snapDistance(value: number);
  133863. get snapDistance(): number;
  133864. /**
  133865. * Ratio for the scale of the gizmo (Default: 1)
  133866. */
  133867. set scaleRatio(value: number);
  133868. get scaleRatio(): number;
  133869. /**
  133870. * Disposes of the gizmo
  133871. */
  133872. dispose(): void;
  133873. /**
  133874. * CustomMeshes are not supported by this gizmo
  133875. * @param mesh The mesh to replace the default mesh of the gizmo
  133876. */
  133877. setCustomMesh(mesh: Mesh): void;
  133878. }
  133879. }
  133880. declare module BABYLON {
  133881. /**
  133882. * Helps setup gizmo's in the scene to rotate/scale/position nodes
  133883. */
  133884. export class GizmoManager implements IDisposable {
  133885. private scene;
  133886. /**
  133887. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  133888. */
  133889. gizmos: {
  133890. positionGizmo: Nullable<PositionGizmo>;
  133891. rotationGizmo: Nullable<RotationGizmo>;
  133892. scaleGizmo: Nullable<ScaleGizmo>;
  133893. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  133894. };
  133895. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  133896. clearGizmoOnEmptyPointerEvent: boolean;
  133897. /** Fires an event when the manager is attached to a mesh */
  133898. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  133899. /** Fires an event when the manager is attached to a node */
  133900. onAttachedToNodeObservable: Observable<Nullable<Node>>;
  133901. private _gizmosEnabled;
  133902. private _pointerObserver;
  133903. private _attachedMesh;
  133904. private _attachedNode;
  133905. private _boundingBoxColor;
  133906. private _defaultUtilityLayer;
  133907. private _defaultKeepDepthUtilityLayer;
  133908. private _thickness;
  133909. /**
  133910. * When bounding box gizmo is enabled, this can be used to track drag/end events
  133911. */
  133912. boundingBoxDragBehavior: SixDofDragBehavior;
  133913. /**
  133914. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  133915. */
  133916. attachableMeshes: Nullable<Array<AbstractMesh>>;
  133917. /**
  133918. * Array of nodes which will have the gizmo attached when a pointer selected them. If null, all nodes are attachable. (Default: null)
  133919. */
  133920. attachableNodes: Nullable<Array<Node>>;
  133921. /**
  133922. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh/attachToNode. (Default: true)
  133923. */
  133924. usePointerToAttachGizmos: boolean;
  133925. /**
  133926. * Utility layer that the bounding box gizmo belongs to
  133927. */
  133928. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  133929. /**
  133930. * Utility layer that all gizmos besides bounding box belong to
  133931. */
  133932. get utilityLayer(): UtilityLayerRenderer;
  133933. /**
  133934. * Instatiates a gizmo manager
  133935. * @param scene the scene to overlay the gizmos on top of
  133936. * @param thickness display gizmo axis thickness
  133937. */
  133938. constructor(scene: Scene, thickness?: number);
  133939. /**
  133940. * Attaches a set of gizmos to the specified mesh
  133941. * @param mesh The mesh the gizmo's should be attached to
  133942. */
  133943. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  133944. /**
  133945. * Attaches a set of gizmos to the specified node
  133946. * @param node The node the gizmo's should be attached to
  133947. */
  133948. attachToNode(node: Nullable<Node>): void;
  133949. /**
  133950. * If the position gizmo is enabled
  133951. */
  133952. set positionGizmoEnabled(value: boolean);
  133953. get positionGizmoEnabled(): boolean;
  133954. /**
  133955. * If the rotation gizmo is enabled
  133956. */
  133957. set rotationGizmoEnabled(value: boolean);
  133958. get rotationGizmoEnabled(): boolean;
  133959. /**
  133960. * If the scale gizmo is enabled
  133961. */
  133962. set scaleGizmoEnabled(value: boolean);
  133963. get scaleGizmoEnabled(): boolean;
  133964. /**
  133965. * If the boundingBox gizmo is enabled
  133966. */
  133967. set boundingBoxGizmoEnabled(value: boolean);
  133968. get boundingBoxGizmoEnabled(): boolean;
  133969. /**
  133970. * Disposes of the gizmo manager
  133971. */
  133972. dispose(): void;
  133973. }
  133974. }
  133975. declare module BABYLON {
  133976. /**
  133977. * A directional light is defined by a direction (what a surprise!).
  133978. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  133979. * 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.
  133980. * Documentation: https://doc.babylonjs.com/babylon101/lights
  133981. */
  133982. export class DirectionalLight extends ShadowLight {
  133983. private _shadowFrustumSize;
  133984. /**
  133985. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  133986. */
  133987. get shadowFrustumSize(): number;
  133988. /**
  133989. * Specifies a fix frustum size for the shadow generation.
  133990. */
  133991. set shadowFrustumSize(value: number);
  133992. private _shadowOrthoScale;
  133993. /**
  133994. * Gets the shadow projection scale against the optimal computed one.
  133995. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  133996. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  133997. */
  133998. get shadowOrthoScale(): number;
  133999. /**
  134000. * Sets the shadow projection scale against the optimal computed one.
  134001. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  134002. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  134003. */
  134004. set shadowOrthoScale(value: number);
  134005. /**
  134006. * Automatically compute the projection matrix to best fit (including all the casters)
  134007. * on each frame.
  134008. */
  134009. autoUpdateExtends: boolean;
  134010. /**
  134011. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  134012. * on each frame. autoUpdateExtends must be set to true for this to work
  134013. */
  134014. autoCalcShadowZBounds: boolean;
  134015. private _orthoLeft;
  134016. private _orthoRight;
  134017. private _orthoTop;
  134018. private _orthoBottom;
  134019. /**
  134020. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  134021. * The directional light is emitted from everywhere in the given direction.
  134022. * It can cast shadows.
  134023. * Documentation : https://doc.babylonjs.com/babylon101/lights
  134024. * @param name The friendly name of the light
  134025. * @param direction The direction of the light
  134026. * @param scene The scene the light belongs to
  134027. */
  134028. constructor(name: string, direction: Vector3, scene: Scene);
  134029. /**
  134030. * Returns the string "DirectionalLight".
  134031. * @return The class name
  134032. */
  134033. getClassName(): string;
  134034. /**
  134035. * Returns the integer 1.
  134036. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  134037. */
  134038. getTypeID(): number;
  134039. /**
  134040. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  134041. * Returns the DirectionalLight Shadow projection matrix.
  134042. */
  134043. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  134044. /**
  134045. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  134046. * Returns the DirectionalLight Shadow projection matrix.
  134047. */
  134048. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  134049. /**
  134050. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  134051. * Returns the DirectionalLight Shadow projection matrix.
  134052. */
  134053. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  134054. protected _buildUniformLayout(): void;
  134055. /**
  134056. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  134057. * @param effect The effect to update
  134058. * @param lightIndex The index of the light in the effect to update
  134059. * @returns The directional light
  134060. */
  134061. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  134062. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  134063. /**
  134064. * Gets the minZ used for shadow according to both the scene and the light.
  134065. *
  134066. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  134067. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  134068. * @param activeCamera The camera we are returning the min for
  134069. * @returns the depth min z
  134070. */
  134071. getDepthMinZ(activeCamera: Camera): number;
  134072. /**
  134073. * Gets the maxZ used for shadow according to both the scene and the light.
  134074. *
  134075. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  134076. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  134077. * @param activeCamera The camera we are returning the max for
  134078. * @returns the depth max z
  134079. */
  134080. getDepthMaxZ(activeCamera: Camera): number;
  134081. /**
  134082. * Prepares the list of defines specific to the light type.
  134083. * @param defines the list of defines
  134084. * @param lightIndex defines the index of the light for the effect
  134085. */
  134086. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  134087. }
  134088. }
  134089. declare module BABYLON {
  134090. /**
  134091. * Class containing static functions to help procedurally build meshes
  134092. */
  134093. export class HemisphereBuilder {
  134094. /**
  134095. * Creates a hemisphere mesh
  134096. * @param name defines the name of the mesh
  134097. * @param options defines the options used to create the mesh
  134098. * @param scene defines the hosting scene
  134099. * @returns the hemisphere mesh
  134100. */
  134101. static CreateHemisphere(name: string, options: {
  134102. segments?: number;
  134103. diameter?: number;
  134104. sideOrientation?: number;
  134105. }, scene: any): Mesh;
  134106. }
  134107. }
  134108. declare module BABYLON {
  134109. /**
  134110. * A spot light is defined by a position, a direction, an angle, and an exponent.
  134111. * These values define a cone of light starting from the position, emitting toward the direction.
  134112. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  134113. * and the exponent defines the speed of the decay of the light with distance (reach).
  134114. * Documentation: https://doc.babylonjs.com/babylon101/lights
  134115. */
  134116. export class SpotLight extends ShadowLight {
  134117. private _angle;
  134118. private _innerAngle;
  134119. private _cosHalfAngle;
  134120. private _lightAngleScale;
  134121. private _lightAngleOffset;
  134122. /**
  134123. * Gets the cone angle of the spot light in Radians.
  134124. */
  134125. get angle(): number;
  134126. /**
  134127. * Sets the cone angle of the spot light in Radians.
  134128. */
  134129. set angle(value: number);
  134130. /**
  134131. * Only used in gltf falloff mode, this defines the angle where
  134132. * the directional falloff will start before cutting at angle which could be seen
  134133. * as outer angle.
  134134. */
  134135. get innerAngle(): number;
  134136. /**
  134137. * Only used in gltf falloff mode, this defines the angle where
  134138. * the directional falloff will start before cutting at angle which could be seen
  134139. * as outer angle.
  134140. */
  134141. set innerAngle(value: number);
  134142. private _shadowAngleScale;
  134143. /**
  134144. * Allows scaling the angle of the light for shadow generation only.
  134145. */
  134146. get shadowAngleScale(): number;
  134147. /**
  134148. * Allows scaling the angle of the light for shadow generation only.
  134149. */
  134150. set shadowAngleScale(value: number);
  134151. /**
  134152. * The light decay speed with the distance from the emission spot.
  134153. */
  134154. exponent: number;
  134155. private _projectionTextureMatrix;
  134156. /**
  134157. * Allows reading the projecton texture
  134158. */
  134159. get projectionTextureMatrix(): Matrix;
  134160. protected _projectionTextureLightNear: number;
  134161. /**
  134162. * Gets the near clip of the Spotlight for texture projection.
  134163. */
  134164. get projectionTextureLightNear(): number;
  134165. /**
  134166. * Sets the near clip of the Spotlight for texture projection.
  134167. */
  134168. set projectionTextureLightNear(value: number);
  134169. protected _projectionTextureLightFar: number;
  134170. /**
  134171. * Gets the far clip of the Spotlight for texture projection.
  134172. */
  134173. get projectionTextureLightFar(): number;
  134174. /**
  134175. * Sets the far clip of the Spotlight for texture projection.
  134176. */
  134177. set projectionTextureLightFar(value: number);
  134178. protected _projectionTextureUpDirection: Vector3;
  134179. /**
  134180. * Gets the Up vector of the Spotlight for texture projection.
  134181. */
  134182. get projectionTextureUpDirection(): Vector3;
  134183. /**
  134184. * Sets the Up vector of the Spotlight for texture projection.
  134185. */
  134186. set projectionTextureUpDirection(value: Vector3);
  134187. private _projectionTexture;
  134188. /**
  134189. * Gets the projection texture of the light.
  134190. */
  134191. get projectionTexture(): Nullable<BaseTexture>;
  134192. /**
  134193. * Sets the projection texture of the light.
  134194. */
  134195. set projectionTexture(value: Nullable<BaseTexture>);
  134196. private _projectionTextureViewLightDirty;
  134197. private _projectionTextureProjectionLightDirty;
  134198. private _projectionTextureDirty;
  134199. private _projectionTextureViewTargetVector;
  134200. private _projectionTextureViewLightMatrix;
  134201. private _projectionTextureProjectionLightMatrix;
  134202. private _projectionTextureScalingMatrix;
  134203. /**
  134204. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  134205. * It can cast shadows.
  134206. * Documentation : https://doc.babylonjs.com/babylon101/lights
  134207. * @param name The light friendly name
  134208. * @param position The position of the spot light in the scene
  134209. * @param direction The direction of the light in the scene
  134210. * @param angle The cone angle of the light in Radians
  134211. * @param exponent The light decay speed with the distance from the emission spot
  134212. * @param scene The scene the lights belongs to
  134213. */
  134214. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  134215. /**
  134216. * Returns the string "SpotLight".
  134217. * @returns the class name
  134218. */
  134219. getClassName(): string;
  134220. /**
  134221. * Returns the integer 2.
  134222. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  134223. */
  134224. getTypeID(): number;
  134225. /**
  134226. * Overrides the direction setter to recompute the projection texture view light Matrix.
  134227. */
  134228. protected _setDirection(value: Vector3): void;
  134229. /**
  134230. * Overrides the position setter to recompute the projection texture view light Matrix.
  134231. */
  134232. protected _setPosition(value: Vector3): void;
  134233. /**
  134234. * 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.
  134235. * Returns the SpotLight.
  134236. */
  134237. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  134238. protected _computeProjectionTextureViewLightMatrix(): void;
  134239. protected _computeProjectionTextureProjectionLightMatrix(): void;
  134240. /**
  134241. * Main function for light texture projection matrix computing.
  134242. */
  134243. protected _computeProjectionTextureMatrix(): void;
  134244. protected _buildUniformLayout(): void;
  134245. private _computeAngleValues;
  134246. /**
  134247. * Sets the passed Effect "effect" with the Light textures.
  134248. * @param effect The effect to update
  134249. * @param lightIndex The index of the light in the effect to update
  134250. * @returns The light
  134251. */
  134252. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  134253. /**
  134254. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  134255. * @param effect The effect to update
  134256. * @param lightIndex The index of the light in the effect to update
  134257. * @returns The spot light
  134258. */
  134259. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  134260. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  134261. /**
  134262. * Disposes the light and the associated resources.
  134263. */
  134264. dispose(): void;
  134265. /**
  134266. * Prepares the list of defines specific to the light type.
  134267. * @param defines the list of defines
  134268. * @param lightIndex defines the index of the light for the effect
  134269. */
  134270. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  134271. }
  134272. }
  134273. declare module BABYLON {
  134274. /**
  134275. * Gizmo that enables viewing a light
  134276. */
  134277. export class LightGizmo extends Gizmo {
  134278. private _lightMesh;
  134279. private _material;
  134280. private _cachedPosition;
  134281. private _cachedForward;
  134282. private _attachedMeshParent;
  134283. private _pointerObserver;
  134284. /**
  134285. * Event that fires each time the gizmo is clicked
  134286. */
  134287. onClickedObservable: Observable<Light>;
  134288. /**
  134289. * Creates a LightGizmo
  134290. * @param gizmoLayer The utility layer the gizmo will be added to
  134291. */
  134292. constructor(gizmoLayer?: UtilityLayerRenderer);
  134293. private _light;
  134294. /**
  134295. * The light that the gizmo is attached to
  134296. */
  134297. set light(light: Nullable<Light>);
  134298. get light(): Nullable<Light>;
  134299. /**
  134300. * Gets the material used to render the light gizmo
  134301. */
  134302. get material(): StandardMaterial;
  134303. /**
  134304. * @hidden
  134305. * Updates the gizmo to match the attached mesh's position/rotation
  134306. */
  134307. protected _update(): void;
  134308. private static _Scale;
  134309. /**
  134310. * Creates the lines for a light mesh
  134311. */
  134312. private static _CreateLightLines;
  134313. /**
  134314. * Disposes of the light gizmo
  134315. */
  134316. dispose(): void;
  134317. private static _CreateHemisphericLightMesh;
  134318. private static _CreatePointLightMesh;
  134319. private static _CreateSpotLightMesh;
  134320. private static _CreateDirectionalLightMesh;
  134321. }
  134322. }
  134323. declare module BABYLON {
  134324. /**
  134325. * Gizmo that enables viewing a camera
  134326. */
  134327. export class CameraGizmo extends Gizmo {
  134328. private _cameraMesh;
  134329. private _cameraLinesMesh;
  134330. private _material;
  134331. private _pointerObserver;
  134332. /**
  134333. * Event that fires each time the gizmo is clicked
  134334. */
  134335. onClickedObservable: Observable<Camera>;
  134336. /**
  134337. * Creates a CameraGizmo
  134338. * @param gizmoLayer The utility layer the gizmo will be added to
  134339. */
  134340. constructor(gizmoLayer?: UtilityLayerRenderer);
  134341. private _camera;
  134342. /** Gets or sets a boolean indicating if frustum lines must be rendered (true by default)) */
  134343. get displayFrustum(): boolean;
  134344. set displayFrustum(value: boolean);
  134345. /**
  134346. * The camera that the gizmo is attached to
  134347. */
  134348. set camera(camera: Nullable<Camera>);
  134349. get camera(): Nullable<Camera>;
  134350. /**
  134351. * Gets the material used to render the camera gizmo
  134352. */
  134353. get material(): StandardMaterial;
  134354. /**
  134355. * @hidden
  134356. * Updates the gizmo to match the attached mesh's position/rotation
  134357. */
  134358. protected _update(): void;
  134359. private static _Scale;
  134360. private _invProjection;
  134361. /**
  134362. * Disposes of the camera gizmo
  134363. */
  134364. dispose(): void;
  134365. private static _CreateCameraMesh;
  134366. private static _CreateCameraFrustum;
  134367. }
  134368. }
  134369. declare module BABYLON {
  134370. /** @hidden */
  134371. export var backgroundFragmentDeclaration: {
  134372. name: string;
  134373. shader: string;
  134374. };
  134375. }
  134376. declare module BABYLON {
  134377. /** @hidden */
  134378. export var backgroundUboDeclaration: {
  134379. name: string;
  134380. shader: string;
  134381. };
  134382. }
  134383. declare module BABYLON {
  134384. /** @hidden */
  134385. export var backgroundPixelShader: {
  134386. name: string;
  134387. shader: string;
  134388. };
  134389. }
  134390. declare module BABYLON {
  134391. /** @hidden */
  134392. export var backgroundVertexDeclaration: {
  134393. name: string;
  134394. shader: string;
  134395. };
  134396. }
  134397. declare module BABYLON {
  134398. /** @hidden */
  134399. export var backgroundVertexShader: {
  134400. name: string;
  134401. shader: string;
  134402. };
  134403. }
  134404. declare module BABYLON {
  134405. /**
  134406. * Background material used to create an efficient environement around your scene.
  134407. */
  134408. export class BackgroundMaterial extends PushMaterial {
  134409. /**
  134410. * Standard reflectance value at parallel view angle.
  134411. */
  134412. static StandardReflectance0: number;
  134413. /**
  134414. * Standard reflectance value at grazing angle.
  134415. */
  134416. static StandardReflectance90: number;
  134417. protected _primaryColor: Color3;
  134418. /**
  134419. * Key light Color (multiply against the environement texture)
  134420. */
  134421. primaryColor: Color3;
  134422. protected __perceptualColor: Nullable<Color3>;
  134423. /**
  134424. * Experimental Internal Use Only.
  134425. *
  134426. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  134427. * This acts as a helper to set the primary color to a more "human friendly" value.
  134428. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  134429. * output color as close as possible from the chosen value.
  134430. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  134431. * part of lighting setup.)
  134432. */
  134433. get _perceptualColor(): Nullable<Color3>;
  134434. set _perceptualColor(value: Nullable<Color3>);
  134435. protected _primaryColorShadowLevel: float;
  134436. /**
  134437. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  134438. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  134439. */
  134440. get primaryColorShadowLevel(): float;
  134441. set primaryColorShadowLevel(value: float);
  134442. protected _primaryColorHighlightLevel: float;
  134443. /**
  134444. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  134445. * The primary color is used at the level chosen to define what the white area would look.
  134446. */
  134447. get primaryColorHighlightLevel(): float;
  134448. set primaryColorHighlightLevel(value: float);
  134449. protected _reflectionTexture: Nullable<BaseTexture>;
  134450. /**
  134451. * Reflection Texture used in the material.
  134452. * Should be author in a specific way for the best result (refer to the documentation).
  134453. */
  134454. reflectionTexture: Nullable<BaseTexture>;
  134455. protected _reflectionBlur: float;
  134456. /**
  134457. * Reflection Texture level of blur.
  134458. *
  134459. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  134460. * texture twice.
  134461. */
  134462. reflectionBlur: float;
  134463. protected _diffuseTexture: Nullable<BaseTexture>;
  134464. /**
  134465. * Diffuse Texture used in the material.
  134466. * Should be author in a specific way for the best result (refer to the documentation).
  134467. */
  134468. diffuseTexture: Nullable<BaseTexture>;
  134469. protected _shadowLights: Nullable<IShadowLight[]>;
  134470. /**
  134471. * Specify the list of lights casting shadow on the material.
  134472. * All scene shadow lights will be included if null.
  134473. */
  134474. shadowLights: Nullable<IShadowLight[]>;
  134475. protected _shadowLevel: float;
  134476. /**
  134477. * Helps adjusting the shadow to a softer level if required.
  134478. * 0 means black shadows and 1 means no shadows.
  134479. */
  134480. shadowLevel: float;
  134481. protected _sceneCenter: Vector3;
  134482. /**
  134483. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  134484. * It is usually zero but might be interesting to modify according to your setup.
  134485. */
  134486. sceneCenter: Vector3;
  134487. protected _opacityFresnel: boolean;
  134488. /**
  134489. * This helps specifying that the material is falling off to the sky box at grazing angle.
  134490. * This helps ensuring a nice transition when the camera goes under the ground.
  134491. */
  134492. opacityFresnel: boolean;
  134493. protected _reflectionFresnel: boolean;
  134494. /**
  134495. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  134496. * This helps adding a mirror texture on the ground.
  134497. */
  134498. reflectionFresnel: boolean;
  134499. protected _reflectionFalloffDistance: number;
  134500. /**
  134501. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  134502. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  134503. */
  134504. reflectionFalloffDistance: number;
  134505. protected _reflectionAmount: number;
  134506. /**
  134507. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  134508. */
  134509. reflectionAmount: number;
  134510. protected _reflectionReflectance0: number;
  134511. /**
  134512. * This specifies the weight of the reflection at grazing angle.
  134513. */
  134514. reflectionReflectance0: number;
  134515. protected _reflectionReflectance90: number;
  134516. /**
  134517. * This specifies the weight of the reflection at a perpendicular point of view.
  134518. */
  134519. reflectionReflectance90: number;
  134520. /**
  134521. * Sets the reflection reflectance fresnel values according to the default standard
  134522. * empirically know to work well :-)
  134523. */
  134524. set reflectionStandardFresnelWeight(value: number);
  134525. protected _useRGBColor: boolean;
  134526. /**
  134527. * Helps to directly use the maps channels instead of their level.
  134528. */
  134529. useRGBColor: boolean;
  134530. protected _enableNoise: boolean;
  134531. /**
  134532. * This helps reducing the banding effect that could occur on the background.
  134533. */
  134534. enableNoise: boolean;
  134535. /**
  134536. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  134537. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  134538. * Recommended to be keep at 1.0 except for special cases.
  134539. */
  134540. get fovMultiplier(): number;
  134541. set fovMultiplier(value: number);
  134542. private _fovMultiplier;
  134543. /**
  134544. * Enable the FOV adjustment feature controlled by fovMultiplier.
  134545. */
  134546. useEquirectangularFOV: boolean;
  134547. private _maxSimultaneousLights;
  134548. /**
  134549. * Number of Simultaneous lights allowed on the material.
  134550. */
  134551. maxSimultaneousLights: int;
  134552. private _shadowOnly;
  134553. /**
  134554. * Make the material only render shadows
  134555. */
  134556. shadowOnly: boolean;
  134557. /**
  134558. * Default configuration related to image processing available in the Background Material.
  134559. */
  134560. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  134561. /**
  134562. * Keep track of the image processing observer to allow dispose and replace.
  134563. */
  134564. private _imageProcessingObserver;
  134565. /**
  134566. * Attaches a new image processing configuration to the PBR Material.
  134567. * @param configuration (if null the scene configuration will be use)
  134568. */
  134569. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  134570. /**
  134571. * Gets the image processing configuration used either in this material.
  134572. */
  134573. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  134574. /**
  134575. * Sets the Default image processing configuration used either in the this material.
  134576. *
  134577. * If sets to null, the scene one is in use.
  134578. */
  134579. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  134580. /**
  134581. * Gets wether the color curves effect is enabled.
  134582. */
  134583. get cameraColorCurvesEnabled(): boolean;
  134584. /**
  134585. * Sets wether the color curves effect is enabled.
  134586. */
  134587. set cameraColorCurvesEnabled(value: boolean);
  134588. /**
  134589. * Gets wether the color grading effect is enabled.
  134590. */
  134591. get cameraColorGradingEnabled(): boolean;
  134592. /**
  134593. * Gets wether the color grading effect is enabled.
  134594. */
  134595. set cameraColorGradingEnabled(value: boolean);
  134596. /**
  134597. * Gets wether tonemapping is enabled or not.
  134598. */
  134599. get cameraToneMappingEnabled(): boolean;
  134600. /**
  134601. * Sets wether tonemapping is enabled or not
  134602. */
  134603. set cameraToneMappingEnabled(value: boolean);
  134604. /**
  134605. * The camera exposure used on this material.
  134606. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  134607. * This corresponds to a photographic exposure.
  134608. */
  134609. get cameraExposure(): float;
  134610. /**
  134611. * The camera exposure used on this material.
  134612. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  134613. * This corresponds to a photographic exposure.
  134614. */
  134615. set cameraExposure(value: float);
  134616. /**
  134617. * Gets The camera contrast used on this material.
  134618. */
  134619. get cameraContrast(): float;
  134620. /**
  134621. * Sets The camera contrast used on this material.
  134622. */
  134623. set cameraContrast(value: float);
  134624. /**
  134625. * Gets the Color Grading 2D Lookup Texture.
  134626. */
  134627. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  134628. /**
  134629. * Sets the Color Grading 2D Lookup Texture.
  134630. */
  134631. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  134632. /**
  134633. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  134634. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  134635. * 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;
  134636. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  134637. */
  134638. get cameraColorCurves(): Nullable<ColorCurves>;
  134639. /**
  134640. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  134641. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  134642. * 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;
  134643. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  134644. */
  134645. set cameraColorCurves(value: Nullable<ColorCurves>);
  134646. /**
  134647. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  134648. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  134649. */
  134650. switchToBGR: boolean;
  134651. private _renderTargets;
  134652. private _reflectionControls;
  134653. private _white;
  134654. private _primaryShadowColor;
  134655. private _primaryHighlightColor;
  134656. /**
  134657. * Instantiates a Background Material in the given scene
  134658. * @param name The friendly name of the material
  134659. * @param scene The scene to add the material to
  134660. */
  134661. constructor(name: string, scene: Scene);
  134662. /**
  134663. * Gets a boolean indicating that current material needs to register RTT
  134664. */
  134665. get hasRenderTargetTextures(): boolean;
  134666. /**
  134667. * The entire material has been created in order to prevent overdraw.
  134668. * @returns false
  134669. */
  134670. needAlphaTesting(): boolean;
  134671. /**
  134672. * The entire material has been created in order to prevent overdraw.
  134673. * @returns true if blending is enable
  134674. */
  134675. needAlphaBlending(): boolean;
  134676. /**
  134677. * Checks wether the material is ready to be rendered for a given mesh.
  134678. * @param mesh The mesh to render
  134679. * @param subMesh The submesh to check against
  134680. * @param useInstances Specify wether or not the material is used with instances
  134681. * @returns true if all the dependencies are ready (Textures, Effects...)
  134682. */
  134683. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  134684. /**
  134685. * Compute the primary color according to the chosen perceptual color.
  134686. */
  134687. private _computePrimaryColorFromPerceptualColor;
  134688. /**
  134689. * Compute the highlights and shadow colors according to their chosen levels.
  134690. */
  134691. private _computePrimaryColors;
  134692. /**
  134693. * Build the uniform buffer used in the material.
  134694. */
  134695. buildUniformLayout(): void;
  134696. /**
  134697. * Unbind the material.
  134698. */
  134699. unbind(): void;
  134700. /**
  134701. * Bind only the world matrix to the material.
  134702. * @param world The world matrix to bind.
  134703. */
  134704. bindOnlyWorldMatrix(world: Matrix): void;
  134705. /**
  134706. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  134707. * @param world The world matrix to bind.
  134708. * @param subMesh The submesh to bind for.
  134709. */
  134710. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  134711. /**
  134712. * Checks to see if a texture is used in the material.
  134713. * @param texture - Base texture to use.
  134714. * @returns - Boolean specifying if a texture is used in the material.
  134715. */
  134716. hasTexture(texture: BaseTexture): boolean;
  134717. /**
  134718. * Dispose the material.
  134719. * @param forceDisposeEffect Force disposal of the associated effect.
  134720. * @param forceDisposeTextures Force disposal of the associated textures.
  134721. */
  134722. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  134723. /**
  134724. * Clones the material.
  134725. * @param name The cloned name.
  134726. * @returns The cloned material.
  134727. */
  134728. clone(name: string): BackgroundMaterial;
  134729. /**
  134730. * Serializes the current material to its JSON representation.
  134731. * @returns The JSON representation.
  134732. */
  134733. serialize(): any;
  134734. /**
  134735. * Gets the class name of the material
  134736. * @returns "BackgroundMaterial"
  134737. */
  134738. getClassName(): string;
  134739. /**
  134740. * Parse a JSON input to create back a background material.
  134741. * @param source The JSON data to parse
  134742. * @param scene The scene to create the parsed material in
  134743. * @param rootUrl The root url of the assets the material depends upon
  134744. * @returns the instantiated BackgroundMaterial.
  134745. */
  134746. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  134747. }
  134748. }
  134749. declare module BABYLON {
  134750. /**
  134751. * Represents the different options available during the creation of
  134752. * a Environment helper.
  134753. *
  134754. * This can control the default ground, skybox and image processing setup of your scene.
  134755. */
  134756. export interface IEnvironmentHelperOptions {
  134757. /**
  134758. * Specifies whether or not to create a ground.
  134759. * True by default.
  134760. */
  134761. createGround: boolean;
  134762. /**
  134763. * Specifies the ground size.
  134764. * 15 by default.
  134765. */
  134766. groundSize: number;
  134767. /**
  134768. * The texture used on the ground for the main color.
  134769. * Comes from the BabylonJS CDN by default.
  134770. *
  134771. * Remarks: Can be either a texture or a url.
  134772. */
  134773. groundTexture: string | BaseTexture;
  134774. /**
  134775. * The color mixed in the ground texture by default.
  134776. * BabylonJS clearColor by default.
  134777. */
  134778. groundColor: Color3;
  134779. /**
  134780. * Specifies the ground opacity.
  134781. * 1 by default.
  134782. */
  134783. groundOpacity: number;
  134784. /**
  134785. * Enables the ground to receive shadows.
  134786. * True by default.
  134787. */
  134788. enableGroundShadow: boolean;
  134789. /**
  134790. * Helps preventing the shadow to be fully black on the ground.
  134791. * 0.5 by default.
  134792. */
  134793. groundShadowLevel: number;
  134794. /**
  134795. * Creates a mirror texture attach to the ground.
  134796. * false by default.
  134797. */
  134798. enableGroundMirror: boolean;
  134799. /**
  134800. * Specifies the ground mirror size ratio.
  134801. * 0.3 by default as the default kernel is 64.
  134802. */
  134803. groundMirrorSizeRatio: number;
  134804. /**
  134805. * Specifies the ground mirror blur kernel size.
  134806. * 64 by default.
  134807. */
  134808. groundMirrorBlurKernel: number;
  134809. /**
  134810. * Specifies the ground mirror visibility amount.
  134811. * 1 by default
  134812. */
  134813. groundMirrorAmount: number;
  134814. /**
  134815. * Specifies the ground mirror reflectance weight.
  134816. * This uses the standard weight of the background material to setup the fresnel effect
  134817. * of the mirror.
  134818. * 1 by default.
  134819. */
  134820. groundMirrorFresnelWeight: number;
  134821. /**
  134822. * Specifies the ground mirror Falloff distance.
  134823. * This can helps reducing the size of the reflection.
  134824. * 0 by Default.
  134825. */
  134826. groundMirrorFallOffDistance: number;
  134827. /**
  134828. * Specifies the ground mirror texture type.
  134829. * Unsigned Int by Default.
  134830. */
  134831. groundMirrorTextureType: number;
  134832. /**
  134833. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  134834. * the shown objects.
  134835. */
  134836. groundYBias: number;
  134837. /**
  134838. * Specifies whether or not to create a skybox.
  134839. * True by default.
  134840. */
  134841. createSkybox: boolean;
  134842. /**
  134843. * Specifies the skybox size.
  134844. * 20 by default.
  134845. */
  134846. skyboxSize: number;
  134847. /**
  134848. * The texture used on the skybox for the main color.
  134849. * Comes from the BabylonJS CDN by default.
  134850. *
  134851. * Remarks: Can be either a texture or a url.
  134852. */
  134853. skyboxTexture: string | BaseTexture;
  134854. /**
  134855. * The color mixed in the skybox texture by default.
  134856. * BabylonJS clearColor by default.
  134857. */
  134858. skyboxColor: Color3;
  134859. /**
  134860. * The background rotation around the Y axis of the scene.
  134861. * This helps aligning the key lights of your scene with the background.
  134862. * 0 by default.
  134863. */
  134864. backgroundYRotation: number;
  134865. /**
  134866. * Compute automatically the size of the elements to best fit with the scene.
  134867. */
  134868. sizeAuto: boolean;
  134869. /**
  134870. * Default position of the rootMesh if autoSize is not true.
  134871. */
  134872. rootPosition: Vector3;
  134873. /**
  134874. * Sets up the image processing in the scene.
  134875. * true by default.
  134876. */
  134877. setupImageProcessing: boolean;
  134878. /**
  134879. * The texture used as your environment texture in the scene.
  134880. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  134881. *
  134882. * Remarks: Can be either a texture or a url.
  134883. */
  134884. environmentTexture: string | BaseTexture;
  134885. /**
  134886. * The value of the exposure to apply to the scene.
  134887. * 0.6 by default if setupImageProcessing is true.
  134888. */
  134889. cameraExposure: number;
  134890. /**
  134891. * The value of the contrast to apply to the scene.
  134892. * 1.6 by default if setupImageProcessing is true.
  134893. */
  134894. cameraContrast: number;
  134895. /**
  134896. * Specifies whether or not tonemapping should be enabled in the scene.
  134897. * true by default if setupImageProcessing is true.
  134898. */
  134899. toneMappingEnabled: boolean;
  134900. }
  134901. /**
  134902. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  134903. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  134904. * It also helps with the default setup of your imageProcessing configuration.
  134905. */
  134906. export class EnvironmentHelper {
  134907. /**
  134908. * Default ground texture URL.
  134909. */
  134910. private static _groundTextureCDNUrl;
  134911. /**
  134912. * Default skybox texture URL.
  134913. */
  134914. private static _skyboxTextureCDNUrl;
  134915. /**
  134916. * Default environment texture URL.
  134917. */
  134918. private static _environmentTextureCDNUrl;
  134919. /**
  134920. * Creates the default options for the helper.
  134921. */
  134922. private static _getDefaultOptions;
  134923. private _rootMesh;
  134924. /**
  134925. * Gets the root mesh created by the helper.
  134926. */
  134927. get rootMesh(): Mesh;
  134928. private _skybox;
  134929. /**
  134930. * Gets the skybox created by the helper.
  134931. */
  134932. get skybox(): Nullable<Mesh>;
  134933. private _skyboxTexture;
  134934. /**
  134935. * Gets the skybox texture created by the helper.
  134936. */
  134937. get skyboxTexture(): Nullable<BaseTexture>;
  134938. private _skyboxMaterial;
  134939. /**
  134940. * Gets the skybox material created by the helper.
  134941. */
  134942. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  134943. private _ground;
  134944. /**
  134945. * Gets the ground mesh created by the helper.
  134946. */
  134947. get ground(): Nullable<Mesh>;
  134948. private _groundTexture;
  134949. /**
  134950. * Gets the ground texture created by the helper.
  134951. */
  134952. get groundTexture(): Nullable<BaseTexture>;
  134953. private _groundMirror;
  134954. /**
  134955. * Gets the ground mirror created by the helper.
  134956. */
  134957. get groundMirror(): Nullable<MirrorTexture>;
  134958. /**
  134959. * Gets the ground mirror render list to helps pushing the meshes
  134960. * you wish in the ground reflection.
  134961. */
  134962. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  134963. private _groundMaterial;
  134964. /**
  134965. * Gets the ground material created by the helper.
  134966. */
  134967. get groundMaterial(): Nullable<BackgroundMaterial>;
  134968. /**
  134969. * Stores the creation options.
  134970. */
  134971. private readonly _scene;
  134972. private _options;
  134973. /**
  134974. * This observable will be notified with any error during the creation of the environment,
  134975. * mainly texture creation errors.
  134976. */
  134977. onErrorObservable: Observable<{
  134978. message?: string;
  134979. exception?: any;
  134980. }>;
  134981. /**
  134982. * constructor
  134983. * @param options Defines the options we want to customize the helper
  134984. * @param scene The scene to add the material to
  134985. */
  134986. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  134987. /**
  134988. * Updates the background according to the new options
  134989. * @param options
  134990. */
  134991. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  134992. /**
  134993. * Sets the primary color of all the available elements.
  134994. * @param color the main color to affect to the ground and the background
  134995. */
  134996. setMainColor(color: Color3): void;
  134997. /**
  134998. * Setup the image processing according to the specified options.
  134999. */
  135000. private _setupImageProcessing;
  135001. /**
  135002. * Setup the environment texture according to the specified options.
  135003. */
  135004. private _setupEnvironmentTexture;
  135005. /**
  135006. * Setup the background according to the specified options.
  135007. */
  135008. private _setupBackground;
  135009. /**
  135010. * Get the scene sizes according to the setup.
  135011. */
  135012. private _getSceneSize;
  135013. /**
  135014. * Setup the ground according to the specified options.
  135015. */
  135016. private _setupGround;
  135017. /**
  135018. * Setup the ground material according to the specified options.
  135019. */
  135020. private _setupGroundMaterial;
  135021. /**
  135022. * Setup the ground diffuse texture according to the specified options.
  135023. */
  135024. private _setupGroundDiffuseTexture;
  135025. /**
  135026. * Setup the ground mirror texture according to the specified options.
  135027. */
  135028. private _setupGroundMirrorTexture;
  135029. /**
  135030. * Setup the ground to receive the mirror texture.
  135031. */
  135032. private _setupMirrorInGroundMaterial;
  135033. /**
  135034. * Setup the skybox according to the specified options.
  135035. */
  135036. private _setupSkybox;
  135037. /**
  135038. * Setup the skybox material according to the specified options.
  135039. */
  135040. private _setupSkyboxMaterial;
  135041. /**
  135042. * Setup the skybox reflection texture according to the specified options.
  135043. */
  135044. private _setupSkyboxReflectionTexture;
  135045. private _errorHandler;
  135046. /**
  135047. * Dispose all the elements created by the Helper.
  135048. */
  135049. dispose(): void;
  135050. }
  135051. }
  135052. declare module BABYLON {
  135053. /**
  135054. * Display a 360/180 degree texture on an approximately spherical surface, useful for VR applications or skyboxes.
  135055. * As a subclass of TransformNode, this allow parenting to the camera or multiple textures with different locations in the scene.
  135056. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  135057. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  135058. */
  135059. export abstract class TextureDome<T extends Texture> extends TransformNode {
  135060. protected onError: Nullable<(message?: string, exception?: any) => void>;
  135061. /**
  135062. * Define the source as a Monoscopic panoramic 360/180.
  135063. */
  135064. static readonly MODE_MONOSCOPIC: number;
  135065. /**
  135066. * Define the source as a Stereoscopic TopBottom/OverUnder panoramic 360/180.
  135067. */
  135068. static readonly MODE_TOPBOTTOM: number;
  135069. /**
  135070. * Define the source as a Stereoscopic Side by Side panoramic 360/180.
  135071. */
  135072. static readonly MODE_SIDEBYSIDE: number;
  135073. private _halfDome;
  135074. protected _useDirectMapping: boolean;
  135075. /**
  135076. * The texture being displayed on the sphere
  135077. */
  135078. protected _texture: T;
  135079. /**
  135080. * Gets the texture being displayed on the sphere
  135081. */
  135082. get texture(): T;
  135083. /**
  135084. * Sets the texture being displayed on the sphere
  135085. */
  135086. set texture(newTexture: T);
  135087. /**
  135088. * The skybox material
  135089. */
  135090. protected _material: BackgroundMaterial;
  135091. /**
  135092. * The surface used for the dome
  135093. */
  135094. protected _mesh: Mesh;
  135095. /**
  135096. * Gets the mesh used for the dome.
  135097. */
  135098. get mesh(): Mesh;
  135099. /**
  135100. * A mesh that will be used to mask the back of the dome in case it is a 180 degree movie.
  135101. */
  135102. private _halfDomeMask;
  135103. /**
  135104. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  135105. * Also see the options.resolution property.
  135106. */
  135107. get fovMultiplier(): number;
  135108. set fovMultiplier(value: number);
  135109. protected _textureMode: number;
  135110. /**
  135111. * Gets or set the current texture mode for the texture. It can be:
  135112. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  135113. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  135114. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  135115. */
  135116. get textureMode(): number;
  135117. /**
  135118. * Sets the current texture mode for the texture. It can be:
  135119. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  135120. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  135121. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  135122. */
  135123. set textureMode(value: number);
  135124. /**
  135125. * Is it a 180 degrees dome (half dome) or 360 texture (full dome)
  135126. */
  135127. get halfDome(): boolean;
  135128. /**
  135129. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  135130. */
  135131. set halfDome(enabled: boolean);
  135132. /**
  135133. * Oberserver used in Stereoscopic VR Mode.
  135134. */
  135135. private _onBeforeCameraRenderObserver;
  135136. /**
  135137. * Observable raised when an error occured while loading the 360 image
  135138. */
  135139. onLoadErrorObservable: Observable<string>;
  135140. /**
  135141. * Create an instance of this class and pass through the parameters to the relevant classes- Texture, StandardMaterial, and Mesh.
  135142. * @param name Element's name, child elements will append suffixes for their own names.
  135143. * @param textureUrlOrElement defines the url(s) or the (video) HTML element to use
  135144. * @param options An object containing optional or exposed sub element properties
  135145. */
  135146. constructor(name: string, textureUrlOrElement: string | string[] | HTMLVideoElement, options: {
  135147. resolution?: number;
  135148. clickToPlay?: boolean;
  135149. autoPlay?: boolean;
  135150. loop?: boolean;
  135151. size?: number;
  135152. poster?: string;
  135153. faceForward?: boolean;
  135154. useDirectMapping?: boolean;
  135155. halfDomeMode?: boolean;
  135156. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  135157. protected abstract _initTexture(urlsOrElement: string | string[] | HTMLElement, scene: Scene, options: any): T;
  135158. protected _changeTextureMode(value: number): void;
  135159. /**
  135160. * Releases resources associated with this node.
  135161. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  135162. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  135163. */
  135164. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  135165. }
  135166. }
  135167. declare module BABYLON {
  135168. /**
  135169. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  135170. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  135171. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  135172. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  135173. */
  135174. export class PhotoDome extends TextureDome<Texture> {
  135175. /**
  135176. * Define the image as a Monoscopic panoramic 360 image.
  135177. */
  135178. static readonly MODE_MONOSCOPIC: number;
  135179. /**
  135180. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  135181. */
  135182. static readonly MODE_TOPBOTTOM: number;
  135183. /**
  135184. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  135185. */
  135186. static readonly MODE_SIDEBYSIDE: number;
  135187. /**
  135188. * Gets or sets the texture being displayed on the sphere
  135189. */
  135190. get photoTexture(): Texture;
  135191. /**
  135192. * sets the texture being displayed on the sphere
  135193. */
  135194. set photoTexture(value: Texture);
  135195. /**
  135196. * Gets the current video mode for the video. It can be:
  135197. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  135198. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  135199. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  135200. */
  135201. get imageMode(): number;
  135202. /**
  135203. * Sets the current video mode for the video. It can be:
  135204. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  135205. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  135206. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  135207. */
  135208. set imageMode(value: number);
  135209. protected _initTexture(urlsOrElement: string, scene: Scene, options: any): Texture;
  135210. }
  135211. }
  135212. declare module BABYLON {
  135213. /**
  135214. * Class used to host RGBD texture specific utilities
  135215. */
  135216. export class RGBDTextureTools {
  135217. /**
  135218. * Expand the RGBD Texture from RGBD to Half Float if possible.
  135219. * @param texture the texture to expand.
  135220. */
  135221. static ExpandRGBDTexture(texture: Texture): void;
  135222. }
  135223. }
  135224. declare module BABYLON {
  135225. /**
  135226. * Class used to host texture specific utilities
  135227. */
  135228. export class BRDFTextureTools {
  135229. /**
  135230. * Prevents texture cache collision
  135231. */
  135232. private static _instanceNumber;
  135233. /**
  135234. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  135235. * @param scene defines the hosting scene
  135236. * @returns the environment BRDF texture
  135237. */
  135238. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  135239. private static _environmentBRDFBase64Texture;
  135240. }
  135241. }
  135242. declare module BABYLON {
  135243. /**
  135244. * @hidden
  135245. */
  135246. export interface IMaterialClearCoatDefines {
  135247. CLEARCOAT: boolean;
  135248. CLEARCOAT_DEFAULTIOR: boolean;
  135249. CLEARCOAT_TEXTURE: boolean;
  135250. CLEARCOAT_TEXTUREDIRECTUV: number;
  135251. CLEARCOAT_BUMP: boolean;
  135252. CLEARCOAT_BUMPDIRECTUV: number;
  135253. CLEARCOAT_TINT: boolean;
  135254. CLEARCOAT_TINT_TEXTURE: boolean;
  135255. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  135256. /** @hidden */
  135257. _areTexturesDirty: boolean;
  135258. }
  135259. /**
  135260. * Define the code related to the clear coat parameters of the pbr material.
  135261. */
  135262. export class PBRClearCoatConfiguration {
  135263. /**
  135264. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  135265. * The default fits with a polyurethane material.
  135266. */
  135267. private static readonly _DefaultIndexOfRefraction;
  135268. private _isEnabled;
  135269. /**
  135270. * Defines if the clear coat is enabled in the material.
  135271. */
  135272. isEnabled: boolean;
  135273. /**
  135274. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  135275. */
  135276. intensity: number;
  135277. /**
  135278. * Defines the clear coat layer roughness.
  135279. */
  135280. roughness: number;
  135281. private _indexOfRefraction;
  135282. /**
  135283. * Defines the index of refraction of the clear coat.
  135284. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  135285. * The default fits with a polyurethane material.
  135286. * Changing the default value is more performance intensive.
  135287. */
  135288. indexOfRefraction: number;
  135289. private _texture;
  135290. /**
  135291. * Stores the clear coat values in a texture.
  135292. */
  135293. texture: Nullable<BaseTexture>;
  135294. private _bumpTexture;
  135295. /**
  135296. * Define the clear coat specific bump texture.
  135297. */
  135298. bumpTexture: Nullable<BaseTexture>;
  135299. private _isTintEnabled;
  135300. /**
  135301. * Defines if the clear coat tint is enabled in the material.
  135302. */
  135303. isTintEnabled: boolean;
  135304. /**
  135305. * Defines the clear coat tint of the material.
  135306. * This is only use if tint is enabled
  135307. */
  135308. tintColor: Color3;
  135309. /**
  135310. * Defines the distance at which the tint color should be found in the
  135311. * clear coat media.
  135312. * This is only use if tint is enabled
  135313. */
  135314. tintColorAtDistance: number;
  135315. /**
  135316. * Defines the clear coat layer thickness.
  135317. * This is only use if tint is enabled
  135318. */
  135319. tintThickness: number;
  135320. private _tintTexture;
  135321. /**
  135322. * Stores the clear tint values in a texture.
  135323. * rgb is tint
  135324. * a is a thickness factor
  135325. */
  135326. tintTexture: Nullable<BaseTexture>;
  135327. /** @hidden */
  135328. private _internalMarkAllSubMeshesAsTexturesDirty;
  135329. /** @hidden */
  135330. _markAllSubMeshesAsTexturesDirty(): void;
  135331. /**
  135332. * Instantiate a new istance of clear coat configuration.
  135333. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  135334. */
  135335. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  135336. /**
  135337. * Gets wehter the submesh is ready to be used or not.
  135338. * @param defines the list of "defines" to update.
  135339. * @param scene defines the scene the material belongs to.
  135340. * @param engine defines the engine the material belongs to.
  135341. * @param disableBumpMap defines wether the material disables bump or not.
  135342. * @returns - boolean indicating that the submesh is ready or not.
  135343. */
  135344. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  135345. /**
  135346. * Checks to see if a texture is used in the material.
  135347. * @param defines the list of "defines" to update.
  135348. * @param scene defines the scene to the material belongs to.
  135349. */
  135350. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  135351. /**
  135352. * Binds the material data.
  135353. * @param uniformBuffer defines the Uniform buffer to fill in.
  135354. * @param scene defines the scene the material belongs to.
  135355. * @param engine defines the engine the material belongs to.
  135356. * @param disableBumpMap defines wether the material disables bump or not.
  135357. * @param isFrozen defines wether the material is frozen or not.
  135358. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  135359. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  135360. */
  135361. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  135362. /**
  135363. * Checks to see if a texture is used in the material.
  135364. * @param texture - Base texture to use.
  135365. * @returns - Boolean specifying if a texture is used in the material.
  135366. */
  135367. hasTexture(texture: BaseTexture): boolean;
  135368. /**
  135369. * Returns an array of the actively used textures.
  135370. * @param activeTextures Array of BaseTextures
  135371. */
  135372. getActiveTextures(activeTextures: BaseTexture[]): void;
  135373. /**
  135374. * Returns the animatable textures.
  135375. * @param animatables Array of animatable textures.
  135376. */
  135377. getAnimatables(animatables: IAnimatable[]): void;
  135378. /**
  135379. * Disposes the resources of the material.
  135380. * @param forceDisposeTextures - Forces the disposal of all textures.
  135381. */
  135382. dispose(forceDisposeTextures?: boolean): void;
  135383. /**
  135384. * Get the current class name of the texture useful for serialization or dynamic coding.
  135385. * @returns "PBRClearCoatConfiguration"
  135386. */
  135387. getClassName(): string;
  135388. /**
  135389. * Add fallbacks to the effect fallbacks list.
  135390. * @param defines defines the Base texture to use.
  135391. * @param fallbacks defines the current fallback list.
  135392. * @param currentRank defines the current fallback rank.
  135393. * @returns the new fallback rank.
  135394. */
  135395. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  135396. /**
  135397. * Add the required uniforms to the current list.
  135398. * @param uniforms defines the current uniform list.
  135399. */
  135400. static AddUniforms(uniforms: string[]): void;
  135401. /**
  135402. * Add the required samplers to the current list.
  135403. * @param samplers defines the current sampler list.
  135404. */
  135405. static AddSamplers(samplers: string[]): void;
  135406. /**
  135407. * Add the required uniforms to the current buffer.
  135408. * @param uniformBuffer defines the current uniform buffer.
  135409. */
  135410. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  135411. /**
  135412. * Makes a duplicate of the current configuration into another one.
  135413. * @param clearCoatConfiguration define the config where to copy the info
  135414. */
  135415. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  135416. /**
  135417. * Serializes this clear coat configuration.
  135418. * @returns - An object with the serialized config.
  135419. */
  135420. serialize(): any;
  135421. /**
  135422. * Parses a anisotropy Configuration from a serialized object.
  135423. * @param source - Serialized object.
  135424. * @param scene Defines the scene we are parsing for
  135425. * @param rootUrl Defines the rootUrl to load from
  135426. */
  135427. parse(source: any, scene: Scene, rootUrl: string): void;
  135428. }
  135429. }
  135430. declare module BABYLON {
  135431. /**
  135432. * @hidden
  135433. */
  135434. export interface IMaterialAnisotropicDefines {
  135435. ANISOTROPIC: boolean;
  135436. ANISOTROPIC_TEXTURE: boolean;
  135437. ANISOTROPIC_TEXTUREDIRECTUV: number;
  135438. MAINUV1: boolean;
  135439. _areTexturesDirty: boolean;
  135440. _needUVs: boolean;
  135441. }
  135442. /**
  135443. * Define the code related to the anisotropic parameters of the pbr material.
  135444. */
  135445. export class PBRAnisotropicConfiguration {
  135446. private _isEnabled;
  135447. /**
  135448. * Defines if the anisotropy is enabled in the material.
  135449. */
  135450. isEnabled: boolean;
  135451. /**
  135452. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  135453. */
  135454. intensity: number;
  135455. /**
  135456. * Defines if the effect is along the tangents, bitangents or in between.
  135457. * By default, the effect is "strectching" the highlights along the tangents.
  135458. */
  135459. direction: Vector2;
  135460. private _texture;
  135461. /**
  135462. * Stores the anisotropy values in a texture.
  135463. * rg is direction (like normal from -1 to 1)
  135464. * b is a intensity
  135465. */
  135466. texture: Nullable<BaseTexture>;
  135467. /** @hidden */
  135468. private _internalMarkAllSubMeshesAsTexturesDirty;
  135469. /** @hidden */
  135470. _markAllSubMeshesAsTexturesDirty(): void;
  135471. /**
  135472. * Instantiate a new istance of anisotropy configuration.
  135473. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  135474. */
  135475. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  135476. /**
  135477. * Specifies that the submesh is ready to be used.
  135478. * @param defines the list of "defines" to update.
  135479. * @param scene defines the scene the material belongs to.
  135480. * @returns - boolean indicating that the submesh is ready or not.
  135481. */
  135482. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  135483. /**
  135484. * Checks to see if a texture is used in the material.
  135485. * @param defines the list of "defines" to update.
  135486. * @param mesh the mesh we are preparing the defines for.
  135487. * @param scene defines the scene the material belongs to.
  135488. */
  135489. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  135490. /**
  135491. * Binds the material data.
  135492. * @param uniformBuffer defines the Uniform buffer to fill in.
  135493. * @param scene defines the scene the material belongs to.
  135494. * @param isFrozen defines wether the material is frozen or not.
  135495. */
  135496. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  135497. /**
  135498. * Checks to see if a texture is used in the material.
  135499. * @param texture - Base texture to use.
  135500. * @returns - Boolean specifying if a texture is used in the material.
  135501. */
  135502. hasTexture(texture: BaseTexture): boolean;
  135503. /**
  135504. * Returns an array of the actively used textures.
  135505. * @param activeTextures Array of BaseTextures
  135506. */
  135507. getActiveTextures(activeTextures: BaseTexture[]): void;
  135508. /**
  135509. * Returns the animatable textures.
  135510. * @param animatables Array of animatable textures.
  135511. */
  135512. getAnimatables(animatables: IAnimatable[]): void;
  135513. /**
  135514. * Disposes the resources of the material.
  135515. * @param forceDisposeTextures - Forces the disposal of all textures.
  135516. */
  135517. dispose(forceDisposeTextures?: boolean): void;
  135518. /**
  135519. * Get the current class name of the texture useful for serialization or dynamic coding.
  135520. * @returns "PBRAnisotropicConfiguration"
  135521. */
  135522. getClassName(): string;
  135523. /**
  135524. * Add fallbacks to the effect fallbacks list.
  135525. * @param defines defines the Base texture to use.
  135526. * @param fallbacks defines the current fallback list.
  135527. * @param currentRank defines the current fallback rank.
  135528. * @returns the new fallback rank.
  135529. */
  135530. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  135531. /**
  135532. * Add the required uniforms to the current list.
  135533. * @param uniforms defines the current uniform list.
  135534. */
  135535. static AddUniforms(uniforms: string[]): void;
  135536. /**
  135537. * Add the required uniforms to the current buffer.
  135538. * @param uniformBuffer defines the current uniform buffer.
  135539. */
  135540. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  135541. /**
  135542. * Add the required samplers to the current list.
  135543. * @param samplers defines the current sampler list.
  135544. */
  135545. static AddSamplers(samplers: string[]): void;
  135546. /**
  135547. * Makes a duplicate of the current configuration into another one.
  135548. * @param anisotropicConfiguration define the config where to copy the info
  135549. */
  135550. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  135551. /**
  135552. * Serializes this anisotropy configuration.
  135553. * @returns - An object with the serialized config.
  135554. */
  135555. serialize(): any;
  135556. /**
  135557. * Parses a anisotropy Configuration from a serialized object.
  135558. * @param source - Serialized object.
  135559. * @param scene Defines the scene we are parsing for
  135560. * @param rootUrl Defines the rootUrl to load from
  135561. */
  135562. parse(source: any, scene: Scene, rootUrl: string): void;
  135563. }
  135564. }
  135565. declare module BABYLON {
  135566. /**
  135567. * @hidden
  135568. */
  135569. export interface IMaterialBRDFDefines {
  135570. BRDF_V_HEIGHT_CORRELATED: boolean;
  135571. MS_BRDF_ENERGY_CONSERVATION: boolean;
  135572. SPHERICAL_HARMONICS: boolean;
  135573. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  135574. /** @hidden */
  135575. _areMiscDirty: boolean;
  135576. }
  135577. /**
  135578. * Define the code related to the BRDF parameters of the pbr material.
  135579. */
  135580. export class PBRBRDFConfiguration {
  135581. /**
  135582. * Default value used for the energy conservation.
  135583. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  135584. */
  135585. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  135586. /**
  135587. * Default value used for the Smith Visibility Height Correlated mode.
  135588. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  135589. */
  135590. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  135591. /**
  135592. * Default value used for the IBL diffuse part.
  135593. * This can help switching back to the polynomials mode globally which is a tiny bit
  135594. * less GPU intensive at the drawback of a lower quality.
  135595. */
  135596. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  135597. /**
  135598. * Default value used for activating energy conservation for the specular workflow.
  135599. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  135600. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  135601. */
  135602. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  135603. private _useEnergyConservation;
  135604. /**
  135605. * Defines if the material uses energy conservation.
  135606. */
  135607. useEnergyConservation: boolean;
  135608. private _useSmithVisibilityHeightCorrelated;
  135609. /**
  135610. * LEGACY Mode set to false
  135611. * Defines if the material uses height smith correlated visibility term.
  135612. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  135613. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  135614. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  135615. * Not relying on height correlated will also disable energy conservation.
  135616. */
  135617. useSmithVisibilityHeightCorrelated: boolean;
  135618. private _useSphericalHarmonics;
  135619. /**
  135620. * LEGACY Mode set to false
  135621. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  135622. * diffuse part of the IBL.
  135623. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  135624. * to the ground truth.
  135625. */
  135626. useSphericalHarmonics: boolean;
  135627. private _useSpecularGlossinessInputEnergyConservation;
  135628. /**
  135629. * Defines if the material uses energy conservation, when the specular workflow is active.
  135630. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  135631. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  135632. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  135633. */
  135634. useSpecularGlossinessInputEnergyConservation: boolean;
  135635. /** @hidden */
  135636. private _internalMarkAllSubMeshesAsMiscDirty;
  135637. /** @hidden */
  135638. _markAllSubMeshesAsMiscDirty(): void;
  135639. /**
  135640. * Instantiate a new istance of clear coat configuration.
  135641. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  135642. */
  135643. constructor(markAllSubMeshesAsMiscDirty: () => void);
  135644. /**
  135645. * Checks to see if a texture is used in the material.
  135646. * @param defines the list of "defines" to update.
  135647. */
  135648. prepareDefines(defines: IMaterialBRDFDefines): void;
  135649. /**
  135650. * Get the current class name of the texture useful for serialization or dynamic coding.
  135651. * @returns "PBRClearCoatConfiguration"
  135652. */
  135653. getClassName(): string;
  135654. /**
  135655. * Makes a duplicate of the current configuration into another one.
  135656. * @param brdfConfiguration define the config where to copy the info
  135657. */
  135658. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  135659. /**
  135660. * Serializes this BRDF configuration.
  135661. * @returns - An object with the serialized config.
  135662. */
  135663. serialize(): any;
  135664. /**
  135665. * Parses a anisotropy Configuration from a serialized object.
  135666. * @param source - Serialized object.
  135667. * @param scene Defines the scene we are parsing for
  135668. * @param rootUrl Defines the rootUrl to load from
  135669. */
  135670. parse(source: any, scene: Scene, rootUrl: string): void;
  135671. }
  135672. }
  135673. declare module BABYLON {
  135674. /**
  135675. * @hidden
  135676. */
  135677. export interface IMaterialSheenDefines {
  135678. SHEEN: boolean;
  135679. SHEEN_TEXTURE: boolean;
  135680. SHEEN_TEXTUREDIRECTUV: number;
  135681. SHEEN_LINKWITHALBEDO: boolean;
  135682. SHEEN_ROUGHNESS: boolean;
  135683. SHEEN_ALBEDOSCALING: boolean;
  135684. /** @hidden */
  135685. _areTexturesDirty: boolean;
  135686. }
  135687. /**
  135688. * Define the code related to the Sheen parameters of the pbr material.
  135689. */
  135690. export class PBRSheenConfiguration {
  135691. private _isEnabled;
  135692. /**
  135693. * Defines if the material uses sheen.
  135694. */
  135695. isEnabled: boolean;
  135696. private _linkSheenWithAlbedo;
  135697. /**
  135698. * Defines if the sheen is linked to the sheen color.
  135699. */
  135700. linkSheenWithAlbedo: boolean;
  135701. /**
  135702. * Defines the sheen intensity.
  135703. */
  135704. intensity: number;
  135705. /**
  135706. * Defines the sheen color.
  135707. */
  135708. color: Color3;
  135709. private _texture;
  135710. /**
  135711. * Stores the sheen tint values in a texture.
  135712. * rgb is tint
  135713. * a is a intensity or roughness if roughness has been defined
  135714. */
  135715. texture: Nullable<BaseTexture>;
  135716. private _roughness;
  135717. /**
  135718. * Defines the sheen roughness.
  135719. * It is not taken into account if linkSheenWithAlbedo is true.
  135720. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  135721. */
  135722. roughness: Nullable<number>;
  135723. private _albedoScaling;
  135724. /**
  135725. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  135726. * It allows the strength of the sheen effect to not depend on the base color of the material,
  135727. * making it easier to setup and tweak the effect
  135728. */
  135729. albedoScaling: boolean;
  135730. /** @hidden */
  135731. private _internalMarkAllSubMeshesAsTexturesDirty;
  135732. /** @hidden */
  135733. _markAllSubMeshesAsTexturesDirty(): void;
  135734. /**
  135735. * Instantiate a new istance of clear coat configuration.
  135736. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  135737. */
  135738. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  135739. /**
  135740. * Specifies that the submesh is ready to be used.
  135741. * @param defines the list of "defines" to update.
  135742. * @param scene defines the scene the material belongs to.
  135743. * @returns - boolean indicating that the submesh is ready or not.
  135744. */
  135745. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  135746. /**
  135747. * Checks to see if a texture is used in the material.
  135748. * @param defines the list of "defines" to update.
  135749. * @param scene defines the scene the material belongs to.
  135750. */
  135751. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  135752. /**
  135753. * Binds the material data.
  135754. * @param uniformBuffer defines the Uniform buffer to fill in.
  135755. * @param scene defines the scene the material belongs to.
  135756. * @param isFrozen defines wether the material is frozen or not.
  135757. */
  135758. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  135759. /**
  135760. * Checks to see if a texture is used in the material.
  135761. * @param texture - Base texture to use.
  135762. * @returns - Boolean specifying if a texture is used in the material.
  135763. */
  135764. hasTexture(texture: BaseTexture): boolean;
  135765. /**
  135766. * Returns an array of the actively used textures.
  135767. * @param activeTextures Array of BaseTextures
  135768. */
  135769. getActiveTextures(activeTextures: BaseTexture[]): void;
  135770. /**
  135771. * Returns the animatable textures.
  135772. * @param animatables Array of animatable textures.
  135773. */
  135774. getAnimatables(animatables: IAnimatable[]): void;
  135775. /**
  135776. * Disposes the resources of the material.
  135777. * @param forceDisposeTextures - Forces the disposal of all textures.
  135778. */
  135779. dispose(forceDisposeTextures?: boolean): void;
  135780. /**
  135781. * Get the current class name of the texture useful for serialization or dynamic coding.
  135782. * @returns "PBRSheenConfiguration"
  135783. */
  135784. getClassName(): string;
  135785. /**
  135786. * Add fallbacks to the effect fallbacks list.
  135787. * @param defines defines the Base texture to use.
  135788. * @param fallbacks defines the current fallback list.
  135789. * @param currentRank defines the current fallback rank.
  135790. * @returns the new fallback rank.
  135791. */
  135792. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  135793. /**
  135794. * Add the required uniforms to the current list.
  135795. * @param uniforms defines the current uniform list.
  135796. */
  135797. static AddUniforms(uniforms: string[]): void;
  135798. /**
  135799. * Add the required uniforms to the current buffer.
  135800. * @param uniformBuffer defines the current uniform buffer.
  135801. */
  135802. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  135803. /**
  135804. * Add the required samplers to the current list.
  135805. * @param samplers defines the current sampler list.
  135806. */
  135807. static AddSamplers(samplers: string[]): void;
  135808. /**
  135809. * Makes a duplicate of the current configuration into another one.
  135810. * @param sheenConfiguration define the config where to copy the info
  135811. */
  135812. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  135813. /**
  135814. * Serializes this BRDF configuration.
  135815. * @returns - An object with the serialized config.
  135816. */
  135817. serialize(): any;
  135818. /**
  135819. * Parses a anisotropy Configuration from a serialized object.
  135820. * @param source - Serialized object.
  135821. * @param scene Defines the scene we are parsing for
  135822. * @param rootUrl Defines the rootUrl to load from
  135823. */
  135824. parse(source: any, scene: Scene, rootUrl: string): void;
  135825. }
  135826. }
  135827. declare module BABYLON {
  135828. /**
  135829. * @hidden
  135830. */
  135831. export interface IMaterialSubSurfaceDefines {
  135832. SUBSURFACE: boolean;
  135833. SS_REFRACTION: boolean;
  135834. SS_TRANSLUCENCY: boolean;
  135835. SS_SCATTERING: boolean;
  135836. SS_THICKNESSANDMASK_TEXTURE: boolean;
  135837. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  135838. SS_REFRACTIONMAP_3D: boolean;
  135839. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  135840. SS_LODINREFRACTIONALPHA: boolean;
  135841. SS_GAMMAREFRACTION: boolean;
  135842. SS_RGBDREFRACTION: boolean;
  135843. SS_LINEARSPECULARREFRACTION: boolean;
  135844. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  135845. SS_ALBEDOFORREFRACTIONTINT: boolean;
  135846. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  135847. /** @hidden */
  135848. _areTexturesDirty: boolean;
  135849. }
  135850. /**
  135851. * Define the code related to the sub surface parameters of the pbr material.
  135852. */
  135853. export class PBRSubSurfaceConfiguration {
  135854. private _isRefractionEnabled;
  135855. /**
  135856. * Defines if the refraction is enabled in the material.
  135857. */
  135858. isRefractionEnabled: boolean;
  135859. private _isTranslucencyEnabled;
  135860. /**
  135861. * Defines if the translucency is enabled in the material.
  135862. */
  135863. isTranslucencyEnabled: boolean;
  135864. private _isScatteringEnabled;
  135865. /**
  135866. * Defines if the sub surface scattering is enabled in the material.
  135867. */
  135868. isScatteringEnabled: boolean;
  135869. private _scatteringDiffusionProfileIndex;
  135870. /**
  135871. * Diffusion profile for subsurface scattering.
  135872. * Useful for better scattering in the skins or foliages.
  135873. */
  135874. get scatteringDiffusionProfile(): Nullable<Color3>;
  135875. set scatteringDiffusionProfile(c: Nullable<Color3>);
  135876. /**
  135877. * Defines the refraction intensity of the material.
  135878. * The refraction when enabled replaces the Diffuse part of the material.
  135879. * The intensity helps transitionning between diffuse and refraction.
  135880. */
  135881. refractionIntensity: number;
  135882. /**
  135883. * Defines the translucency intensity of the material.
  135884. * When translucency has been enabled, this defines how much of the "translucency"
  135885. * is addded to the diffuse part of the material.
  135886. */
  135887. translucencyIntensity: number;
  135888. /**
  135889. * When enabled, transparent surfaces will be tinted with the albedo colour (independent of thickness)
  135890. */
  135891. useAlbedoToTintRefraction: boolean;
  135892. private _thicknessTexture;
  135893. /**
  135894. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  135895. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  135896. * 0 would mean minimumThickness
  135897. * 1 would mean maximumThickness
  135898. * The other channels might be use as a mask to vary the different effects intensity.
  135899. */
  135900. thicknessTexture: Nullable<BaseTexture>;
  135901. private _refractionTexture;
  135902. /**
  135903. * Defines the texture to use for refraction.
  135904. */
  135905. refractionTexture: Nullable<BaseTexture>;
  135906. private _indexOfRefraction;
  135907. /**
  135908. * Index of refraction of the material base layer.
  135909. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  135910. *
  135911. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  135912. *
  135913. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  135914. */
  135915. indexOfRefraction: number;
  135916. private _volumeIndexOfRefraction;
  135917. /**
  135918. * Index of refraction of the material's volume.
  135919. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  135920. *
  135921. * This ONLY impacts refraction. If not provided or given a non-valid value,
  135922. * the volume will use the same IOR as the surface.
  135923. */
  135924. get volumeIndexOfRefraction(): number;
  135925. set volumeIndexOfRefraction(value: number);
  135926. private _invertRefractionY;
  135927. /**
  135928. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  135929. */
  135930. invertRefractionY: boolean;
  135931. private _linkRefractionWithTransparency;
  135932. /**
  135933. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  135934. * Materials half opaque for instance using refraction could benefit from this control.
  135935. */
  135936. linkRefractionWithTransparency: boolean;
  135937. /**
  135938. * Defines the minimum thickness stored in the thickness map.
  135939. * If no thickness map is defined, this value will be used to simulate thickness.
  135940. */
  135941. minimumThickness: number;
  135942. /**
  135943. * Defines the maximum thickness stored in the thickness map.
  135944. */
  135945. maximumThickness: number;
  135946. /**
  135947. * Defines the volume tint of the material.
  135948. * This is used for both translucency and scattering.
  135949. */
  135950. tintColor: Color3;
  135951. /**
  135952. * Defines the distance at which the tint color should be found in the media.
  135953. * This is used for refraction only.
  135954. */
  135955. tintColorAtDistance: number;
  135956. /**
  135957. * Defines how far each channel transmit through the media.
  135958. * It is defined as a color to simplify it selection.
  135959. */
  135960. diffusionDistance: Color3;
  135961. private _useMaskFromThicknessTexture;
  135962. /**
  135963. * Stores the intensity of the different subsurface effects in the thickness texture.
  135964. * * the green channel is the translucency intensity.
  135965. * * the blue channel is the scattering intensity.
  135966. * * the alpha channel is the refraction intensity.
  135967. */
  135968. useMaskFromThicknessTexture: boolean;
  135969. private _scene;
  135970. /** @hidden */
  135971. private _internalMarkAllSubMeshesAsTexturesDirty;
  135972. private _internalMarkScenePrePassDirty;
  135973. /** @hidden */
  135974. _markAllSubMeshesAsTexturesDirty(): void;
  135975. /** @hidden */
  135976. _markScenePrePassDirty(): void;
  135977. /**
  135978. * Instantiate a new istance of sub surface configuration.
  135979. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  135980. * @param markScenePrePassDirty Callback to flag the scene as prepass dirty
  135981. * @param scene The scene
  135982. */
  135983. constructor(markAllSubMeshesAsTexturesDirty: () => void, markScenePrePassDirty: () => void, scene: Scene);
  135984. /**
  135985. * Gets wehter the submesh is ready to be used or not.
  135986. * @param defines the list of "defines" to update.
  135987. * @param scene defines the scene the material belongs to.
  135988. * @returns - boolean indicating that the submesh is ready or not.
  135989. */
  135990. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  135991. /**
  135992. * Checks to see if a texture is used in the material.
  135993. * @param defines the list of "defines" to update.
  135994. * @param scene defines the scene to the material belongs to.
  135995. */
  135996. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  135997. /**
  135998. * Binds the material data.
  135999. * @param uniformBuffer defines the Uniform buffer to fill in.
  136000. * @param scene defines the scene the material belongs to.
  136001. * @param engine defines the engine the material belongs to.
  136002. * @param isFrozen defines whether the material is frozen or not.
  136003. * @param lodBasedMicrosurface defines whether the material relies on lod based microsurface or not.
  136004. * @param realTimeFiltering defines whether the textures should be filtered on the fly.
  136005. */
  136006. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean, realTimeFiltering: boolean): void;
  136007. /**
  136008. * Unbinds the material from the mesh.
  136009. * @param activeEffect defines the effect that should be unbound from.
  136010. * @returns true if unbound, otherwise false
  136011. */
  136012. unbind(activeEffect: Effect): boolean;
  136013. /**
  136014. * Returns the texture used for refraction or null if none is used.
  136015. * @param scene defines the scene the material belongs to.
  136016. * @returns - Refraction texture if present. If no refraction texture and refraction
  136017. * is linked with transparency, returns environment texture. Otherwise, returns null.
  136018. */
  136019. private _getRefractionTexture;
  136020. /**
  136021. * Returns true if alpha blending should be disabled.
  136022. */
  136023. get disableAlphaBlending(): boolean;
  136024. /**
  136025. * Fills the list of render target textures.
  136026. * @param renderTargets the list of render targets to update
  136027. */
  136028. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  136029. /**
  136030. * Checks to see if a texture is used in the material.
  136031. * @param texture - Base texture to use.
  136032. * @returns - Boolean specifying if a texture is used in the material.
  136033. */
  136034. hasTexture(texture: BaseTexture): boolean;
  136035. /**
  136036. * Gets a boolean indicating that current material needs to register RTT
  136037. * @returns true if this uses a render target otherwise false.
  136038. */
  136039. hasRenderTargetTextures(): boolean;
  136040. /**
  136041. * Returns an array of the actively used textures.
  136042. * @param activeTextures Array of BaseTextures
  136043. */
  136044. getActiveTextures(activeTextures: BaseTexture[]): void;
  136045. /**
  136046. * Returns the animatable textures.
  136047. * @param animatables Array of animatable textures.
  136048. */
  136049. getAnimatables(animatables: IAnimatable[]): void;
  136050. /**
  136051. * Disposes the resources of the material.
  136052. * @param forceDisposeTextures - Forces the disposal of all textures.
  136053. */
  136054. dispose(forceDisposeTextures?: boolean): void;
  136055. /**
  136056. * Get the current class name of the texture useful for serialization or dynamic coding.
  136057. * @returns "PBRSubSurfaceConfiguration"
  136058. */
  136059. getClassName(): string;
  136060. /**
  136061. * Add fallbacks to the effect fallbacks list.
  136062. * @param defines defines the Base texture to use.
  136063. * @param fallbacks defines the current fallback list.
  136064. * @param currentRank defines the current fallback rank.
  136065. * @returns the new fallback rank.
  136066. */
  136067. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  136068. /**
  136069. * Add the required uniforms to the current list.
  136070. * @param uniforms defines the current uniform list.
  136071. */
  136072. static AddUniforms(uniforms: string[]): void;
  136073. /**
  136074. * Add the required samplers to the current list.
  136075. * @param samplers defines the current sampler list.
  136076. */
  136077. static AddSamplers(samplers: string[]): void;
  136078. /**
  136079. * Add the required uniforms to the current buffer.
  136080. * @param uniformBuffer defines the current uniform buffer.
  136081. */
  136082. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  136083. /**
  136084. * Makes a duplicate of the current configuration into another one.
  136085. * @param configuration define the config where to copy the info
  136086. */
  136087. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  136088. /**
  136089. * Serializes this Sub Surface configuration.
  136090. * @returns - An object with the serialized config.
  136091. */
  136092. serialize(): any;
  136093. /**
  136094. * Parses a anisotropy Configuration from a serialized object.
  136095. * @param source - Serialized object.
  136096. * @param scene Defines the scene we are parsing for
  136097. * @param rootUrl Defines the rootUrl to load from
  136098. */
  136099. parse(source: any, scene: Scene, rootUrl: string): void;
  136100. }
  136101. }
  136102. declare module BABYLON {
  136103. /** @hidden */
  136104. export var pbrFragmentDeclaration: {
  136105. name: string;
  136106. shader: string;
  136107. };
  136108. }
  136109. declare module BABYLON {
  136110. /** @hidden */
  136111. export var pbrUboDeclaration: {
  136112. name: string;
  136113. shader: string;
  136114. };
  136115. }
  136116. declare module BABYLON {
  136117. /** @hidden */
  136118. export var pbrFragmentExtraDeclaration: {
  136119. name: string;
  136120. shader: string;
  136121. };
  136122. }
  136123. declare module BABYLON {
  136124. /** @hidden */
  136125. export var pbrFragmentSamplersDeclaration: {
  136126. name: string;
  136127. shader: string;
  136128. };
  136129. }
  136130. declare module BABYLON {
  136131. /** @hidden */
  136132. export var importanceSampling: {
  136133. name: string;
  136134. shader: string;
  136135. };
  136136. }
  136137. declare module BABYLON {
  136138. /** @hidden */
  136139. export var pbrHelperFunctions: {
  136140. name: string;
  136141. shader: string;
  136142. };
  136143. }
  136144. declare module BABYLON {
  136145. /** @hidden */
  136146. export var harmonicsFunctions: {
  136147. name: string;
  136148. shader: string;
  136149. };
  136150. }
  136151. declare module BABYLON {
  136152. /** @hidden */
  136153. export var pbrDirectLightingSetupFunctions: {
  136154. name: string;
  136155. shader: string;
  136156. };
  136157. }
  136158. declare module BABYLON {
  136159. /** @hidden */
  136160. export var pbrDirectLightingFalloffFunctions: {
  136161. name: string;
  136162. shader: string;
  136163. };
  136164. }
  136165. declare module BABYLON {
  136166. /** @hidden */
  136167. export var pbrBRDFFunctions: {
  136168. name: string;
  136169. shader: string;
  136170. };
  136171. }
  136172. declare module BABYLON {
  136173. /** @hidden */
  136174. export var hdrFilteringFunctions: {
  136175. name: string;
  136176. shader: string;
  136177. };
  136178. }
  136179. declare module BABYLON {
  136180. /** @hidden */
  136181. export var pbrDirectLightingFunctions: {
  136182. name: string;
  136183. shader: string;
  136184. };
  136185. }
  136186. declare module BABYLON {
  136187. /** @hidden */
  136188. export var pbrIBLFunctions: {
  136189. name: string;
  136190. shader: string;
  136191. };
  136192. }
  136193. declare module BABYLON {
  136194. /** @hidden */
  136195. export var pbrBlockAlbedoOpacity: {
  136196. name: string;
  136197. shader: string;
  136198. };
  136199. }
  136200. declare module BABYLON {
  136201. /** @hidden */
  136202. export var pbrBlockReflectivity: {
  136203. name: string;
  136204. shader: string;
  136205. };
  136206. }
  136207. declare module BABYLON {
  136208. /** @hidden */
  136209. export var pbrBlockAmbientOcclusion: {
  136210. name: string;
  136211. shader: string;
  136212. };
  136213. }
  136214. declare module BABYLON {
  136215. /** @hidden */
  136216. export var pbrBlockAlphaFresnel: {
  136217. name: string;
  136218. shader: string;
  136219. };
  136220. }
  136221. declare module BABYLON {
  136222. /** @hidden */
  136223. export var pbrBlockAnisotropic: {
  136224. name: string;
  136225. shader: string;
  136226. };
  136227. }
  136228. declare module BABYLON {
  136229. /** @hidden */
  136230. export var pbrBlockReflection: {
  136231. name: string;
  136232. shader: string;
  136233. };
  136234. }
  136235. declare module BABYLON {
  136236. /** @hidden */
  136237. export var pbrBlockSheen: {
  136238. name: string;
  136239. shader: string;
  136240. };
  136241. }
  136242. declare module BABYLON {
  136243. /** @hidden */
  136244. export var pbrBlockClearcoat: {
  136245. name: string;
  136246. shader: string;
  136247. };
  136248. }
  136249. declare module BABYLON {
  136250. /** @hidden */
  136251. export var pbrBlockSubSurface: {
  136252. name: string;
  136253. shader: string;
  136254. };
  136255. }
  136256. declare module BABYLON {
  136257. /** @hidden */
  136258. export var pbrBlockNormalGeometric: {
  136259. name: string;
  136260. shader: string;
  136261. };
  136262. }
  136263. declare module BABYLON {
  136264. /** @hidden */
  136265. export var pbrBlockNormalFinal: {
  136266. name: string;
  136267. shader: string;
  136268. };
  136269. }
  136270. declare module BABYLON {
  136271. /** @hidden */
  136272. export var pbrBlockLightmapInit: {
  136273. name: string;
  136274. shader: string;
  136275. };
  136276. }
  136277. declare module BABYLON {
  136278. /** @hidden */
  136279. export var pbrBlockGeometryInfo: {
  136280. name: string;
  136281. shader: string;
  136282. };
  136283. }
  136284. declare module BABYLON {
  136285. /** @hidden */
  136286. export var pbrBlockReflectance0: {
  136287. name: string;
  136288. shader: string;
  136289. };
  136290. }
  136291. declare module BABYLON {
  136292. /** @hidden */
  136293. export var pbrBlockReflectance: {
  136294. name: string;
  136295. shader: string;
  136296. };
  136297. }
  136298. declare module BABYLON {
  136299. /** @hidden */
  136300. export var pbrBlockDirectLighting: {
  136301. name: string;
  136302. shader: string;
  136303. };
  136304. }
  136305. declare module BABYLON {
  136306. /** @hidden */
  136307. export var pbrBlockFinalLitComponents: {
  136308. name: string;
  136309. shader: string;
  136310. };
  136311. }
  136312. declare module BABYLON {
  136313. /** @hidden */
  136314. export var pbrBlockFinalUnlitComponents: {
  136315. name: string;
  136316. shader: string;
  136317. };
  136318. }
  136319. declare module BABYLON {
  136320. /** @hidden */
  136321. export var pbrBlockFinalColorComposition: {
  136322. name: string;
  136323. shader: string;
  136324. };
  136325. }
  136326. declare module BABYLON {
  136327. /** @hidden */
  136328. export var pbrBlockImageProcessing: {
  136329. name: string;
  136330. shader: string;
  136331. };
  136332. }
  136333. declare module BABYLON {
  136334. /** @hidden */
  136335. export var pbrDebug: {
  136336. name: string;
  136337. shader: string;
  136338. };
  136339. }
  136340. declare module BABYLON {
  136341. /** @hidden */
  136342. export var pbrPixelShader: {
  136343. name: string;
  136344. shader: string;
  136345. };
  136346. }
  136347. declare module BABYLON {
  136348. /** @hidden */
  136349. export var pbrVertexDeclaration: {
  136350. name: string;
  136351. shader: string;
  136352. };
  136353. }
  136354. declare module BABYLON {
  136355. /** @hidden */
  136356. export var pbrVertexShader: {
  136357. name: string;
  136358. shader: string;
  136359. };
  136360. }
  136361. declare module BABYLON {
  136362. /**
  136363. * Manages the defines for the PBR Material.
  136364. * @hidden
  136365. */
  136366. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines, IMaterialDetailMapDefines {
  136367. PBR: boolean;
  136368. NUM_SAMPLES: string;
  136369. REALTIME_FILTERING: boolean;
  136370. MAINUV1: boolean;
  136371. MAINUV2: boolean;
  136372. UV1: boolean;
  136373. UV2: boolean;
  136374. ALBEDO: boolean;
  136375. GAMMAALBEDO: boolean;
  136376. ALBEDODIRECTUV: number;
  136377. VERTEXCOLOR: boolean;
  136378. DETAIL: boolean;
  136379. DETAILDIRECTUV: number;
  136380. DETAIL_NORMALBLENDMETHOD: number;
  136381. AMBIENT: boolean;
  136382. AMBIENTDIRECTUV: number;
  136383. AMBIENTINGRAYSCALE: boolean;
  136384. OPACITY: boolean;
  136385. VERTEXALPHA: boolean;
  136386. OPACITYDIRECTUV: number;
  136387. OPACITYRGB: boolean;
  136388. ALPHATEST: boolean;
  136389. DEPTHPREPASS: boolean;
  136390. ALPHABLEND: boolean;
  136391. ALPHAFROMALBEDO: boolean;
  136392. ALPHATESTVALUE: string;
  136393. SPECULAROVERALPHA: boolean;
  136394. RADIANCEOVERALPHA: boolean;
  136395. ALPHAFRESNEL: boolean;
  136396. LINEARALPHAFRESNEL: boolean;
  136397. PREMULTIPLYALPHA: boolean;
  136398. EMISSIVE: boolean;
  136399. EMISSIVEDIRECTUV: number;
  136400. REFLECTIVITY: boolean;
  136401. REFLECTIVITYDIRECTUV: number;
  136402. SPECULARTERM: boolean;
  136403. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  136404. MICROSURFACEAUTOMATIC: boolean;
  136405. LODBASEDMICROSFURACE: boolean;
  136406. MICROSURFACEMAP: boolean;
  136407. MICROSURFACEMAPDIRECTUV: number;
  136408. METALLICWORKFLOW: boolean;
  136409. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  136410. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  136411. METALLNESSSTOREINMETALMAPBLUE: boolean;
  136412. AOSTOREINMETALMAPRED: boolean;
  136413. METALLIC_REFLECTANCE: boolean;
  136414. METALLIC_REFLECTANCEDIRECTUV: number;
  136415. ENVIRONMENTBRDF: boolean;
  136416. ENVIRONMENTBRDF_RGBD: boolean;
  136417. NORMAL: boolean;
  136418. TANGENT: boolean;
  136419. BUMP: boolean;
  136420. BUMPDIRECTUV: number;
  136421. OBJECTSPACE_NORMALMAP: boolean;
  136422. PARALLAX: boolean;
  136423. PARALLAXOCCLUSION: boolean;
  136424. NORMALXYSCALE: boolean;
  136425. LIGHTMAP: boolean;
  136426. LIGHTMAPDIRECTUV: number;
  136427. USELIGHTMAPASSHADOWMAP: boolean;
  136428. GAMMALIGHTMAP: boolean;
  136429. RGBDLIGHTMAP: boolean;
  136430. REFLECTION: boolean;
  136431. REFLECTIONMAP_3D: boolean;
  136432. REFLECTIONMAP_SPHERICAL: boolean;
  136433. REFLECTIONMAP_PLANAR: boolean;
  136434. REFLECTIONMAP_CUBIC: boolean;
  136435. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  136436. REFLECTIONMAP_PROJECTION: boolean;
  136437. REFLECTIONMAP_SKYBOX: boolean;
  136438. REFLECTIONMAP_EXPLICIT: boolean;
  136439. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  136440. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  136441. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  136442. INVERTCUBICMAP: boolean;
  136443. USESPHERICALFROMREFLECTIONMAP: boolean;
  136444. USEIRRADIANCEMAP: boolean;
  136445. SPHERICAL_HARMONICS: boolean;
  136446. USESPHERICALINVERTEX: boolean;
  136447. REFLECTIONMAP_OPPOSITEZ: boolean;
  136448. LODINREFLECTIONALPHA: boolean;
  136449. GAMMAREFLECTION: boolean;
  136450. RGBDREFLECTION: boolean;
  136451. LINEARSPECULARREFLECTION: boolean;
  136452. RADIANCEOCCLUSION: boolean;
  136453. HORIZONOCCLUSION: boolean;
  136454. INSTANCES: boolean;
  136455. THIN_INSTANCES: boolean;
  136456. PREPASS: boolean;
  136457. SCENE_MRT_COUNT: number;
  136458. NUM_BONE_INFLUENCERS: number;
  136459. BonesPerMesh: number;
  136460. BONETEXTURE: boolean;
  136461. NONUNIFORMSCALING: boolean;
  136462. MORPHTARGETS: boolean;
  136463. MORPHTARGETS_NORMAL: boolean;
  136464. MORPHTARGETS_TANGENT: boolean;
  136465. MORPHTARGETS_UV: boolean;
  136466. NUM_MORPH_INFLUENCERS: number;
  136467. IMAGEPROCESSING: boolean;
  136468. VIGNETTE: boolean;
  136469. VIGNETTEBLENDMODEMULTIPLY: boolean;
  136470. VIGNETTEBLENDMODEOPAQUE: boolean;
  136471. TONEMAPPING: boolean;
  136472. TONEMAPPING_ACES: boolean;
  136473. CONTRAST: boolean;
  136474. COLORCURVES: boolean;
  136475. COLORGRADING: boolean;
  136476. COLORGRADING3D: boolean;
  136477. SAMPLER3DGREENDEPTH: boolean;
  136478. SAMPLER3DBGRMAP: boolean;
  136479. IMAGEPROCESSINGPOSTPROCESS: boolean;
  136480. EXPOSURE: boolean;
  136481. MULTIVIEW: boolean;
  136482. USEPHYSICALLIGHTFALLOFF: boolean;
  136483. USEGLTFLIGHTFALLOFF: boolean;
  136484. TWOSIDEDLIGHTING: boolean;
  136485. SHADOWFLOAT: boolean;
  136486. CLIPPLANE: boolean;
  136487. CLIPPLANE2: boolean;
  136488. CLIPPLANE3: boolean;
  136489. CLIPPLANE4: boolean;
  136490. CLIPPLANE5: boolean;
  136491. CLIPPLANE6: boolean;
  136492. POINTSIZE: boolean;
  136493. FOG: boolean;
  136494. LOGARITHMICDEPTH: boolean;
  136495. FORCENORMALFORWARD: boolean;
  136496. SPECULARAA: boolean;
  136497. CLEARCOAT: boolean;
  136498. CLEARCOAT_DEFAULTIOR: boolean;
  136499. CLEARCOAT_TEXTURE: boolean;
  136500. CLEARCOAT_TEXTUREDIRECTUV: number;
  136501. CLEARCOAT_BUMP: boolean;
  136502. CLEARCOAT_BUMPDIRECTUV: number;
  136503. CLEARCOAT_TINT: boolean;
  136504. CLEARCOAT_TINT_TEXTURE: boolean;
  136505. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  136506. ANISOTROPIC: boolean;
  136507. ANISOTROPIC_TEXTURE: boolean;
  136508. ANISOTROPIC_TEXTUREDIRECTUV: number;
  136509. BRDF_V_HEIGHT_CORRELATED: boolean;
  136510. MS_BRDF_ENERGY_CONSERVATION: boolean;
  136511. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  136512. SHEEN: boolean;
  136513. SHEEN_TEXTURE: boolean;
  136514. SHEEN_TEXTUREDIRECTUV: number;
  136515. SHEEN_LINKWITHALBEDO: boolean;
  136516. SHEEN_ROUGHNESS: boolean;
  136517. SHEEN_ALBEDOSCALING: boolean;
  136518. SUBSURFACE: boolean;
  136519. SS_REFRACTION: boolean;
  136520. SS_TRANSLUCENCY: boolean;
  136521. SS_SCATTERING: boolean;
  136522. SS_THICKNESSANDMASK_TEXTURE: boolean;
  136523. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  136524. SS_REFRACTIONMAP_3D: boolean;
  136525. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  136526. SS_LODINREFRACTIONALPHA: boolean;
  136527. SS_GAMMAREFRACTION: boolean;
  136528. SS_RGBDREFRACTION: boolean;
  136529. SS_LINEARSPECULARREFRACTION: boolean;
  136530. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  136531. SS_ALBEDOFORREFRACTIONTINT: boolean;
  136532. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  136533. UNLIT: boolean;
  136534. DEBUGMODE: number;
  136535. /**
  136536. * Initializes the PBR Material defines.
  136537. */
  136538. constructor();
  136539. /**
  136540. * Resets the PBR Material defines.
  136541. */
  136542. reset(): void;
  136543. }
  136544. /**
  136545. * The Physically based material base class of BJS.
  136546. *
  136547. * This offers the main features of a standard PBR material.
  136548. * For more information, please refer to the documentation :
  136549. * https://doc.babylonjs.com/how_to/physically_based_rendering
  136550. */
  136551. export abstract class PBRBaseMaterial extends PushMaterial {
  136552. /**
  136553. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  136554. */
  136555. static readonly PBRMATERIAL_OPAQUE: number;
  136556. /**
  136557. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  136558. */
  136559. static readonly PBRMATERIAL_ALPHATEST: number;
  136560. /**
  136561. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  136562. */
  136563. static readonly PBRMATERIAL_ALPHABLEND: number;
  136564. /**
  136565. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  136566. * They are also discarded below the alpha cutoff threshold to improve performances.
  136567. */
  136568. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  136569. /**
  136570. * Defines the default value of how much AO map is occluding the analytical lights
  136571. * (point spot...).
  136572. */
  136573. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  136574. /**
  136575. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  136576. */
  136577. static readonly LIGHTFALLOFF_PHYSICAL: number;
  136578. /**
  136579. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  136580. * to enhance interoperability with other engines.
  136581. */
  136582. static readonly LIGHTFALLOFF_GLTF: number;
  136583. /**
  136584. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  136585. * to enhance interoperability with other materials.
  136586. */
  136587. static readonly LIGHTFALLOFF_STANDARD: number;
  136588. /**
  136589. * Intensity of the direct lights e.g. the four lights available in your scene.
  136590. * This impacts both the direct diffuse and specular highlights.
  136591. */
  136592. protected _directIntensity: number;
  136593. /**
  136594. * Intensity of the emissive part of the material.
  136595. * This helps controlling the emissive effect without modifying the emissive color.
  136596. */
  136597. protected _emissiveIntensity: number;
  136598. /**
  136599. * Intensity of the environment e.g. how much the environment will light the object
  136600. * either through harmonics for rough material or through the refelction for shiny ones.
  136601. */
  136602. protected _environmentIntensity: number;
  136603. /**
  136604. * This is a special control allowing the reduction of the specular highlights coming from the
  136605. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  136606. */
  136607. protected _specularIntensity: number;
  136608. /**
  136609. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  136610. */
  136611. private _lightingInfos;
  136612. /**
  136613. * Debug Control allowing disabling the bump map on this material.
  136614. */
  136615. protected _disableBumpMap: boolean;
  136616. /**
  136617. * AKA Diffuse Texture in standard nomenclature.
  136618. */
  136619. protected _albedoTexture: Nullable<BaseTexture>;
  136620. /**
  136621. * AKA Occlusion Texture in other nomenclature.
  136622. */
  136623. protected _ambientTexture: Nullable<BaseTexture>;
  136624. /**
  136625. * AKA Occlusion Texture Intensity in other nomenclature.
  136626. */
  136627. protected _ambientTextureStrength: number;
  136628. /**
  136629. * Defines how much the AO map is occluding the analytical lights (point spot...).
  136630. * 1 means it completely occludes it
  136631. * 0 mean it has no impact
  136632. */
  136633. protected _ambientTextureImpactOnAnalyticalLights: number;
  136634. /**
  136635. * Stores the alpha values in a texture.
  136636. */
  136637. protected _opacityTexture: Nullable<BaseTexture>;
  136638. /**
  136639. * Stores the reflection values in a texture.
  136640. */
  136641. protected _reflectionTexture: Nullable<BaseTexture>;
  136642. /**
  136643. * Stores the emissive values in a texture.
  136644. */
  136645. protected _emissiveTexture: Nullable<BaseTexture>;
  136646. /**
  136647. * AKA Specular texture in other nomenclature.
  136648. */
  136649. protected _reflectivityTexture: Nullable<BaseTexture>;
  136650. /**
  136651. * Used to switch from specular/glossiness to metallic/roughness workflow.
  136652. */
  136653. protected _metallicTexture: Nullable<BaseTexture>;
  136654. /**
  136655. * Specifies the metallic scalar of the metallic/roughness workflow.
  136656. * Can also be used to scale the metalness values of the metallic texture.
  136657. */
  136658. protected _metallic: Nullable<number>;
  136659. /**
  136660. * Specifies the roughness scalar of the metallic/roughness workflow.
  136661. * Can also be used to scale the roughness values of the metallic texture.
  136662. */
  136663. protected _roughness: Nullable<number>;
  136664. /**
  136665. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  136666. * By default the indexOfrefraction is used to compute F0;
  136667. *
  136668. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  136669. *
  136670. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  136671. * F90 = metallicReflectanceColor;
  136672. */
  136673. protected _metallicF0Factor: number;
  136674. /**
  136675. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  136676. * By default the F90 is always 1;
  136677. *
  136678. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  136679. *
  136680. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  136681. * F90 = metallicReflectanceColor;
  136682. */
  136683. protected _metallicReflectanceColor: Color3;
  136684. /**
  136685. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  136686. * This is multiply against the scalar values defined in the material.
  136687. */
  136688. protected _metallicReflectanceTexture: Nullable<BaseTexture>;
  136689. /**
  136690. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  136691. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  136692. */
  136693. protected _microSurfaceTexture: Nullable<BaseTexture>;
  136694. /**
  136695. * Stores surface normal data used to displace a mesh in a texture.
  136696. */
  136697. protected _bumpTexture: Nullable<BaseTexture>;
  136698. /**
  136699. * Stores the pre-calculated light information of a mesh in a texture.
  136700. */
  136701. protected _lightmapTexture: Nullable<BaseTexture>;
  136702. /**
  136703. * The color of a material in ambient lighting.
  136704. */
  136705. protected _ambientColor: Color3;
  136706. /**
  136707. * AKA Diffuse Color in other nomenclature.
  136708. */
  136709. protected _albedoColor: Color3;
  136710. /**
  136711. * AKA Specular Color in other nomenclature.
  136712. */
  136713. protected _reflectivityColor: Color3;
  136714. /**
  136715. * The color applied when light is reflected from a material.
  136716. */
  136717. protected _reflectionColor: Color3;
  136718. /**
  136719. * The color applied when light is emitted from a material.
  136720. */
  136721. protected _emissiveColor: Color3;
  136722. /**
  136723. * AKA Glossiness in other nomenclature.
  136724. */
  136725. protected _microSurface: number;
  136726. /**
  136727. * Specifies that the material will use the light map as a show map.
  136728. */
  136729. protected _useLightmapAsShadowmap: boolean;
  136730. /**
  136731. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  136732. * makes the reflect vector face the model (under horizon).
  136733. */
  136734. protected _useHorizonOcclusion: boolean;
  136735. /**
  136736. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  136737. * too much the area relying on ambient texture to define their ambient occlusion.
  136738. */
  136739. protected _useRadianceOcclusion: boolean;
  136740. /**
  136741. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  136742. */
  136743. protected _useAlphaFromAlbedoTexture: boolean;
  136744. /**
  136745. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  136746. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  136747. */
  136748. protected _useSpecularOverAlpha: boolean;
  136749. /**
  136750. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  136751. */
  136752. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  136753. /**
  136754. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  136755. */
  136756. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  136757. /**
  136758. * Specifies if the metallic texture contains the roughness information in its green channel.
  136759. */
  136760. protected _useRoughnessFromMetallicTextureGreen: boolean;
  136761. /**
  136762. * Specifies if the metallic texture contains the metallness information in its blue channel.
  136763. */
  136764. protected _useMetallnessFromMetallicTextureBlue: boolean;
  136765. /**
  136766. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  136767. */
  136768. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  136769. /**
  136770. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  136771. */
  136772. protected _useAmbientInGrayScale: boolean;
  136773. /**
  136774. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  136775. * The material will try to infer what glossiness each pixel should be.
  136776. */
  136777. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  136778. /**
  136779. * Defines the falloff type used in this material.
  136780. * It by default is Physical.
  136781. */
  136782. protected _lightFalloff: number;
  136783. /**
  136784. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  136785. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  136786. */
  136787. protected _useRadianceOverAlpha: boolean;
  136788. /**
  136789. * Allows using an object space normal map (instead of tangent space).
  136790. */
  136791. protected _useObjectSpaceNormalMap: boolean;
  136792. /**
  136793. * Allows using the bump map in parallax mode.
  136794. */
  136795. protected _useParallax: boolean;
  136796. /**
  136797. * Allows using the bump map in parallax occlusion mode.
  136798. */
  136799. protected _useParallaxOcclusion: boolean;
  136800. /**
  136801. * Controls the scale bias of the parallax mode.
  136802. */
  136803. protected _parallaxScaleBias: number;
  136804. /**
  136805. * If sets to true, disables all the lights affecting the material.
  136806. */
  136807. protected _disableLighting: boolean;
  136808. /**
  136809. * Number of Simultaneous lights allowed on the material.
  136810. */
  136811. protected _maxSimultaneousLights: number;
  136812. /**
  136813. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  136814. */
  136815. protected _invertNormalMapX: boolean;
  136816. /**
  136817. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  136818. */
  136819. protected _invertNormalMapY: boolean;
  136820. /**
  136821. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  136822. */
  136823. protected _twoSidedLighting: boolean;
  136824. /**
  136825. * Defines the alpha limits in alpha test mode.
  136826. */
  136827. protected _alphaCutOff: number;
  136828. /**
  136829. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  136830. */
  136831. protected _forceAlphaTest: boolean;
  136832. /**
  136833. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  136834. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  136835. */
  136836. protected _useAlphaFresnel: boolean;
  136837. /**
  136838. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  136839. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  136840. */
  136841. protected _useLinearAlphaFresnel: boolean;
  136842. /**
  136843. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  136844. * from cos thetav and roughness:
  136845. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  136846. */
  136847. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  136848. /**
  136849. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  136850. */
  136851. protected _forceIrradianceInFragment: boolean;
  136852. private _realTimeFiltering;
  136853. /**
  136854. * Enables realtime filtering on the texture.
  136855. */
  136856. get realTimeFiltering(): boolean;
  136857. set realTimeFiltering(b: boolean);
  136858. private _realTimeFilteringQuality;
  136859. /**
  136860. * Quality switch for realtime filtering
  136861. */
  136862. get realTimeFilteringQuality(): number;
  136863. set realTimeFilteringQuality(n: number);
  136864. /**
  136865. * Can this material render to several textures at once
  136866. */
  136867. get canRenderToMRT(): boolean;
  136868. /**
  136869. * Force normal to face away from face.
  136870. */
  136871. protected _forceNormalForward: boolean;
  136872. /**
  136873. * Enables specular anti aliasing in the PBR shader.
  136874. * It will both interacts on the Geometry for analytical and IBL lighting.
  136875. * It also prefilter the roughness map based on the bump values.
  136876. */
  136877. protected _enableSpecularAntiAliasing: boolean;
  136878. /**
  136879. * Default configuration related to image processing available in the PBR Material.
  136880. */
  136881. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  136882. /**
  136883. * Keep track of the image processing observer to allow dispose and replace.
  136884. */
  136885. private _imageProcessingObserver;
  136886. /**
  136887. * Attaches a new image processing configuration to the PBR Material.
  136888. * @param configuration
  136889. */
  136890. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  136891. /**
  136892. * Stores the available render targets.
  136893. */
  136894. private _renderTargets;
  136895. /**
  136896. * Sets the global ambient color for the material used in lighting calculations.
  136897. */
  136898. private _globalAmbientColor;
  136899. /**
  136900. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  136901. */
  136902. private _useLogarithmicDepth;
  136903. /**
  136904. * If set to true, no lighting calculations will be applied.
  136905. */
  136906. private _unlit;
  136907. private _debugMode;
  136908. /**
  136909. * @hidden
  136910. * This is reserved for the inspector.
  136911. * Defines the material debug mode.
  136912. * It helps seeing only some components of the material while troubleshooting.
  136913. */
  136914. debugMode: number;
  136915. /**
  136916. * @hidden
  136917. * This is reserved for the inspector.
  136918. * Specify from where on screen the debug mode should start.
  136919. * The value goes from -1 (full screen) to 1 (not visible)
  136920. * It helps with side by side comparison against the final render
  136921. * This defaults to -1
  136922. */
  136923. private debugLimit;
  136924. /**
  136925. * @hidden
  136926. * This is reserved for the inspector.
  136927. * As the default viewing range might not be enough (if the ambient is really small for instance)
  136928. * You can use the factor to better multiply the final value.
  136929. */
  136930. private debugFactor;
  136931. /**
  136932. * Defines the clear coat layer parameters for the material.
  136933. */
  136934. readonly clearCoat: PBRClearCoatConfiguration;
  136935. /**
  136936. * Defines the anisotropic parameters for the material.
  136937. */
  136938. readonly anisotropy: PBRAnisotropicConfiguration;
  136939. /**
  136940. * Defines the BRDF parameters for the material.
  136941. */
  136942. readonly brdf: PBRBRDFConfiguration;
  136943. /**
  136944. * Defines the Sheen parameters for the material.
  136945. */
  136946. readonly sheen: PBRSheenConfiguration;
  136947. /**
  136948. * Defines the SubSurface parameters for the material.
  136949. */
  136950. readonly subSurface: PBRSubSurfaceConfiguration;
  136951. /**
  136952. * Defines the detail map parameters for the material.
  136953. */
  136954. readonly detailMap: DetailMapConfiguration;
  136955. protected _rebuildInParallel: boolean;
  136956. /**
  136957. * Instantiates a new PBRMaterial instance.
  136958. *
  136959. * @param name The material name
  136960. * @param scene The scene the material will be use in.
  136961. */
  136962. constructor(name: string, scene: Scene);
  136963. /**
  136964. * Gets a boolean indicating that current material needs to register RTT
  136965. */
  136966. get hasRenderTargetTextures(): boolean;
  136967. /**
  136968. * Gets the name of the material class.
  136969. */
  136970. getClassName(): string;
  136971. /**
  136972. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  136973. */
  136974. get useLogarithmicDepth(): boolean;
  136975. /**
  136976. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  136977. */
  136978. set useLogarithmicDepth(value: boolean);
  136979. /**
  136980. * Returns true if alpha blending should be disabled.
  136981. */
  136982. protected get _disableAlphaBlending(): boolean;
  136983. /**
  136984. * Specifies whether or not this material should be rendered in alpha blend mode.
  136985. */
  136986. needAlphaBlending(): boolean;
  136987. /**
  136988. * Specifies whether or not this material should be rendered in alpha test mode.
  136989. */
  136990. needAlphaTesting(): boolean;
  136991. /**
  136992. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  136993. */
  136994. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  136995. /**
  136996. * Gets the texture used for the alpha test.
  136997. */
  136998. getAlphaTestTexture(): Nullable<BaseTexture>;
  136999. /**
  137000. * Specifies that the submesh is ready to be used.
  137001. * @param mesh - BJS mesh.
  137002. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  137003. * @param useInstances - Specifies that instances should be used.
  137004. * @returns - boolean indicating that the submesh is ready or not.
  137005. */
  137006. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  137007. /**
  137008. * Specifies if the material uses metallic roughness workflow.
  137009. * @returns boolean specifiying if the material uses metallic roughness workflow.
  137010. */
  137011. isMetallicWorkflow(): boolean;
  137012. private _prepareEffect;
  137013. private _prepareDefines;
  137014. /**
  137015. * Force shader compilation
  137016. */
  137017. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  137018. /**
  137019. * Initializes the uniform buffer layout for the shader.
  137020. */
  137021. buildUniformLayout(): void;
  137022. /**
  137023. * Unbinds the material from the mesh
  137024. */
  137025. unbind(): void;
  137026. /**
  137027. * Binds the submesh data.
  137028. * @param world - The world matrix.
  137029. * @param mesh - The BJS mesh.
  137030. * @param subMesh - A submesh of the BJS mesh.
  137031. */
  137032. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  137033. /**
  137034. * Returns the animatable textures.
  137035. * @returns - Array of animatable textures.
  137036. */
  137037. getAnimatables(): IAnimatable[];
  137038. /**
  137039. * Returns the texture used for reflections.
  137040. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  137041. */
  137042. private _getReflectionTexture;
  137043. /**
  137044. * Returns an array of the actively used textures.
  137045. * @returns - Array of BaseTextures
  137046. */
  137047. getActiveTextures(): BaseTexture[];
  137048. /**
  137049. * Checks to see if a texture is used in the material.
  137050. * @param texture - Base texture to use.
  137051. * @returns - Boolean specifying if a texture is used in the material.
  137052. */
  137053. hasTexture(texture: BaseTexture): boolean;
  137054. /**
  137055. * Sets the required values to the prepass renderer.
  137056. * @param prePassRenderer defines the prepass renderer to setup
  137057. */
  137058. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  137059. /**
  137060. * Disposes the resources of the material.
  137061. * @param forceDisposeEffect - Forces the disposal of effects.
  137062. * @param forceDisposeTextures - Forces the disposal of all textures.
  137063. */
  137064. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  137065. }
  137066. }
  137067. declare module BABYLON {
  137068. /**
  137069. * The Physically based material of BJS.
  137070. *
  137071. * This offers the main features of a standard PBR material.
  137072. * For more information, please refer to the documentation :
  137073. * https://doc.babylonjs.com/how_to/physically_based_rendering
  137074. */
  137075. export class PBRMaterial extends PBRBaseMaterial {
  137076. /**
  137077. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  137078. */
  137079. static readonly PBRMATERIAL_OPAQUE: number;
  137080. /**
  137081. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  137082. */
  137083. static readonly PBRMATERIAL_ALPHATEST: number;
  137084. /**
  137085. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  137086. */
  137087. static readonly PBRMATERIAL_ALPHABLEND: number;
  137088. /**
  137089. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  137090. * They are also discarded below the alpha cutoff threshold to improve performances.
  137091. */
  137092. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  137093. /**
  137094. * Defines the default value of how much AO map is occluding the analytical lights
  137095. * (point spot...).
  137096. */
  137097. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  137098. /**
  137099. * Intensity of the direct lights e.g. the four lights available in your scene.
  137100. * This impacts both the direct diffuse and specular highlights.
  137101. */
  137102. directIntensity: number;
  137103. /**
  137104. * Intensity of the emissive part of the material.
  137105. * This helps controlling the emissive effect without modifying the emissive color.
  137106. */
  137107. emissiveIntensity: number;
  137108. /**
  137109. * Intensity of the environment e.g. how much the environment will light the object
  137110. * either through harmonics for rough material or through the refelction for shiny ones.
  137111. */
  137112. environmentIntensity: number;
  137113. /**
  137114. * This is a special control allowing the reduction of the specular highlights coming from the
  137115. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  137116. */
  137117. specularIntensity: number;
  137118. /**
  137119. * Debug Control allowing disabling the bump map on this material.
  137120. */
  137121. disableBumpMap: boolean;
  137122. /**
  137123. * AKA Diffuse Texture in standard nomenclature.
  137124. */
  137125. albedoTexture: BaseTexture;
  137126. /**
  137127. * AKA Occlusion Texture in other nomenclature.
  137128. */
  137129. ambientTexture: BaseTexture;
  137130. /**
  137131. * AKA Occlusion Texture Intensity in other nomenclature.
  137132. */
  137133. ambientTextureStrength: number;
  137134. /**
  137135. * Defines how much the AO map is occluding the analytical lights (point spot...).
  137136. * 1 means it completely occludes it
  137137. * 0 mean it has no impact
  137138. */
  137139. ambientTextureImpactOnAnalyticalLights: number;
  137140. /**
  137141. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  137142. */
  137143. opacityTexture: BaseTexture;
  137144. /**
  137145. * Stores the reflection values in a texture.
  137146. */
  137147. reflectionTexture: Nullable<BaseTexture>;
  137148. /**
  137149. * Stores the emissive values in a texture.
  137150. */
  137151. emissiveTexture: BaseTexture;
  137152. /**
  137153. * AKA Specular texture in other nomenclature.
  137154. */
  137155. reflectivityTexture: BaseTexture;
  137156. /**
  137157. * Used to switch from specular/glossiness to metallic/roughness workflow.
  137158. */
  137159. metallicTexture: BaseTexture;
  137160. /**
  137161. * Specifies the metallic scalar of the metallic/roughness workflow.
  137162. * Can also be used to scale the metalness values of the metallic texture.
  137163. */
  137164. metallic: Nullable<number>;
  137165. /**
  137166. * Specifies the roughness scalar of the metallic/roughness workflow.
  137167. * Can also be used to scale the roughness values of the metallic texture.
  137168. */
  137169. roughness: Nullable<number>;
  137170. /**
  137171. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  137172. * By default the indexOfrefraction is used to compute F0;
  137173. *
  137174. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  137175. *
  137176. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  137177. * F90 = metallicReflectanceColor;
  137178. */
  137179. metallicF0Factor: number;
  137180. /**
  137181. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  137182. * By default the F90 is always 1;
  137183. *
  137184. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  137185. *
  137186. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  137187. * F90 = metallicReflectanceColor;
  137188. */
  137189. metallicReflectanceColor: Color3;
  137190. /**
  137191. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  137192. * This is multiply against the scalar values defined in the material.
  137193. */
  137194. metallicReflectanceTexture: Nullable<BaseTexture>;
  137195. /**
  137196. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  137197. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  137198. */
  137199. microSurfaceTexture: BaseTexture;
  137200. /**
  137201. * Stores surface normal data used to displace a mesh in a texture.
  137202. */
  137203. bumpTexture: BaseTexture;
  137204. /**
  137205. * Stores the pre-calculated light information of a mesh in a texture.
  137206. */
  137207. lightmapTexture: BaseTexture;
  137208. /**
  137209. * Stores the refracted light information in a texture.
  137210. */
  137211. get refractionTexture(): Nullable<BaseTexture>;
  137212. set refractionTexture(value: Nullable<BaseTexture>);
  137213. /**
  137214. * The color of a material in ambient lighting.
  137215. */
  137216. ambientColor: Color3;
  137217. /**
  137218. * AKA Diffuse Color in other nomenclature.
  137219. */
  137220. albedoColor: Color3;
  137221. /**
  137222. * AKA Specular Color in other nomenclature.
  137223. */
  137224. reflectivityColor: Color3;
  137225. /**
  137226. * The color reflected from the material.
  137227. */
  137228. reflectionColor: Color3;
  137229. /**
  137230. * The color emitted from the material.
  137231. */
  137232. emissiveColor: Color3;
  137233. /**
  137234. * AKA Glossiness in other nomenclature.
  137235. */
  137236. microSurface: number;
  137237. /**
  137238. * Index of refraction of the material base layer.
  137239. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  137240. *
  137241. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  137242. *
  137243. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  137244. */
  137245. get indexOfRefraction(): number;
  137246. set indexOfRefraction(value: number);
  137247. /**
  137248. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  137249. */
  137250. get invertRefractionY(): boolean;
  137251. set invertRefractionY(value: boolean);
  137252. /**
  137253. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  137254. * Materials half opaque for instance using refraction could benefit from this control.
  137255. */
  137256. get linkRefractionWithTransparency(): boolean;
  137257. set linkRefractionWithTransparency(value: boolean);
  137258. /**
  137259. * If true, the light map contains occlusion information instead of lighting info.
  137260. */
  137261. useLightmapAsShadowmap: boolean;
  137262. /**
  137263. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  137264. */
  137265. useAlphaFromAlbedoTexture: boolean;
  137266. /**
  137267. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  137268. */
  137269. forceAlphaTest: boolean;
  137270. /**
  137271. * Defines the alpha limits in alpha test mode.
  137272. */
  137273. alphaCutOff: number;
  137274. /**
  137275. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  137276. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  137277. */
  137278. useSpecularOverAlpha: boolean;
  137279. /**
  137280. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  137281. */
  137282. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  137283. /**
  137284. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  137285. */
  137286. useRoughnessFromMetallicTextureAlpha: boolean;
  137287. /**
  137288. * Specifies if the metallic texture contains the roughness information in its green channel.
  137289. */
  137290. useRoughnessFromMetallicTextureGreen: boolean;
  137291. /**
  137292. * Specifies if the metallic texture contains the metallness information in its blue channel.
  137293. */
  137294. useMetallnessFromMetallicTextureBlue: boolean;
  137295. /**
  137296. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  137297. */
  137298. useAmbientOcclusionFromMetallicTextureRed: boolean;
  137299. /**
  137300. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  137301. */
  137302. useAmbientInGrayScale: boolean;
  137303. /**
  137304. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  137305. * The material will try to infer what glossiness each pixel should be.
  137306. */
  137307. useAutoMicroSurfaceFromReflectivityMap: boolean;
  137308. /**
  137309. * BJS is using an harcoded light falloff based on a manually sets up range.
  137310. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  137311. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  137312. */
  137313. get usePhysicalLightFalloff(): boolean;
  137314. /**
  137315. * BJS is using an harcoded light falloff based on a manually sets up range.
  137316. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  137317. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  137318. */
  137319. set usePhysicalLightFalloff(value: boolean);
  137320. /**
  137321. * In order to support the falloff compatibility with gltf, a special mode has been added
  137322. * to reproduce the gltf light falloff.
  137323. */
  137324. get useGLTFLightFalloff(): boolean;
  137325. /**
  137326. * In order to support the falloff compatibility with gltf, a special mode has been added
  137327. * to reproduce the gltf light falloff.
  137328. */
  137329. set useGLTFLightFalloff(value: boolean);
  137330. /**
  137331. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  137332. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  137333. */
  137334. useRadianceOverAlpha: boolean;
  137335. /**
  137336. * Allows using an object space normal map (instead of tangent space).
  137337. */
  137338. useObjectSpaceNormalMap: boolean;
  137339. /**
  137340. * Allows using the bump map in parallax mode.
  137341. */
  137342. useParallax: boolean;
  137343. /**
  137344. * Allows using the bump map in parallax occlusion mode.
  137345. */
  137346. useParallaxOcclusion: boolean;
  137347. /**
  137348. * Controls the scale bias of the parallax mode.
  137349. */
  137350. parallaxScaleBias: number;
  137351. /**
  137352. * If sets to true, disables all the lights affecting the material.
  137353. */
  137354. disableLighting: boolean;
  137355. /**
  137356. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  137357. */
  137358. forceIrradianceInFragment: boolean;
  137359. /**
  137360. * Number of Simultaneous lights allowed on the material.
  137361. */
  137362. maxSimultaneousLights: number;
  137363. /**
  137364. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  137365. */
  137366. invertNormalMapX: boolean;
  137367. /**
  137368. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  137369. */
  137370. invertNormalMapY: boolean;
  137371. /**
  137372. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  137373. */
  137374. twoSidedLighting: boolean;
  137375. /**
  137376. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  137377. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  137378. */
  137379. useAlphaFresnel: boolean;
  137380. /**
  137381. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  137382. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  137383. */
  137384. useLinearAlphaFresnel: boolean;
  137385. /**
  137386. * Let user defines the brdf lookup texture used for IBL.
  137387. * A default 8bit version is embedded but you could point at :
  137388. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  137389. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  137390. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  137391. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  137392. */
  137393. environmentBRDFTexture: Nullable<BaseTexture>;
  137394. /**
  137395. * Force normal to face away from face.
  137396. */
  137397. forceNormalForward: boolean;
  137398. /**
  137399. * Enables specular anti aliasing in the PBR shader.
  137400. * It will both interacts on the Geometry for analytical and IBL lighting.
  137401. * It also prefilter the roughness map based on the bump values.
  137402. */
  137403. enableSpecularAntiAliasing: boolean;
  137404. /**
  137405. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  137406. * makes the reflect vector face the model (under horizon).
  137407. */
  137408. useHorizonOcclusion: boolean;
  137409. /**
  137410. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  137411. * too much the area relying on ambient texture to define their ambient occlusion.
  137412. */
  137413. useRadianceOcclusion: boolean;
  137414. /**
  137415. * If set to true, no lighting calculations will be applied.
  137416. */
  137417. unlit: boolean;
  137418. /**
  137419. * Gets the image processing configuration used either in this material.
  137420. */
  137421. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  137422. /**
  137423. * Sets the Default image processing configuration used either in the this material.
  137424. *
  137425. * If sets to null, the scene one is in use.
  137426. */
  137427. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  137428. /**
  137429. * Gets wether the color curves effect is enabled.
  137430. */
  137431. get cameraColorCurvesEnabled(): boolean;
  137432. /**
  137433. * Sets wether the color curves effect is enabled.
  137434. */
  137435. set cameraColorCurvesEnabled(value: boolean);
  137436. /**
  137437. * Gets wether the color grading effect is enabled.
  137438. */
  137439. get cameraColorGradingEnabled(): boolean;
  137440. /**
  137441. * Gets wether the color grading effect is enabled.
  137442. */
  137443. set cameraColorGradingEnabled(value: boolean);
  137444. /**
  137445. * Gets wether tonemapping is enabled or not.
  137446. */
  137447. get cameraToneMappingEnabled(): boolean;
  137448. /**
  137449. * Sets wether tonemapping is enabled or not
  137450. */
  137451. set cameraToneMappingEnabled(value: boolean);
  137452. /**
  137453. * The camera exposure used on this material.
  137454. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  137455. * This corresponds to a photographic exposure.
  137456. */
  137457. get cameraExposure(): number;
  137458. /**
  137459. * The camera exposure used on this material.
  137460. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  137461. * This corresponds to a photographic exposure.
  137462. */
  137463. set cameraExposure(value: number);
  137464. /**
  137465. * Gets The camera contrast used on this material.
  137466. */
  137467. get cameraContrast(): number;
  137468. /**
  137469. * Sets The camera contrast used on this material.
  137470. */
  137471. set cameraContrast(value: number);
  137472. /**
  137473. * Gets the Color Grading 2D Lookup Texture.
  137474. */
  137475. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  137476. /**
  137477. * Sets the Color Grading 2D Lookup Texture.
  137478. */
  137479. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  137480. /**
  137481. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  137482. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  137483. * 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;
  137484. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  137485. */
  137486. get cameraColorCurves(): Nullable<ColorCurves>;
  137487. /**
  137488. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  137489. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  137490. * 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;
  137491. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  137492. */
  137493. set cameraColorCurves(value: Nullable<ColorCurves>);
  137494. /**
  137495. * Instantiates a new PBRMaterial instance.
  137496. *
  137497. * @param name The material name
  137498. * @param scene The scene the material will be use in.
  137499. */
  137500. constructor(name: string, scene: Scene);
  137501. /**
  137502. * Returns the name of this material class.
  137503. */
  137504. getClassName(): string;
  137505. /**
  137506. * Makes a duplicate of the current material.
  137507. * @param name - name to use for the new material.
  137508. */
  137509. clone(name: string): PBRMaterial;
  137510. /**
  137511. * Serializes this PBR Material.
  137512. * @returns - An object with the serialized material.
  137513. */
  137514. serialize(): any;
  137515. /**
  137516. * Parses a PBR Material from a serialized object.
  137517. * @param source - Serialized object.
  137518. * @param scene - BJS scene instance.
  137519. * @param rootUrl - url for the scene object
  137520. * @returns - PBRMaterial
  137521. */
  137522. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  137523. }
  137524. }
  137525. declare module BABYLON {
  137526. /**
  137527. * Direct draw surface info
  137528. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  137529. */
  137530. export interface DDSInfo {
  137531. /**
  137532. * Width of the texture
  137533. */
  137534. width: number;
  137535. /**
  137536. * Width of the texture
  137537. */
  137538. height: number;
  137539. /**
  137540. * Number of Mipmaps for the texture
  137541. * @see https://en.wikipedia.org/wiki/Mipmap
  137542. */
  137543. mipmapCount: number;
  137544. /**
  137545. * If the textures format is a known fourCC format
  137546. * @see https://www.fourcc.org/
  137547. */
  137548. isFourCC: boolean;
  137549. /**
  137550. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  137551. */
  137552. isRGB: boolean;
  137553. /**
  137554. * If the texture is a lumincance format
  137555. */
  137556. isLuminance: boolean;
  137557. /**
  137558. * If this is a cube texture
  137559. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  137560. */
  137561. isCube: boolean;
  137562. /**
  137563. * If the texture is a compressed format eg. FOURCC_DXT1
  137564. */
  137565. isCompressed: boolean;
  137566. /**
  137567. * The dxgiFormat of the texture
  137568. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  137569. */
  137570. dxgiFormat: number;
  137571. /**
  137572. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  137573. */
  137574. textureType: number;
  137575. /**
  137576. * Sphericle polynomial created for the dds texture
  137577. */
  137578. sphericalPolynomial?: SphericalPolynomial;
  137579. }
  137580. /**
  137581. * Class used to provide DDS decompression tools
  137582. */
  137583. export class DDSTools {
  137584. /**
  137585. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  137586. */
  137587. static StoreLODInAlphaChannel: boolean;
  137588. /**
  137589. * Gets DDS information from an array buffer
  137590. * @param data defines the array buffer view to read data from
  137591. * @returns the DDS information
  137592. */
  137593. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  137594. private static _FloatView;
  137595. private static _Int32View;
  137596. private static _ToHalfFloat;
  137597. private static _FromHalfFloat;
  137598. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  137599. private static _GetHalfFloatRGBAArrayBuffer;
  137600. private static _GetFloatRGBAArrayBuffer;
  137601. private static _GetFloatAsUIntRGBAArrayBuffer;
  137602. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  137603. private static _GetRGBAArrayBuffer;
  137604. private static _ExtractLongWordOrder;
  137605. private static _GetRGBArrayBuffer;
  137606. private static _GetLuminanceArrayBuffer;
  137607. /**
  137608. * Uploads DDS Levels to a Babylon Texture
  137609. * @hidden
  137610. */
  137611. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  137612. }
  137613. interface ThinEngine {
  137614. /**
  137615. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  137616. * @param rootUrl defines the url where the file to load is located
  137617. * @param scene defines the current scene
  137618. * @param lodScale defines scale to apply to the mip map selection
  137619. * @param lodOffset defines offset to apply to the mip map selection
  137620. * @param onLoad defines an optional callback raised when the texture is loaded
  137621. * @param onError defines an optional callback raised if there is an issue to load the texture
  137622. * @param format defines the format of the data
  137623. * @param forcedExtension defines the extension to use to pick the right loader
  137624. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  137625. * @returns the cube texture as an InternalTexture
  137626. */
  137627. 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;
  137628. }
  137629. }
  137630. declare module BABYLON {
  137631. /**
  137632. * Implementation of the DDS Texture Loader.
  137633. * @hidden
  137634. */
  137635. export class _DDSTextureLoader implements IInternalTextureLoader {
  137636. /**
  137637. * Defines wether the loader supports cascade loading the different faces.
  137638. */
  137639. readonly supportCascades: boolean;
  137640. /**
  137641. * This returns if the loader support the current file information.
  137642. * @param extension defines the file extension of the file being loaded
  137643. * @returns true if the loader can load the specified file
  137644. */
  137645. canLoad(extension: string): boolean;
  137646. /**
  137647. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  137648. * @param data contains the texture data
  137649. * @param texture defines the BabylonJS internal texture
  137650. * @param createPolynomials will be true if polynomials have been requested
  137651. * @param onLoad defines the callback to trigger once the texture is ready
  137652. * @param onError defines the callback to trigger in case of error
  137653. */
  137654. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  137655. /**
  137656. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  137657. * @param data contains the texture data
  137658. * @param texture defines the BabylonJS internal texture
  137659. * @param callback defines the method to call once ready to upload
  137660. */
  137661. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  137662. }
  137663. }
  137664. declare module BABYLON {
  137665. /**
  137666. * Implementation of the ENV Texture Loader.
  137667. * @hidden
  137668. */
  137669. export class _ENVTextureLoader implements IInternalTextureLoader {
  137670. /**
  137671. * Defines wether the loader supports cascade loading the different faces.
  137672. */
  137673. readonly supportCascades: boolean;
  137674. /**
  137675. * This returns if the loader support the current file information.
  137676. * @param extension defines the file extension of the file being loaded
  137677. * @returns true if the loader can load the specified file
  137678. */
  137679. canLoad(extension: string): boolean;
  137680. /**
  137681. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  137682. * @param data contains the texture data
  137683. * @param texture defines the BabylonJS internal texture
  137684. * @param createPolynomials will be true if polynomials have been requested
  137685. * @param onLoad defines the callback to trigger once the texture is ready
  137686. * @param onError defines the callback to trigger in case of error
  137687. */
  137688. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  137689. /**
  137690. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  137691. * @param data contains the texture data
  137692. * @param texture defines the BabylonJS internal texture
  137693. * @param callback defines the method to call once ready to upload
  137694. */
  137695. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  137696. }
  137697. }
  137698. declare module BABYLON {
  137699. /**
  137700. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  137701. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  137702. */
  137703. export class KhronosTextureContainer {
  137704. /** contents of the KTX container file */
  137705. data: ArrayBufferView;
  137706. private static HEADER_LEN;
  137707. private static COMPRESSED_2D;
  137708. private static COMPRESSED_3D;
  137709. private static TEX_2D;
  137710. private static TEX_3D;
  137711. /**
  137712. * Gets the openGL type
  137713. */
  137714. glType: number;
  137715. /**
  137716. * Gets the openGL type size
  137717. */
  137718. glTypeSize: number;
  137719. /**
  137720. * Gets the openGL format
  137721. */
  137722. glFormat: number;
  137723. /**
  137724. * Gets the openGL internal format
  137725. */
  137726. glInternalFormat: number;
  137727. /**
  137728. * Gets the base internal format
  137729. */
  137730. glBaseInternalFormat: number;
  137731. /**
  137732. * Gets image width in pixel
  137733. */
  137734. pixelWidth: number;
  137735. /**
  137736. * Gets image height in pixel
  137737. */
  137738. pixelHeight: number;
  137739. /**
  137740. * Gets image depth in pixels
  137741. */
  137742. pixelDepth: number;
  137743. /**
  137744. * Gets the number of array elements
  137745. */
  137746. numberOfArrayElements: number;
  137747. /**
  137748. * Gets the number of faces
  137749. */
  137750. numberOfFaces: number;
  137751. /**
  137752. * Gets the number of mipmap levels
  137753. */
  137754. numberOfMipmapLevels: number;
  137755. /**
  137756. * Gets the bytes of key value data
  137757. */
  137758. bytesOfKeyValueData: number;
  137759. /**
  137760. * Gets the load type
  137761. */
  137762. loadType: number;
  137763. /**
  137764. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  137765. */
  137766. isInvalid: boolean;
  137767. /**
  137768. * Creates a new KhronosTextureContainer
  137769. * @param data contents of the KTX container file
  137770. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  137771. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  137772. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  137773. */
  137774. constructor(
  137775. /** contents of the KTX container file */
  137776. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  137777. /**
  137778. * Uploads KTX content to a Babylon Texture.
  137779. * It is assumed that the texture has already been created & is currently bound
  137780. * @hidden
  137781. */
  137782. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  137783. private _upload2DCompressedLevels;
  137784. /**
  137785. * Checks if the given data starts with a KTX file identifier.
  137786. * @param data the data to check
  137787. * @returns true if the data is a KTX file or false otherwise
  137788. */
  137789. static IsValid(data: ArrayBufferView): boolean;
  137790. }
  137791. }
  137792. declare module BABYLON {
  137793. /**
  137794. * Helper class to push actions to a pool of workers.
  137795. */
  137796. export class WorkerPool implements IDisposable {
  137797. private _workerInfos;
  137798. private _pendingActions;
  137799. /**
  137800. * Constructor
  137801. * @param workers Array of workers to use for actions
  137802. */
  137803. constructor(workers: Array<Worker>);
  137804. /**
  137805. * Terminates all workers and clears any pending actions.
  137806. */
  137807. dispose(): void;
  137808. /**
  137809. * Pushes an action to the worker pool. If all the workers are active, the action will be
  137810. * pended until a worker has completed its action.
  137811. * @param action The action to perform. Call onComplete when the action is complete.
  137812. */
  137813. push(action: (worker: Worker, onComplete: () => void) => void): void;
  137814. private _execute;
  137815. }
  137816. }
  137817. declare module BABYLON {
  137818. /**
  137819. * Class for loading KTX2 files
  137820. * @hidden
  137821. */
  137822. export class KhronosTextureContainer2 {
  137823. private static _WorkerPoolPromise?;
  137824. private static _Initialized;
  137825. private static _Ktx2Decoder;
  137826. /**
  137827. * URL to use when loading the KTX2 decoder module
  137828. */
  137829. static JSModuleURL: string;
  137830. /**
  137831. * Default number of workers used to handle data decoding
  137832. */
  137833. static DefaultNumWorkers: number;
  137834. private static GetDefaultNumWorkers;
  137835. private _engine;
  137836. private static _CreateWorkerPool;
  137837. /**
  137838. * Constructor
  137839. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  137840. */
  137841. constructor(engine: ThinEngine, numWorkers?: number);
  137842. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture): Promise<void>;
  137843. /**
  137844. * Stop all async operations and release resources.
  137845. */
  137846. dispose(): void;
  137847. protected _createTexture(data: any, internalTexture: InternalTexture): void;
  137848. /**
  137849. * Checks if the given data starts with a KTX2 file identifier.
  137850. * @param data the data to check
  137851. * @returns true if the data is a KTX2 file or false otherwise
  137852. */
  137853. static IsValid(data: ArrayBufferView): boolean;
  137854. }
  137855. export function workerFunc(): void;
  137856. }
  137857. declare module BABYLON {
  137858. /**
  137859. * Implementation of the KTX Texture Loader.
  137860. * @hidden
  137861. */
  137862. export class _KTXTextureLoader implements IInternalTextureLoader {
  137863. /**
  137864. * Defines wether the loader supports cascade loading the different faces.
  137865. */
  137866. readonly supportCascades: boolean;
  137867. /**
  137868. * This returns if the loader support the current file information.
  137869. * @param extension defines the file extension of the file being loaded
  137870. * @param mimeType defines the optional mime type of the file being loaded
  137871. * @returns true if the loader can load the specified file
  137872. */
  137873. canLoad(extension: string, mimeType?: string): boolean;
  137874. /**
  137875. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  137876. * @param data contains the texture data
  137877. * @param texture defines the BabylonJS internal texture
  137878. * @param createPolynomials will be true if polynomials have been requested
  137879. * @param onLoad defines the callback to trigger once the texture is ready
  137880. * @param onError defines the callback to trigger in case of error
  137881. */
  137882. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  137883. /**
  137884. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  137885. * @param data contains the texture data
  137886. * @param texture defines the BabylonJS internal texture
  137887. * @param callback defines the method to call once ready to upload
  137888. */
  137889. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  137890. }
  137891. }
  137892. declare module BABYLON {
  137893. /** @hidden */
  137894. export var _forceSceneHelpersToBundle: boolean;
  137895. interface Scene {
  137896. /**
  137897. * Creates a default light for the scene.
  137898. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  137899. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  137900. */
  137901. createDefaultLight(replace?: boolean): void;
  137902. /**
  137903. * Creates a default camera for the scene.
  137904. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  137905. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  137906. * @param replace has default false, when true replaces the active camera in the scene
  137907. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  137908. */
  137909. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  137910. /**
  137911. * Creates a default camera and a default light.
  137912. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  137913. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  137914. * @param replace has the default false, when true replaces the active camera/light in the scene
  137915. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  137916. */
  137917. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  137918. /**
  137919. * Creates a new sky box
  137920. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  137921. * @param environmentTexture defines the texture to use as environment texture
  137922. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  137923. * @param scale defines the overall scale of the skybox
  137924. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  137925. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  137926. * @returns a new mesh holding the sky box
  137927. */
  137928. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  137929. /**
  137930. * Creates a new environment
  137931. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  137932. * @param options defines the options you can use to configure the environment
  137933. * @returns the new EnvironmentHelper
  137934. */
  137935. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  137936. /**
  137937. * Creates a new VREXperienceHelper
  137938. * @see https://doc.babylonjs.com/how_to/webvr_helper
  137939. * @param webVROptions defines the options used to create the new VREXperienceHelper
  137940. * @returns a new VREXperienceHelper
  137941. */
  137942. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  137943. /**
  137944. * Creates a new WebXRDefaultExperience
  137945. * @see https://doc.babylonjs.com/how_to/introduction_to_webxr
  137946. * @param options experience options
  137947. * @returns a promise for a new WebXRDefaultExperience
  137948. */
  137949. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  137950. }
  137951. }
  137952. declare module BABYLON {
  137953. /**
  137954. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  137955. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  137956. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  137957. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  137958. */
  137959. export class VideoDome extends TextureDome<VideoTexture> {
  137960. /**
  137961. * Define the video source as a Monoscopic panoramic 360 video.
  137962. */
  137963. static readonly MODE_MONOSCOPIC: number;
  137964. /**
  137965. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  137966. */
  137967. static readonly MODE_TOPBOTTOM: number;
  137968. /**
  137969. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  137970. */
  137971. static readonly MODE_SIDEBYSIDE: number;
  137972. /**
  137973. * Get the video texture associated with this video dome
  137974. */
  137975. get videoTexture(): VideoTexture;
  137976. /**
  137977. * Get the video mode of this dome
  137978. */
  137979. get videoMode(): number;
  137980. /**
  137981. * Set the video mode of this dome.
  137982. * @see textureMode
  137983. */
  137984. set videoMode(value: number);
  137985. protected _initTexture(urlsOrElement: string | string[] | HTMLVideoElement, scene: Scene, options: any): VideoTexture;
  137986. }
  137987. }
  137988. declare module BABYLON {
  137989. /**
  137990. * This class can be used to get instrumentation data from a Babylon engine
  137991. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  137992. */
  137993. export class EngineInstrumentation implements IDisposable {
  137994. /**
  137995. * Define the instrumented engine.
  137996. */
  137997. engine: Engine;
  137998. private _captureGPUFrameTime;
  137999. private _gpuFrameTimeToken;
  138000. private _gpuFrameTime;
  138001. private _captureShaderCompilationTime;
  138002. private _shaderCompilationTime;
  138003. private _onBeginFrameObserver;
  138004. private _onEndFrameObserver;
  138005. private _onBeforeShaderCompilationObserver;
  138006. private _onAfterShaderCompilationObserver;
  138007. /**
  138008. * Gets the perf counter used for GPU frame time
  138009. */
  138010. get gpuFrameTimeCounter(): PerfCounter;
  138011. /**
  138012. * Gets the GPU frame time capture status
  138013. */
  138014. get captureGPUFrameTime(): boolean;
  138015. /**
  138016. * Enable or disable the GPU frame time capture
  138017. */
  138018. set captureGPUFrameTime(value: boolean);
  138019. /**
  138020. * Gets the perf counter used for shader compilation time
  138021. */
  138022. get shaderCompilationTimeCounter(): PerfCounter;
  138023. /**
  138024. * Gets the shader compilation time capture status
  138025. */
  138026. get captureShaderCompilationTime(): boolean;
  138027. /**
  138028. * Enable or disable the shader compilation time capture
  138029. */
  138030. set captureShaderCompilationTime(value: boolean);
  138031. /**
  138032. * Instantiates a new engine instrumentation.
  138033. * This class can be used to get instrumentation data from a Babylon engine
  138034. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  138035. * @param engine Defines the engine to instrument
  138036. */
  138037. constructor(
  138038. /**
  138039. * Define the instrumented engine.
  138040. */
  138041. engine: Engine);
  138042. /**
  138043. * Dispose and release associated resources.
  138044. */
  138045. dispose(): void;
  138046. }
  138047. }
  138048. declare module BABYLON {
  138049. /**
  138050. * This class can be used to get instrumentation data from a Babylon engine
  138051. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  138052. */
  138053. export class SceneInstrumentation implements IDisposable {
  138054. /**
  138055. * Defines the scene to instrument
  138056. */
  138057. scene: Scene;
  138058. private _captureActiveMeshesEvaluationTime;
  138059. private _activeMeshesEvaluationTime;
  138060. private _captureRenderTargetsRenderTime;
  138061. private _renderTargetsRenderTime;
  138062. private _captureFrameTime;
  138063. private _frameTime;
  138064. private _captureRenderTime;
  138065. private _renderTime;
  138066. private _captureInterFrameTime;
  138067. private _interFrameTime;
  138068. private _captureParticlesRenderTime;
  138069. private _particlesRenderTime;
  138070. private _captureSpritesRenderTime;
  138071. private _spritesRenderTime;
  138072. private _capturePhysicsTime;
  138073. private _physicsTime;
  138074. private _captureAnimationsTime;
  138075. private _animationsTime;
  138076. private _captureCameraRenderTime;
  138077. private _cameraRenderTime;
  138078. private _onBeforeActiveMeshesEvaluationObserver;
  138079. private _onAfterActiveMeshesEvaluationObserver;
  138080. private _onBeforeRenderTargetsRenderObserver;
  138081. private _onAfterRenderTargetsRenderObserver;
  138082. private _onAfterRenderObserver;
  138083. private _onBeforeDrawPhaseObserver;
  138084. private _onAfterDrawPhaseObserver;
  138085. private _onBeforeAnimationsObserver;
  138086. private _onBeforeParticlesRenderingObserver;
  138087. private _onAfterParticlesRenderingObserver;
  138088. private _onBeforeSpritesRenderingObserver;
  138089. private _onAfterSpritesRenderingObserver;
  138090. private _onBeforePhysicsObserver;
  138091. private _onAfterPhysicsObserver;
  138092. private _onAfterAnimationsObserver;
  138093. private _onBeforeCameraRenderObserver;
  138094. private _onAfterCameraRenderObserver;
  138095. /**
  138096. * Gets the perf counter used for active meshes evaluation time
  138097. */
  138098. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  138099. /**
  138100. * Gets the active meshes evaluation time capture status
  138101. */
  138102. get captureActiveMeshesEvaluationTime(): boolean;
  138103. /**
  138104. * Enable or disable the active meshes evaluation time capture
  138105. */
  138106. set captureActiveMeshesEvaluationTime(value: boolean);
  138107. /**
  138108. * Gets the perf counter used for render targets render time
  138109. */
  138110. get renderTargetsRenderTimeCounter(): PerfCounter;
  138111. /**
  138112. * Gets the render targets render time capture status
  138113. */
  138114. get captureRenderTargetsRenderTime(): boolean;
  138115. /**
  138116. * Enable or disable the render targets render time capture
  138117. */
  138118. set captureRenderTargetsRenderTime(value: boolean);
  138119. /**
  138120. * Gets the perf counter used for particles render time
  138121. */
  138122. get particlesRenderTimeCounter(): PerfCounter;
  138123. /**
  138124. * Gets the particles render time capture status
  138125. */
  138126. get captureParticlesRenderTime(): boolean;
  138127. /**
  138128. * Enable or disable the particles render time capture
  138129. */
  138130. set captureParticlesRenderTime(value: boolean);
  138131. /**
  138132. * Gets the perf counter used for sprites render time
  138133. */
  138134. get spritesRenderTimeCounter(): PerfCounter;
  138135. /**
  138136. * Gets the sprites render time capture status
  138137. */
  138138. get captureSpritesRenderTime(): boolean;
  138139. /**
  138140. * Enable or disable the sprites render time capture
  138141. */
  138142. set captureSpritesRenderTime(value: boolean);
  138143. /**
  138144. * Gets the perf counter used for physics time
  138145. */
  138146. get physicsTimeCounter(): PerfCounter;
  138147. /**
  138148. * Gets the physics time capture status
  138149. */
  138150. get capturePhysicsTime(): boolean;
  138151. /**
  138152. * Enable or disable the physics time capture
  138153. */
  138154. set capturePhysicsTime(value: boolean);
  138155. /**
  138156. * Gets the perf counter used for animations time
  138157. */
  138158. get animationsTimeCounter(): PerfCounter;
  138159. /**
  138160. * Gets the animations time capture status
  138161. */
  138162. get captureAnimationsTime(): boolean;
  138163. /**
  138164. * Enable or disable the animations time capture
  138165. */
  138166. set captureAnimationsTime(value: boolean);
  138167. /**
  138168. * Gets the perf counter used for frame time capture
  138169. */
  138170. get frameTimeCounter(): PerfCounter;
  138171. /**
  138172. * Gets the frame time capture status
  138173. */
  138174. get captureFrameTime(): boolean;
  138175. /**
  138176. * Enable or disable the frame time capture
  138177. */
  138178. set captureFrameTime(value: boolean);
  138179. /**
  138180. * Gets the perf counter used for inter-frames time capture
  138181. */
  138182. get interFrameTimeCounter(): PerfCounter;
  138183. /**
  138184. * Gets the inter-frames time capture status
  138185. */
  138186. get captureInterFrameTime(): boolean;
  138187. /**
  138188. * Enable or disable the inter-frames time capture
  138189. */
  138190. set captureInterFrameTime(value: boolean);
  138191. /**
  138192. * Gets the perf counter used for render time capture
  138193. */
  138194. get renderTimeCounter(): PerfCounter;
  138195. /**
  138196. * Gets the render time capture status
  138197. */
  138198. get captureRenderTime(): boolean;
  138199. /**
  138200. * Enable or disable the render time capture
  138201. */
  138202. set captureRenderTime(value: boolean);
  138203. /**
  138204. * Gets the perf counter used for camera render time capture
  138205. */
  138206. get cameraRenderTimeCounter(): PerfCounter;
  138207. /**
  138208. * Gets the camera render time capture status
  138209. */
  138210. get captureCameraRenderTime(): boolean;
  138211. /**
  138212. * Enable or disable the camera render time capture
  138213. */
  138214. set captureCameraRenderTime(value: boolean);
  138215. /**
  138216. * Gets the perf counter used for draw calls
  138217. */
  138218. get drawCallsCounter(): PerfCounter;
  138219. /**
  138220. * Instantiates a new scene instrumentation.
  138221. * This class can be used to get instrumentation data from a Babylon engine
  138222. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  138223. * @param scene Defines the scene to instrument
  138224. */
  138225. constructor(
  138226. /**
  138227. * Defines the scene to instrument
  138228. */
  138229. scene: Scene);
  138230. /**
  138231. * Dispose and release associated resources.
  138232. */
  138233. dispose(): void;
  138234. }
  138235. }
  138236. declare module BABYLON {
  138237. /** @hidden */
  138238. export var glowMapGenerationPixelShader: {
  138239. name: string;
  138240. shader: string;
  138241. };
  138242. }
  138243. declare module BABYLON {
  138244. /** @hidden */
  138245. export var glowMapGenerationVertexShader: {
  138246. name: string;
  138247. shader: string;
  138248. };
  138249. }
  138250. declare module BABYLON {
  138251. /**
  138252. * Effect layer options. This helps customizing the behaviour
  138253. * of the effect layer.
  138254. */
  138255. export interface IEffectLayerOptions {
  138256. /**
  138257. * Multiplication factor apply to the canvas size to compute the render target size
  138258. * used to generated the objects (the smaller the faster).
  138259. */
  138260. mainTextureRatio: number;
  138261. /**
  138262. * Enforces a fixed size texture to ensure effect stability across devices.
  138263. */
  138264. mainTextureFixedSize?: number;
  138265. /**
  138266. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  138267. */
  138268. alphaBlendingMode: number;
  138269. /**
  138270. * The camera attached to the layer.
  138271. */
  138272. camera: Nullable<Camera>;
  138273. /**
  138274. * The rendering group to draw the layer in.
  138275. */
  138276. renderingGroupId: number;
  138277. }
  138278. /**
  138279. * The effect layer Helps adding post process effect blended with the main pass.
  138280. *
  138281. * This can be for instance use to generate glow or higlight effects on the scene.
  138282. *
  138283. * The effect layer class can not be used directly and is intented to inherited from to be
  138284. * customized per effects.
  138285. */
  138286. export abstract class EffectLayer {
  138287. private _vertexBuffers;
  138288. private _indexBuffer;
  138289. private _cachedDefines;
  138290. private _effectLayerMapGenerationEffect;
  138291. private _effectLayerOptions;
  138292. private _mergeEffect;
  138293. protected _scene: Scene;
  138294. protected _engine: Engine;
  138295. protected _maxSize: number;
  138296. protected _mainTextureDesiredSize: ISize;
  138297. protected _mainTexture: RenderTargetTexture;
  138298. protected _shouldRender: boolean;
  138299. protected _postProcesses: PostProcess[];
  138300. protected _textures: BaseTexture[];
  138301. protected _emissiveTextureAndColor: {
  138302. texture: Nullable<BaseTexture>;
  138303. color: Color4;
  138304. };
  138305. /**
  138306. * The name of the layer
  138307. */
  138308. name: string;
  138309. /**
  138310. * The clear color of the texture used to generate the glow map.
  138311. */
  138312. neutralColor: Color4;
  138313. /**
  138314. * Specifies whether the highlight layer is enabled or not.
  138315. */
  138316. isEnabled: boolean;
  138317. /**
  138318. * Gets the camera attached to the layer.
  138319. */
  138320. get camera(): Nullable<Camera>;
  138321. /**
  138322. * Gets the rendering group id the layer should render in.
  138323. */
  138324. get renderingGroupId(): number;
  138325. set renderingGroupId(renderingGroupId: number);
  138326. /**
  138327. * An event triggered when the effect layer has been disposed.
  138328. */
  138329. onDisposeObservable: Observable<EffectLayer>;
  138330. /**
  138331. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  138332. */
  138333. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  138334. /**
  138335. * An event triggered when the generated texture is being merged in the scene.
  138336. */
  138337. onBeforeComposeObservable: Observable<EffectLayer>;
  138338. /**
  138339. * An event triggered when the mesh is rendered into the effect render target.
  138340. */
  138341. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  138342. /**
  138343. * An event triggered after the mesh has been rendered into the effect render target.
  138344. */
  138345. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  138346. /**
  138347. * An event triggered when the generated texture has been merged in the scene.
  138348. */
  138349. onAfterComposeObservable: Observable<EffectLayer>;
  138350. /**
  138351. * An event triggered when the efffect layer changes its size.
  138352. */
  138353. onSizeChangedObservable: Observable<EffectLayer>;
  138354. /** @hidden */
  138355. static _SceneComponentInitialization: (scene: Scene) => void;
  138356. /**
  138357. * Instantiates a new effect Layer and references it in the scene.
  138358. * @param name The name of the layer
  138359. * @param scene The scene to use the layer in
  138360. */
  138361. constructor(
  138362. /** The Friendly of the effect in the scene */
  138363. name: string, scene: Scene);
  138364. /**
  138365. * Get the effect name of the layer.
  138366. * @return The effect name
  138367. */
  138368. abstract getEffectName(): string;
  138369. /**
  138370. * Checks for the readiness of the element composing the layer.
  138371. * @param subMesh the mesh to check for
  138372. * @param useInstances specify whether or not to use instances to render the mesh
  138373. * @return true if ready otherwise, false
  138374. */
  138375. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  138376. /**
  138377. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  138378. * @returns true if the effect requires stencil during the main canvas render pass.
  138379. */
  138380. abstract needStencil(): boolean;
  138381. /**
  138382. * Create the merge effect. This is the shader use to blit the information back
  138383. * to the main canvas at the end of the scene rendering.
  138384. * @returns The effect containing the shader used to merge the effect on the main canvas
  138385. */
  138386. protected abstract _createMergeEffect(): Effect;
  138387. /**
  138388. * Creates the render target textures and post processes used in the effect layer.
  138389. */
  138390. protected abstract _createTextureAndPostProcesses(): void;
  138391. /**
  138392. * Implementation specific of rendering the generating effect on the main canvas.
  138393. * @param effect The effect used to render through
  138394. */
  138395. protected abstract _internalRender(effect: Effect): void;
  138396. /**
  138397. * Sets the required values for both the emissive texture and and the main color.
  138398. */
  138399. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  138400. /**
  138401. * Free any resources and references associated to a mesh.
  138402. * Internal use
  138403. * @param mesh The mesh to free.
  138404. */
  138405. abstract _disposeMesh(mesh: Mesh): void;
  138406. /**
  138407. * Serializes this layer (Glow or Highlight for example)
  138408. * @returns a serialized layer object
  138409. */
  138410. abstract serialize?(): any;
  138411. /**
  138412. * Initializes the effect layer with the required options.
  138413. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  138414. */
  138415. protected _init(options: Partial<IEffectLayerOptions>): void;
  138416. /**
  138417. * Generates the index buffer of the full screen quad blending to the main canvas.
  138418. */
  138419. private _generateIndexBuffer;
  138420. /**
  138421. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  138422. */
  138423. private _generateVertexBuffer;
  138424. /**
  138425. * Sets the main texture desired size which is the closest power of two
  138426. * of the engine canvas size.
  138427. */
  138428. private _setMainTextureSize;
  138429. /**
  138430. * Creates the main texture for the effect layer.
  138431. */
  138432. protected _createMainTexture(): void;
  138433. /**
  138434. * Adds specific effects defines.
  138435. * @param defines The defines to add specifics to.
  138436. */
  138437. protected _addCustomEffectDefines(defines: string[]): void;
  138438. /**
  138439. * Checks for the readiness of the element composing the layer.
  138440. * @param subMesh the mesh to check for
  138441. * @param useInstances specify whether or not to use instances to render the mesh
  138442. * @param emissiveTexture the associated emissive texture used to generate the glow
  138443. * @return true if ready otherwise, false
  138444. */
  138445. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  138446. /**
  138447. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  138448. */
  138449. render(): void;
  138450. /**
  138451. * Determine if a given mesh will be used in the current effect.
  138452. * @param mesh mesh to test
  138453. * @returns true if the mesh will be used
  138454. */
  138455. hasMesh(mesh: AbstractMesh): boolean;
  138456. /**
  138457. * Returns true if the layer contains information to display, otherwise false.
  138458. * @returns true if the glow layer should be rendered
  138459. */
  138460. shouldRender(): boolean;
  138461. /**
  138462. * Returns true if the mesh should render, otherwise false.
  138463. * @param mesh The mesh to render
  138464. * @returns true if it should render otherwise false
  138465. */
  138466. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  138467. /**
  138468. * Returns true if the mesh can be rendered, otherwise false.
  138469. * @param mesh The mesh to render
  138470. * @param material The material used on the mesh
  138471. * @returns true if it can be rendered otherwise false
  138472. */
  138473. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  138474. /**
  138475. * Returns true if the mesh should render, otherwise false.
  138476. * @param mesh The mesh to render
  138477. * @returns true if it should render otherwise false
  138478. */
  138479. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  138480. /**
  138481. * Renders the submesh passed in parameter to the generation map.
  138482. */
  138483. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  138484. /**
  138485. * Defines whether the current material of the mesh should be use to render the effect.
  138486. * @param mesh defines the current mesh to render
  138487. */
  138488. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  138489. /**
  138490. * Rebuild the required buffers.
  138491. * @hidden Internal use only.
  138492. */
  138493. _rebuild(): void;
  138494. /**
  138495. * Dispose only the render target textures and post process.
  138496. */
  138497. private _disposeTextureAndPostProcesses;
  138498. /**
  138499. * Dispose the highlight layer and free resources.
  138500. */
  138501. dispose(): void;
  138502. /**
  138503. * Gets the class name of the effect layer
  138504. * @returns the string with the class name of the effect layer
  138505. */
  138506. getClassName(): string;
  138507. /**
  138508. * Creates an effect layer from parsed effect layer data
  138509. * @param parsedEffectLayer defines effect layer data
  138510. * @param scene defines the current scene
  138511. * @param rootUrl defines the root URL containing the effect layer information
  138512. * @returns a parsed effect Layer
  138513. */
  138514. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  138515. }
  138516. }
  138517. declare module BABYLON {
  138518. interface AbstractScene {
  138519. /**
  138520. * The list of effect layers (highlights/glow) added to the scene
  138521. * @see https://doc.babylonjs.com/how_to/highlight_layer
  138522. * @see https://doc.babylonjs.com/how_to/glow_layer
  138523. */
  138524. effectLayers: Array<EffectLayer>;
  138525. /**
  138526. * Removes the given effect layer from this scene.
  138527. * @param toRemove defines the effect layer to remove
  138528. * @returns the index of the removed effect layer
  138529. */
  138530. removeEffectLayer(toRemove: EffectLayer): number;
  138531. /**
  138532. * Adds the given effect layer to this scene
  138533. * @param newEffectLayer defines the effect layer to add
  138534. */
  138535. addEffectLayer(newEffectLayer: EffectLayer): void;
  138536. }
  138537. /**
  138538. * Defines the layer scene component responsible to manage any effect layers
  138539. * in a given scene.
  138540. */
  138541. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  138542. /**
  138543. * The component name helpfull to identify the component in the list of scene components.
  138544. */
  138545. readonly name: string;
  138546. /**
  138547. * The scene the component belongs to.
  138548. */
  138549. scene: Scene;
  138550. private _engine;
  138551. private _renderEffects;
  138552. private _needStencil;
  138553. private _previousStencilState;
  138554. /**
  138555. * Creates a new instance of the component for the given scene
  138556. * @param scene Defines the scene to register the component in
  138557. */
  138558. constructor(scene: Scene);
  138559. /**
  138560. * Registers the component in a given scene
  138561. */
  138562. register(): void;
  138563. /**
  138564. * Rebuilds the elements related to this component in case of
  138565. * context lost for instance.
  138566. */
  138567. rebuild(): void;
  138568. /**
  138569. * Serializes the component data to the specified json object
  138570. * @param serializationObject The object to serialize to
  138571. */
  138572. serialize(serializationObject: any): void;
  138573. /**
  138574. * Adds all the elements from the container to the scene
  138575. * @param container the container holding the elements
  138576. */
  138577. addFromContainer(container: AbstractScene): void;
  138578. /**
  138579. * Removes all the elements in the container from the scene
  138580. * @param container contains the elements to remove
  138581. * @param dispose if the removed element should be disposed (default: false)
  138582. */
  138583. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  138584. /**
  138585. * Disposes the component and the associated ressources.
  138586. */
  138587. dispose(): void;
  138588. private _isReadyForMesh;
  138589. private _renderMainTexture;
  138590. private _setStencil;
  138591. private _setStencilBack;
  138592. private _draw;
  138593. private _drawCamera;
  138594. private _drawRenderingGroup;
  138595. }
  138596. }
  138597. declare module BABYLON {
  138598. /** @hidden */
  138599. export var glowMapMergePixelShader: {
  138600. name: string;
  138601. shader: string;
  138602. };
  138603. }
  138604. declare module BABYLON {
  138605. /** @hidden */
  138606. export var glowMapMergeVertexShader: {
  138607. name: string;
  138608. shader: string;
  138609. };
  138610. }
  138611. declare module BABYLON {
  138612. interface AbstractScene {
  138613. /**
  138614. * Return a the first highlight layer of the scene with a given name.
  138615. * @param name The name of the highlight layer to look for.
  138616. * @return The highlight layer if found otherwise null.
  138617. */
  138618. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  138619. }
  138620. /**
  138621. * Glow layer options. This helps customizing the behaviour
  138622. * of the glow layer.
  138623. */
  138624. export interface IGlowLayerOptions {
  138625. /**
  138626. * Multiplication factor apply to the canvas size to compute the render target size
  138627. * used to generated the glowing objects (the smaller the faster).
  138628. */
  138629. mainTextureRatio: number;
  138630. /**
  138631. * Enforces a fixed size texture to ensure resize independant blur.
  138632. */
  138633. mainTextureFixedSize?: number;
  138634. /**
  138635. * How big is the kernel of the blur texture.
  138636. */
  138637. blurKernelSize: number;
  138638. /**
  138639. * The camera attached to the layer.
  138640. */
  138641. camera: Nullable<Camera>;
  138642. /**
  138643. * Enable MSAA by chosing the number of samples.
  138644. */
  138645. mainTextureSamples?: number;
  138646. /**
  138647. * The rendering group to draw the layer in.
  138648. */
  138649. renderingGroupId: number;
  138650. }
  138651. /**
  138652. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  138653. *
  138654. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  138655. *
  138656. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  138657. */
  138658. export class GlowLayer extends EffectLayer {
  138659. /**
  138660. * Effect Name of the layer.
  138661. */
  138662. static readonly EffectName: string;
  138663. /**
  138664. * The default blur kernel size used for the glow.
  138665. */
  138666. static DefaultBlurKernelSize: number;
  138667. /**
  138668. * The default texture size ratio used for the glow.
  138669. */
  138670. static DefaultTextureRatio: number;
  138671. /**
  138672. * Sets the kernel size of the blur.
  138673. */
  138674. set blurKernelSize(value: number);
  138675. /**
  138676. * Gets the kernel size of the blur.
  138677. */
  138678. get blurKernelSize(): number;
  138679. /**
  138680. * Sets the glow intensity.
  138681. */
  138682. set intensity(value: number);
  138683. /**
  138684. * Gets the glow intensity.
  138685. */
  138686. get intensity(): number;
  138687. private _options;
  138688. private _intensity;
  138689. private _horizontalBlurPostprocess1;
  138690. private _verticalBlurPostprocess1;
  138691. private _horizontalBlurPostprocess2;
  138692. private _verticalBlurPostprocess2;
  138693. private _blurTexture1;
  138694. private _blurTexture2;
  138695. private _postProcesses1;
  138696. private _postProcesses2;
  138697. private _includedOnlyMeshes;
  138698. private _excludedMeshes;
  138699. private _meshesUsingTheirOwnMaterials;
  138700. /**
  138701. * Callback used to let the user override the color selection on a per mesh basis
  138702. */
  138703. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  138704. /**
  138705. * Callback used to let the user override the texture selection on a per mesh basis
  138706. */
  138707. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  138708. /**
  138709. * Instantiates a new glow Layer and references it to the scene.
  138710. * @param name The name of the layer
  138711. * @param scene The scene to use the layer in
  138712. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  138713. */
  138714. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  138715. /**
  138716. * Get the effect name of the layer.
  138717. * @return The effect name
  138718. */
  138719. getEffectName(): string;
  138720. /**
  138721. * Create the merge effect. This is the shader use to blit the information back
  138722. * to the main canvas at the end of the scene rendering.
  138723. */
  138724. protected _createMergeEffect(): Effect;
  138725. /**
  138726. * Creates the render target textures and post processes used in the glow layer.
  138727. */
  138728. protected _createTextureAndPostProcesses(): void;
  138729. /**
  138730. * Checks for the readiness of the element composing the layer.
  138731. * @param subMesh the mesh to check for
  138732. * @param useInstances specify wether or not to use instances to render the mesh
  138733. * @param emissiveTexture the associated emissive texture used to generate the glow
  138734. * @return true if ready otherwise, false
  138735. */
  138736. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  138737. /**
  138738. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  138739. */
  138740. needStencil(): boolean;
  138741. /**
  138742. * Returns true if the mesh can be rendered, otherwise false.
  138743. * @param mesh The mesh to render
  138744. * @param material The material used on the mesh
  138745. * @returns true if it can be rendered otherwise false
  138746. */
  138747. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  138748. /**
  138749. * Implementation specific of rendering the generating effect on the main canvas.
  138750. * @param effect The effect used to render through
  138751. */
  138752. protected _internalRender(effect: Effect): void;
  138753. /**
  138754. * Sets the required values for both the emissive texture and and the main color.
  138755. */
  138756. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  138757. /**
  138758. * Returns true if the mesh should render, otherwise false.
  138759. * @param mesh The mesh to render
  138760. * @returns true if it should render otherwise false
  138761. */
  138762. protected _shouldRenderMesh(mesh: Mesh): boolean;
  138763. /**
  138764. * Adds specific effects defines.
  138765. * @param defines The defines to add specifics to.
  138766. */
  138767. protected _addCustomEffectDefines(defines: string[]): void;
  138768. /**
  138769. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  138770. * @param mesh The mesh to exclude from the glow layer
  138771. */
  138772. addExcludedMesh(mesh: Mesh): void;
  138773. /**
  138774. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  138775. * @param mesh The mesh to remove
  138776. */
  138777. removeExcludedMesh(mesh: Mesh): void;
  138778. /**
  138779. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  138780. * @param mesh The mesh to include in the glow layer
  138781. */
  138782. addIncludedOnlyMesh(mesh: Mesh): void;
  138783. /**
  138784. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  138785. * @param mesh The mesh to remove
  138786. */
  138787. removeIncludedOnlyMesh(mesh: Mesh): void;
  138788. /**
  138789. * Determine if a given mesh will be used in the glow layer
  138790. * @param mesh The mesh to test
  138791. * @returns true if the mesh will be highlighted by the current glow layer
  138792. */
  138793. hasMesh(mesh: AbstractMesh): boolean;
  138794. /**
  138795. * Defines whether the current material of the mesh should be use to render the effect.
  138796. * @param mesh defines the current mesh to render
  138797. */
  138798. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  138799. /**
  138800. * Add a mesh to be rendered through its own material and not with emissive only.
  138801. * @param mesh The mesh for which we need to use its material
  138802. */
  138803. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  138804. /**
  138805. * Remove a mesh from being rendered through its own material and not with emissive only.
  138806. * @param mesh The mesh for which we need to not use its material
  138807. */
  138808. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  138809. /**
  138810. * Free any resources and references associated to a mesh.
  138811. * Internal use
  138812. * @param mesh The mesh to free.
  138813. * @hidden
  138814. */
  138815. _disposeMesh(mesh: Mesh): void;
  138816. /**
  138817. * Gets the class name of the effect layer
  138818. * @returns the string with the class name of the effect layer
  138819. */
  138820. getClassName(): string;
  138821. /**
  138822. * Serializes this glow layer
  138823. * @returns a serialized glow layer object
  138824. */
  138825. serialize(): any;
  138826. /**
  138827. * Creates a Glow Layer from parsed glow layer data
  138828. * @param parsedGlowLayer defines glow layer data
  138829. * @param scene defines the current scene
  138830. * @param rootUrl defines the root URL containing the glow layer information
  138831. * @returns a parsed Glow Layer
  138832. */
  138833. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  138834. }
  138835. }
  138836. declare module BABYLON {
  138837. /** @hidden */
  138838. export var glowBlurPostProcessPixelShader: {
  138839. name: string;
  138840. shader: string;
  138841. };
  138842. }
  138843. declare module BABYLON {
  138844. interface AbstractScene {
  138845. /**
  138846. * Return a the first highlight layer of the scene with a given name.
  138847. * @param name The name of the highlight layer to look for.
  138848. * @return The highlight layer if found otherwise null.
  138849. */
  138850. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  138851. }
  138852. /**
  138853. * Highlight layer options. This helps customizing the behaviour
  138854. * of the highlight layer.
  138855. */
  138856. export interface IHighlightLayerOptions {
  138857. /**
  138858. * Multiplication factor apply to the canvas size to compute the render target size
  138859. * used to generated the glowing objects (the smaller the faster).
  138860. */
  138861. mainTextureRatio: number;
  138862. /**
  138863. * Enforces a fixed size texture to ensure resize independant blur.
  138864. */
  138865. mainTextureFixedSize?: number;
  138866. /**
  138867. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  138868. * of the picture to blur (the smaller the faster).
  138869. */
  138870. blurTextureSizeRatio: number;
  138871. /**
  138872. * How big in texel of the blur texture is the vertical blur.
  138873. */
  138874. blurVerticalSize: number;
  138875. /**
  138876. * How big in texel of the blur texture is the horizontal blur.
  138877. */
  138878. blurHorizontalSize: number;
  138879. /**
  138880. * Alpha blending mode used to apply the blur. Default is combine.
  138881. */
  138882. alphaBlendingMode: number;
  138883. /**
  138884. * The camera attached to the layer.
  138885. */
  138886. camera: Nullable<Camera>;
  138887. /**
  138888. * Should we display highlight as a solid stroke?
  138889. */
  138890. isStroke?: boolean;
  138891. /**
  138892. * The rendering group to draw the layer in.
  138893. */
  138894. renderingGroupId: number;
  138895. }
  138896. /**
  138897. * The highlight layer Helps adding a glow effect around a mesh.
  138898. *
  138899. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  138900. * glowy meshes to your scene.
  138901. *
  138902. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  138903. */
  138904. export class HighlightLayer extends EffectLayer {
  138905. name: string;
  138906. /**
  138907. * Effect Name of the highlight layer.
  138908. */
  138909. static readonly EffectName: string;
  138910. /**
  138911. * The neutral color used during the preparation of the glow effect.
  138912. * This is black by default as the blend operation is a blend operation.
  138913. */
  138914. static NeutralColor: Color4;
  138915. /**
  138916. * Stencil value used for glowing meshes.
  138917. */
  138918. static GlowingMeshStencilReference: number;
  138919. /**
  138920. * Stencil value used for the other meshes in the scene.
  138921. */
  138922. static NormalMeshStencilReference: number;
  138923. /**
  138924. * Specifies whether or not the inner glow is ACTIVE in the layer.
  138925. */
  138926. innerGlow: boolean;
  138927. /**
  138928. * Specifies whether or not the outer glow is ACTIVE in the layer.
  138929. */
  138930. outerGlow: boolean;
  138931. /**
  138932. * Specifies the horizontal size of the blur.
  138933. */
  138934. set blurHorizontalSize(value: number);
  138935. /**
  138936. * Specifies the vertical size of the blur.
  138937. */
  138938. set blurVerticalSize(value: number);
  138939. /**
  138940. * Gets the horizontal size of the blur.
  138941. */
  138942. get blurHorizontalSize(): number;
  138943. /**
  138944. * Gets the vertical size of the blur.
  138945. */
  138946. get blurVerticalSize(): number;
  138947. /**
  138948. * An event triggered when the highlight layer is being blurred.
  138949. */
  138950. onBeforeBlurObservable: Observable<HighlightLayer>;
  138951. /**
  138952. * An event triggered when the highlight layer has been blurred.
  138953. */
  138954. onAfterBlurObservable: Observable<HighlightLayer>;
  138955. private _instanceGlowingMeshStencilReference;
  138956. private _options;
  138957. private _downSamplePostprocess;
  138958. private _horizontalBlurPostprocess;
  138959. private _verticalBlurPostprocess;
  138960. private _blurTexture;
  138961. private _meshes;
  138962. private _excludedMeshes;
  138963. /**
  138964. * Instantiates a new highlight Layer and references it to the scene..
  138965. * @param name The name of the layer
  138966. * @param scene The scene to use the layer in
  138967. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  138968. */
  138969. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  138970. /**
  138971. * Get the effect name of the layer.
  138972. * @return The effect name
  138973. */
  138974. getEffectName(): string;
  138975. /**
  138976. * Create the merge effect. This is the shader use to blit the information back
  138977. * to the main canvas at the end of the scene rendering.
  138978. */
  138979. protected _createMergeEffect(): Effect;
  138980. /**
  138981. * Creates the render target textures and post processes used in the highlight layer.
  138982. */
  138983. protected _createTextureAndPostProcesses(): void;
  138984. /**
  138985. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  138986. */
  138987. needStencil(): boolean;
  138988. /**
  138989. * Checks for the readiness of the element composing the layer.
  138990. * @param subMesh the mesh to check for
  138991. * @param useInstances specify wether or not to use instances to render the mesh
  138992. * @param emissiveTexture the associated emissive texture used to generate the glow
  138993. * @return true if ready otherwise, false
  138994. */
  138995. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  138996. /**
  138997. * Implementation specific of rendering the generating effect on the main canvas.
  138998. * @param effect The effect used to render through
  138999. */
  139000. protected _internalRender(effect: Effect): void;
  139001. /**
  139002. * Returns true if the layer contains information to display, otherwise false.
  139003. */
  139004. shouldRender(): boolean;
  139005. /**
  139006. * Returns true if the mesh should render, otherwise false.
  139007. * @param mesh The mesh to render
  139008. * @returns true if it should render otherwise false
  139009. */
  139010. protected _shouldRenderMesh(mesh: Mesh): boolean;
  139011. /**
  139012. * Returns true if the mesh can be rendered, otherwise false.
  139013. * @param mesh The mesh to render
  139014. * @param material The material used on the mesh
  139015. * @returns true if it can be rendered otherwise false
  139016. */
  139017. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  139018. /**
  139019. * Adds specific effects defines.
  139020. * @param defines The defines to add specifics to.
  139021. */
  139022. protected _addCustomEffectDefines(defines: string[]): void;
  139023. /**
  139024. * Sets the required values for both the emissive texture and and the main color.
  139025. */
  139026. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  139027. /**
  139028. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  139029. * @param mesh The mesh to exclude from the highlight layer
  139030. */
  139031. addExcludedMesh(mesh: Mesh): void;
  139032. /**
  139033. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  139034. * @param mesh The mesh to highlight
  139035. */
  139036. removeExcludedMesh(mesh: Mesh): void;
  139037. /**
  139038. * Determine if a given mesh will be highlighted by the current HighlightLayer
  139039. * @param mesh mesh to test
  139040. * @returns true if the mesh will be highlighted by the current HighlightLayer
  139041. */
  139042. hasMesh(mesh: AbstractMesh): boolean;
  139043. /**
  139044. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  139045. * @param mesh The mesh to highlight
  139046. * @param color The color of the highlight
  139047. * @param glowEmissiveOnly Extract the glow from the emissive texture
  139048. */
  139049. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  139050. /**
  139051. * Remove a mesh from the highlight layer in order to make it stop glowing.
  139052. * @param mesh The mesh to highlight
  139053. */
  139054. removeMesh(mesh: Mesh): void;
  139055. /**
  139056. * Remove all the meshes currently referenced in the highlight layer
  139057. */
  139058. removeAllMeshes(): void;
  139059. /**
  139060. * Force the stencil to the normal expected value for none glowing parts
  139061. */
  139062. private _defaultStencilReference;
  139063. /**
  139064. * Free any resources and references associated to a mesh.
  139065. * Internal use
  139066. * @param mesh The mesh to free.
  139067. * @hidden
  139068. */
  139069. _disposeMesh(mesh: Mesh): void;
  139070. /**
  139071. * Dispose the highlight layer and free resources.
  139072. */
  139073. dispose(): void;
  139074. /**
  139075. * Gets the class name of the effect layer
  139076. * @returns the string with the class name of the effect layer
  139077. */
  139078. getClassName(): string;
  139079. /**
  139080. * Serializes this Highlight layer
  139081. * @returns a serialized Highlight layer object
  139082. */
  139083. serialize(): any;
  139084. /**
  139085. * Creates a Highlight layer from parsed Highlight layer data
  139086. * @param parsedHightlightLayer defines the Highlight layer data
  139087. * @param scene defines the current scene
  139088. * @param rootUrl defines the root URL containing the Highlight layer information
  139089. * @returns a parsed Highlight layer
  139090. */
  139091. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  139092. }
  139093. }
  139094. declare module BABYLON {
  139095. interface AbstractScene {
  139096. /**
  139097. * The list of layers (background and foreground) of the scene
  139098. */
  139099. layers: Array<Layer>;
  139100. }
  139101. /**
  139102. * Defines the layer scene component responsible to manage any layers
  139103. * in a given scene.
  139104. */
  139105. export class LayerSceneComponent implements ISceneComponent {
  139106. /**
  139107. * The component name helpfull to identify the component in the list of scene components.
  139108. */
  139109. readonly name: string;
  139110. /**
  139111. * The scene the component belongs to.
  139112. */
  139113. scene: Scene;
  139114. private _engine;
  139115. /**
  139116. * Creates a new instance of the component for the given scene
  139117. * @param scene Defines the scene to register the component in
  139118. */
  139119. constructor(scene: Scene);
  139120. /**
  139121. * Registers the component in a given scene
  139122. */
  139123. register(): void;
  139124. /**
  139125. * Rebuilds the elements related to this component in case of
  139126. * context lost for instance.
  139127. */
  139128. rebuild(): void;
  139129. /**
  139130. * Disposes the component and the associated ressources.
  139131. */
  139132. dispose(): void;
  139133. private _draw;
  139134. private _drawCameraPredicate;
  139135. private _drawCameraBackground;
  139136. private _drawCameraForeground;
  139137. private _drawRenderTargetPredicate;
  139138. private _drawRenderTargetBackground;
  139139. private _drawRenderTargetForeground;
  139140. /**
  139141. * Adds all the elements from the container to the scene
  139142. * @param container the container holding the elements
  139143. */
  139144. addFromContainer(container: AbstractScene): void;
  139145. /**
  139146. * Removes all the elements in the container from the scene
  139147. * @param container contains the elements to remove
  139148. * @param dispose if the removed element should be disposed (default: false)
  139149. */
  139150. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  139151. }
  139152. }
  139153. declare module BABYLON {
  139154. /** @hidden */
  139155. export var layerPixelShader: {
  139156. name: string;
  139157. shader: string;
  139158. };
  139159. }
  139160. declare module BABYLON {
  139161. /** @hidden */
  139162. export var layerVertexShader: {
  139163. name: string;
  139164. shader: string;
  139165. };
  139166. }
  139167. declare module BABYLON {
  139168. /**
  139169. * This represents a full screen 2d layer.
  139170. * This can be useful to display a picture in the background of your scene for instance.
  139171. * @see https://www.babylonjs-playground.com/#08A2BS#1
  139172. */
  139173. export class Layer {
  139174. /**
  139175. * Define the name of the layer.
  139176. */
  139177. name: string;
  139178. /**
  139179. * Define the texture the layer should display.
  139180. */
  139181. texture: Nullable<Texture>;
  139182. /**
  139183. * Is the layer in background or foreground.
  139184. */
  139185. isBackground: boolean;
  139186. /**
  139187. * Define the color of the layer (instead of texture).
  139188. */
  139189. color: Color4;
  139190. /**
  139191. * Define the scale of the layer in order to zoom in out of the texture.
  139192. */
  139193. scale: Vector2;
  139194. /**
  139195. * Define an offset for the layer in order to shift the texture.
  139196. */
  139197. offset: Vector2;
  139198. /**
  139199. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  139200. */
  139201. alphaBlendingMode: number;
  139202. /**
  139203. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  139204. * Alpha test will not mix with the background color in case of transparency.
  139205. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  139206. */
  139207. alphaTest: boolean;
  139208. /**
  139209. * Define a mask to restrict the layer to only some of the scene cameras.
  139210. */
  139211. layerMask: number;
  139212. /**
  139213. * Define the list of render target the layer is visible into.
  139214. */
  139215. renderTargetTextures: RenderTargetTexture[];
  139216. /**
  139217. * Define if the layer is only used in renderTarget or if it also
  139218. * renders in the main frame buffer of the canvas.
  139219. */
  139220. renderOnlyInRenderTargetTextures: boolean;
  139221. private _scene;
  139222. private _vertexBuffers;
  139223. private _indexBuffer;
  139224. private _effect;
  139225. private _previousDefines;
  139226. /**
  139227. * An event triggered when the layer is disposed.
  139228. */
  139229. onDisposeObservable: Observable<Layer>;
  139230. private _onDisposeObserver;
  139231. /**
  139232. * Back compatibility with callback before the onDisposeObservable existed.
  139233. * The set callback will be triggered when the layer has been disposed.
  139234. */
  139235. set onDispose(callback: () => void);
  139236. /**
  139237. * An event triggered before rendering the scene
  139238. */
  139239. onBeforeRenderObservable: Observable<Layer>;
  139240. private _onBeforeRenderObserver;
  139241. /**
  139242. * Back compatibility with callback before the onBeforeRenderObservable existed.
  139243. * The set callback will be triggered just before rendering the layer.
  139244. */
  139245. set onBeforeRender(callback: () => void);
  139246. /**
  139247. * An event triggered after rendering the scene
  139248. */
  139249. onAfterRenderObservable: Observable<Layer>;
  139250. private _onAfterRenderObserver;
  139251. /**
  139252. * Back compatibility with callback before the onAfterRenderObservable existed.
  139253. * The set callback will be triggered just after rendering the layer.
  139254. */
  139255. set onAfterRender(callback: () => void);
  139256. /**
  139257. * Instantiates a new layer.
  139258. * This represents a full screen 2d layer.
  139259. * This can be useful to display a picture in the background of your scene for instance.
  139260. * @see https://www.babylonjs-playground.com/#08A2BS#1
  139261. * @param name Define the name of the layer in the scene
  139262. * @param imgUrl Define the url of the texture to display in the layer
  139263. * @param scene Define the scene the layer belongs to
  139264. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  139265. * @param color Defines a color for the layer
  139266. */
  139267. constructor(
  139268. /**
  139269. * Define the name of the layer.
  139270. */
  139271. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  139272. private _createIndexBuffer;
  139273. /** @hidden */
  139274. _rebuild(): void;
  139275. /**
  139276. * Renders the layer in the scene.
  139277. */
  139278. render(): void;
  139279. /**
  139280. * Disposes and releases the associated ressources.
  139281. */
  139282. dispose(): void;
  139283. }
  139284. }
  139285. declare module BABYLON {
  139286. /** @hidden */
  139287. export var lensFlarePixelShader: {
  139288. name: string;
  139289. shader: string;
  139290. };
  139291. }
  139292. declare module BABYLON {
  139293. /** @hidden */
  139294. export var lensFlareVertexShader: {
  139295. name: string;
  139296. shader: string;
  139297. };
  139298. }
  139299. declare module BABYLON {
  139300. /**
  139301. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  139302. * It is usually composed of several `lensFlare`.
  139303. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  139304. */
  139305. export class LensFlareSystem {
  139306. /**
  139307. * Define the name of the lens flare system
  139308. */
  139309. name: string;
  139310. /**
  139311. * List of lens flares used in this system.
  139312. */
  139313. lensFlares: LensFlare[];
  139314. /**
  139315. * Define a limit from the border the lens flare can be visible.
  139316. */
  139317. borderLimit: number;
  139318. /**
  139319. * Define a viewport border we do not want to see the lens flare in.
  139320. */
  139321. viewportBorder: number;
  139322. /**
  139323. * Define a predicate which could limit the list of meshes able to occlude the effect.
  139324. */
  139325. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  139326. /**
  139327. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  139328. */
  139329. layerMask: number;
  139330. /**
  139331. * Define the id of the lens flare system in the scene.
  139332. * (equal to name by default)
  139333. */
  139334. id: string;
  139335. private _scene;
  139336. private _emitter;
  139337. private _vertexBuffers;
  139338. private _indexBuffer;
  139339. private _effect;
  139340. private _positionX;
  139341. private _positionY;
  139342. private _isEnabled;
  139343. /** @hidden */
  139344. static _SceneComponentInitialization: (scene: Scene) => void;
  139345. /**
  139346. * Instantiates a lens flare system.
  139347. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  139348. * It is usually composed of several `lensFlare`.
  139349. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  139350. * @param name Define the name of the lens flare system in the scene
  139351. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  139352. * @param scene Define the scene the lens flare system belongs to
  139353. */
  139354. constructor(
  139355. /**
  139356. * Define the name of the lens flare system
  139357. */
  139358. name: string, emitter: any, scene: Scene);
  139359. /**
  139360. * Define if the lens flare system is enabled.
  139361. */
  139362. get isEnabled(): boolean;
  139363. set isEnabled(value: boolean);
  139364. /**
  139365. * Get the scene the effects belongs to.
  139366. * @returns the scene holding the lens flare system
  139367. */
  139368. getScene(): Scene;
  139369. /**
  139370. * Get the emitter of the lens flare system.
  139371. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  139372. * @returns the emitter of the lens flare system
  139373. */
  139374. getEmitter(): any;
  139375. /**
  139376. * Set the emitter of the lens flare system.
  139377. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  139378. * @param newEmitter Define the new emitter of the system
  139379. */
  139380. setEmitter(newEmitter: any): void;
  139381. /**
  139382. * Get the lens flare system emitter position.
  139383. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  139384. * @returns the position
  139385. */
  139386. getEmitterPosition(): Vector3;
  139387. /**
  139388. * @hidden
  139389. */
  139390. computeEffectivePosition(globalViewport: Viewport): boolean;
  139391. /** @hidden */
  139392. _isVisible(): boolean;
  139393. /**
  139394. * @hidden
  139395. */
  139396. render(): boolean;
  139397. /**
  139398. * Dispose and release the lens flare with its associated resources.
  139399. */
  139400. dispose(): void;
  139401. /**
  139402. * Parse a lens flare system from a JSON repressentation
  139403. * @param parsedLensFlareSystem Define the JSON to parse
  139404. * @param scene Define the scene the parsed system should be instantiated in
  139405. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  139406. * @returns the parsed system
  139407. */
  139408. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  139409. /**
  139410. * Serialize the current Lens Flare System into a JSON representation.
  139411. * @returns the serialized JSON
  139412. */
  139413. serialize(): any;
  139414. }
  139415. }
  139416. declare module BABYLON {
  139417. /**
  139418. * This represents one of the lens effect in a `lensFlareSystem`.
  139419. * It controls one of the indiviual texture used in the effect.
  139420. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  139421. */
  139422. export class LensFlare {
  139423. /**
  139424. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  139425. */
  139426. size: number;
  139427. /**
  139428. * 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.
  139429. */
  139430. position: number;
  139431. /**
  139432. * Define the lens color.
  139433. */
  139434. color: Color3;
  139435. /**
  139436. * Define the lens texture.
  139437. */
  139438. texture: Nullable<Texture>;
  139439. /**
  139440. * Define the alpha mode to render this particular lens.
  139441. */
  139442. alphaMode: number;
  139443. private _system;
  139444. /**
  139445. * Creates a new Lens Flare.
  139446. * This represents one of the lens effect in a `lensFlareSystem`.
  139447. * It controls one of the indiviual texture used in the effect.
  139448. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  139449. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  139450. * @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.
  139451. * @param color Define the lens color
  139452. * @param imgUrl Define the lens texture url
  139453. * @param system Define the `lensFlareSystem` this flare is part of
  139454. * @returns The newly created Lens Flare
  139455. */
  139456. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  139457. /**
  139458. * Instantiates a new Lens Flare.
  139459. * This represents one of the lens effect in a `lensFlareSystem`.
  139460. * It controls one of the indiviual texture used in the effect.
  139461. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  139462. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  139463. * @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.
  139464. * @param color Define the lens color
  139465. * @param imgUrl Define the lens texture url
  139466. * @param system Define the `lensFlareSystem` this flare is part of
  139467. */
  139468. constructor(
  139469. /**
  139470. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  139471. */
  139472. size: number,
  139473. /**
  139474. * 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.
  139475. */
  139476. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  139477. /**
  139478. * Dispose and release the lens flare with its associated resources.
  139479. */
  139480. dispose(): void;
  139481. }
  139482. }
  139483. declare module BABYLON {
  139484. interface AbstractScene {
  139485. /**
  139486. * The list of lens flare system added to the scene
  139487. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  139488. */
  139489. lensFlareSystems: Array<LensFlareSystem>;
  139490. /**
  139491. * Removes the given lens flare system from this scene.
  139492. * @param toRemove The lens flare system to remove
  139493. * @returns The index of the removed lens flare system
  139494. */
  139495. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  139496. /**
  139497. * Adds the given lens flare system to this scene
  139498. * @param newLensFlareSystem The lens flare system to add
  139499. */
  139500. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  139501. /**
  139502. * Gets a lens flare system using its name
  139503. * @param name defines the name to look for
  139504. * @returns the lens flare system or null if not found
  139505. */
  139506. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  139507. /**
  139508. * Gets a lens flare system using its id
  139509. * @param id defines the id to look for
  139510. * @returns the lens flare system or null if not found
  139511. */
  139512. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  139513. }
  139514. /**
  139515. * Defines the lens flare scene component responsible to manage any lens flares
  139516. * in a given scene.
  139517. */
  139518. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  139519. /**
  139520. * The component name helpfull to identify the component in the list of scene components.
  139521. */
  139522. readonly name: string;
  139523. /**
  139524. * The scene the component belongs to.
  139525. */
  139526. scene: Scene;
  139527. /**
  139528. * Creates a new instance of the component for the given scene
  139529. * @param scene Defines the scene to register the component in
  139530. */
  139531. constructor(scene: Scene);
  139532. /**
  139533. * Registers the component in a given scene
  139534. */
  139535. register(): void;
  139536. /**
  139537. * Rebuilds the elements related to this component in case of
  139538. * context lost for instance.
  139539. */
  139540. rebuild(): void;
  139541. /**
  139542. * Adds all the elements from the container to the scene
  139543. * @param container the container holding the elements
  139544. */
  139545. addFromContainer(container: AbstractScene): void;
  139546. /**
  139547. * Removes all the elements in the container from the scene
  139548. * @param container contains the elements to remove
  139549. * @param dispose if the removed element should be disposed (default: false)
  139550. */
  139551. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  139552. /**
  139553. * Serializes the component data to the specified json object
  139554. * @param serializationObject The object to serialize to
  139555. */
  139556. serialize(serializationObject: any): void;
  139557. /**
  139558. * Disposes the component and the associated ressources.
  139559. */
  139560. dispose(): void;
  139561. private _draw;
  139562. }
  139563. }
  139564. declare module BABYLON {
  139565. /** @hidden */
  139566. export var depthPixelShader: {
  139567. name: string;
  139568. shader: string;
  139569. };
  139570. }
  139571. declare module BABYLON {
  139572. /** @hidden */
  139573. export var depthVertexShader: {
  139574. name: string;
  139575. shader: string;
  139576. };
  139577. }
  139578. declare module BABYLON {
  139579. /**
  139580. * This represents a depth renderer in Babylon.
  139581. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  139582. */
  139583. export class DepthRenderer {
  139584. private _scene;
  139585. private _depthMap;
  139586. private _effect;
  139587. private readonly _storeNonLinearDepth;
  139588. private readonly _clearColor;
  139589. /** Get if the depth renderer is using packed depth or not */
  139590. readonly isPacked: boolean;
  139591. private _cachedDefines;
  139592. private _camera;
  139593. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  139594. enabled: boolean;
  139595. /**
  139596. * Specifiess that the depth renderer will only be used within
  139597. * the camera it is created for.
  139598. * This can help forcing its rendering during the camera processing.
  139599. */
  139600. useOnlyInActiveCamera: boolean;
  139601. /** @hidden */
  139602. static _SceneComponentInitialization: (scene: Scene) => void;
  139603. /**
  139604. * Instantiates a depth renderer
  139605. * @param scene The scene the renderer belongs to
  139606. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  139607. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  139608. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  139609. */
  139610. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  139611. /**
  139612. * Creates the depth rendering effect and checks if the effect is ready.
  139613. * @param subMesh The submesh to be used to render the depth map of
  139614. * @param useInstances If multiple world instances should be used
  139615. * @returns if the depth renderer is ready to render the depth map
  139616. */
  139617. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  139618. /**
  139619. * Gets the texture which the depth map will be written to.
  139620. * @returns The depth map texture
  139621. */
  139622. getDepthMap(): RenderTargetTexture;
  139623. /**
  139624. * Disposes of the depth renderer.
  139625. */
  139626. dispose(): void;
  139627. }
  139628. }
  139629. declare module BABYLON {
  139630. /** @hidden */
  139631. export var minmaxReduxPixelShader: {
  139632. name: string;
  139633. shader: string;
  139634. };
  139635. }
  139636. declare module BABYLON {
  139637. /**
  139638. * This class computes a min/max reduction from a texture: it means it computes the minimum
  139639. * and maximum values from all values of the texture.
  139640. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  139641. * The source values are read from the red channel of the texture.
  139642. */
  139643. export class MinMaxReducer {
  139644. /**
  139645. * Observable triggered when the computation has been performed
  139646. */
  139647. onAfterReductionPerformed: Observable<{
  139648. min: number;
  139649. max: number;
  139650. }>;
  139651. protected _camera: Camera;
  139652. protected _sourceTexture: Nullable<RenderTargetTexture>;
  139653. protected _reductionSteps: Nullable<Array<PostProcess>>;
  139654. protected _postProcessManager: PostProcessManager;
  139655. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  139656. protected _forceFullscreenViewport: boolean;
  139657. /**
  139658. * Creates a min/max reducer
  139659. * @param camera The camera to use for the post processes
  139660. */
  139661. constructor(camera: Camera);
  139662. /**
  139663. * Gets the texture used to read the values from.
  139664. */
  139665. get sourceTexture(): Nullable<RenderTargetTexture>;
  139666. /**
  139667. * Sets the source texture to read the values from.
  139668. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  139669. * because in such textures '1' value must not be taken into account to compute the maximum
  139670. * as this value is used to clear the texture.
  139671. * Note that the computation is not activated by calling this function, you must call activate() for that!
  139672. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  139673. * @param depthRedux Indicates if the texture is a depth texture or not
  139674. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  139675. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  139676. */
  139677. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  139678. /**
  139679. * Defines the refresh rate of the computation.
  139680. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  139681. */
  139682. get refreshRate(): number;
  139683. set refreshRate(value: number);
  139684. protected _activated: boolean;
  139685. /**
  139686. * Gets the activation status of the reducer
  139687. */
  139688. get activated(): boolean;
  139689. /**
  139690. * Activates the reduction computation.
  139691. * When activated, the observers registered in onAfterReductionPerformed are
  139692. * called after the compuation is performed
  139693. */
  139694. activate(): void;
  139695. /**
  139696. * Deactivates the reduction computation.
  139697. */
  139698. deactivate(): void;
  139699. /**
  139700. * Disposes the min/max reducer
  139701. * @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.
  139702. */
  139703. dispose(disposeAll?: boolean): void;
  139704. }
  139705. }
  139706. declare module BABYLON {
  139707. /**
  139708. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  139709. */
  139710. export class DepthReducer extends MinMaxReducer {
  139711. private _depthRenderer;
  139712. private _depthRendererId;
  139713. /**
  139714. * Gets the depth renderer used for the computation.
  139715. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  139716. */
  139717. get depthRenderer(): Nullable<DepthRenderer>;
  139718. /**
  139719. * Creates a depth reducer
  139720. * @param camera The camera used to render the depth texture
  139721. */
  139722. constructor(camera: Camera);
  139723. /**
  139724. * Sets the depth renderer to use to generate the depth map
  139725. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  139726. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  139727. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  139728. */
  139729. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  139730. /** @hidden */
  139731. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  139732. /**
  139733. * Activates the reduction computation.
  139734. * When activated, the observers registered in onAfterReductionPerformed are
  139735. * called after the compuation is performed
  139736. */
  139737. activate(): void;
  139738. /**
  139739. * Deactivates the reduction computation.
  139740. */
  139741. deactivate(): void;
  139742. /**
  139743. * Disposes the depth reducer
  139744. * @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.
  139745. */
  139746. dispose(disposeAll?: boolean): void;
  139747. }
  139748. }
  139749. declare module BABYLON {
  139750. /**
  139751. * A CSM implementation allowing casting shadows on large scenes.
  139752. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  139753. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  139754. */
  139755. export class CascadedShadowGenerator extends ShadowGenerator {
  139756. private static readonly frustumCornersNDCSpace;
  139757. /**
  139758. * Name of the CSM class
  139759. */
  139760. static CLASSNAME: string;
  139761. /**
  139762. * Defines the default number of cascades used by the CSM.
  139763. */
  139764. static readonly DEFAULT_CASCADES_COUNT: number;
  139765. /**
  139766. * Defines the minimum number of cascades used by the CSM.
  139767. */
  139768. static readonly MIN_CASCADES_COUNT: number;
  139769. /**
  139770. * Defines the maximum number of cascades used by the CSM.
  139771. */
  139772. static readonly MAX_CASCADES_COUNT: number;
  139773. protected _validateFilter(filter: number): number;
  139774. /**
  139775. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  139776. */
  139777. penumbraDarkness: number;
  139778. private _numCascades;
  139779. /**
  139780. * Gets or set the number of cascades used by the CSM.
  139781. */
  139782. get numCascades(): number;
  139783. set numCascades(value: number);
  139784. /**
  139785. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  139786. * The trade off is that you lose some precision in the shadow rendering when enabling this setting.
  139787. */
  139788. stabilizeCascades: boolean;
  139789. private _freezeShadowCastersBoundingInfo;
  139790. private _freezeShadowCastersBoundingInfoObservable;
  139791. /**
  139792. * Enables or disables the shadow casters bounding info computation.
  139793. * If your shadow casters don't move, you can disable this feature.
  139794. * If it is enabled, the bounding box computation is done every frame.
  139795. */
  139796. get freezeShadowCastersBoundingInfo(): boolean;
  139797. set freezeShadowCastersBoundingInfo(freeze: boolean);
  139798. private _scbiMin;
  139799. private _scbiMax;
  139800. protected _computeShadowCastersBoundingInfo(): void;
  139801. protected _shadowCastersBoundingInfo: BoundingInfo;
  139802. /**
  139803. * Gets or sets the shadow casters bounding info.
  139804. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  139805. * so that the system won't overwrite the bounds you provide
  139806. */
  139807. get shadowCastersBoundingInfo(): BoundingInfo;
  139808. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  139809. protected _breaksAreDirty: boolean;
  139810. protected _minDistance: number;
  139811. protected _maxDistance: number;
  139812. /**
  139813. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  139814. *
  139815. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  139816. * If you don't know these values, simply leave them to their defaults and don't call this function.
  139817. * @param min minimal distance for the breaks (default to 0.)
  139818. * @param max maximal distance for the breaks (default to 1.)
  139819. */
  139820. setMinMaxDistance(min: number, max: number): void;
  139821. /** Gets the minimal distance used in the cascade break computation */
  139822. get minDistance(): number;
  139823. /** Gets the maximal distance used in the cascade break computation */
  139824. get maxDistance(): number;
  139825. /**
  139826. * Gets the class name of that object
  139827. * @returns "CascadedShadowGenerator"
  139828. */
  139829. getClassName(): string;
  139830. private _cascadeMinExtents;
  139831. private _cascadeMaxExtents;
  139832. /**
  139833. * Gets a cascade minimum extents
  139834. * @param cascadeIndex index of the cascade
  139835. * @returns the minimum cascade extents
  139836. */
  139837. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  139838. /**
  139839. * Gets a cascade maximum extents
  139840. * @param cascadeIndex index of the cascade
  139841. * @returns the maximum cascade extents
  139842. */
  139843. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  139844. private _cascades;
  139845. private _currentLayer;
  139846. private _viewSpaceFrustumsZ;
  139847. private _viewMatrices;
  139848. private _projectionMatrices;
  139849. private _transformMatrices;
  139850. private _transformMatricesAsArray;
  139851. private _frustumLengths;
  139852. private _lightSizeUVCorrection;
  139853. private _depthCorrection;
  139854. private _frustumCornersWorldSpace;
  139855. private _frustumCenter;
  139856. private _shadowCameraPos;
  139857. private _shadowMaxZ;
  139858. /**
  139859. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  139860. * It defaults to camera.maxZ
  139861. */
  139862. get shadowMaxZ(): number;
  139863. /**
  139864. * Sets the shadow max z distance.
  139865. */
  139866. set shadowMaxZ(value: number);
  139867. protected _debug: boolean;
  139868. /**
  139869. * Gets or sets the debug flag.
  139870. * When enabled, the cascades are materialized by different colors on the screen.
  139871. */
  139872. get debug(): boolean;
  139873. set debug(dbg: boolean);
  139874. private _depthClamp;
  139875. /**
  139876. * Gets or sets the depth clamping value.
  139877. *
  139878. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  139879. * to account for the shadow casters far away.
  139880. *
  139881. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  139882. */
  139883. get depthClamp(): boolean;
  139884. set depthClamp(value: boolean);
  139885. private _cascadeBlendPercentage;
  139886. /**
  139887. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  139888. * It defaults to 0.1 (10% blending).
  139889. */
  139890. get cascadeBlendPercentage(): number;
  139891. set cascadeBlendPercentage(value: number);
  139892. private _lambda;
  139893. /**
  139894. * Gets or set the lambda parameter.
  139895. * This parameter is used to split the camera frustum and create the cascades.
  139896. * 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.
  139897. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  139898. */
  139899. get lambda(): number;
  139900. set lambda(value: number);
  139901. /**
  139902. * Gets the view matrix corresponding to a given cascade
  139903. * @param cascadeNum cascade to retrieve the view matrix from
  139904. * @returns the cascade view matrix
  139905. */
  139906. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  139907. /**
  139908. * Gets the projection matrix corresponding to a given cascade
  139909. * @param cascadeNum cascade to retrieve the projection matrix from
  139910. * @returns the cascade projection matrix
  139911. */
  139912. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  139913. /**
  139914. * Gets the transformation matrix corresponding to a given cascade
  139915. * @param cascadeNum cascade to retrieve the transformation matrix from
  139916. * @returns the cascade transformation matrix
  139917. */
  139918. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  139919. private _depthRenderer;
  139920. /**
  139921. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  139922. *
  139923. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  139924. *
  139925. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  139926. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  139927. * @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
  139928. */
  139929. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  139930. private _depthReducer;
  139931. private _autoCalcDepthBounds;
  139932. /**
  139933. * Gets or sets the autoCalcDepthBounds property.
  139934. *
  139935. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  139936. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  139937. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  139938. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  139939. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  139940. */
  139941. get autoCalcDepthBounds(): boolean;
  139942. set autoCalcDepthBounds(value: boolean);
  139943. /**
  139944. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  139945. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  139946. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  139947. * for setting the refresh rate on the renderer yourself!
  139948. */
  139949. get autoCalcDepthBoundsRefreshRate(): number;
  139950. set autoCalcDepthBoundsRefreshRate(value: number);
  139951. /**
  139952. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  139953. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  139954. * you change the camera near/far planes!
  139955. */
  139956. splitFrustum(): void;
  139957. private _splitFrustum;
  139958. private _computeMatrices;
  139959. private _computeFrustumInWorldSpace;
  139960. private _computeCascadeFrustum;
  139961. /**
  139962. * Support test.
  139963. */
  139964. static get IsSupported(): boolean;
  139965. /** @hidden */
  139966. static _SceneComponentInitialization: (scene: Scene) => void;
  139967. /**
  139968. * Creates a Cascaded Shadow Generator object.
  139969. * A ShadowGenerator is the required tool to use the shadows.
  139970. * Each directional light casting shadows needs to use its own ShadowGenerator.
  139971. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  139972. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  139973. * @param light The directional light object generating the shadows.
  139974. * @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.
  139975. */
  139976. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  139977. protected _initializeGenerator(): void;
  139978. protected _createTargetRenderTexture(): void;
  139979. protected _initializeShadowMap(): void;
  139980. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  139981. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  139982. /**
  139983. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  139984. * @param defines Defines of the material we want to update
  139985. * @param lightIndex Index of the light in the enabled light list of the material
  139986. */
  139987. prepareDefines(defines: any, lightIndex: number): void;
  139988. /**
  139989. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  139990. * defined in the generator but impacting the effect).
  139991. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  139992. * @param effect The effect we are binfing the information for
  139993. */
  139994. bindShadowLight(lightIndex: string, effect: Effect): void;
  139995. /**
  139996. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  139997. * (eq to view projection * shadow projection matrices)
  139998. * @returns The transform matrix used to create the shadow map
  139999. */
  140000. getTransformMatrix(): Matrix;
  140001. /**
  140002. * Disposes the ShadowGenerator.
  140003. * Returns nothing.
  140004. */
  140005. dispose(): void;
  140006. /**
  140007. * Serializes the shadow generator setup to a json object.
  140008. * @returns The serialized JSON object
  140009. */
  140010. serialize(): any;
  140011. /**
  140012. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  140013. * @param parsedShadowGenerator The JSON object to parse
  140014. * @param scene The scene to create the shadow map for
  140015. * @returns The parsed shadow generator
  140016. */
  140017. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  140018. }
  140019. }
  140020. declare module BABYLON {
  140021. /**
  140022. * Defines the shadow generator component responsible to manage any shadow generators
  140023. * in a given scene.
  140024. */
  140025. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  140026. /**
  140027. * The component name helpfull to identify the component in the list of scene components.
  140028. */
  140029. readonly name: string;
  140030. /**
  140031. * The scene the component belongs to.
  140032. */
  140033. scene: Scene;
  140034. /**
  140035. * Creates a new instance of the component for the given scene
  140036. * @param scene Defines the scene to register the component in
  140037. */
  140038. constructor(scene: Scene);
  140039. /**
  140040. * Registers the component in a given scene
  140041. */
  140042. register(): void;
  140043. /**
  140044. * Rebuilds the elements related to this component in case of
  140045. * context lost for instance.
  140046. */
  140047. rebuild(): void;
  140048. /**
  140049. * Serializes the component data to the specified json object
  140050. * @param serializationObject The object to serialize to
  140051. */
  140052. serialize(serializationObject: any): void;
  140053. /**
  140054. * Adds all the elements from the container to the scene
  140055. * @param container the container holding the elements
  140056. */
  140057. addFromContainer(container: AbstractScene): void;
  140058. /**
  140059. * Removes all the elements in the container from the scene
  140060. * @param container contains the elements to remove
  140061. * @param dispose if the removed element should be disposed (default: false)
  140062. */
  140063. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  140064. /**
  140065. * Rebuilds the elements related to this component in case of
  140066. * context lost for instance.
  140067. */
  140068. dispose(): void;
  140069. private _gatherRenderTargets;
  140070. }
  140071. }
  140072. declare module BABYLON {
  140073. /**
  140074. * A point light is a light defined by an unique point in world space.
  140075. * The light is emitted in every direction from this point.
  140076. * A good example of a point light is a standard light bulb.
  140077. * Documentation: https://doc.babylonjs.com/babylon101/lights
  140078. */
  140079. export class PointLight extends ShadowLight {
  140080. private _shadowAngle;
  140081. /**
  140082. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  140083. * This specifies what angle the shadow will use to be created.
  140084. *
  140085. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  140086. */
  140087. get shadowAngle(): number;
  140088. /**
  140089. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  140090. * This specifies what angle the shadow will use to be created.
  140091. *
  140092. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  140093. */
  140094. set shadowAngle(value: number);
  140095. /**
  140096. * Gets the direction if it has been set.
  140097. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  140098. */
  140099. get direction(): Vector3;
  140100. /**
  140101. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  140102. */
  140103. set direction(value: Vector3);
  140104. /**
  140105. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  140106. * A PointLight emits the light in every direction.
  140107. * It can cast shadows.
  140108. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  140109. * ```javascript
  140110. * var pointLight = new PointLight("pl", camera.position, scene);
  140111. * ```
  140112. * Documentation : https://doc.babylonjs.com/babylon101/lights
  140113. * @param name The light friendly name
  140114. * @param position The position of the point light in the scene
  140115. * @param scene The scene the lights belongs to
  140116. */
  140117. constructor(name: string, position: Vector3, scene: Scene);
  140118. /**
  140119. * Returns the string "PointLight"
  140120. * @returns the class name
  140121. */
  140122. getClassName(): string;
  140123. /**
  140124. * Returns the integer 0.
  140125. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  140126. */
  140127. getTypeID(): number;
  140128. /**
  140129. * Specifies wether or not the shadowmap should be a cube texture.
  140130. * @returns true if the shadowmap needs to be a cube texture.
  140131. */
  140132. needCube(): boolean;
  140133. /**
  140134. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  140135. * @param faceIndex The index of the face we are computed the direction to generate shadow
  140136. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  140137. */
  140138. getShadowDirection(faceIndex?: number): Vector3;
  140139. /**
  140140. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  140141. * - fov = PI / 2
  140142. * - aspect ratio : 1.0
  140143. * - z-near and far equal to the active camera minZ and maxZ.
  140144. * Returns the PointLight.
  140145. */
  140146. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  140147. protected _buildUniformLayout(): void;
  140148. /**
  140149. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  140150. * @param effect The effect to update
  140151. * @param lightIndex The index of the light in the effect to update
  140152. * @returns The point light
  140153. */
  140154. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  140155. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  140156. /**
  140157. * Prepares the list of defines specific to the light type.
  140158. * @param defines the list of defines
  140159. * @param lightIndex defines the index of the light for the effect
  140160. */
  140161. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  140162. }
  140163. }
  140164. declare module BABYLON {
  140165. /**
  140166. * Header information of HDR texture files.
  140167. */
  140168. export interface HDRInfo {
  140169. /**
  140170. * The height of the texture in pixels.
  140171. */
  140172. height: number;
  140173. /**
  140174. * The width of the texture in pixels.
  140175. */
  140176. width: number;
  140177. /**
  140178. * The index of the beginning of the data in the binary file.
  140179. */
  140180. dataPosition: number;
  140181. }
  140182. /**
  140183. * This groups tools to convert HDR texture to native colors array.
  140184. */
  140185. export class HDRTools {
  140186. private static Ldexp;
  140187. private static Rgbe2float;
  140188. private static readStringLine;
  140189. /**
  140190. * Reads header information from an RGBE texture stored in a native array.
  140191. * More information on this format are available here:
  140192. * https://en.wikipedia.org/wiki/RGBE_image_format
  140193. *
  140194. * @param uint8array The binary file stored in native array.
  140195. * @return The header information.
  140196. */
  140197. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  140198. /**
  140199. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  140200. * This RGBE texture needs to store the information as a panorama.
  140201. *
  140202. * More information on this format are available here:
  140203. * https://en.wikipedia.org/wiki/RGBE_image_format
  140204. *
  140205. * @param buffer The binary file stored in an array buffer.
  140206. * @param size The expected size of the extracted cubemap.
  140207. * @return The Cube Map information.
  140208. */
  140209. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  140210. /**
  140211. * Returns the pixels data extracted from an RGBE texture.
  140212. * This pixels will be stored left to right up to down in the R G B order in one array.
  140213. *
  140214. * More information on this format are available here:
  140215. * https://en.wikipedia.org/wiki/RGBE_image_format
  140216. *
  140217. * @param uint8array The binary file stored in an array buffer.
  140218. * @param hdrInfo The header information of the file.
  140219. * @return The pixels data in RGB right to left up to down order.
  140220. */
  140221. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  140222. private static RGBE_ReadPixels_RLE;
  140223. private static RGBE_ReadPixels_NOT_RLE;
  140224. }
  140225. }
  140226. declare module BABYLON {
  140227. /**
  140228. * Effect Render Options
  140229. */
  140230. export interface IEffectRendererOptions {
  140231. /**
  140232. * Defines the vertices positions.
  140233. */
  140234. positions?: number[];
  140235. /**
  140236. * Defines the indices.
  140237. */
  140238. indices?: number[];
  140239. }
  140240. /**
  140241. * Helper class to render one or more effects.
  140242. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  140243. */
  140244. export class EffectRenderer {
  140245. private engine;
  140246. private static _DefaultOptions;
  140247. private _vertexBuffers;
  140248. private _indexBuffer;
  140249. private _fullscreenViewport;
  140250. /**
  140251. * Creates an effect renderer
  140252. * @param engine the engine to use for rendering
  140253. * @param options defines the options of the effect renderer
  140254. */
  140255. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  140256. /**
  140257. * Sets the current viewport in normalized coordinates 0-1
  140258. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  140259. */
  140260. setViewport(viewport?: Viewport): void;
  140261. /**
  140262. * Binds the embedded attributes buffer to the effect.
  140263. * @param effect Defines the effect to bind the attributes for
  140264. */
  140265. bindBuffers(effect: Effect): void;
  140266. /**
  140267. * Sets the current effect wrapper to use during draw.
  140268. * The effect needs to be ready before calling this api.
  140269. * This also sets the default full screen position attribute.
  140270. * @param effectWrapper Defines the effect to draw with
  140271. */
  140272. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  140273. /**
  140274. * Restores engine states
  140275. */
  140276. restoreStates(): void;
  140277. /**
  140278. * Draws a full screen quad.
  140279. */
  140280. draw(): void;
  140281. private isRenderTargetTexture;
  140282. /**
  140283. * renders one or more effects to a specified texture
  140284. * @param effectWrapper the effect to renderer
  140285. * @param outputTexture texture to draw to, if null it will render to the screen.
  140286. */
  140287. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  140288. /**
  140289. * Disposes of the effect renderer
  140290. */
  140291. dispose(): void;
  140292. }
  140293. /**
  140294. * Options to create an EffectWrapper
  140295. */
  140296. interface EffectWrapperCreationOptions {
  140297. /**
  140298. * Engine to use to create the effect
  140299. */
  140300. engine: ThinEngine;
  140301. /**
  140302. * Fragment shader for the effect
  140303. */
  140304. fragmentShader: string;
  140305. /**
  140306. * Use the shader store instead of direct source code
  140307. */
  140308. useShaderStore?: boolean;
  140309. /**
  140310. * Vertex shader for the effect
  140311. */
  140312. vertexShader?: string;
  140313. /**
  140314. * Attributes to use in the shader
  140315. */
  140316. attributeNames?: Array<string>;
  140317. /**
  140318. * Uniforms to use in the shader
  140319. */
  140320. uniformNames?: Array<string>;
  140321. /**
  140322. * Texture sampler names to use in the shader
  140323. */
  140324. samplerNames?: Array<string>;
  140325. /**
  140326. * Defines to use in the shader
  140327. */
  140328. defines?: Array<string>;
  140329. /**
  140330. * Callback when effect is compiled
  140331. */
  140332. onCompiled?: Nullable<(effect: Effect) => void>;
  140333. /**
  140334. * The friendly name of the effect displayed in Spector.
  140335. */
  140336. name?: string;
  140337. }
  140338. /**
  140339. * Wraps an effect to be used for rendering
  140340. */
  140341. export class EffectWrapper {
  140342. /**
  140343. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  140344. */
  140345. onApplyObservable: Observable<{}>;
  140346. /**
  140347. * The underlying effect
  140348. */
  140349. effect: Effect;
  140350. /**
  140351. * Creates an effect to be renderer
  140352. * @param creationOptions options to create the effect
  140353. */
  140354. constructor(creationOptions: EffectWrapperCreationOptions);
  140355. /**
  140356. * Disposes of the effect wrapper
  140357. */
  140358. dispose(): void;
  140359. }
  140360. }
  140361. declare module BABYLON {
  140362. /** @hidden */
  140363. export var hdrFilteringVertexShader: {
  140364. name: string;
  140365. shader: string;
  140366. };
  140367. }
  140368. declare module BABYLON {
  140369. /** @hidden */
  140370. export var hdrFilteringPixelShader: {
  140371. name: string;
  140372. shader: string;
  140373. };
  140374. }
  140375. declare module BABYLON {
  140376. /**
  140377. * Options for texture filtering
  140378. */
  140379. interface IHDRFilteringOptions {
  140380. /**
  140381. * Scales pixel intensity for the input HDR map.
  140382. */
  140383. hdrScale?: number;
  140384. /**
  140385. * Quality of the filter. Should be `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` for prefiltering
  140386. */
  140387. quality?: number;
  140388. }
  140389. /**
  140390. * Filters HDR maps to get correct renderings of PBR reflections
  140391. */
  140392. export class HDRFiltering {
  140393. private _engine;
  140394. private _effectRenderer;
  140395. private _effectWrapper;
  140396. private _lodGenerationOffset;
  140397. private _lodGenerationScale;
  140398. /**
  140399. * Quality switch for prefiltering. Should be set to `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` unless
  140400. * you care about baking speed.
  140401. */
  140402. quality: number;
  140403. /**
  140404. * Scales pixel intensity for the input HDR map.
  140405. */
  140406. hdrScale: number;
  140407. /**
  140408. * Instantiates HDR filter for reflection maps
  140409. *
  140410. * @param engine Thin engine
  140411. * @param options Options
  140412. */
  140413. constructor(engine: ThinEngine, options?: IHDRFilteringOptions);
  140414. private _createRenderTarget;
  140415. private _prefilterInternal;
  140416. private _createEffect;
  140417. /**
  140418. * Get a value indicating if the filter is ready to be used
  140419. * @param texture Texture to filter
  140420. * @returns true if the filter is ready
  140421. */
  140422. isReady(texture: BaseTexture): boolean;
  140423. /**
  140424. * Prefilters a cube texture to have mipmap levels representing roughness values.
  140425. * Prefiltering will be invoked at the end of next rendering pass.
  140426. * This has to be done once the map is loaded, and has not been prefiltered by a third party software.
  140427. * See http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf for more information
  140428. * @param texture Texture to filter
  140429. * @param onFinished Callback when filtering is done
  140430. * @return Promise called when prefiltering is done
  140431. */
  140432. prefilter(texture: BaseTexture, onFinished?: Nullable<() => void>): Promise<unknown> | undefined;
  140433. }
  140434. }
  140435. declare module BABYLON {
  140436. /**
  140437. * This represents a texture coming from an HDR input.
  140438. *
  140439. * The only supported format is currently panorama picture stored in RGBE format.
  140440. * Example of such files can be found on HDRLib: http://hdrlib.com/
  140441. */
  140442. export class HDRCubeTexture extends BaseTexture {
  140443. private static _facesMapping;
  140444. private _generateHarmonics;
  140445. private _noMipmap;
  140446. private _prefilterOnLoad;
  140447. private _textureMatrix;
  140448. private _size;
  140449. private _onLoad;
  140450. private _onError;
  140451. /**
  140452. * The texture URL.
  140453. */
  140454. url: string;
  140455. protected _isBlocking: boolean;
  140456. /**
  140457. * Sets wether or not the texture is blocking during loading.
  140458. */
  140459. set isBlocking(value: boolean);
  140460. /**
  140461. * Gets wether or not the texture is blocking during loading.
  140462. */
  140463. get isBlocking(): boolean;
  140464. protected _rotationY: number;
  140465. /**
  140466. * Sets texture matrix rotation angle around Y axis in radians.
  140467. */
  140468. set rotationY(value: number);
  140469. /**
  140470. * Gets texture matrix rotation angle around Y axis radians.
  140471. */
  140472. get rotationY(): number;
  140473. /**
  140474. * Gets or sets the center of the bounding box associated with the cube texture
  140475. * It must define where the camera used to render the texture was set
  140476. */
  140477. boundingBoxPosition: Vector3;
  140478. private _boundingBoxSize;
  140479. /**
  140480. * Gets or sets the size of the bounding box associated with the cube texture
  140481. * When defined, the cubemap will switch to local mode
  140482. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  140483. * @example https://www.babylonjs-playground.com/#RNASML
  140484. */
  140485. set boundingBoxSize(value: Vector3);
  140486. get boundingBoxSize(): Vector3;
  140487. /**
  140488. * Instantiates an HDRTexture from the following parameters.
  140489. *
  140490. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  140491. * @param sceneOrEngine The scene or engine the texture will be used in
  140492. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  140493. * @param noMipmap Forces to not generate the mipmap if true
  140494. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  140495. * @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)
  140496. * @param prefilterOnLoad Prefilters HDR texture to allow use of this texture as a PBR reflection texture.
  140497. */
  140498. 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>);
  140499. /**
  140500. * Get the current class name of the texture useful for serialization or dynamic coding.
  140501. * @returns "HDRCubeTexture"
  140502. */
  140503. getClassName(): string;
  140504. /**
  140505. * Occurs when the file is raw .hdr file.
  140506. */
  140507. private loadTexture;
  140508. clone(): HDRCubeTexture;
  140509. delayLoad(): void;
  140510. /**
  140511. * Get the texture reflection matrix used to rotate/transform the reflection.
  140512. * @returns the reflection matrix
  140513. */
  140514. getReflectionTextureMatrix(): Matrix;
  140515. /**
  140516. * Set the texture reflection matrix used to rotate/transform the reflection.
  140517. * @param value Define the reflection matrix to set
  140518. */
  140519. setReflectionTextureMatrix(value: Matrix): void;
  140520. /**
  140521. * Parses a JSON representation of an HDR Texture in order to create the texture
  140522. * @param parsedTexture Define the JSON representation
  140523. * @param scene Define the scene the texture should be created in
  140524. * @param rootUrl Define the root url in case we need to load relative dependencies
  140525. * @returns the newly created texture after parsing
  140526. */
  140527. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  140528. serialize(): any;
  140529. }
  140530. }
  140531. declare module BABYLON {
  140532. /**
  140533. * Class used to control physics engine
  140534. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  140535. */
  140536. export class PhysicsEngine implements IPhysicsEngine {
  140537. private _physicsPlugin;
  140538. /**
  140539. * Global value used to control the smallest number supported by the simulation
  140540. */
  140541. static Epsilon: number;
  140542. private _impostors;
  140543. private _joints;
  140544. private _subTimeStep;
  140545. /**
  140546. * Gets the gravity vector used by the simulation
  140547. */
  140548. gravity: Vector3;
  140549. /**
  140550. * Factory used to create the default physics plugin.
  140551. * @returns The default physics plugin
  140552. */
  140553. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  140554. /**
  140555. * Creates a new Physics Engine
  140556. * @param gravity defines the gravity vector used by the simulation
  140557. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  140558. */
  140559. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  140560. /**
  140561. * Sets the gravity vector used by the simulation
  140562. * @param gravity defines the gravity vector to use
  140563. */
  140564. setGravity(gravity: Vector3): void;
  140565. /**
  140566. * Set the time step of the physics engine.
  140567. * Default is 1/60.
  140568. * To slow it down, enter 1/600 for example.
  140569. * To speed it up, 1/30
  140570. * @param newTimeStep defines the new timestep to apply to this world.
  140571. */
  140572. setTimeStep(newTimeStep?: number): void;
  140573. /**
  140574. * Get the time step of the physics engine.
  140575. * @returns the current time step
  140576. */
  140577. getTimeStep(): number;
  140578. /**
  140579. * Set the sub time step of the physics engine.
  140580. * Default is 0 meaning there is no sub steps
  140581. * To increase physics resolution precision, set a small value (like 1 ms)
  140582. * @param subTimeStep defines the new sub timestep used for physics resolution.
  140583. */
  140584. setSubTimeStep(subTimeStep?: number): void;
  140585. /**
  140586. * Get the sub time step of the physics engine.
  140587. * @returns the current sub time step
  140588. */
  140589. getSubTimeStep(): number;
  140590. /**
  140591. * Release all resources
  140592. */
  140593. dispose(): void;
  140594. /**
  140595. * Gets the name of the current physics plugin
  140596. * @returns the name of the plugin
  140597. */
  140598. getPhysicsPluginName(): string;
  140599. /**
  140600. * Adding a new impostor for the impostor tracking.
  140601. * This will be done by the impostor itself.
  140602. * @param impostor the impostor to add
  140603. */
  140604. addImpostor(impostor: PhysicsImpostor): void;
  140605. /**
  140606. * Remove an impostor from the engine.
  140607. * This impostor and its mesh will not longer be updated by the physics engine.
  140608. * @param impostor the impostor to remove
  140609. */
  140610. removeImpostor(impostor: PhysicsImpostor): void;
  140611. /**
  140612. * Add a joint to the physics engine
  140613. * @param mainImpostor defines the main impostor to which the joint is added.
  140614. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  140615. * @param joint defines the joint that will connect both impostors.
  140616. */
  140617. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  140618. /**
  140619. * Removes a joint from the simulation
  140620. * @param mainImpostor defines the impostor used with the joint
  140621. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  140622. * @param joint defines the joint to remove
  140623. */
  140624. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  140625. /**
  140626. * Called by the scene. No need to call it.
  140627. * @param delta defines the timespam between frames
  140628. */
  140629. _step(delta: number): void;
  140630. /**
  140631. * Gets the current plugin used to run the simulation
  140632. * @returns current plugin
  140633. */
  140634. getPhysicsPlugin(): IPhysicsEnginePlugin;
  140635. /**
  140636. * Gets the list of physic impostors
  140637. * @returns an array of PhysicsImpostor
  140638. */
  140639. getImpostors(): Array<PhysicsImpostor>;
  140640. /**
  140641. * Gets the impostor for a physics enabled object
  140642. * @param object defines the object impersonated by the impostor
  140643. * @returns the PhysicsImpostor or null if not found
  140644. */
  140645. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  140646. /**
  140647. * Gets the impostor for a physics body object
  140648. * @param body defines physics body used by the impostor
  140649. * @returns the PhysicsImpostor or null if not found
  140650. */
  140651. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  140652. /**
  140653. * Does a raycast in the physics world
  140654. * @param from when should the ray start?
  140655. * @param to when should the ray end?
  140656. * @returns PhysicsRaycastResult
  140657. */
  140658. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  140659. }
  140660. }
  140661. declare module BABYLON {
  140662. /** @hidden */
  140663. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  140664. private _useDeltaForWorldStep;
  140665. world: any;
  140666. name: string;
  140667. private _physicsMaterials;
  140668. private _fixedTimeStep;
  140669. private _cannonRaycastResult;
  140670. private _raycastResult;
  140671. private _physicsBodysToRemoveAfterStep;
  140672. private _firstFrame;
  140673. BJSCANNON: any;
  140674. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  140675. setGravity(gravity: Vector3): void;
  140676. setTimeStep(timeStep: number): void;
  140677. getTimeStep(): number;
  140678. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  140679. private _removeMarkedPhysicsBodiesFromWorld;
  140680. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  140681. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  140682. generatePhysicsBody(impostor: PhysicsImpostor): void;
  140683. private _processChildMeshes;
  140684. removePhysicsBody(impostor: PhysicsImpostor): void;
  140685. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  140686. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  140687. private _addMaterial;
  140688. private _checkWithEpsilon;
  140689. private _createShape;
  140690. private _createHeightmap;
  140691. private _minus90X;
  140692. private _plus90X;
  140693. private _tmpPosition;
  140694. private _tmpDeltaPosition;
  140695. private _tmpUnityRotation;
  140696. private _updatePhysicsBodyTransformation;
  140697. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  140698. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  140699. isSupported(): boolean;
  140700. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  140701. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  140702. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  140703. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  140704. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  140705. getBodyMass(impostor: PhysicsImpostor): number;
  140706. getBodyFriction(impostor: PhysicsImpostor): number;
  140707. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  140708. getBodyRestitution(impostor: PhysicsImpostor): number;
  140709. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  140710. sleepBody(impostor: PhysicsImpostor): void;
  140711. wakeUpBody(impostor: PhysicsImpostor): void;
  140712. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  140713. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  140714. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  140715. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  140716. getRadius(impostor: PhysicsImpostor): number;
  140717. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  140718. dispose(): void;
  140719. private _extendNamespace;
  140720. /**
  140721. * Does a raycast in the physics world
  140722. * @param from when should the ray start?
  140723. * @param to when should the ray end?
  140724. * @returns PhysicsRaycastResult
  140725. */
  140726. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  140727. }
  140728. }
  140729. declare module BABYLON {
  140730. /** @hidden */
  140731. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  140732. private _useDeltaForWorldStep;
  140733. world: any;
  140734. name: string;
  140735. BJSOIMO: any;
  140736. private _raycastResult;
  140737. private _fixedTimeStep;
  140738. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, oimoInjection?: any);
  140739. setGravity(gravity: Vector3): void;
  140740. setTimeStep(timeStep: number): void;
  140741. getTimeStep(): number;
  140742. private _tmpImpostorsArray;
  140743. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  140744. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  140745. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  140746. generatePhysicsBody(impostor: PhysicsImpostor): void;
  140747. private _tmpPositionVector;
  140748. removePhysicsBody(impostor: PhysicsImpostor): void;
  140749. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  140750. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  140751. isSupported(): boolean;
  140752. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  140753. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  140754. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  140755. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  140756. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  140757. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  140758. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  140759. getBodyMass(impostor: PhysicsImpostor): number;
  140760. getBodyFriction(impostor: PhysicsImpostor): number;
  140761. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  140762. getBodyRestitution(impostor: PhysicsImpostor): number;
  140763. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  140764. sleepBody(impostor: PhysicsImpostor): void;
  140765. wakeUpBody(impostor: PhysicsImpostor): void;
  140766. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  140767. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  140768. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  140769. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  140770. getRadius(impostor: PhysicsImpostor): number;
  140771. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  140772. dispose(): void;
  140773. /**
  140774. * Does a raycast in the physics world
  140775. * @param from when should the ray start?
  140776. * @param to when should the ray end?
  140777. * @returns PhysicsRaycastResult
  140778. */
  140779. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  140780. }
  140781. }
  140782. declare module BABYLON {
  140783. /**
  140784. * AmmoJS Physics plugin
  140785. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  140786. * @see https://github.com/kripken/ammo.js/
  140787. */
  140788. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  140789. private _useDeltaForWorldStep;
  140790. /**
  140791. * Reference to the Ammo library
  140792. */
  140793. bjsAMMO: any;
  140794. /**
  140795. * Created ammoJS world which physics bodies are added to
  140796. */
  140797. world: any;
  140798. /**
  140799. * Name of the plugin
  140800. */
  140801. name: string;
  140802. private _timeStep;
  140803. private _fixedTimeStep;
  140804. private _maxSteps;
  140805. private _tmpQuaternion;
  140806. private _tmpAmmoTransform;
  140807. private _tmpAmmoQuaternion;
  140808. private _tmpAmmoConcreteContactResultCallback;
  140809. private _collisionConfiguration;
  140810. private _dispatcher;
  140811. private _overlappingPairCache;
  140812. private _solver;
  140813. private _softBodySolver;
  140814. private _tmpAmmoVectorA;
  140815. private _tmpAmmoVectorB;
  140816. private _tmpAmmoVectorC;
  140817. private _tmpAmmoVectorD;
  140818. private _tmpContactCallbackResult;
  140819. private _tmpAmmoVectorRCA;
  140820. private _tmpAmmoVectorRCB;
  140821. private _raycastResult;
  140822. private static readonly DISABLE_COLLISION_FLAG;
  140823. private static readonly KINEMATIC_FLAG;
  140824. private static readonly DISABLE_DEACTIVATION_FLAG;
  140825. /**
  140826. * Initializes the ammoJS plugin
  140827. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  140828. * @param ammoInjection can be used to inject your own ammo reference
  140829. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  140830. */
  140831. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  140832. /**
  140833. * Sets the gravity of the physics world (m/(s^2))
  140834. * @param gravity Gravity to set
  140835. */
  140836. setGravity(gravity: Vector3): void;
  140837. /**
  140838. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  140839. * @param timeStep timestep to use in seconds
  140840. */
  140841. setTimeStep(timeStep: number): void;
  140842. /**
  140843. * 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)
  140844. * @param fixedTimeStep fixedTimeStep to use in seconds
  140845. */
  140846. setFixedTimeStep(fixedTimeStep: number): void;
  140847. /**
  140848. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  140849. * @param maxSteps the maximum number of steps by the physics engine per frame
  140850. */
  140851. setMaxSteps(maxSteps: number): void;
  140852. /**
  140853. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  140854. * @returns the current timestep in seconds
  140855. */
  140856. getTimeStep(): number;
  140857. /**
  140858. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  140859. */
  140860. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  140861. private _isImpostorInContact;
  140862. private _isImpostorPairInContact;
  140863. private _stepSimulation;
  140864. /**
  140865. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  140866. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  140867. * After the step the babylon meshes are set to the position of the physics imposters
  140868. * @param delta amount of time to step forward
  140869. * @param impostors array of imposters to update before/after the step
  140870. */
  140871. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  140872. /**
  140873. * Update babylon mesh to match physics world object
  140874. * @param impostor imposter to match
  140875. */
  140876. private _afterSoftStep;
  140877. /**
  140878. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  140879. * @param impostor imposter to match
  140880. */
  140881. private _ropeStep;
  140882. /**
  140883. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  140884. * @param impostor imposter to match
  140885. */
  140886. private _softbodyOrClothStep;
  140887. private _tmpMatrix;
  140888. /**
  140889. * Applies an impulse on the imposter
  140890. * @param impostor imposter to apply impulse to
  140891. * @param force amount of force to be applied to the imposter
  140892. * @param contactPoint the location to apply the impulse on the imposter
  140893. */
  140894. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  140895. /**
  140896. * Applies a force on the imposter
  140897. * @param impostor imposter to apply force
  140898. * @param force amount of force to be applied to the imposter
  140899. * @param contactPoint the location to apply the force on the imposter
  140900. */
  140901. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  140902. /**
  140903. * Creates a physics body using the plugin
  140904. * @param impostor the imposter to create the physics body on
  140905. */
  140906. generatePhysicsBody(impostor: PhysicsImpostor): void;
  140907. /**
  140908. * Removes the physics body from the imposter and disposes of the body's memory
  140909. * @param impostor imposter to remove the physics body from
  140910. */
  140911. removePhysicsBody(impostor: PhysicsImpostor): void;
  140912. /**
  140913. * Generates a joint
  140914. * @param impostorJoint the imposter joint to create the joint with
  140915. */
  140916. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  140917. /**
  140918. * Removes a joint
  140919. * @param impostorJoint the imposter joint to remove the joint from
  140920. */
  140921. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  140922. private _addMeshVerts;
  140923. /**
  140924. * Initialise the soft body vertices to match its object's (mesh) vertices
  140925. * Softbody vertices (nodes) are in world space and to match this
  140926. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  140927. * @param impostor to create the softbody for
  140928. */
  140929. private _softVertexData;
  140930. /**
  140931. * Create an impostor's soft body
  140932. * @param impostor to create the softbody for
  140933. */
  140934. private _createSoftbody;
  140935. /**
  140936. * Create cloth for an impostor
  140937. * @param impostor to create the softbody for
  140938. */
  140939. private _createCloth;
  140940. /**
  140941. * Create rope for an impostor
  140942. * @param impostor to create the softbody for
  140943. */
  140944. private _createRope;
  140945. /**
  140946. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  140947. * @param impostor to create the custom physics shape for
  140948. */
  140949. private _createCustom;
  140950. private _addHullVerts;
  140951. private _createShape;
  140952. /**
  140953. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  140954. * @param impostor imposter containing the physics body and babylon object
  140955. */
  140956. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  140957. /**
  140958. * Sets the babylon object's position/rotation from the physics body's position/rotation
  140959. * @param impostor imposter containing the physics body and babylon object
  140960. * @param newPosition new position
  140961. * @param newRotation new rotation
  140962. */
  140963. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  140964. /**
  140965. * If this plugin is supported
  140966. * @returns true if its supported
  140967. */
  140968. isSupported(): boolean;
  140969. /**
  140970. * Sets the linear velocity of the physics body
  140971. * @param impostor imposter to set the velocity on
  140972. * @param velocity velocity to set
  140973. */
  140974. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  140975. /**
  140976. * Sets the angular velocity of the physics body
  140977. * @param impostor imposter to set the velocity on
  140978. * @param velocity velocity to set
  140979. */
  140980. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  140981. /**
  140982. * gets the linear velocity
  140983. * @param impostor imposter to get linear velocity from
  140984. * @returns linear velocity
  140985. */
  140986. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  140987. /**
  140988. * gets the angular velocity
  140989. * @param impostor imposter to get angular velocity from
  140990. * @returns angular velocity
  140991. */
  140992. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  140993. /**
  140994. * Sets the mass of physics body
  140995. * @param impostor imposter to set the mass on
  140996. * @param mass mass to set
  140997. */
  140998. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  140999. /**
  141000. * Gets the mass of the physics body
  141001. * @param impostor imposter to get the mass from
  141002. * @returns mass
  141003. */
  141004. getBodyMass(impostor: PhysicsImpostor): number;
  141005. /**
  141006. * Gets friction of the impostor
  141007. * @param impostor impostor to get friction from
  141008. * @returns friction value
  141009. */
  141010. getBodyFriction(impostor: PhysicsImpostor): number;
  141011. /**
  141012. * Sets friction of the impostor
  141013. * @param impostor impostor to set friction on
  141014. * @param friction friction value
  141015. */
  141016. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  141017. /**
  141018. * Gets restitution of the impostor
  141019. * @param impostor impostor to get restitution from
  141020. * @returns restitution value
  141021. */
  141022. getBodyRestitution(impostor: PhysicsImpostor): number;
  141023. /**
  141024. * Sets resitution of the impostor
  141025. * @param impostor impostor to set resitution on
  141026. * @param restitution resitution value
  141027. */
  141028. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  141029. /**
  141030. * Gets pressure inside the impostor
  141031. * @param impostor impostor to get pressure from
  141032. * @returns pressure value
  141033. */
  141034. getBodyPressure(impostor: PhysicsImpostor): number;
  141035. /**
  141036. * Sets pressure inside a soft body impostor
  141037. * Cloth and rope must remain 0 pressure
  141038. * @param impostor impostor to set pressure on
  141039. * @param pressure pressure value
  141040. */
  141041. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  141042. /**
  141043. * Gets stiffness of the impostor
  141044. * @param impostor impostor to get stiffness from
  141045. * @returns pressure value
  141046. */
  141047. getBodyStiffness(impostor: PhysicsImpostor): number;
  141048. /**
  141049. * Sets stiffness of the impostor
  141050. * @param impostor impostor to set stiffness on
  141051. * @param stiffness stiffness value from 0 to 1
  141052. */
  141053. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  141054. /**
  141055. * Gets velocityIterations of the impostor
  141056. * @param impostor impostor to get velocity iterations from
  141057. * @returns velocityIterations value
  141058. */
  141059. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  141060. /**
  141061. * Sets velocityIterations of the impostor
  141062. * @param impostor impostor to set velocity iterations on
  141063. * @param velocityIterations velocityIterations value
  141064. */
  141065. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  141066. /**
  141067. * Gets positionIterations of the impostor
  141068. * @param impostor impostor to get position iterations from
  141069. * @returns positionIterations value
  141070. */
  141071. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  141072. /**
  141073. * Sets positionIterations of the impostor
  141074. * @param impostor impostor to set position on
  141075. * @param positionIterations positionIterations value
  141076. */
  141077. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  141078. /**
  141079. * Append an anchor to a cloth object
  141080. * @param impostor is the cloth impostor to add anchor to
  141081. * @param otherImpostor is the rigid impostor to anchor to
  141082. * @param width ratio across width from 0 to 1
  141083. * @param height ratio up height from 0 to 1
  141084. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  141085. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  141086. */
  141087. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  141088. /**
  141089. * Append an hook to a rope object
  141090. * @param impostor is the rope impostor to add hook to
  141091. * @param otherImpostor is the rigid impostor to hook to
  141092. * @param length ratio along the rope from 0 to 1
  141093. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  141094. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  141095. */
  141096. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  141097. /**
  141098. * Sleeps the physics body and stops it from being active
  141099. * @param impostor impostor to sleep
  141100. */
  141101. sleepBody(impostor: PhysicsImpostor): void;
  141102. /**
  141103. * Activates the physics body
  141104. * @param impostor impostor to activate
  141105. */
  141106. wakeUpBody(impostor: PhysicsImpostor): void;
  141107. /**
  141108. * Updates the distance parameters of the joint
  141109. * @param joint joint to update
  141110. * @param maxDistance maximum distance of the joint
  141111. * @param minDistance minimum distance of the joint
  141112. */
  141113. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  141114. /**
  141115. * Sets a motor on the joint
  141116. * @param joint joint to set motor on
  141117. * @param speed speed of the motor
  141118. * @param maxForce maximum force of the motor
  141119. * @param motorIndex index of the motor
  141120. */
  141121. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  141122. /**
  141123. * Sets the motors limit
  141124. * @param joint joint to set limit on
  141125. * @param upperLimit upper limit
  141126. * @param lowerLimit lower limit
  141127. */
  141128. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  141129. /**
  141130. * Syncs the position and rotation of a mesh with the impostor
  141131. * @param mesh mesh to sync
  141132. * @param impostor impostor to update the mesh with
  141133. */
  141134. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  141135. /**
  141136. * Gets the radius of the impostor
  141137. * @param impostor impostor to get radius from
  141138. * @returns the radius
  141139. */
  141140. getRadius(impostor: PhysicsImpostor): number;
  141141. /**
  141142. * Gets the box size of the impostor
  141143. * @param impostor impostor to get box size from
  141144. * @param result the resulting box size
  141145. */
  141146. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  141147. /**
  141148. * Disposes of the impostor
  141149. */
  141150. dispose(): void;
  141151. /**
  141152. * Does a raycast in the physics world
  141153. * @param from when should the ray start?
  141154. * @param to when should the ray end?
  141155. * @returns PhysicsRaycastResult
  141156. */
  141157. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  141158. }
  141159. }
  141160. declare module BABYLON {
  141161. interface AbstractScene {
  141162. /**
  141163. * The list of reflection probes added to the scene
  141164. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  141165. */
  141166. reflectionProbes: Array<ReflectionProbe>;
  141167. /**
  141168. * Removes the given reflection probe from this scene.
  141169. * @param toRemove The reflection probe to remove
  141170. * @returns The index of the removed reflection probe
  141171. */
  141172. removeReflectionProbe(toRemove: ReflectionProbe): number;
  141173. /**
  141174. * Adds the given reflection probe to this scene.
  141175. * @param newReflectionProbe The reflection probe to add
  141176. */
  141177. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  141178. }
  141179. /**
  141180. * Class used to generate realtime reflection / refraction cube textures
  141181. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  141182. */
  141183. export class ReflectionProbe {
  141184. /** defines the name of the probe */
  141185. name: string;
  141186. private _scene;
  141187. private _renderTargetTexture;
  141188. private _projectionMatrix;
  141189. private _viewMatrix;
  141190. private _target;
  141191. private _add;
  141192. private _attachedMesh;
  141193. private _invertYAxis;
  141194. /** Gets or sets probe position (center of the cube map) */
  141195. position: Vector3;
  141196. /**
  141197. * Creates a new reflection probe
  141198. * @param name defines the name of the probe
  141199. * @param size defines the texture resolution (for each face)
  141200. * @param scene defines the hosting scene
  141201. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  141202. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  141203. */
  141204. constructor(
  141205. /** defines the name of the probe */
  141206. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  141207. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  141208. get samples(): number;
  141209. set samples(value: number);
  141210. /** Gets or sets the refresh rate to use (on every frame by default) */
  141211. get refreshRate(): number;
  141212. set refreshRate(value: number);
  141213. /**
  141214. * Gets the hosting scene
  141215. * @returns a Scene
  141216. */
  141217. getScene(): Scene;
  141218. /** Gets the internal CubeTexture used to render to */
  141219. get cubeTexture(): RenderTargetTexture;
  141220. /** Gets the list of meshes to render */
  141221. get renderList(): Nullable<AbstractMesh[]>;
  141222. /**
  141223. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  141224. * @param mesh defines the mesh to attach to
  141225. */
  141226. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  141227. /**
  141228. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  141229. * @param renderingGroupId The rendering group id corresponding to its index
  141230. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  141231. */
  141232. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  141233. /**
  141234. * Clean all associated resources
  141235. */
  141236. dispose(): void;
  141237. /**
  141238. * Converts the reflection probe information to a readable string for debug purpose.
  141239. * @param fullDetails Supports for multiple levels of logging within scene loading
  141240. * @returns the human readable reflection probe info
  141241. */
  141242. toString(fullDetails?: boolean): string;
  141243. /**
  141244. * Get the class name of the relfection probe.
  141245. * @returns "ReflectionProbe"
  141246. */
  141247. getClassName(): string;
  141248. /**
  141249. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  141250. * @returns The JSON representation of the texture
  141251. */
  141252. serialize(): any;
  141253. /**
  141254. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  141255. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  141256. * @param scene Define the scene the parsed reflection probe should be instantiated in
  141257. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  141258. * @returns The parsed reflection probe if successful
  141259. */
  141260. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  141261. }
  141262. }
  141263. declare module BABYLON {
  141264. /** @hidden */
  141265. export var _BabylonLoaderRegistered: boolean;
  141266. /**
  141267. * Helps setting up some configuration for the babylon file loader.
  141268. */
  141269. export class BabylonFileLoaderConfiguration {
  141270. /**
  141271. * The loader does not allow injecting custom physix engine into the plugins.
  141272. * Unfortunately in ES6, we need to manually inject them into the plugin.
  141273. * So you could set this variable to your engine import to make it work.
  141274. */
  141275. static LoaderInjectedPhysicsEngine: any;
  141276. }
  141277. }
  141278. declare module BABYLON {
  141279. /**
  141280. * The Physically based simple base material of BJS.
  141281. *
  141282. * This enables better naming and convention enforcements on top of the pbrMaterial.
  141283. * It is used as the base class for both the specGloss and metalRough conventions.
  141284. */
  141285. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  141286. /**
  141287. * Number of Simultaneous lights allowed on the material.
  141288. */
  141289. maxSimultaneousLights: number;
  141290. /**
  141291. * If sets to true, disables all the lights affecting the material.
  141292. */
  141293. disableLighting: boolean;
  141294. /**
  141295. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  141296. */
  141297. environmentTexture: BaseTexture;
  141298. /**
  141299. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  141300. */
  141301. invertNormalMapX: boolean;
  141302. /**
  141303. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  141304. */
  141305. invertNormalMapY: boolean;
  141306. /**
  141307. * Normal map used in the model.
  141308. */
  141309. normalTexture: BaseTexture;
  141310. /**
  141311. * Emissivie color used to self-illuminate the model.
  141312. */
  141313. emissiveColor: Color3;
  141314. /**
  141315. * Emissivie texture used to self-illuminate the model.
  141316. */
  141317. emissiveTexture: BaseTexture;
  141318. /**
  141319. * Occlusion Channel Strenght.
  141320. */
  141321. occlusionStrength: number;
  141322. /**
  141323. * Occlusion Texture of the material (adding extra occlusion effects).
  141324. */
  141325. occlusionTexture: BaseTexture;
  141326. /**
  141327. * Defines the alpha limits in alpha test mode.
  141328. */
  141329. alphaCutOff: number;
  141330. /**
  141331. * Gets the current double sided mode.
  141332. */
  141333. get doubleSided(): boolean;
  141334. /**
  141335. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  141336. */
  141337. set doubleSided(value: boolean);
  141338. /**
  141339. * Stores the pre-calculated light information of a mesh in a texture.
  141340. */
  141341. lightmapTexture: BaseTexture;
  141342. /**
  141343. * If true, the light map contains occlusion information instead of lighting info.
  141344. */
  141345. useLightmapAsShadowmap: boolean;
  141346. /**
  141347. * Instantiates a new PBRMaterial instance.
  141348. *
  141349. * @param name The material name
  141350. * @param scene The scene the material will be use in.
  141351. */
  141352. constructor(name: string, scene: Scene);
  141353. getClassName(): string;
  141354. }
  141355. }
  141356. declare module BABYLON {
  141357. /**
  141358. * The PBR material of BJS following the metal roughness convention.
  141359. *
  141360. * This fits to the PBR convention in the GLTF definition:
  141361. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  141362. */
  141363. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  141364. /**
  141365. * The base color has two different interpretations depending on the value of metalness.
  141366. * When the material is a metal, the base color is the specific measured reflectance value
  141367. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  141368. * of the material.
  141369. */
  141370. baseColor: Color3;
  141371. /**
  141372. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  141373. * well as opacity information in the alpha channel.
  141374. */
  141375. baseTexture: BaseTexture;
  141376. /**
  141377. * Specifies the metallic scalar value of the material.
  141378. * Can also be used to scale the metalness values of the metallic texture.
  141379. */
  141380. metallic: number;
  141381. /**
  141382. * Specifies the roughness scalar value of the material.
  141383. * Can also be used to scale the roughness values of the metallic texture.
  141384. */
  141385. roughness: number;
  141386. /**
  141387. * Texture containing both the metallic value in the B channel and the
  141388. * roughness value in the G channel to keep better precision.
  141389. */
  141390. metallicRoughnessTexture: BaseTexture;
  141391. /**
  141392. * Instantiates a new PBRMetalRoughnessMaterial instance.
  141393. *
  141394. * @param name The material name
  141395. * @param scene The scene the material will be use in.
  141396. */
  141397. constructor(name: string, scene: Scene);
  141398. /**
  141399. * Return the currrent class name of the material.
  141400. */
  141401. getClassName(): string;
  141402. /**
  141403. * Makes a duplicate of the current material.
  141404. * @param name - name to use for the new material.
  141405. */
  141406. clone(name: string): PBRMetallicRoughnessMaterial;
  141407. /**
  141408. * Serialize the material to a parsable JSON object.
  141409. */
  141410. serialize(): any;
  141411. /**
  141412. * Parses a JSON object correponding to the serialize function.
  141413. */
  141414. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  141415. }
  141416. }
  141417. declare module BABYLON {
  141418. /**
  141419. * The PBR material of BJS following the specular glossiness convention.
  141420. *
  141421. * This fits to the PBR convention in the GLTF definition:
  141422. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  141423. */
  141424. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  141425. /**
  141426. * Specifies the diffuse color of the material.
  141427. */
  141428. diffuseColor: Color3;
  141429. /**
  141430. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  141431. * channel.
  141432. */
  141433. diffuseTexture: BaseTexture;
  141434. /**
  141435. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  141436. */
  141437. specularColor: Color3;
  141438. /**
  141439. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  141440. */
  141441. glossiness: number;
  141442. /**
  141443. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  141444. */
  141445. specularGlossinessTexture: BaseTexture;
  141446. /**
  141447. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  141448. *
  141449. * @param name The material name
  141450. * @param scene The scene the material will be use in.
  141451. */
  141452. constructor(name: string, scene: Scene);
  141453. /**
  141454. * Return the currrent class name of the material.
  141455. */
  141456. getClassName(): string;
  141457. /**
  141458. * Makes a duplicate of the current material.
  141459. * @param name - name to use for the new material.
  141460. */
  141461. clone(name: string): PBRSpecularGlossinessMaterial;
  141462. /**
  141463. * Serialize the material to a parsable JSON object.
  141464. */
  141465. serialize(): any;
  141466. /**
  141467. * Parses a JSON object correponding to the serialize function.
  141468. */
  141469. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  141470. }
  141471. }
  141472. declare module BABYLON {
  141473. /**
  141474. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  141475. * It can help converting any input color in a desired output one. This can then be used to create effects
  141476. * from sepia, black and white to sixties or futuristic rendering...
  141477. *
  141478. * The only supported format is currently 3dl.
  141479. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  141480. */
  141481. export class ColorGradingTexture extends BaseTexture {
  141482. /**
  141483. * The texture URL.
  141484. */
  141485. url: string;
  141486. /**
  141487. * Empty line regex stored for GC.
  141488. */
  141489. private static _noneEmptyLineRegex;
  141490. private _textureMatrix;
  141491. private _onLoad;
  141492. /**
  141493. * Instantiates a ColorGradingTexture from the following parameters.
  141494. *
  141495. * @param url The location of the color gradind data (currently only supporting 3dl)
  141496. * @param sceneOrEngine The scene or engine the texture will be used in
  141497. * @param onLoad defines a callback triggered when the texture has been loaded
  141498. */
  141499. constructor(url: string, sceneOrEngine: Scene | ThinEngine, onLoad?: Nullable<() => void>);
  141500. /**
  141501. * Fires the onload event from the constructor if requested.
  141502. */
  141503. private _triggerOnLoad;
  141504. /**
  141505. * Returns the texture matrix used in most of the material.
  141506. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  141507. */
  141508. getTextureMatrix(): Matrix;
  141509. /**
  141510. * Occurs when the file being loaded is a .3dl LUT file.
  141511. */
  141512. private load3dlTexture;
  141513. /**
  141514. * Starts the loading process of the texture.
  141515. */
  141516. private loadTexture;
  141517. /**
  141518. * Clones the color gradind texture.
  141519. */
  141520. clone(): ColorGradingTexture;
  141521. /**
  141522. * Called during delayed load for textures.
  141523. */
  141524. delayLoad(): void;
  141525. /**
  141526. * Parses a color grading texture serialized by Babylon.
  141527. * @param parsedTexture The texture information being parsedTexture
  141528. * @param scene The scene to load the texture in
  141529. * @param rootUrl The root url of the data assets to load
  141530. * @return A color gradind texture
  141531. */
  141532. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  141533. /**
  141534. * Serializes the LUT texture to json format.
  141535. */
  141536. serialize(): any;
  141537. }
  141538. }
  141539. declare module BABYLON {
  141540. /**
  141541. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  141542. */
  141543. export class EquiRectangularCubeTexture extends BaseTexture {
  141544. /** The six faces of the cube. */
  141545. private static _FacesMapping;
  141546. private _noMipmap;
  141547. private _onLoad;
  141548. private _onError;
  141549. /** The size of the cubemap. */
  141550. private _size;
  141551. /** The buffer of the image. */
  141552. private _buffer;
  141553. /** The width of the input image. */
  141554. private _width;
  141555. /** The height of the input image. */
  141556. private _height;
  141557. /** The URL to the image. */
  141558. url: string;
  141559. /**
  141560. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  141561. * @param url The location of the image
  141562. * @param scene The scene the texture will be used in
  141563. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  141564. * @param noMipmap Forces to not generate the mipmap if true
  141565. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  141566. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  141567. * @param onLoad — defines a callback called when texture is loaded
  141568. * @param onError — defines a callback called if there is an error
  141569. */
  141570. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  141571. /**
  141572. * Load the image data, by putting the image on a canvas and extracting its buffer.
  141573. */
  141574. private loadImage;
  141575. /**
  141576. * Convert the image buffer into a cubemap and create a CubeTexture.
  141577. */
  141578. private loadTexture;
  141579. /**
  141580. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  141581. * @param buffer The ArrayBuffer that should be converted.
  141582. * @returns The buffer as Float32Array.
  141583. */
  141584. private getFloat32ArrayFromArrayBuffer;
  141585. /**
  141586. * Get the current class name of the texture useful for serialization or dynamic coding.
  141587. * @returns "EquiRectangularCubeTexture"
  141588. */
  141589. getClassName(): string;
  141590. /**
  141591. * Create a clone of the current EquiRectangularCubeTexture and return it.
  141592. * @returns A clone of the current EquiRectangularCubeTexture.
  141593. */
  141594. clone(): EquiRectangularCubeTexture;
  141595. }
  141596. }
  141597. declare module BABYLON {
  141598. /**
  141599. * Defines the options related to the creation of an HtmlElementTexture
  141600. */
  141601. export interface IHtmlElementTextureOptions {
  141602. /**
  141603. * Defines wether mip maps should be created or not.
  141604. */
  141605. generateMipMaps?: boolean;
  141606. /**
  141607. * Defines the sampling mode of the texture.
  141608. */
  141609. samplingMode?: number;
  141610. /**
  141611. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  141612. */
  141613. engine: Nullable<ThinEngine>;
  141614. /**
  141615. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  141616. */
  141617. scene: Nullable<Scene>;
  141618. }
  141619. /**
  141620. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  141621. * To be as efficient as possible depending on your constraints nothing aside the first upload
  141622. * is automatically managed.
  141623. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  141624. * in your application.
  141625. *
  141626. * As the update is not automatic, you need to call them manually.
  141627. */
  141628. export class HtmlElementTexture extends BaseTexture {
  141629. /**
  141630. * The texture URL.
  141631. */
  141632. element: HTMLVideoElement | HTMLCanvasElement;
  141633. private static readonly DefaultOptions;
  141634. private _textureMatrix;
  141635. private _isVideo;
  141636. private _generateMipMaps;
  141637. private _samplingMode;
  141638. /**
  141639. * Instantiates a HtmlElementTexture from the following parameters.
  141640. *
  141641. * @param name Defines the name of the texture
  141642. * @param element Defines the video or canvas the texture is filled with
  141643. * @param options Defines the other none mandatory texture creation options
  141644. */
  141645. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  141646. private _createInternalTexture;
  141647. /**
  141648. * Returns the texture matrix used in most of the material.
  141649. */
  141650. getTextureMatrix(): Matrix;
  141651. /**
  141652. * Updates the content of the texture.
  141653. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  141654. */
  141655. update(invertY?: Nullable<boolean>): void;
  141656. }
  141657. }
  141658. declare module BABYLON {
  141659. /**
  141660. * Based on jsTGALoader - Javascript loader for TGA file
  141661. * By Vincent Thibault
  141662. * @see http://blog.robrowser.com/javascript-tga-loader.html
  141663. */
  141664. export class TGATools {
  141665. private static _TYPE_INDEXED;
  141666. private static _TYPE_RGB;
  141667. private static _TYPE_GREY;
  141668. private static _TYPE_RLE_INDEXED;
  141669. private static _TYPE_RLE_RGB;
  141670. private static _TYPE_RLE_GREY;
  141671. private static _ORIGIN_MASK;
  141672. private static _ORIGIN_SHIFT;
  141673. private static _ORIGIN_BL;
  141674. private static _ORIGIN_BR;
  141675. private static _ORIGIN_UL;
  141676. private static _ORIGIN_UR;
  141677. /**
  141678. * Gets the header of a TGA file
  141679. * @param data defines the TGA data
  141680. * @returns the header
  141681. */
  141682. static GetTGAHeader(data: Uint8Array): any;
  141683. /**
  141684. * Uploads TGA content to a Babylon Texture
  141685. * @hidden
  141686. */
  141687. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  141688. /** @hidden */
  141689. 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;
  141690. /** @hidden */
  141691. 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;
  141692. /** @hidden */
  141693. 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;
  141694. /** @hidden */
  141695. 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;
  141696. /** @hidden */
  141697. 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;
  141698. /** @hidden */
  141699. 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;
  141700. }
  141701. }
  141702. declare module BABYLON {
  141703. /**
  141704. * Implementation of the TGA Texture Loader.
  141705. * @hidden
  141706. */
  141707. export class _TGATextureLoader implements IInternalTextureLoader {
  141708. /**
  141709. * Defines wether the loader supports cascade loading the different faces.
  141710. */
  141711. readonly supportCascades: boolean;
  141712. /**
  141713. * This returns if the loader support the current file information.
  141714. * @param extension defines the file extension of the file being loaded
  141715. * @returns true if the loader can load the specified file
  141716. */
  141717. canLoad(extension: string): boolean;
  141718. /**
  141719. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  141720. * @param data contains the texture data
  141721. * @param texture defines the BabylonJS internal texture
  141722. * @param createPolynomials will be true if polynomials have been requested
  141723. * @param onLoad defines the callback to trigger once the texture is ready
  141724. * @param onError defines the callback to trigger in case of error
  141725. */
  141726. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  141727. /**
  141728. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  141729. * @param data contains the texture data
  141730. * @param texture defines the BabylonJS internal texture
  141731. * @param callback defines the method to call once ready to upload
  141732. */
  141733. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  141734. }
  141735. }
  141736. declare module BABYLON {
  141737. /**
  141738. * Info about the .basis files
  141739. */
  141740. class BasisFileInfo {
  141741. /**
  141742. * If the file has alpha
  141743. */
  141744. hasAlpha: boolean;
  141745. /**
  141746. * Info about each image of the basis file
  141747. */
  141748. images: Array<{
  141749. levels: Array<{
  141750. width: number;
  141751. height: number;
  141752. transcodedPixels: ArrayBufferView;
  141753. }>;
  141754. }>;
  141755. }
  141756. /**
  141757. * Result of transcoding a basis file
  141758. */
  141759. class TranscodeResult {
  141760. /**
  141761. * Info about the .basis file
  141762. */
  141763. fileInfo: BasisFileInfo;
  141764. /**
  141765. * Format to use when loading the file
  141766. */
  141767. format: number;
  141768. }
  141769. /**
  141770. * Configuration options for the Basis transcoder
  141771. */
  141772. export class BasisTranscodeConfiguration {
  141773. /**
  141774. * Supported compression formats used to determine the supported output format of the transcoder
  141775. */
  141776. supportedCompressionFormats?: {
  141777. /**
  141778. * etc1 compression format
  141779. */
  141780. etc1?: boolean;
  141781. /**
  141782. * s3tc compression format
  141783. */
  141784. s3tc?: boolean;
  141785. /**
  141786. * pvrtc compression format
  141787. */
  141788. pvrtc?: boolean;
  141789. /**
  141790. * etc2 compression format
  141791. */
  141792. etc2?: boolean;
  141793. };
  141794. /**
  141795. * If mipmap levels should be loaded for transcoded images (Default: true)
  141796. */
  141797. loadMipmapLevels?: boolean;
  141798. /**
  141799. * Index of a single image to load (Default: all images)
  141800. */
  141801. loadSingleImage?: number;
  141802. }
  141803. /**
  141804. * Used to load .Basis files
  141805. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  141806. */
  141807. export class BasisTools {
  141808. private static _IgnoreSupportedFormats;
  141809. /**
  141810. * URL to use when loading the basis transcoder
  141811. */
  141812. static JSModuleURL: string;
  141813. /**
  141814. * URL to use when loading the wasm module for the transcoder
  141815. */
  141816. static WasmModuleURL: string;
  141817. /**
  141818. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  141819. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  141820. * @returns internal format corresponding to the Basis format
  141821. */
  141822. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  141823. private static _WorkerPromise;
  141824. private static _Worker;
  141825. private static _actionId;
  141826. private static _CreateWorkerAsync;
  141827. /**
  141828. * Transcodes a loaded image file to compressed pixel data
  141829. * @param data image data to transcode
  141830. * @param config configuration options for the transcoding
  141831. * @returns a promise resulting in the transcoded image
  141832. */
  141833. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  141834. /**
  141835. * Loads a texture from the transcode result
  141836. * @param texture texture load to
  141837. * @param transcodeResult the result of transcoding the basis file to load from
  141838. */
  141839. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  141840. }
  141841. }
  141842. declare module BABYLON {
  141843. /**
  141844. * Loader for .basis file format
  141845. */
  141846. export class _BasisTextureLoader implements IInternalTextureLoader {
  141847. /**
  141848. * Defines whether the loader supports cascade loading the different faces.
  141849. */
  141850. readonly supportCascades: boolean;
  141851. /**
  141852. * This returns if the loader support the current file information.
  141853. * @param extension defines the file extension of the file being loaded
  141854. * @returns true if the loader can load the specified file
  141855. */
  141856. canLoad(extension: string): boolean;
  141857. /**
  141858. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  141859. * @param data contains the texture data
  141860. * @param texture defines the BabylonJS internal texture
  141861. * @param createPolynomials will be true if polynomials have been requested
  141862. * @param onLoad defines the callback to trigger once the texture is ready
  141863. * @param onError defines the callback to trigger in case of error
  141864. */
  141865. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  141866. /**
  141867. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  141868. * @param data contains the texture data
  141869. * @param texture defines the BabylonJS internal texture
  141870. * @param callback defines the method to call once ready to upload
  141871. */
  141872. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  141873. }
  141874. }
  141875. declare module BABYLON {
  141876. /**
  141877. * Defines the basic options interface of a TexturePacker Frame
  141878. */
  141879. export interface ITexturePackerFrame {
  141880. /**
  141881. * The frame ID
  141882. */
  141883. id: number;
  141884. /**
  141885. * The frames Scale
  141886. */
  141887. scale: Vector2;
  141888. /**
  141889. * The Frames offset
  141890. */
  141891. offset: Vector2;
  141892. }
  141893. /**
  141894. * This is a support class for frame Data on texture packer sets.
  141895. */
  141896. export class TexturePackerFrame implements ITexturePackerFrame {
  141897. /**
  141898. * The frame ID
  141899. */
  141900. id: number;
  141901. /**
  141902. * The frames Scale
  141903. */
  141904. scale: Vector2;
  141905. /**
  141906. * The Frames offset
  141907. */
  141908. offset: Vector2;
  141909. /**
  141910. * Initializes a texture package frame.
  141911. * @param id The numerical frame identifier
  141912. * @param scale Scalar Vector2 for UV frame
  141913. * @param offset Vector2 for the frame position in UV units.
  141914. * @returns TexturePackerFrame
  141915. */
  141916. constructor(id: number, scale: Vector2, offset: Vector2);
  141917. }
  141918. }
  141919. declare module BABYLON {
  141920. /**
  141921. * Defines the basic options interface of a TexturePacker
  141922. */
  141923. export interface ITexturePackerOptions {
  141924. /**
  141925. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  141926. */
  141927. map?: string[];
  141928. /**
  141929. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  141930. */
  141931. uvsIn?: string;
  141932. /**
  141933. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  141934. */
  141935. uvsOut?: string;
  141936. /**
  141937. * number representing the layout style. Defaults to LAYOUT_STRIP
  141938. */
  141939. layout?: number;
  141940. /**
  141941. * number of columns if using custom column count layout(2). This defaults to 4.
  141942. */
  141943. colnum?: number;
  141944. /**
  141945. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  141946. */
  141947. updateInputMeshes?: boolean;
  141948. /**
  141949. * boolean flag to dispose all the source textures. Defaults to true.
  141950. */
  141951. disposeSources?: boolean;
  141952. /**
  141953. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  141954. */
  141955. fillBlanks?: boolean;
  141956. /**
  141957. * string value representing the context fill style color. Defaults to 'black'.
  141958. */
  141959. customFillColor?: string;
  141960. /**
  141961. * Width and Height Value of each Frame in the TexturePacker Sets
  141962. */
  141963. frameSize?: number;
  141964. /**
  141965. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  141966. */
  141967. paddingRatio?: number;
  141968. /**
  141969. * Number that declares the fill method for the padding gutter.
  141970. */
  141971. paddingMode?: number;
  141972. /**
  141973. * If in SUBUV_COLOR padding mode what color to use.
  141974. */
  141975. paddingColor?: Color3 | Color4;
  141976. }
  141977. /**
  141978. * Defines the basic interface of a TexturePacker JSON File
  141979. */
  141980. export interface ITexturePackerJSON {
  141981. /**
  141982. * The frame ID
  141983. */
  141984. name: string;
  141985. /**
  141986. * The base64 channel data
  141987. */
  141988. sets: any;
  141989. /**
  141990. * The options of the Packer
  141991. */
  141992. options: ITexturePackerOptions;
  141993. /**
  141994. * The frame data of the Packer
  141995. */
  141996. frames: Array<number>;
  141997. }
  141998. /**
  141999. * This is a support class that generates a series of packed texture sets.
  142000. * @see https://doc.babylonjs.com/babylon101/materials
  142001. */
  142002. export class TexturePacker {
  142003. /** Packer Layout Constant 0 */
  142004. static readonly LAYOUT_STRIP: number;
  142005. /** Packer Layout Constant 1 */
  142006. static readonly LAYOUT_POWER2: number;
  142007. /** Packer Layout Constant 2 */
  142008. static readonly LAYOUT_COLNUM: number;
  142009. /** Packer Layout Constant 0 */
  142010. static readonly SUBUV_WRAP: number;
  142011. /** Packer Layout Constant 1 */
  142012. static readonly SUBUV_EXTEND: number;
  142013. /** Packer Layout Constant 2 */
  142014. static readonly SUBUV_COLOR: number;
  142015. /** The Name of the Texture Package */
  142016. name: string;
  142017. /** The scene scope of the TexturePacker */
  142018. scene: Scene;
  142019. /** The Meshes to target */
  142020. meshes: AbstractMesh[];
  142021. /** Arguments passed with the Constructor */
  142022. options: ITexturePackerOptions;
  142023. /** The promise that is started upon initialization */
  142024. promise: Nullable<Promise<TexturePacker | string>>;
  142025. /** The Container object for the channel sets that are generated */
  142026. sets: object;
  142027. /** The Container array for the frames that are generated */
  142028. frames: TexturePackerFrame[];
  142029. /** The expected number of textures the system is parsing. */
  142030. private _expecting;
  142031. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  142032. private _paddingValue;
  142033. /**
  142034. * Initializes a texture package series from an array of meshes or a single mesh.
  142035. * @param name The name of the package
  142036. * @param meshes The target meshes to compose the package from
  142037. * @param options The arguments that texture packer should follow while building.
  142038. * @param scene The scene which the textures are scoped to.
  142039. * @returns TexturePacker
  142040. */
  142041. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  142042. /**
  142043. * Starts the package process
  142044. * @param resolve The promises resolution function
  142045. * @returns TexturePacker
  142046. */
  142047. private _createFrames;
  142048. /**
  142049. * Calculates the Size of the Channel Sets
  142050. * @returns Vector2
  142051. */
  142052. private _calculateSize;
  142053. /**
  142054. * Calculates the UV data for the frames.
  142055. * @param baseSize the base frameSize
  142056. * @param padding the base frame padding
  142057. * @param dtSize size of the Dynamic Texture for that channel
  142058. * @param dtUnits is 1/dtSize
  142059. * @param update flag to update the input meshes
  142060. */
  142061. private _calculateMeshUVFrames;
  142062. /**
  142063. * Calculates the frames Offset.
  142064. * @param index of the frame
  142065. * @returns Vector2
  142066. */
  142067. private _getFrameOffset;
  142068. /**
  142069. * Updates a Mesh to the frame data
  142070. * @param mesh that is the target
  142071. * @param frameID or the frame index
  142072. */
  142073. private _updateMeshUV;
  142074. /**
  142075. * Updates a Meshes materials to use the texture packer channels
  142076. * @param m is the mesh to target
  142077. * @param force all channels on the packer to be set.
  142078. */
  142079. private _updateTextureReferences;
  142080. /**
  142081. * Public method to set a Mesh to a frame
  142082. * @param m that is the target
  142083. * @param frameID or the frame index
  142084. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  142085. */
  142086. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  142087. /**
  142088. * Starts the async promise to compile the texture packer.
  142089. * @returns Promise<void>
  142090. */
  142091. processAsync(): Promise<void>;
  142092. /**
  142093. * Disposes all textures associated with this packer
  142094. */
  142095. dispose(): void;
  142096. /**
  142097. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  142098. * @param imageType is the image type to use.
  142099. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  142100. */
  142101. download(imageType?: string, quality?: number): void;
  142102. /**
  142103. * Public method to load a texturePacker JSON file.
  142104. * @param data of the JSON file in string format.
  142105. */
  142106. updateFromJSON(data: string): void;
  142107. }
  142108. }
  142109. declare module BABYLON {
  142110. /**
  142111. * 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.
  142112. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  142113. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  142114. */
  142115. export class CustomProceduralTexture extends ProceduralTexture {
  142116. private _animate;
  142117. private _time;
  142118. private _config;
  142119. private _texturePath;
  142120. /**
  142121. * Instantiates a new Custom Procedural Texture.
  142122. * 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.
  142123. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  142124. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  142125. * @param name Define the name of the texture
  142126. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  142127. * @param size Define the size of the texture to create
  142128. * @param scene Define the scene the texture belongs to
  142129. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  142130. * @param generateMipMaps Define if the texture should creates mip maps or not
  142131. */
  142132. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  142133. private _loadJson;
  142134. /**
  142135. * Is the texture ready to be used ? (rendered at least once)
  142136. * @returns true if ready, otherwise, false.
  142137. */
  142138. isReady(): boolean;
  142139. /**
  142140. * Render the texture to its associated render target.
  142141. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  142142. */
  142143. render(useCameraPostProcess?: boolean): void;
  142144. /**
  142145. * Update the list of dependant textures samplers in the shader.
  142146. */
  142147. updateTextures(): void;
  142148. /**
  142149. * Update the uniform values of the procedural texture in the shader.
  142150. */
  142151. updateShaderUniforms(): void;
  142152. /**
  142153. * Define if the texture animates or not.
  142154. */
  142155. get animate(): boolean;
  142156. set animate(value: boolean);
  142157. }
  142158. }
  142159. declare module BABYLON {
  142160. /** @hidden */
  142161. export var noisePixelShader: {
  142162. name: string;
  142163. shader: string;
  142164. };
  142165. }
  142166. declare module BABYLON {
  142167. /**
  142168. * Class used to generate noise procedural textures
  142169. */
  142170. export class NoiseProceduralTexture extends ProceduralTexture {
  142171. /** Gets or sets the start time (default is 0) */
  142172. time: number;
  142173. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  142174. brightness: number;
  142175. /** Defines the number of octaves to process */
  142176. octaves: number;
  142177. /** Defines the level of persistence (0.8 by default) */
  142178. persistence: number;
  142179. /** Gets or sets animation speed factor (default is 1) */
  142180. animationSpeedFactor: number;
  142181. /**
  142182. * Creates a new NoiseProceduralTexture
  142183. * @param name defines the name fo the texture
  142184. * @param size defines the size of the texture (default is 256)
  142185. * @param scene defines the hosting scene
  142186. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  142187. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  142188. */
  142189. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  142190. private _updateShaderUniforms;
  142191. protected _getDefines(): string;
  142192. /** Generate the current state of the procedural texture */
  142193. render(useCameraPostProcess?: boolean): void;
  142194. /**
  142195. * Serializes this noise procedural texture
  142196. * @returns a serialized noise procedural texture object
  142197. */
  142198. serialize(): any;
  142199. /**
  142200. * Clone the texture.
  142201. * @returns the cloned texture
  142202. */
  142203. clone(): NoiseProceduralTexture;
  142204. /**
  142205. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  142206. * @param parsedTexture defines parsed texture data
  142207. * @param scene defines the current scene
  142208. * @param rootUrl defines the root URL containing noise procedural texture information
  142209. * @returns a parsed NoiseProceduralTexture
  142210. */
  142211. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  142212. }
  142213. }
  142214. declare module BABYLON {
  142215. /**
  142216. * Raw cube texture where the raw buffers are passed in
  142217. */
  142218. export class RawCubeTexture extends CubeTexture {
  142219. /**
  142220. * Creates a cube texture where the raw buffers are passed in.
  142221. * @param scene defines the scene the texture is attached to
  142222. * @param data defines the array of data to use to create each face
  142223. * @param size defines the size of the textures
  142224. * @param format defines the format of the data
  142225. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  142226. * @param generateMipMaps defines if the engine should generate the mip levels
  142227. * @param invertY defines if data must be stored with Y axis inverted
  142228. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  142229. * @param compression defines the compression used (null by default)
  142230. */
  142231. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  142232. /**
  142233. * Updates the raw cube texture.
  142234. * @param data defines the data to store
  142235. * @param format defines the data format
  142236. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  142237. * @param invertY defines if data must be stored with Y axis inverted
  142238. * @param compression defines the compression used (null by default)
  142239. * @param level defines which level of the texture to update
  142240. */
  142241. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  142242. /**
  142243. * Updates a raw cube texture with RGBD encoded data.
  142244. * @param data defines the array of data [mipmap][face] to use to create each face
  142245. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  142246. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  142247. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  142248. * @returns a promsie that resolves when the operation is complete
  142249. */
  142250. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  142251. /**
  142252. * Clones the raw cube texture.
  142253. * @return a new cube texture
  142254. */
  142255. clone(): CubeTexture;
  142256. /** @hidden */
  142257. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  142258. }
  142259. }
  142260. declare module BABYLON {
  142261. /**
  142262. * Class used to store 2D array textures containing user data
  142263. */
  142264. export class RawTexture2DArray extends Texture {
  142265. /** Gets or sets the texture format to use */
  142266. format: number;
  142267. /**
  142268. * Create a new RawTexture2DArray
  142269. * @param data defines the data of the texture
  142270. * @param width defines the width of the texture
  142271. * @param height defines the height of the texture
  142272. * @param depth defines the number of layers of the texture
  142273. * @param format defines the texture format to use
  142274. * @param scene defines the hosting scene
  142275. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  142276. * @param invertY defines if texture must be stored with Y axis inverted
  142277. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  142278. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  142279. */
  142280. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  142281. /** Gets or sets the texture format to use */
  142282. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  142283. /**
  142284. * Update the texture with new data
  142285. * @param data defines the data to store in the texture
  142286. */
  142287. update(data: ArrayBufferView): void;
  142288. }
  142289. }
  142290. declare module BABYLON {
  142291. /**
  142292. * Class used to store 3D textures containing user data
  142293. */
  142294. export class RawTexture3D extends Texture {
  142295. /** Gets or sets the texture format to use */
  142296. format: number;
  142297. /**
  142298. * Create a new RawTexture3D
  142299. * @param data defines the data of the texture
  142300. * @param width defines the width of the texture
  142301. * @param height defines the height of the texture
  142302. * @param depth defines the depth of the texture
  142303. * @param format defines the texture format to use
  142304. * @param scene defines the hosting scene
  142305. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  142306. * @param invertY defines if texture must be stored with Y axis inverted
  142307. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  142308. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  142309. */
  142310. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  142311. /** Gets or sets the texture format to use */
  142312. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  142313. /**
  142314. * Update the texture with new data
  142315. * @param data defines the data to store in the texture
  142316. */
  142317. update(data: ArrayBufferView): void;
  142318. }
  142319. }
  142320. declare module BABYLON {
  142321. /**
  142322. * Creates a refraction texture used by refraction channel of the standard material.
  142323. * It is like a mirror but to see through a material.
  142324. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  142325. */
  142326. export class RefractionTexture extends RenderTargetTexture {
  142327. /**
  142328. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  142329. * 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.
  142330. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  142331. */
  142332. refractionPlane: Plane;
  142333. /**
  142334. * Define how deep under the surface we should see.
  142335. */
  142336. depth: number;
  142337. /**
  142338. * Creates a refraction texture used by refraction channel of the standard material.
  142339. * It is like a mirror but to see through a material.
  142340. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  142341. * @param name Define the texture name
  142342. * @param size Define the size of the underlying texture
  142343. * @param scene Define the scene the refraction belongs to
  142344. * @param generateMipMaps Define if we need to generate mips level for the refraction
  142345. */
  142346. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  142347. /**
  142348. * Clone the refraction texture.
  142349. * @returns the cloned texture
  142350. */
  142351. clone(): RefractionTexture;
  142352. /**
  142353. * Serialize the texture to a JSON representation you could use in Parse later on
  142354. * @returns the serialized JSON representation
  142355. */
  142356. serialize(): any;
  142357. }
  142358. }
  142359. declare module BABYLON {
  142360. /**
  142361. * Block used to add support for vertex skinning (bones)
  142362. */
  142363. export class BonesBlock extends NodeMaterialBlock {
  142364. /**
  142365. * Creates a new BonesBlock
  142366. * @param name defines the block name
  142367. */
  142368. constructor(name: string);
  142369. /**
  142370. * Initialize the block and prepare the context for build
  142371. * @param state defines the state that will be used for the build
  142372. */
  142373. initialize(state: NodeMaterialBuildState): void;
  142374. /**
  142375. * Gets the current class name
  142376. * @returns the class name
  142377. */
  142378. getClassName(): string;
  142379. /**
  142380. * Gets the matrix indices input component
  142381. */
  142382. get matricesIndices(): NodeMaterialConnectionPoint;
  142383. /**
  142384. * Gets the matrix weights input component
  142385. */
  142386. get matricesWeights(): NodeMaterialConnectionPoint;
  142387. /**
  142388. * Gets the extra matrix indices input component
  142389. */
  142390. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  142391. /**
  142392. * Gets the extra matrix weights input component
  142393. */
  142394. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  142395. /**
  142396. * Gets the world input component
  142397. */
  142398. get world(): NodeMaterialConnectionPoint;
  142399. /**
  142400. * Gets the output component
  142401. */
  142402. get output(): NodeMaterialConnectionPoint;
  142403. autoConfigure(material: NodeMaterial): void;
  142404. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  142405. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  142406. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  142407. protected _buildBlock(state: NodeMaterialBuildState): this;
  142408. }
  142409. }
  142410. declare module BABYLON {
  142411. /**
  142412. * Block used to add support for instances
  142413. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  142414. */
  142415. export class InstancesBlock extends NodeMaterialBlock {
  142416. /**
  142417. * Creates a new InstancesBlock
  142418. * @param name defines the block name
  142419. */
  142420. constructor(name: string);
  142421. /**
  142422. * Gets the current class name
  142423. * @returns the class name
  142424. */
  142425. getClassName(): string;
  142426. /**
  142427. * Gets the first world row input component
  142428. */
  142429. get world0(): NodeMaterialConnectionPoint;
  142430. /**
  142431. * Gets the second world row input component
  142432. */
  142433. get world1(): NodeMaterialConnectionPoint;
  142434. /**
  142435. * Gets the third world row input component
  142436. */
  142437. get world2(): NodeMaterialConnectionPoint;
  142438. /**
  142439. * Gets the forth world row input component
  142440. */
  142441. get world3(): NodeMaterialConnectionPoint;
  142442. /**
  142443. * Gets the world input component
  142444. */
  142445. get world(): NodeMaterialConnectionPoint;
  142446. /**
  142447. * Gets the output component
  142448. */
  142449. get output(): NodeMaterialConnectionPoint;
  142450. /**
  142451. * Gets the isntanceID component
  142452. */
  142453. get instanceID(): NodeMaterialConnectionPoint;
  142454. autoConfigure(material: NodeMaterial): void;
  142455. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  142456. protected _buildBlock(state: NodeMaterialBuildState): this;
  142457. }
  142458. }
  142459. declare module BABYLON {
  142460. /**
  142461. * Block used to add morph targets support to vertex shader
  142462. */
  142463. export class MorphTargetsBlock extends NodeMaterialBlock {
  142464. private _repeatableContentAnchor;
  142465. /**
  142466. * Create a new MorphTargetsBlock
  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 position input component
  142477. */
  142478. get position(): NodeMaterialConnectionPoint;
  142479. /**
  142480. * Gets the normal input component
  142481. */
  142482. get normal(): NodeMaterialConnectionPoint;
  142483. /**
  142484. * Gets the tangent input component
  142485. */
  142486. get tangent(): NodeMaterialConnectionPoint;
  142487. /**
  142488. * Gets the tangent input component
  142489. */
  142490. get uv(): NodeMaterialConnectionPoint;
  142491. /**
  142492. * Gets the position output component
  142493. */
  142494. get positionOutput(): NodeMaterialConnectionPoint;
  142495. /**
  142496. * Gets the normal output component
  142497. */
  142498. get normalOutput(): NodeMaterialConnectionPoint;
  142499. /**
  142500. * Gets the tangent output component
  142501. */
  142502. get tangentOutput(): NodeMaterialConnectionPoint;
  142503. /**
  142504. * Gets the tangent output component
  142505. */
  142506. get uvOutput(): NodeMaterialConnectionPoint;
  142507. initialize(state: NodeMaterialBuildState): void;
  142508. autoConfigure(material: NodeMaterial): void;
  142509. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  142510. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  142511. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  142512. protected _buildBlock(state: NodeMaterialBuildState): this;
  142513. }
  142514. }
  142515. declare module BABYLON {
  142516. /**
  142517. * Block used to get data information from a light
  142518. */
  142519. export class LightInformationBlock extends NodeMaterialBlock {
  142520. private _lightDataUniformName;
  142521. private _lightColorUniformName;
  142522. private _lightTypeDefineName;
  142523. /**
  142524. * Gets or sets the light associated with this block
  142525. */
  142526. light: Nullable<Light>;
  142527. /**
  142528. * Creates a new LightInformationBlock
  142529. * @param name defines the block name
  142530. */
  142531. constructor(name: string);
  142532. /**
  142533. * Gets the current class name
  142534. * @returns the class name
  142535. */
  142536. getClassName(): string;
  142537. /**
  142538. * Gets the world position input component
  142539. */
  142540. get worldPosition(): NodeMaterialConnectionPoint;
  142541. /**
  142542. * Gets the direction output component
  142543. */
  142544. get direction(): NodeMaterialConnectionPoint;
  142545. /**
  142546. * Gets the direction output component
  142547. */
  142548. get color(): NodeMaterialConnectionPoint;
  142549. /**
  142550. * Gets the direction output component
  142551. */
  142552. get intensity(): NodeMaterialConnectionPoint;
  142553. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  142554. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  142555. protected _buildBlock(state: NodeMaterialBuildState): this;
  142556. serialize(): any;
  142557. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  142558. }
  142559. }
  142560. declare module BABYLON {
  142561. /**
  142562. * Block used to add image processing support to fragment shader
  142563. */
  142564. export class ImageProcessingBlock extends NodeMaterialBlock {
  142565. /**
  142566. * Create a new ImageProcessingBlock
  142567. * @param name defines the block name
  142568. */
  142569. constructor(name: string);
  142570. /**
  142571. * Gets the current class name
  142572. * @returns the class name
  142573. */
  142574. getClassName(): string;
  142575. /**
  142576. * Gets the color input component
  142577. */
  142578. get color(): NodeMaterialConnectionPoint;
  142579. /**
  142580. * Gets the output component
  142581. */
  142582. get output(): NodeMaterialConnectionPoint;
  142583. /**
  142584. * Initialize the block and prepare the context for build
  142585. * @param state defines the state that will be used for the build
  142586. */
  142587. initialize(state: NodeMaterialBuildState): void;
  142588. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  142589. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  142590. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  142591. protected _buildBlock(state: NodeMaterialBuildState): this;
  142592. }
  142593. }
  142594. declare module BABYLON {
  142595. /**
  142596. * Block used to pertub normals based on a normal map
  142597. */
  142598. export class PerturbNormalBlock extends NodeMaterialBlock {
  142599. private _tangentSpaceParameterName;
  142600. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  142601. invertX: boolean;
  142602. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  142603. invertY: boolean;
  142604. /**
  142605. * Create a new PerturbNormalBlock
  142606. * @param name defines the block name
  142607. */
  142608. constructor(name: string);
  142609. /**
  142610. * Gets the current class name
  142611. * @returns the class name
  142612. */
  142613. getClassName(): string;
  142614. /**
  142615. * Gets the world position input component
  142616. */
  142617. get worldPosition(): NodeMaterialConnectionPoint;
  142618. /**
  142619. * Gets the world normal input component
  142620. */
  142621. get worldNormal(): NodeMaterialConnectionPoint;
  142622. /**
  142623. * Gets the world tangent input component
  142624. */
  142625. get worldTangent(): NodeMaterialConnectionPoint;
  142626. /**
  142627. * Gets the uv input component
  142628. */
  142629. get uv(): NodeMaterialConnectionPoint;
  142630. /**
  142631. * Gets the normal map color input component
  142632. */
  142633. get normalMapColor(): NodeMaterialConnectionPoint;
  142634. /**
  142635. * Gets the strength input component
  142636. */
  142637. get strength(): NodeMaterialConnectionPoint;
  142638. /**
  142639. * Gets the output component
  142640. */
  142641. get output(): NodeMaterialConnectionPoint;
  142642. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  142643. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  142644. autoConfigure(material: NodeMaterial): void;
  142645. protected _buildBlock(state: NodeMaterialBuildState): this;
  142646. protected _dumpPropertiesCode(): string;
  142647. serialize(): any;
  142648. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  142649. }
  142650. }
  142651. declare module BABYLON {
  142652. /**
  142653. * Block used to discard a pixel if a value is smaller than a cutoff
  142654. */
  142655. export class DiscardBlock extends NodeMaterialBlock {
  142656. /**
  142657. * Create a new DiscardBlock
  142658. * @param name defines the block name
  142659. */
  142660. constructor(name: string);
  142661. /**
  142662. * Gets the current class name
  142663. * @returns the class name
  142664. */
  142665. getClassName(): string;
  142666. /**
  142667. * Gets the color input component
  142668. */
  142669. get value(): NodeMaterialConnectionPoint;
  142670. /**
  142671. * Gets the cutoff input component
  142672. */
  142673. get cutoff(): NodeMaterialConnectionPoint;
  142674. protected _buildBlock(state: NodeMaterialBuildState): this;
  142675. }
  142676. }
  142677. declare module BABYLON {
  142678. /**
  142679. * Block used to test if the fragment shader is front facing
  142680. */
  142681. export class FrontFacingBlock extends NodeMaterialBlock {
  142682. /**
  142683. * Creates a new FrontFacingBlock
  142684. * @param name defines the block name
  142685. */
  142686. constructor(name: string);
  142687. /**
  142688. * Gets the current class name
  142689. * @returns the class name
  142690. */
  142691. getClassName(): string;
  142692. /**
  142693. * Gets the output component
  142694. */
  142695. get output(): NodeMaterialConnectionPoint;
  142696. protected _buildBlock(state: NodeMaterialBuildState): this;
  142697. }
  142698. }
  142699. declare module BABYLON {
  142700. /**
  142701. * Block used to get the derivative value on x and y of a given input
  142702. */
  142703. export class DerivativeBlock extends NodeMaterialBlock {
  142704. /**
  142705. * Create a new DerivativeBlock
  142706. * @param name defines the block name
  142707. */
  142708. constructor(name: string);
  142709. /**
  142710. * Gets the current class name
  142711. * @returns the class name
  142712. */
  142713. getClassName(): string;
  142714. /**
  142715. * Gets the input component
  142716. */
  142717. get input(): NodeMaterialConnectionPoint;
  142718. /**
  142719. * Gets the derivative output on x
  142720. */
  142721. get dx(): NodeMaterialConnectionPoint;
  142722. /**
  142723. * Gets the derivative output on y
  142724. */
  142725. get dy(): NodeMaterialConnectionPoint;
  142726. protected _buildBlock(state: NodeMaterialBuildState): this;
  142727. }
  142728. }
  142729. declare module BABYLON {
  142730. /**
  142731. * Block used to make gl_FragCoord available
  142732. */
  142733. export class FragCoordBlock extends NodeMaterialBlock {
  142734. /**
  142735. * Creates a new FragCoordBlock
  142736. * @param name defines the block name
  142737. */
  142738. constructor(name: string);
  142739. /**
  142740. * Gets the current class name
  142741. * @returns the class name
  142742. */
  142743. getClassName(): string;
  142744. /**
  142745. * Gets the xy component
  142746. */
  142747. get xy(): NodeMaterialConnectionPoint;
  142748. /**
  142749. * Gets the xyz component
  142750. */
  142751. get xyz(): NodeMaterialConnectionPoint;
  142752. /**
  142753. * Gets the xyzw component
  142754. */
  142755. get xyzw(): NodeMaterialConnectionPoint;
  142756. /**
  142757. * Gets the x component
  142758. */
  142759. get x(): NodeMaterialConnectionPoint;
  142760. /**
  142761. * Gets the y component
  142762. */
  142763. get y(): NodeMaterialConnectionPoint;
  142764. /**
  142765. * Gets the z component
  142766. */
  142767. get z(): NodeMaterialConnectionPoint;
  142768. /**
  142769. * Gets the w component
  142770. */
  142771. get output(): NodeMaterialConnectionPoint;
  142772. protected writeOutputs(state: NodeMaterialBuildState): string;
  142773. protected _buildBlock(state: NodeMaterialBuildState): this;
  142774. }
  142775. }
  142776. declare module BABYLON {
  142777. /**
  142778. * Block used to get the screen sizes
  142779. */
  142780. export class ScreenSizeBlock extends NodeMaterialBlock {
  142781. private _varName;
  142782. private _scene;
  142783. /**
  142784. * Creates a new ScreenSizeBlock
  142785. * @param name defines the block name
  142786. */
  142787. constructor(name: string);
  142788. /**
  142789. * Gets the current class name
  142790. * @returns the class name
  142791. */
  142792. getClassName(): string;
  142793. /**
  142794. * Gets the xy component
  142795. */
  142796. get xy(): NodeMaterialConnectionPoint;
  142797. /**
  142798. * Gets the x component
  142799. */
  142800. get x(): NodeMaterialConnectionPoint;
  142801. /**
  142802. * Gets the y component
  142803. */
  142804. get y(): NodeMaterialConnectionPoint;
  142805. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  142806. protected writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  142807. protected _buildBlock(state: NodeMaterialBuildState): this;
  142808. }
  142809. }
  142810. declare module BABYLON {
  142811. /**
  142812. * Block used to add support for scene fog
  142813. */
  142814. export class FogBlock extends NodeMaterialBlock {
  142815. private _fogDistanceName;
  142816. private _fogParameters;
  142817. /**
  142818. * Create a new FogBlock
  142819. * @param name defines the block name
  142820. */
  142821. constructor(name: string);
  142822. /**
  142823. * Gets the current class name
  142824. * @returns the class name
  142825. */
  142826. getClassName(): string;
  142827. /**
  142828. * Gets the world position input component
  142829. */
  142830. get worldPosition(): NodeMaterialConnectionPoint;
  142831. /**
  142832. * Gets the view input component
  142833. */
  142834. get view(): NodeMaterialConnectionPoint;
  142835. /**
  142836. * Gets the color input component
  142837. */
  142838. get input(): NodeMaterialConnectionPoint;
  142839. /**
  142840. * Gets the fog color input component
  142841. */
  142842. get fogColor(): NodeMaterialConnectionPoint;
  142843. /**
  142844. * Gets the output component
  142845. */
  142846. get output(): NodeMaterialConnectionPoint;
  142847. autoConfigure(material: NodeMaterial): void;
  142848. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  142849. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  142850. protected _buildBlock(state: NodeMaterialBuildState): this;
  142851. }
  142852. }
  142853. declare module BABYLON {
  142854. /**
  142855. * Block used to add light in the fragment shader
  142856. */
  142857. export class LightBlock extends NodeMaterialBlock {
  142858. private _lightId;
  142859. /**
  142860. * Gets or sets the light associated with this block
  142861. */
  142862. light: Nullable<Light>;
  142863. /**
  142864. * Create a new LightBlock
  142865. * @param name defines the block name
  142866. */
  142867. constructor(name: string);
  142868. /**
  142869. * Gets the current class name
  142870. * @returns the class name
  142871. */
  142872. getClassName(): string;
  142873. /**
  142874. * Gets the world position input component
  142875. */
  142876. get worldPosition(): NodeMaterialConnectionPoint;
  142877. /**
  142878. * Gets the world normal input component
  142879. */
  142880. get worldNormal(): NodeMaterialConnectionPoint;
  142881. /**
  142882. * Gets the camera (or eye) position component
  142883. */
  142884. get cameraPosition(): NodeMaterialConnectionPoint;
  142885. /**
  142886. * Gets the glossiness component
  142887. */
  142888. get glossiness(): NodeMaterialConnectionPoint;
  142889. /**
  142890. * Gets the glossinness power component
  142891. */
  142892. get glossPower(): NodeMaterialConnectionPoint;
  142893. /**
  142894. * Gets the diffuse color component
  142895. */
  142896. get diffuseColor(): NodeMaterialConnectionPoint;
  142897. /**
  142898. * Gets the specular color component
  142899. */
  142900. get specularColor(): NodeMaterialConnectionPoint;
  142901. /**
  142902. * Gets the diffuse output component
  142903. */
  142904. get diffuseOutput(): NodeMaterialConnectionPoint;
  142905. /**
  142906. * Gets the specular output component
  142907. */
  142908. get specularOutput(): NodeMaterialConnectionPoint;
  142909. /**
  142910. * Gets the shadow output component
  142911. */
  142912. get shadow(): NodeMaterialConnectionPoint;
  142913. autoConfigure(material: NodeMaterial): void;
  142914. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  142915. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  142916. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  142917. private _injectVertexCode;
  142918. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  142919. serialize(): any;
  142920. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  142921. }
  142922. }
  142923. declare module BABYLON {
  142924. /**
  142925. * Block used to read a reflection texture from a sampler
  142926. */
  142927. export class ReflectionTextureBlock extends ReflectionTextureBaseBlock {
  142928. /**
  142929. * Create a new ReflectionTextureBlock
  142930. * @param name defines the block name
  142931. */
  142932. constructor(name: string);
  142933. /**
  142934. * Gets the current class name
  142935. * @returns the class name
  142936. */
  142937. getClassName(): string;
  142938. /**
  142939. * Gets the world position input component
  142940. */
  142941. get position(): NodeMaterialConnectionPoint;
  142942. /**
  142943. * Gets the world position input component
  142944. */
  142945. get worldPosition(): NodeMaterialConnectionPoint;
  142946. /**
  142947. * Gets the world normal input component
  142948. */
  142949. get worldNormal(): NodeMaterialConnectionPoint;
  142950. /**
  142951. * Gets the world input component
  142952. */
  142953. get world(): NodeMaterialConnectionPoint;
  142954. /**
  142955. * Gets the camera (or eye) position component
  142956. */
  142957. get cameraPosition(): NodeMaterialConnectionPoint;
  142958. /**
  142959. * Gets the view input component
  142960. */
  142961. get view(): NodeMaterialConnectionPoint;
  142962. /**
  142963. * Gets the rgb output component
  142964. */
  142965. get rgb(): NodeMaterialConnectionPoint;
  142966. /**
  142967. * Gets the rgba output component
  142968. */
  142969. get rgba(): NodeMaterialConnectionPoint;
  142970. /**
  142971. * Gets the r output component
  142972. */
  142973. get r(): NodeMaterialConnectionPoint;
  142974. /**
  142975. * Gets the g output component
  142976. */
  142977. get g(): NodeMaterialConnectionPoint;
  142978. /**
  142979. * Gets the b output component
  142980. */
  142981. get b(): NodeMaterialConnectionPoint;
  142982. /**
  142983. * Gets the a output component
  142984. */
  142985. get a(): NodeMaterialConnectionPoint;
  142986. autoConfigure(material: NodeMaterial): void;
  142987. protected _buildBlock(state: NodeMaterialBuildState): this;
  142988. }
  142989. }
  142990. declare module BABYLON {
  142991. /**
  142992. * Block used to add 2 vectors
  142993. */
  142994. export class AddBlock extends NodeMaterialBlock {
  142995. /**
  142996. * Creates a new AddBlock
  142997. * @param name defines the block name
  142998. */
  142999. constructor(name: string);
  143000. /**
  143001. * Gets the current class name
  143002. * @returns the class name
  143003. */
  143004. getClassName(): string;
  143005. /**
  143006. * Gets the left operand input component
  143007. */
  143008. get left(): NodeMaterialConnectionPoint;
  143009. /**
  143010. * Gets the right operand input component
  143011. */
  143012. get right(): NodeMaterialConnectionPoint;
  143013. /**
  143014. * Gets the output component
  143015. */
  143016. get output(): NodeMaterialConnectionPoint;
  143017. protected _buildBlock(state: NodeMaterialBuildState): this;
  143018. }
  143019. }
  143020. declare module BABYLON {
  143021. /**
  143022. * Block used to scale a vector by a float
  143023. */
  143024. export class ScaleBlock extends NodeMaterialBlock {
  143025. /**
  143026. * Creates a new ScaleBlock
  143027. * @param name defines the block name
  143028. */
  143029. constructor(name: string);
  143030. /**
  143031. * Gets the current class name
  143032. * @returns the class name
  143033. */
  143034. getClassName(): string;
  143035. /**
  143036. * Gets the input component
  143037. */
  143038. get input(): NodeMaterialConnectionPoint;
  143039. /**
  143040. * Gets the factor input component
  143041. */
  143042. get factor(): NodeMaterialConnectionPoint;
  143043. /**
  143044. * Gets the output component
  143045. */
  143046. get output(): NodeMaterialConnectionPoint;
  143047. protected _buildBlock(state: NodeMaterialBuildState): this;
  143048. }
  143049. }
  143050. declare module BABYLON {
  143051. /**
  143052. * Block used to clamp a float
  143053. */
  143054. export class ClampBlock extends NodeMaterialBlock {
  143055. /** Gets or sets the minimum range */
  143056. minimum: number;
  143057. /** Gets or sets the maximum range */
  143058. maximum: number;
  143059. /**
  143060. * Creates a new ClampBlock
  143061. * @param name defines the block name
  143062. */
  143063. constructor(name: string);
  143064. /**
  143065. * Gets the current class name
  143066. * @returns the class name
  143067. */
  143068. getClassName(): string;
  143069. /**
  143070. * Gets the value input component
  143071. */
  143072. get value(): NodeMaterialConnectionPoint;
  143073. /**
  143074. * Gets the output component
  143075. */
  143076. get output(): NodeMaterialConnectionPoint;
  143077. protected _buildBlock(state: NodeMaterialBuildState): this;
  143078. protected _dumpPropertiesCode(): string;
  143079. serialize(): any;
  143080. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  143081. }
  143082. }
  143083. declare module BABYLON {
  143084. /**
  143085. * Block used to apply a cross product between 2 vectors
  143086. */
  143087. export class CrossBlock extends NodeMaterialBlock {
  143088. /**
  143089. * Creates a new CrossBlock
  143090. * @param name defines the block name
  143091. */
  143092. constructor(name: string);
  143093. /**
  143094. * Gets the current class name
  143095. * @returns the class name
  143096. */
  143097. getClassName(): string;
  143098. /**
  143099. * Gets the left operand input component
  143100. */
  143101. get left(): NodeMaterialConnectionPoint;
  143102. /**
  143103. * Gets the right operand input component
  143104. */
  143105. get right(): NodeMaterialConnectionPoint;
  143106. /**
  143107. * Gets the output component
  143108. */
  143109. get output(): NodeMaterialConnectionPoint;
  143110. protected _buildBlock(state: NodeMaterialBuildState): this;
  143111. }
  143112. }
  143113. declare module BABYLON {
  143114. /**
  143115. * Block used to apply a dot product between 2 vectors
  143116. */
  143117. export class DotBlock extends NodeMaterialBlock {
  143118. /**
  143119. * Creates a new DotBlock
  143120. * @param name defines the block name
  143121. */
  143122. constructor(name: string);
  143123. /**
  143124. * Gets the current class name
  143125. * @returns the class name
  143126. */
  143127. getClassName(): string;
  143128. /**
  143129. * Gets the left operand input component
  143130. */
  143131. get left(): NodeMaterialConnectionPoint;
  143132. /**
  143133. * Gets the right operand input component
  143134. */
  143135. get right(): NodeMaterialConnectionPoint;
  143136. /**
  143137. * Gets the output component
  143138. */
  143139. get output(): NodeMaterialConnectionPoint;
  143140. protected _buildBlock(state: NodeMaterialBuildState): this;
  143141. }
  143142. }
  143143. declare module BABYLON {
  143144. /**
  143145. * Block used to normalize a vector
  143146. */
  143147. export class NormalizeBlock extends NodeMaterialBlock {
  143148. /**
  143149. * Creates a new NormalizeBlock
  143150. * @param name defines the block name
  143151. */
  143152. constructor(name: string);
  143153. /**
  143154. * Gets the current class name
  143155. * @returns the class name
  143156. */
  143157. getClassName(): string;
  143158. /**
  143159. * Gets the input component
  143160. */
  143161. get input(): NodeMaterialConnectionPoint;
  143162. /**
  143163. * Gets the output component
  143164. */
  143165. get output(): NodeMaterialConnectionPoint;
  143166. protected _buildBlock(state: NodeMaterialBuildState): this;
  143167. }
  143168. }
  143169. declare module BABYLON {
  143170. /**
  143171. * Block used to create a Color3/4 out of individual inputs (one for each component)
  143172. */
  143173. export class ColorMergerBlock extends NodeMaterialBlock {
  143174. /**
  143175. * Create a new ColorMergerBlock
  143176. * @param name defines the block name
  143177. */
  143178. constructor(name: string);
  143179. /**
  143180. * Gets the current class name
  143181. * @returns the class name
  143182. */
  143183. getClassName(): string;
  143184. /**
  143185. * Gets the rgb component (input)
  143186. */
  143187. get rgbIn(): NodeMaterialConnectionPoint;
  143188. /**
  143189. * Gets the r component (input)
  143190. */
  143191. get r(): NodeMaterialConnectionPoint;
  143192. /**
  143193. * Gets the g component (input)
  143194. */
  143195. get g(): NodeMaterialConnectionPoint;
  143196. /**
  143197. * Gets the b component (input)
  143198. */
  143199. get b(): NodeMaterialConnectionPoint;
  143200. /**
  143201. * Gets the a component (input)
  143202. */
  143203. get a(): NodeMaterialConnectionPoint;
  143204. /**
  143205. * Gets the rgba component (output)
  143206. */
  143207. get rgba(): NodeMaterialConnectionPoint;
  143208. /**
  143209. * Gets the rgb component (output)
  143210. */
  143211. get rgbOut(): NodeMaterialConnectionPoint;
  143212. /**
  143213. * Gets the rgb component (output)
  143214. * @deprecated Please use rgbOut instead.
  143215. */
  143216. get rgb(): NodeMaterialConnectionPoint;
  143217. protected _buildBlock(state: NodeMaterialBuildState): this;
  143218. }
  143219. }
  143220. declare module BABYLON {
  143221. /**
  143222. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  143223. */
  143224. export class VectorSplitterBlock extends NodeMaterialBlock {
  143225. /**
  143226. * Create a new VectorSplitterBlock
  143227. * @param name defines the block name
  143228. */
  143229. constructor(name: string);
  143230. /**
  143231. * Gets the current class name
  143232. * @returns the class name
  143233. */
  143234. getClassName(): string;
  143235. /**
  143236. * Gets the xyzw component (input)
  143237. */
  143238. get xyzw(): NodeMaterialConnectionPoint;
  143239. /**
  143240. * Gets the xyz component (input)
  143241. */
  143242. get xyzIn(): NodeMaterialConnectionPoint;
  143243. /**
  143244. * Gets the xy component (input)
  143245. */
  143246. get xyIn(): NodeMaterialConnectionPoint;
  143247. /**
  143248. * Gets the xyz component (output)
  143249. */
  143250. get xyzOut(): NodeMaterialConnectionPoint;
  143251. /**
  143252. * Gets the xy component (output)
  143253. */
  143254. get xyOut(): NodeMaterialConnectionPoint;
  143255. /**
  143256. * Gets the x component (output)
  143257. */
  143258. get x(): NodeMaterialConnectionPoint;
  143259. /**
  143260. * Gets the y component (output)
  143261. */
  143262. get y(): NodeMaterialConnectionPoint;
  143263. /**
  143264. * Gets the z component (output)
  143265. */
  143266. get z(): NodeMaterialConnectionPoint;
  143267. /**
  143268. * Gets the w component (output)
  143269. */
  143270. get w(): NodeMaterialConnectionPoint;
  143271. protected _inputRename(name: string): string;
  143272. protected _outputRename(name: string): string;
  143273. protected _buildBlock(state: NodeMaterialBuildState): this;
  143274. }
  143275. }
  143276. declare module BABYLON {
  143277. /**
  143278. * Block used to lerp between 2 values
  143279. */
  143280. export class LerpBlock extends NodeMaterialBlock {
  143281. /**
  143282. * Creates a new LerpBlock
  143283. * @param name defines the block name
  143284. */
  143285. constructor(name: string);
  143286. /**
  143287. * Gets the current class name
  143288. * @returns the class name
  143289. */
  143290. getClassName(): string;
  143291. /**
  143292. * Gets the left operand input component
  143293. */
  143294. get left(): NodeMaterialConnectionPoint;
  143295. /**
  143296. * Gets the right operand input component
  143297. */
  143298. get right(): NodeMaterialConnectionPoint;
  143299. /**
  143300. * Gets the gradient operand input component
  143301. */
  143302. get gradient(): NodeMaterialConnectionPoint;
  143303. /**
  143304. * Gets the output component
  143305. */
  143306. get output(): NodeMaterialConnectionPoint;
  143307. protected _buildBlock(state: NodeMaterialBuildState): this;
  143308. }
  143309. }
  143310. declare module BABYLON {
  143311. /**
  143312. * Block used to divide 2 vectors
  143313. */
  143314. export class DivideBlock extends NodeMaterialBlock {
  143315. /**
  143316. * Creates a new DivideBlock
  143317. * @param name defines the block name
  143318. */
  143319. constructor(name: string);
  143320. /**
  143321. * Gets the current class name
  143322. * @returns the class name
  143323. */
  143324. getClassName(): string;
  143325. /**
  143326. * Gets the left operand input component
  143327. */
  143328. get left(): NodeMaterialConnectionPoint;
  143329. /**
  143330. * Gets the right operand input component
  143331. */
  143332. get right(): NodeMaterialConnectionPoint;
  143333. /**
  143334. * Gets the output component
  143335. */
  143336. get output(): NodeMaterialConnectionPoint;
  143337. protected _buildBlock(state: NodeMaterialBuildState): this;
  143338. }
  143339. }
  143340. declare module BABYLON {
  143341. /**
  143342. * Block used to subtract 2 vectors
  143343. */
  143344. export class SubtractBlock extends NodeMaterialBlock {
  143345. /**
  143346. * Creates a new SubtractBlock
  143347. * @param name defines the block name
  143348. */
  143349. constructor(name: string);
  143350. /**
  143351. * Gets the current class name
  143352. * @returns the class name
  143353. */
  143354. getClassName(): string;
  143355. /**
  143356. * Gets the left operand input component
  143357. */
  143358. get left(): NodeMaterialConnectionPoint;
  143359. /**
  143360. * Gets the right operand input component
  143361. */
  143362. get right(): NodeMaterialConnectionPoint;
  143363. /**
  143364. * Gets the output component
  143365. */
  143366. get output(): NodeMaterialConnectionPoint;
  143367. protected _buildBlock(state: NodeMaterialBuildState): this;
  143368. }
  143369. }
  143370. declare module BABYLON {
  143371. /**
  143372. * Block used to step a value
  143373. */
  143374. export class StepBlock extends NodeMaterialBlock {
  143375. /**
  143376. * Creates a new StepBlock
  143377. * @param name defines the block name
  143378. */
  143379. constructor(name: string);
  143380. /**
  143381. * Gets the current class name
  143382. * @returns the class name
  143383. */
  143384. getClassName(): string;
  143385. /**
  143386. * Gets the value operand input component
  143387. */
  143388. get value(): NodeMaterialConnectionPoint;
  143389. /**
  143390. * Gets the edge operand input component
  143391. */
  143392. get edge(): NodeMaterialConnectionPoint;
  143393. /**
  143394. * Gets the output component
  143395. */
  143396. get output(): NodeMaterialConnectionPoint;
  143397. protected _buildBlock(state: NodeMaterialBuildState): this;
  143398. }
  143399. }
  143400. declare module BABYLON {
  143401. /**
  143402. * Block used to get the opposite (1 - x) of a value
  143403. */
  143404. export class OneMinusBlock extends NodeMaterialBlock {
  143405. /**
  143406. * Creates a new OneMinusBlock
  143407. * @param name defines the block name
  143408. */
  143409. constructor(name: string);
  143410. /**
  143411. * Gets the current class name
  143412. * @returns the class name
  143413. */
  143414. getClassName(): string;
  143415. /**
  143416. * Gets the input component
  143417. */
  143418. get input(): NodeMaterialConnectionPoint;
  143419. /**
  143420. * Gets the output component
  143421. */
  143422. get output(): NodeMaterialConnectionPoint;
  143423. protected _buildBlock(state: NodeMaterialBuildState): this;
  143424. }
  143425. }
  143426. declare module BABYLON {
  143427. /**
  143428. * Block used to get the view direction
  143429. */
  143430. export class ViewDirectionBlock extends NodeMaterialBlock {
  143431. /**
  143432. * Creates a new ViewDirectionBlock
  143433. * @param name defines the block name
  143434. */
  143435. constructor(name: string);
  143436. /**
  143437. * Gets the current class name
  143438. * @returns the class name
  143439. */
  143440. getClassName(): string;
  143441. /**
  143442. * Gets the world position component
  143443. */
  143444. get worldPosition(): NodeMaterialConnectionPoint;
  143445. /**
  143446. * Gets the camera position component
  143447. */
  143448. get cameraPosition(): NodeMaterialConnectionPoint;
  143449. /**
  143450. * Gets the output component
  143451. */
  143452. get output(): NodeMaterialConnectionPoint;
  143453. autoConfigure(material: NodeMaterial): void;
  143454. protected _buildBlock(state: NodeMaterialBuildState): this;
  143455. }
  143456. }
  143457. declare module BABYLON {
  143458. /**
  143459. * Block used to compute fresnel value
  143460. */
  143461. export class FresnelBlock extends NodeMaterialBlock {
  143462. /**
  143463. * Create a new FresnelBlock
  143464. * @param name defines the block name
  143465. */
  143466. constructor(name: string);
  143467. /**
  143468. * Gets the current class name
  143469. * @returns the class name
  143470. */
  143471. getClassName(): string;
  143472. /**
  143473. * Gets the world normal input component
  143474. */
  143475. get worldNormal(): NodeMaterialConnectionPoint;
  143476. /**
  143477. * Gets the view direction input component
  143478. */
  143479. get viewDirection(): NodeMaterialConnectionPoint;
  143480. /**
  143481. * Gets the bias input component
  143482. */
  143483. get bias(): NodeMaterialConnectionPoint;
  143484. /**
  143485. * Gets the camera (or eye) position component
  143486. */
  143487. get power(): NodeMaterialConnectionPoint;
  143488. /**
  143489. * Gets the fresnel output component
  143490. */
  143491. get fresnel(): NodeMaterialConnectionPoint;
  143492. autoConfigure(material: NodeMaterial): void;
  143493. protected _buildBlock(state: NodeMaterialBuildState): this;
  143494. }
  143495. }
  143496. declare module BABYLON {
  143497. /**
  143498. * Block used to get the max of 2 values
  143499. */
  143500. export class MaxBlock extends NodeMaterialBlock {
  143501. /**
  143502. * Creates a new MaxBlock
  143503. * @param name defines the block name
  143504. */
  143505. constructor(name: string);
  143506. /**
  143507. * Gets the current class name
  143508. * @returns the class name
  143509. */
  143510. getClassName(): string;
  143511. /**
  143512. * Gets the left operand input component
  143513. */
  143514. get left(): NodeMaterialConnectionPoint;
  143515. /**
  143516. * Gets the right operand input component
  143517. */
  143518. get right(): NodeMaterialConnectionPoint;
  143519. /**
  143520. * Gets the output component
  143521. */
  143522. get output(): NodeMaterialConnectionPoint;
  143523. protected _buildBlock(state: NodeMaterialBuildState): this;
  143524. }
  143525. }
  143526. declare module BABYLON {
  143527. /**
  143528. * Block used to get the min of 2 values
  143529. */
  143530. export class MinBlock extends NodeMaterialBlock {
  143531. /**
  143532. * Creates a new MinBlock
  143533. * @param name defines the block name
  143534. */
  143535. constructor(name: string);
  143536. /**
  143537. * Gets the current class name
  143538. * @returns the class name
  143539. */
  143540. getClassName(): string;
  143541. /**
  143542. * Gets the left operand input component
  143543. */
  143544. get left(): NodeMaterialConnectionPoint;
  143545. /**
  143546. * Gets the right operand input component
  143547. */
  143548. get right(): NodeMaterialConnectionPoint;
  143549. /**
  143550. * Gets the output component
  143551. */
  143552. get output(): NodeMaterialConnectionPoint;
  143553. protected _buildBlock(state: NodeMaterialBuildState): this;
  143554. }
  143555. }
  143556. declare module BABYLON {
  143557. /**
  143558. * Block used to get the distance between 2 values
  143559. */
  143560. export class DistanceBlock extends NodeMaterialBlock {
  143561. /**
  143562. * Creates a new DistanceBlock
  143563. * @param name defines the block name
  143564. */
  143565. constructor(name: string);
  143566. /**
  143567. * Gets the current class name
  143568. * @returns the class name
  143569. */
  143570. getClassName(): string;
  143571. /**
  143572. * Gets the left operand input component
  143573. */
  143574. get left(): NodeMaterialConnectionPoint;
  143575. /**
  143576. * Gets the right operand input component
  143577. */
  143578. get right(): NodeMaterialConnectionPoint;
  143579. /**
  143580. * Gets the output component
  143581. */
  143582. get output(): NodeMaterialConnectionPoint;
  143583. protected _buildBlock(state: NodeMaterialBuildState): this;
  143584. }
  143585. }
  143586. declare module BABYLON {
  143587. /**
  143588. * Block used to get the length of a vector
  143589. */
  143590. export class LengthBlock extends NodeMaterialBlock {
  143591. /**
  143592. * Creates a new LengthBlock
  143593. * @param name defines the block name
  143594. */
  143595. constructor(name: string);
  143596. /**
  143597. * Gets the current class name
  143598. * @returns the class name
  143599. */
  143600. getClassName(): string;
  143601. /**
  143602. * Gets the value input component
  143603. */
  143604. get value(): NodeMaterialConnectionPoint;
  143605. /**
  143606. * Gets the output component
  143607. */
  143608. get output(): NodeMaterialConnectionPoint;
  143609. protected _buildBlock(state: NodeMaterialBuildState): this;
  143610. }
  143611. }
  143612. declare module BABYLON {
  143613. /**
  143614. * Block used to get negative version of a value (i.e. x * -1)
  143615. */
  143616. export class NegateBlock extends NodeMaterialBlock {
  143617. /**
  143618. * Creates a new NegateBlock
  143619. * @param name defines the block name
  143620. */
  143621. constructor(name: string);
  143622. /**
  143623. * Gets the current class name
  143624. * @returns the class name
  143625. */
  143626. getClassName(): string;
  143627. /**
  143628. * Gets the value input component
  143629. */
  143630. get value(): NodeMaterialConnectionPoint;
  143631. /**
  143632. * Gets the output component
  143633. */
  143634. get output(): NodeMaterialConnectionPoint;
  143635. protected _buildBlock(state: NodeMaterialBuildState): this;
  143636. }
  143637. }
  143638. declare module BABYLON {
  143639. /**
  143640. * Block used to get the value of the first parameter raised to the power of the second
  143641. */
  143642. export class PowBlock extends NodeMaterialBlock {
  143643. /**
  143644. * Creates a new PowBlock
  143645. * @param name defines the block name
  143646. */
  143647. constructor(name: string);
  143648. /**
  143649. * Gets the current class name
  143650. * @returns the class name
  143651. */
  143652. getClassName(): string;
  143653. /**
  143654. * Gets the value operand input component
  143655. */
  143656. get value(): NodeMaterialConnectionPoint;
  143657. /**
  143658. * Gets the power operand input component
  143659. */
  143660. get power(): NodeMaterialConnectionPoint;
  143661. /**
  143662. * Gets the output component
  143663. */
  143664. get output(): NodeMaterialConnectionPoint;
  143665. protected _buildBlock(state: NodeMaterialBuildState): this;
  143666. }
  143667. }
  143668. declare module BABYLON {
  143669. /**
  143670. * Block used to get a random number
  143671. */
  143672. export class RandomNumberBlock extends NodeMaterialBlock {
  143673. /**
  143674. * Creates a new RandomNumberBlock
  143675. * @param name defines the block name
  143676. */
  143677. constructor(name: string);
  143678. /**
  143679. * Gets the current class name
  143680. * @returns the class name
  143681. */
  143682. getClassName(): string;
  143683. /**
  143684. * Gets the seed input component
  143685. */
  143686. get seed(): NodeMaterialConnectionPoint;
  143687. /**
  143688. * Gets the output component
  143689. */
  143690. get output(): NodeMaterialConnectionPoint;
  143691. protected _buildBlock(state: NodeMaterialBuildState): this;
  143692. }
  143693. }
  143694. declare module BABYLON {
  143695. /**
  143696. * Block used to compute arc tangent of 2 values
  143697. */
  143698. export class ArcTan2Block extends NodeMaterialBlock {
  143699. /**
  143700. * Creates a new ArcTan2Block
  143701. * @param name defines the block name
  143702. */
  143703. constructor(name: string);
  143704. /**
  143705. * Gets the current class name
  143706. * @returns the class name
  143707. */
  143708. getClassName(): string;
  143709. /**
  143710. * Gets the x operand input component
  143711. */
  143712. get x(): NodeMaterialConnectionPoint;
  143713. /**
  143714. * Gets the y operand input component
  143715. */
  143716. get y(): NodeMaterialConnectionPoint;
  143717. /**
  143718. * Gets the output component
  143719. */
  143720. get output(): NodeMaterialConnectionPoint;
  143721. protected _buildBlock(state: NodeMaterialBuildState): this;
  143722. }
  143723. }
  143724. declare module BABYLON {
  143725. /**
  143726. * Block used to smooth step a value
  143727. */
  143728. export class SmoothStepBlock extends NodeMaterialBlock {
  143729. /**
  143730. * Creates a new SmoothStepBlock
  143731. * @param name defines the block name
  143732. */
  143733. constructor(name: string);
  143734. /**
  143735. * Gets the current class name
  143736. * @returns the class name
  143737. */
  143738. getClassName(): string;
  143739. /**
  143740. * Gets the value operand input component
  143741. */
  143742. get value(): NodeMaterialConnectionPoint;
  143743. /**
  143744. * Gets the first edge operand input component
  143745. */
  143746. get edge0(): NodeMaterialConnectionPoint;
  143747. /**
  143748. * Gets the second edge operand input component
  143749. */
  143750. get edge1(): NodeMaterialConnectionPoint;
  143751. /**
  143752. * Gets the output component
  143753. */
  143754. get output(): NodeMaterialConnectionPoint;
  143755. protected _buildBlock(state: NodeMaterialBuildState): this;
  143756. }
  143757. }
  143758. declare module BABYLON {
  143759. /**
  143760. * Block used to get the reciprocal (1 / x) of a value
  143761. */
  143762. export class ReciprocalBlock extends NodeMaterialBlock {
  143763. /**
  143764. * Creates a new ReciprocalBlock
  143765. * @param name defines the block name
  143766. */
  143767. constructor(name: string);
  143768. /**
  143769. * Gets the current class name
  143770. * @returns the class name
  143771. */
  143772. getClassName(): string;
  143773. /**
  143774. * Gets the input component
  143775. */
  143776. get input(): NodeMaterialConnectionPoint;
  143777. /**
  143778. * Gets the output component
  143779. */
  143780. get output(): NodeMaterialConnectionPoint;
  143781. protected _buildBlock(state: NodeMaterialBuildState): this;
  143782. }
  143783. }
  143784. declare module BABYLON {
  143785. /**
  143786. * Block used to replace a color by another one
  143787. */
  143788. export class ReplaceColorBlock extends NodeMaterialBlock {
  143789. /**
  143790. * Creates a new ReplaceColorBlock
  143791. * @param name defines the block name
  143792. */
  143793. constructor(name: string);
  143794. /**
  143795. * Gets the current class name
  143796. * @returns the class name
  143797. */
  143798. getClassName(): string;
  143799. /**
  143800. * Gets the value input component
  143801. */
  143802. get value(): NodeMaterialConnectionPoint;
  143803. /**
  143804. * Gets the reference input component
  143805. */
  143806. get reference(): NodeMaterialConnectionPoint;
  143807. /**
  143808. * Gets the distance input component
  143809. */
  143810. get distance(): NodeMaterialConnectionPoint;
  143811. /**
  143812. * Gets the replacement input component
  143813. */
  143814. get replacement(): NodeMaterialConnectionPoint;
  143815. /**
  143816. * Gets the output component
  143817. */
  143818. get output(): NodeMaterialConnectionPoint;
  143819. protected _buildBlock(state: NodeMaterialBuildState): this;
  143820. }
  143821. }
  143822. declare module BABYLON {
  143823. /**
  143824. * Block used to posterize a value
  143825. * @see https://en.wikipedia.org/wiki/Posterization
  143826. */
  143827. export class PosterizeBlock extends NodeMaterialBlock {
  143828. /**
  143829. * Creates a new PosterizeBlock
  143830. * @param name defines the block name
  143831. */
  143832. constructor(name: string);
  143833. /**
  143834. * Gets the current class name
  143835. * @returns the class name
  143836. */
  143837. getClassName(): string;
  143838. /**
  143839. * Gets the value input component
  143840. */
  143841. get value(): NodeMaterialConnectionPoint;
  143842. /**
  143843. * Gets the steps input component
  143844. */
  143845. get steps(): NodeMaterialConnectionPoint;
  143846. /**
  143847. * Gets the output component
  143848. */
  143849. get output(): NodeMaterialConnectionPoint;
  143850. protected _buildBlock(state: NodeMaterialBuildState): this;
  143851. }
  143852. }
  143853. declare module BABYLON {
  143854. /**
  143855. * Operations supported by the Wave block
  143856. */
  143857. export enum WaveBlockKind {
  143858. /** SawTooth */
  143859. SawTooth = 0,
  143860. /** Square */
  143861. Square = 1,
  143862. /** Triangle */
  143863. Triangle = 2
  143864. }
  143865. /**
  143866. * Block used to apply wave operation to floats
  143867. */
  143868. export class WaveBlock extends NodeMaterialBlock {
  143869. /**
  143870. * Gets or sets the kibnd of wave to be applied by the block
  143871. */
  143872. kind: WaveBlockKind;
  143873. /**
  143874. * Creates a new WaveBlock
  143875. * @param name defines the block name
  143876. */
  143877. constructor(name: string);
  143878. /**
  143879. * Gets the current class name
  143880. * @returns the class name
  143881. */
  143882. getClassName(): string;
  143883. /**
  143884. * Gets the input component
  143885. */
  143886. get input(): NodeMaterialConnectionPoint;
  143887. /**
  143888. * Gets the output component
  143889. */
  143890. get output(): NodeMaterialConnectionPoint;
  143891. protected _buildBlock(state: NodeMaterialBuildState): this;
  143892. serialize(): any;
  143893. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  143894. }
  143895. }
  143896. declare module BABYLON {
  143897. /**
  143898. * Class used to store a color step for the GradientBlock
  143899. */
  143900. export class GradientBlockColorStep {
  143901. private _step;
  143902. /**
  143903. * Gets value indicating which step this color is associated with (between 0 and 1)
  143904. */
  143905. get step(): number;
  143906. /**
  143907. * Sets a value indicating which step this color is associated with (between 0 and 1)
  143908. */
  143909. set step(val: number);
  143910. private _color;
  143911. /**
  143912. * Gets the color associated with this step
  143913. */
  143914. get color(): Color3;
  143915. /**
  143916. * Sets the color associated with this step
  143917. */
  143918. set color(val: Color3);
  143919. /**
  143920. * Creates a new GradientBlockColorStep
  143921. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  143922. * @param color defines the color associated with this step
  143923. */
  143924. constructor(step: number, color: Color3);
  143925. }
  143926. /**
  143927. * Block used to return a color from a gradient based on an input value between 0 and 1
  143928. */
  143929. export class GradientBlock extends NodeMaterialBlock {
  143930. /**
  143931. * Gets or sets the list of color steps
  143932. */
  143933. colorSteps: GradientBlockColorStep[];
  143934. /** Gets an observable raised when the value is changed */
  143935. onValueChangedObservable: Observable<GradientBlock>;
  143936. /** calls observable when the value is changed*/
  143937. colorStepsUpdated(): void;
  143938. /**
  143939. * Creates a new GradientBlock
  143940. * @param name defines the block name
  143941. */
  143942. constructor(name: string);
  143943. /**
  143944. * Gets the current class name
  143945. * @returns the class name
  143946. */
  143947. getClassName(): string;
  143948. /**
  143949. * Gets the gradient input component
  143950. */
  143951. get gradient(): NodeMaterialConnectionPoint;
  143952. /**
  143953. * Gets the output component
  143954. */
  143955. get output(): NodeMaterialConnectionPoint;
  143956. private _writeColorConstant;
  143957. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  143958. serialize(): any;
  143959. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  143960. protected _dumpPropertiesCode(): string;
  143961. }
  143962. }
  143963. declare module BABYLON {
  143964. /**
  143965. * Block used to normalize lerp between 2 values
  143966. */
  143967. export class NLerpBlock extends NodeMaterialBlock {
  143968. /**
  143969. * Creates a new NLerpBlock
  143970. * @param name defines the block name
  143971. */
  143972. constructor(name: string);
  143973. /**
  143974. * Gets the current class name
  143975. * @returns the class name
  143976. */
  143977. getClassName(): string;
  143978. /**
  143979. * Gets the left operand input component
  143980. */
  143981. get left(): NodeMaterialConnectionPoint;
  143982. /**
  143983. * Gets the right operand input component
  143984. */
  143985. get right(): NodeMaterialConnectionPoint;
  143986. /**
  143987. * Gets the gradient operand input component
  143988. */
  143989. get gradient(): NodeMaterialConnectionPoint;
  143990. /**
  143991. * Gets the output component
  143992. */
  143993. get output(): NodeMaterialConnectionPoint;
  143994. protected _buildBlock(state: NodeMaterialBuildState): this;
  143995. }
  143996. }
  143997. declare module BABYLON {
  143998. /**
  143999. * block used to Generate a Worley Noise 3D Noise Pattern
  144000. */
  144001. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  144002. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  144003. manhattanDistance: boolean;
  144004. /**
  144005. * Creates a new WorleyNoise3DBlock
  144006. * @param name defines the block name
  144007. */
  144008. constructor(name: string);
  144009. /**
  144010. * Gets the current class name
  144011. * @returns the class name
  144012. */
  144013. getClassName(): string;
  144014. /**
  144015. * Gets the seed input component
  144016. */
  144017. get seed(): NodeMaterialConnectionPoint;
  144018. /**
  144019. * Gets the jitter input component
  144020. */
  144021. get jitter(): NodeMaterialConnectionPoint;
  144022. /**
  144023. * Gets the output component
  144024. */
  144025. get output(): NodeMaterialConnectionPoint;
  144026. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  144027. /**
  144028. * Exposes the properties to the UI?
  144029. */
  144030. protected _dumpPropertiesCode(): string;
  144031. /**
  144032. * Exposes the properties to the Seralize?
  144033. */
  144034. serialize(): any;
  144035. /**
  144036. * Exposes the properties to the deseralize?
  144037. */
  144038. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  144039. }
  144040. }
  144041. declare module BABYLON {
  144042. /**
  144043. * block used to Generate a Simplex Perlin 3d Noise Pattern
  144044. */
  144045. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  144046. /**
  144047. * Creates a new SimplexPerlin3DBlock
  144048. * @param name defines the block name
  144049. */
  144050. constructor(name: string);
  144051. /**
  144052. * Gets the current class name
  144053. * @returns the class name
  144054. */
  144055. getClassName(): string;
  144056. /**
  144057. * Gets the seed operand input component
  144058. */
  144059. get seed(): NodeMaterialConnectionPoint;
  144060. /**
  144061. * Gets the output component
  144062. */
  144063. get output(): NodeMaterialConnectionPoint;
  144064. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  144065. }
  144066. }
  144067. declare module BABYLON {
  144068. /**
  144069. * Block used to blend normals
  144070. */
  144071. export class NormalBlendBlock extends NodeMaterialBlock {
  144072. /**
  144073. * Creates a new NormalBlendBlock
  144074. * @param name defines the block name
  144075. */
  144076. constructor(name: string);
  144077. /**
  144078. * Gets the current class name
  144079. * @returns the class name
  144080. */
  144081. getClassName(): string;
  144082. /**
  144083. * Gets the first input component
  144084. */
  144085. get normalMap0(): NodeMaterialConnectionPoint;
  144086. /**
  144087. * Gets the second input component
  144088. */
  144089. get normalMap1(): NodeMaterialConnectionPoint;
  144090. /**
  144091. * Gets the output component
  144092. */
  144093. get output(): NodeMaterialConnectionPoint;
  144094. protected _buildBlock(state: NodeMaterialBuildState): this;
  144095. }
  144096. }
  144097. declare module BABYLON {
  144098. /**
  144099. * Block used to rotate a 2d vector by a given angle
  144100. */
  144101. export class Rotate2dBlock extends NodeMaterialBlock {
  144102. /**
  144103. * Creates a new Rotate2dBlock
  144104. * @param name defines the block name
  144105. */
  144106. constructor(name: string);
  144107. /**
  144108. * Gets the current class name
  144109. * @returns the class name
  144110. */
  144111. getClassName(): string;
  144112. /**
  144113. * Gets the input vector
  144114. */
  144115. get input(): NodeMaterialConnectionPoint;
  144116. /**
  144117. * Gets the input angle
  144118. */
  144119. get angle(): NodeMaterialConnectionPoint;
  144120. /**
  144121. * Gets the output component
  144122. */
  144123. get output(): NodeMaterialConnectionPoint;
  144124. autoConfigure(material: NodeMaterial): void;
  144125. protected _buildBlock(state: NodeMaterialBuildState): this;
  144126. }
  144127. }
  144128. declare module BABYLON {
  144129. /**
  144130. * Block used to get the reflected vector from a direction and a normal
  144131. */
  144132. export class ReflectBlock extends NodeMaterialBlock {
  144133. /**
  144134. * Creates a new ReflectBlock
  144135. * @param name defines the block name
  144136. */
  144137. constructor(name: string);
  144138. /**
  144139. * Gets the current class name
  144140. * @returns the class name
  144141. */
  144142. getClassName(): string;
  144143. /**
  144144. * Gets the incident component
  144145. */
  144146. get incident(): NodeMaterialConnectionPoint;
  144147. /**
  144148. * Gets the normal component
  144149. */
  144150. get normal(): NodeMaterialConnectionPoint;
  144151. /**
  144152. * Gets the output component
  144153. */
  144154. get output(): NodeMaterialConnectionPoint;
  144155. protected _buildBlock(state: NodeMaterialBuildState): this;
  144156. }
  144157. }
  144158. declare module BABYLON {
  144159. /**
  144160. * Block used to get the refracted vector from a direction and a normal
  144161. */
  144162. export class RefractBlock extends NodeMaterialBlock {
  144163. /**
  144164. * Creates a new RefractBlock
  144165. * @param name defines the block name
  144166. */
  144167. constructor(name: string);
  144168. /**
  144169. * Gets the current class name
  144170. * @returns the class name
  144171. */
  144172. getClassName(): string;
  144173. /**
  144174. * Gets the incident component
  144175. */
  144176. get incident(): NodeMaterialConnectionPoint;
  144177. /**
  144178. * Gets the normal component
  144179. */
  144180. get normal(): NodeMaterialConnectionPoint;
  144181. /**
  144182. * Gets the index of refraction component
  144183. */
  144184. get ior(): NodeMaterialConnectionPoint;
  144185. /**
  144186. * Gets the output component
  144187. */
  144188. get output(): NodeMaterialConnectionPoint;
  144189. protected _buildBlock(state: NodeMaterialBuildState): this;
  144190. }
  144191. }
  144192. declare module BABYLON {
  144193. /**
  144194. * Block used to desaturate a color
  144195. */
  144196. export class DesaturateBlock extends NodeMaterialBlock {
  144197. /**
  144198. * Creates a new DesaturateBlock
  144199. * @param name defines the block name
  144200. */
  144201. constructor(name: string);
  144202. /**
  144203. * Gets the current class name
  144204. * @returns the class name
  144205. */
  144206. getClassName(): string;
  144207. /**
  144208. * Gets the color operand input component
  144209. */
  144210. get color(): NodeMaterialConnectionPoint;
  144211. /**
  144212. * Gets the level operand input component
  144213. */
  144214. get level(): NodeMaterialConnectionPoint;
  144215. /**
  144216. * Gets the output component
  144217. */
  144218. get output(): NodeMaterialConnectionPoint;
  144219. protected _buildBlock(state: NodeMaterialBuildState): this;
  144220. }
  144221. }
  144222. declare module BABYLON {
  144223. /**
  144224. * Block used to implement the ambient occlusion module of the PBR material
  144225. */
  144226. export class AmbientOcclusionBlock extends NodeMaterialBlock {
  144227. /**
  144228. * Create a new AmbientOcclusionBlock
  144229. * @param name defines the block name
  144230. */
  144231. constructor(name: string);
  144232. /**
  144233. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  144234. */
  144235. useAmbientInGrayScale: boolean;
  144236. /**
  144237. * Initialize the block and prepare the context for build
  144238. * @param state defines the state that will be used for the build
  144239. */
  144240. initialize(state: NodeMaterialBuildState): void;
  144241. /**
  144242. * Gets the current class name
  144243. * @returns the class name
  144244. */
  144245. getClassName(): string;
  144246. /**
  144247. * Gets the texture input component
  144248. */
  144249. get texture(): NodeMaterialConnectionPoint;
  144250. /**
  144251. * Gets the texture intensity component
  144252. */
  144253. get intensity(): NodeMaterialConnectionPoint;
  144254. /**
  144255. * Gets the direct light intensity input component
  144256. */
  144257. get directLightIntensity(): NodeMaterialConnectionPoint;
  144258. /**
  144259. * Gets the ambient occlusion object output component
  144260. */
  144261. get ambientOcclusion(): NodeMaterialConnectionPoint;
  144262. /**
  144263. * Gets the main code of the block (fragment side)
  144264. * @param block instance of an AmbientOcclusionBlock or null if the code must be generated without an active ambient occlusion module
  144265. * @returns the shader code
  144266. */
  144267. static GetCode(block: Nullable<AmbientOcclusionBlock>): string;
  144268. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  144269. protected _buildBlock(state: NodeMaterialBuildState): this;
  144270. protected _dumpPropertiesCode(): string;
  144271. serialize(): any;
  144272. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  144273. }
  144274. }
  144275. declare module BABYLON {
  144276. /**
  144277. * Block used to implement the reflection module of the PBR material
  144278. */
  144279. export class ReflectionBlock extends ReflectionTextureBaseBlock {
  144280. /** @hidden */
  144281. _defineLODReflectionAlpha: string;
  144282. /** @hidden */
  144283. _defineLinearSpecularReflection: string;
  144284. private _vEnvironmentIrradianceName;
  144285. /** @hidden */
  144286. _vReflectionMicrosurfaceInfosName: string;
  144287. /** @hidden */
  144288. _vReflectionInfosName: string;
  144289. /** @hidden */
  144290. _vReflectionFilteringInfoName: string;
  144291. private _scene;
  144292. /**
  144293. * The three properties below are set by the main PBR block prior to calling methods of this class.
  144294. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  144295. * It's less burden on the user side in the editor part.
  144296. */
  144297. /** @hidden */
  144298. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  144299. /** @hidden */
  144300. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  144301. /** @hidden */
  144302. cameraPositionConnectionPoint: NodeMaterialConnectionPoint;
  144303. /**
  144304. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  144305. * diffuse part of the IBL.
  144306. */
  144307. useSphericalHarmonics: boolean;
  144308. /**
  144309. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  144310. */
  144311. forceIrradianceInFragment: boolean;
  144312. /**
  144313. * Create a new ReflectionBlock
  144314. * @param name defines the block name
  144315. */
  144316. constructor(name: string);
  144317. /**
  144318. * Gets the current class name
  144319. * @returns the class name
  144320. */
  144321. getClassName(): string;
  144322. /**
  144323. * Gets the position input component
  144324. */
  144325. get position(): NodeMaterialConnectionPoint;
  144326. /**
  144327. * Gets the world position input component
  144328. */
  144329. get worldPosition(): NodeMaterialConnectionPoint;
  144330. /**
  144331. * Gets the world normal input component
  144332. */
  144333. get worldNormal(): NodeMaterialConnectionPoint;
  144334. /**
  144335. * Gets the world input component
  144336. */
  144337. get world(): NodeMaterialConnectionPoint;
  144338. /**
  144339. * Gets the camera (or eye) position component
  144340. */
  144341. get cameraPosition(): NodeMaterialConnectionPoint;
  144342. /**
  144343. * Gets the view input component
  144344. */
  144345. get view(): NodeMaterialConnectionPoint;
  144346. /**
  144347. * Gets the color input component
  144348. */
  144349. get color(): NodeMaterialConnectionPoint;
  144350. /**
  144351. * Gets the reflection object output component
  144352. */
  144353. get reflection(): NodeMaterialConnectionPoint;
  144354. /**
  144355. * Returns true if the block has a texture (either its own texture or the environment texture from the scene, if set)
  144356. */
  144357. get hasTexture(): boolean;
  144358. /**
  144359. * Gets the reflection color (either the name of the variable if the color input is connected, else a default value)
  144360. */
  144361. get reflectionColor(): string;
  144362. protected _getTexture(): Nullable<BaseTexture>;
  144363. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  144364. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  144365. /**
  144366. * Gets the code to inject in the vertex shader
  144367. * @param state current state of the node material building
  144368. * @returns the shader code
  144369. */
  144370. handleVertexSide(state: NodeMaterialBuildState): string;
  144371. /**
  144372. * Gets the main code of the block (fragment side)
  144373. * @param state current state of the node material building
  144374. * @param normalVarName name of the existing variable corresponding to the normal
  144375. * @returns the shader code
  144376. */
  144377. getCode(state: NodeMaterialBuildState, normalVarName: string): string;
  144378. protected _buildBlock(state: NodeMaterialBuildState): this;
  144379. protected _dumpPropertiesCode(): string;
  144380. serialize(): any;
  144381. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  144382. }
  144383. }
  144384. declare module BABYLON {
  144385. /**
  144386. * Block used to implement the sheen module of the PBR material
  144387. */
  144388. export class SheenBlock extends NodeMaterialBlock {
  144389. /**
  144390. * Create a new SheenBlock
  144391. * @param name defines the block name
  144392. */
  144393. constructor(name: string);
  144394. /**
  144395. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  144396. * It allows the strength of the sheen effect to not depend on the base color of the material,
  144397. * making it easier to setup and tweak the effect
  144398. */
  144399. albedoScaling: boolean;
  144400. /**
  144401. * Defines if the sheen is linked to the sheen color.
  144402. */
  144403. linkSheenWithAlbedo: boolean;
  144404. /**
  144405. * Initialize the block and prepare the context for build
  144406. * @param state defines the state that will be used for the build
  144407. */
  144408. initialize(state: NodeMaterialBuildState): void;
  144409. /**
  144410. * Gets the current class name
  144411. * @returns the class name
  144412. */
  144413. getClassName(): string;
  144414. /**
  144415. * Gets the intensity input component
  144416. */
  144417. get intensity(): NodeMaterialConnectionPoint;
  144418. /**
  144419. * Gets the color input component
  144420. */
  144421. get color(): NodeMaterialConnectionPoint;
  144422. /**
  144423. * Gets the roughness input component
  144424. */
  144425. get roughness(): NodeMaterialConnectionPoint;
  144426. /**
  144427. * Gets the sheen object output component
  144428. */
  144429. get sheen(): NodeMaterialConnectionPoint;
  144430. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  144431. /**
  144432. * Gets the main code of the block (fragment side)
  144433. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  144434. * @returns the shader code
  144435. */
  144436. getCode(reflectionBlock: Nullable<ReflectionBlock>): string;
  144437. protected _buildBlock(state: NodeMaterialBuildState): this;
  144438. protected _dumpPropertiesCode(): string;
  144439. serialize(): any;
  144440. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  144441. }
  144442. }
  144443. declare module BABYLON {
  144444. /**
  144445. * Block used to implement the reflectivity module of the PBR material
  144446. */
  144447. export class ReflectivityBlock extends NodeMaterialBlock {
  144448. private _metallicReflectanceColor;
  144449. private _metallicF0Factor;
  144450. /** @hidden */
  144451. _vMetallicReflectanceFactorsName: string;
  144452. /**
  144453. * The property below is set by the main PBR block prior to calling methods of this class.
  144454. */
  144455. /** @hidden */
  144456. indexOfRefractionConnectionPoint: Nullable<NodeMaterialConnectionPoint>;
  144457. /**
  144458. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  144459. */
  144460. useAmbientOcclusionFromMetallicTextureRed: boolean;
  144461. /**
  144462. * Specifies if the metallic texture contains the metallness information in its blue channel.
  144463. */
  144464. useMetallnessFromMetallicTextureBlue: boolean;
  144465. /**
  144466. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  144467. */
  144468. useRoughnessFromMetallicTextureAlpha: boolean;
  144469. /**
  144470. * Specifies if the metallic texture contains the roughness information in its green channel.
  144471. */
  144472. useRoughnessFromMetallicTextureGreen: boolean;
  144473. /**
  144474. * Create a new ReflectivityBlock
  144475. * @param name defines the block name
  144476. */
  144477. constructor(name: string);
  144478. /**
  144479. * Initialize the block and prepare the context for build
  144480. * @param state defines the state that will be used for the build
  144481. */
  144482. initialize(state: NodeMaterialBuildState): void;
  144483. /**
  144484. * Gets the current class name
  144485. * @returns the class name
  144486. */
  144487. getClassName(): string;
  144488. /**
  144489. * Gets the metallic input component
  144490. */
  144491. get metallic(): NodeMaterialConnectionPoint;
  144492. /**
  144493. * Gets the roughness input component
  144494. */
  144495. get roughness(): NodeMaterialConnectionPoint;
  144496. /**
  144497. * Gets the texture input component
  144498. */
  144499. get texture(): NodeMaterialConnectionPoint;
  144500. /**
  144501. * Gets the reflectivity object output component
  144502. */
  144503. get reflectivity(): NodeMaterialConnectionPoint;
  144504. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  144505. /**
  144506. * Gets the main code of the block (fragment side)
  144507. * @param state current state of the node material building
  144508. * @param aoIntensityVarName name of the variable with the ambient occlusion intensity
  144509. * @returns the shader code
  144510. */
  144511. getCode(state: NodeMaterialBuildState, aoIntensityVarName: string): string;
  144512. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  144513. protected _buildBlock(state: NodeMaterialBuildState): this;
  144514. protected _dumpPropertiesCode(): string;
  144515. serialize(): any;
  144516. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  144517. }
  144518. }
  144519. declare module BABYLON {
  144520. /**
  144521. * Block used to implement the anisotropy module of the PBR material
  144522. */
  144523. export class AnisotropyBlock extends NodeMaterialBlock {
  144524. /**
  144525. * The two properties below are set by the main PBR block prior to calling methods of this class.
  144526. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  144527. * It's less burden on the user side in the editor part.
  144528. */
  144529. /** @hidden */
  144530. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  144531. /** @hidden */
  144532. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  144533. /**
  144534. * Create a new AnisotropyBlock
  144535. * @param name defines the block name
  144536. */
  144537. constructor(name: string);
  144538. /**
  144539. * Initialize the block and prepare the context for build
  144540. * @param state defines the state that will be used for the build
  144541. */
  144542. initialize(state: NodeMaterialBuildState): void;
  144543. /**
  144544. * Gets the current class name
  144545. * @returns the class name
  144546. */
  144547. getClassName(): string;
  144548. /**
  144549. * Gets the intensity input component
  144550. */
  144551. get intensity(): NodeMaterialConnectionPoint;
  144552. /**
  144553. * Gets the direction input component
  144554. */
  144555. get direction(): NodeMaterialConnectionPoint;
  144556. /**
  144557. * Gets the texture input component
  144558. */
  144559. get texture(): NodeMaterialConnectionPoint;
  144560. /**
  144561. * Gets the uv input component
  144562. */
  144563. get uv(): NodeMaterialConnectionPoint;
  144564. /**
  144565. * Gets the worldTangent input component
  144566. */
  144567. get worldTangent(): NodeMaterialConnectionPoint;
  144568. /**
  144569. * Gets the anisotropy object output component
  144570. */
  144571. get anisotropy(): NodeMaterialConnectionPoint;
  144572. private _generateTBNSpace;
  144573. /**
  144574. * Gets the main code of the block (fragment side)
  144575. * @param state current state of the node material building
  144576. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  144577. * @returns the shader code
  144578. */
  144579. getCode(state: NodeMaterialBuildState, generateTBNSpace?: boolean): string;
  144580. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  144581. protected _buildBlock(state: NodeMaterialBuildState): this;
  144582. }
  144583. }
  144584. declare module BABYLON {
  144585. /**
  144586. * Block used to implement the clear coat module of the PBR material
  144587. */
  144588. export class ClearCoatBlock extends NodeMaterialBlock {
  144589. private _scene;
  144590. /**
  144591. * Create a new ClearCoatBlock
  144592. * @param name defines the block name
  144593. */
  144594. constructor(name: string);
  144595. /**
  144596. * Initialize the block and prepare the context for build
  144597. * @param state defines the state that will be used for the build
  144598. */
  144599. initialize(state: NodeMaterialBuildState): void;
  144600. /**
  144601. * Gets the current class name
  144602. * @returns the class name
  144603. */
  144604. getClassName(): string;
  144605. /**
  144606. * Gets the intensity input component
  144607. */
  144608. get intensity(): NodeMaterialConnectionPoint;
  144609. /**
  144610. * Gets the roughness input component
  144611. */
  144612. get roughness(): NodeMaterialConnectionPoint;
  144613. /**
  144614. * Gets the ior input component
  144615. */
  144616. get ior(): NodeMaterialConnectionPoint;
  144617. /**
  144618. * Gets the texture input component
  144619. */
  144620. get texture(): NodeMaterialConnectionPoint;
  144621. /**
  144622. * Gets the bump texture input component
  144623. */
  144624. get bumpTexture(): NodeMaterialConnectionPoint;
  144625. /**
  144626. * Gets the uv input component
  144627. */
  144628. get uv(): NodeMaterialConnectionPoint;
  144629. /**
  144630. * Gets the tint color input component
  144631. */
  144632. get tintColor(): NodeMaterialConnectionPoint;
  144633. /**
  144634. * Gets the tint "at distance" input component
  144635. */
  144636. get tintAtDistance(): NodeMaterialConnectionPoint;
  144637. /**
  144638. * Gets the tint thickness input component
  144639. */
  144640. get tintThickness(): NodeMaterialConnectionPoint;
  144641. /**
  144642. * Gets the world tangent input component
  144643. */
  144644. get worldTangent(): NodeMaterialConnectionPoint;
  144645. /**
  144646. * Gets the clear coat object output component
  144647. */
  144648. get clearcoat(): NodeMaterialConnectionPoint;
  144649. autoConfigure(material: NodeMaterial): void;
  144650. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  144651. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  144652. private _generateTBNSpace;
  144653. /**
  144654. * Gets the main code of the block (fragment side)
  144655. * @param state current state of the node material building
  144656. * @param ccBlock instance of a ClearCoatBlock or null if the code must be generated without an active clear coat module
  144657. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  144658. * @param worldPosVarName name of the variable holding the world position
  144659. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  144660. * @param vTBNAvailable indicate that the vTBN variable is already existing because it has already been generated by another block (PerturbNormal or Anisotropy)
  144661. * @param worldNormalVarName name of the variable holding the world normal
  144662. * @returns the shader code
  144663. */
  144664. static GetCode(state: NodeMaterialBuildState, ccBlock: Nullable<ClearCoatBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string, generateTBNSpace: boolean, vTBNAvailable: boolean, worldNormalVarName: string): string;
  144665. protected _buildBlock(state: NodeMaterialBuildState): this;
  144666. }
  144667. }
  144668. declare module BABYLON {
  144669. /**
  144670. * Block used to implement the sub surface module of the PBR material
  144671. */
  144672. export class SubSurfaceBlock extends NodeMaterialBlock {
  144673. /**
  144674. * Create a new SubSurfaceBlock
  144675. * @param name defines the block name
  144676. */
  144677. constructor(name: string);
  144678. /**
  144679. * Stores the intensity of the different subsurface effects in the thickness texture.
  144680. * * the green channel is the translucency intensity.
  144681. * * the blue channel is the scattering intensity.
  144682. * * the alpha channel is the refraction intensity.
  144683. */
  144684. useMaskFromThicknessTexture: boolean;
  144685. /**
  144686. * Initialize the block and prepare the context for build
  144687. * @param state defines the state that will be used for the build
  144688. */
  144689. initialize(state: NodeMaterialBuildState): void;
  144690. /**
  144691. * Gets the current class name
  144692. * @returns the class name
  144693. */
  144694. getClassName(): string;
  144695. /**
  144696. * Gets the min thickness input component
  144697. */
  144698. get minThickness(): NodeMaterialConnectionPoint;
  144699. /**
  144700. * Gets the max thickness input component
  144701. */
  144702. get maxThickness(): NodeMaterialConnectionPoint;
  144703. /**
  144704. * Gets the thickness texture component
  144705. */
  144706. get thicknessTexture(): NodeMaterialConnectionPoint;
  144707. /**
  144708. * Gets the tint color input component
  144709. */
  144710. get tintColor(): NodeMaterialConnectionPoint;
  144711. /**
  144712. * Gets the translucency intensity input component
  144713. */
  144714. get translucencyIntensity(): NodeMaterialConnectionPoint;
  144715. /**
  144716. * Gets the translucency diffusion distance input component
  144717. */
  144718. get translucencyDiffusionDistance(): NodeMaterialConnectionPoint;
  144719. /**
  144720. * Gets the refraction object parameters
  144721. */
  144722. get refraction(): NodeMaterialConnectionPoint;
  144723. /**
  144724. * Gets the sub surface object output component
  144725. */
  144726. get subsurface(): NodeMaterialConnectionPoint;
  144727. autoConfigure(material: NodeMaterial): void;
  144728. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  144729. /**
  144730. * Gets the main code of the block (fragment side)
  144731. * @param state current state of the node material building
  144732. * @param ssBlock instance of a SubSurfaceBlock or null if the code must be generated without an active sub surface module
  144733. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  144734. * @param worldPosVarName name of the variable holding the world position
  144735. * @returns the shader code
  144736. */
  144737. static GetCode(state: NodeMaterialBuildState, ssBlock: Nullable<SubSurfaceBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string): string;
  144738. protected _buildBlock(state: NodeMaterialBuildState): this;
  144739. }
  144740. }
  144741. declare module BABYLON {
  144742. /**
  144743. * Block used to implement the PBR metallic/roughness model
  144744. */
  144745. export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
  144746. /**
  144747. * Gets or sets the light associated with this block
  144748. */
  144749. light: Nullable<Light>;
  144750. private _lightId;
  144751. private _scene;
  144752. private _environmentBRDFTexture;
  144753. private _environmentBrdfSamplerName;
  144754. private _vNormalWName;
  144755. private _invertNormalName;
  144756. /**
  144757. * Create a new ReflectionBlock
  144758. * @param name defines the block name
  144759. */
  144760. constructor(name: string);
  144761. /**
  144762. * Intensity of the direct lights e.g. the four lights available in your scene.
  144763. * This impacts both the direct diffuse and specular highlights.
  144764. */
  144765. directIntensity: number;
  144766. /**
  144767. * Intensity of the environment e.g. how much the environment will light the object
  144768. * either through harmonics for rough material or through the refelction for shiny ones.
  144769. */
  144770. environmentIntensity: number;
  144771. /**
  144772. * This is a special control allowing the reduction of the specular highlights coming from the
  144773. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  144774. */
  144775. specularIntensity: number;
  144776. /**
  144777. * Defines the falloff type used in this material.
  144778. * It by default is Physical.
  144779. */
  144780. lightFalloff: number;
  144781. /**
  144782. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  144783. */
  144784. useAlphaFromAlbedoTexture: boolean;
  144785. /**
  144786. * Specifies that alpha test should be used
  144787. */
  144788. useAlphaTest: boolean;
  144789. /**
  144790. * Defines the alpha limits in alpha test mode.
  144791. */
  144792. alphaTestCutoff: number;
  144793. /**
  144794. * Specifies that alpha blending should be used
  144795. */
  144796. useAlphaBlending: boolean;
  144797. /**
  144798. * Defines if the alpha value should be determined via the rgb values.
  144799. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  144800. */
  144801. opacityRGB: boolean;
  144802. /**
  144803. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  144804. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  144805. */
  144806. useRadianceOverAlpha: boolean;
  144807. /**
  144808. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most luminous ones).
  144809. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  144810. */
  144811. useSpecularOverAlpha: boolean;
  144812. /**
  144813. * Enables specular anti aliasing in the PBR shader.
  144814. * It will both interacts on the Geometry for analytical and IBL lighting.
  144815. * It also prefilter the roughness map based on the bump values.
  144816. */
  144817. enableSpecularAntiAliasing: boolean;
  144818. /**
  144819. * Enables realtime filtering on the texture.
  144820. */
  144821. realTimeFiltering: boolean;
  144822. /**
  144823. * Quality switch for realtime filtering
  144824. */
  144825. realTimeFilteringQuality: number;
  144826. /**
  144827. * Defines if the material uses energy conservation.
  144828. */
  144829. useEnergyConservation: boolean;
  144830. /**
  144831. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  144832. * too much the area relying on ambient texture to define their ambient occlusion.
  144833. */
  144834. useRadianceOcclusion: boolean;
  144835. /**
  144836. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  144837. * makes the reflect vector face the model (under horizon).
  144838. */
  144839. useHorizonOcclusion: boolean;
  144840. /**
  144841. * If set to true, no lighting calculations will be applied.
  144842. */
  144843. unlit: boolean;
  144844. /**
  144845. * Force normal to face away from face.
  144846. */
  144847. forceNormalForward: boolean;
  144848. /**
  144849. * Defines the material debug mode.
  144850. * It helps seeing only some components of the material while troubleshooting.
  144851. */
  144852. debugMode: number;
  144853. /**
  144854. * Specify from where on screen the debug mode should start.
  144855. * The value goes from -1 (full screen) to 1 (not visible)
  144856. * It helps with side by side comparison against the final render
  144857. * This defaults to 0
  144858. */
  144859. debugLimit: number;
  144860. /**
  144861. * As the default viewing range might not be enough (if the ambient is really small for instance)
  144862. * You can use the factor to better multiply the final value.
  144863. */
  144864. debugFactor: number;
  144865. /**
  144866. * Initialize the block and prepare the context for build
  144867. * @param state defines the state that will be used for the build
  144868. */
  144869. initialize(state: NodeMaterialBuildState): void;
  144870. /**
  144871. * Gets the current class name
  144872. * @returns the class name
  144873. */
  144874. getClassName(): string;
  144875. /**
  144876. * Gets the world position input component
  144877. */
  144878. get worldPosition(): NodeMaterialConnectionPoint;
  144879. /**
  144880. * Gets the world normal input component
  144881. */
  144882. get worldNormal(): NodeMaterialConnectionPoint;
  144883. /**
  144884. * Gets the perturbed normal input component
  144885. */
  144886. get perturbedNormal(): NodeMaterialConnectionPoint;
  144887. /**
  144888. * Gets the camera position input component
  144889. */
  144890. get cameraPosition(): NodeMaterialConnectionPoint;
  144891. /**
  144892. * Gets the base color input component
  144893. */
  144894. get baseColor(): NodeMaterialConnectionPoint;
  144895. /**
  144896. * Gets the opacity texture input component
  144897. */
  144898. get opacityTexture(): NodeMaterialConnectionPoint;
  144899. /**
  144900. * Gets the ambient color input component
  144901. */
  144902. get ambientColor(): NodeMaterialConnectionPoint;
  144903. /**
  144904. * Gets the reflectivity object parameters
  144905. */
  144906. get reflectivity(): NodeMaterialConnectionPoint;
  144907. /**
  144908. * Gets the ambient occlusion object parameters
  144909. */
  144910. get ambientOcclusion(): NodeMaterialConnectionPoint;
  144911. /**
  144912. * Gets the reflection object parameters
  144913. */
  144914. get reflection(): NodeMaterialConnectionPoint;
  144915. /**
  144916. * Gets the sheen object parameters
  144917. */
  144918. get sheen(): NodeMaterialConnectionPoint;
  144919. /**
  144920. * Gets the clear coat object parameters
  144921. */
  144922. get clearcoat(): NodeMaterialConnectionPoint;
  144923. /**
  144924. * Gets the sub surface object parameters
  144925. */
  144926. get subsurface(): NodeMaterialConnectionPoint;
  144927. /**
  144928. * Gets the anisotropy object parameters
  144929. */
  144930. get anisotropy(): NodeMaterialConnectionPoint;
  144931. /**
  144932. * Gets the ambient output component
  144933. */
  144934. get ambient(): NodeMaterialConnectionPoint;
  144935. /**
  144936. * Gets the diffuse output component
  144937. */
  144938. get diffuse(): NodeMaterialConnectionPoint;
  144939. /**
  144940. * Gets the specular output component
  144941. */
  144942. get specular(): NodeMaterialConnectionPoint;
  144943. /**
  144944. * Gets the sheen output component
  144945. */
  144946. get sheenDir(): NodeMaterialConnectionPoint;
  144947. /**
  144948. * Gets the clear coat output component
  144949. */
  144950. get clearcoatDir(): NodeMaterialConnectionPoint;
  144951. /**
  144952. * Gets the indirect diffuse output component
  144953. */
  144954. get diffuseIndirect(): NodeMaterialConnectionPoint;
  144955. /**
  144956. * Gets the indirect specular output component
  144957. */
  144958. get specularIndirect(): NodeMaterialConnectionPoint;
  144959. /**
  144960. * Gets the indirect sheen output component
  144961. */
  144962. get sheenIndirect(): NodeMaterialConnectionPoint;
  144963. /**
  144964. * Gets the indirect clear coat output component
  144965. */
  144966. get clearcoatIndirect(): NodeMaterialConnectionPoint;
  144967. /**
  144968. * Gets the refraction output component
  144969. */
  144970. get refraction(): NodeMaterialConnectionPoint;
  144971. /**
  144972. * Gets the global lighting output component
  144973. */
  144974. get lighting(): NodeMaterialConnectionPoint;
  144975. /**
  144976. * Gets the shadow output component
  144977. */
  144978. get shadow(): NodeMaterialConnectionPoint;
  144979. /**
  144980. * Gets the alpha output component
  144981. */
  144982. get alpha(): NodeMaterialConnectionPoint;
  144983. autoConfigure(material: NodeMaterial): void;
  144984. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  144985. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  144986. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  144987. private _injectVertexCode;
  144988. /**
  144989. * Gets the code corresponding to the albedo/opacity module
  144990. * @returns the shader code
  144991. */
  144992. getAlbedoOpacityCode(): string;
  144993. protected _buildBlock(state: NodeMaterialBuildState): this;
  144994. protected _dumpPropertiesCode(): string;
  144995. serialize(): any;
  144996. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  144997. }
  144998. }
  144999. declare module BABYLON {
  145000. /**
  145001. * Block used to compute value of one parameter modulo another
  145002. */
  145003. export class ModBlock extends NodeMaterialBlock {
  145004. /**
  145005. * Creates a new ModBlock
  145006. * @param name defines the block name
  145007. */
  145008. constructor(name: string);
  145009. /**
  145010. * Gets the current class name
  145011. * @returns the class name
  145012. */
  145013. getClassName(): string;
  145014. /**
  145015. * Gets the left operand input component
  145016. */
  145017. get left(): NodeMaterialConnectionPoint;
  145018. /**
  145019. * Gets the right operand input component
  145020. */
  145021. get right(): NodeMaterialConnectionPoint;
  145022. /**
  145023. * Gets the output component
  145024. */
  145025. get output(): NodeMaterialConnectionPoint;
  145026. protected _buildBlock(state: NodeMaterialBuildState): this;
  145027. }
  145028. }
  145029. declare module BABYLON {
  145030. /**
  145031. * Configuration for Draco compression
  145032. */
  145033. export interface IDracoCompressionConfiguration {
  145034. /**
  145035. * Configuration for the decoder.
  145036. */
  145037. decoder: {
  145038. /**
  145039. * The url to the WebAssembly module.
  145040. */
  145041. wasmUrl?: string;
  145042. /**
  145043. * The url to the WebAssembly binary.
  145044. */
  145045. wasmBinaryUrl?: string;
  145046. /**
  145047. * The url to the fallback JavaScript module.
  145048. */
  145049. fallbackUrl?: string;
  145050. };
  145051. }
  145052. /**
  145053. * Draco compression (https://google.github.io/draco/)
  145054. *
  145055. * This class wraps the Draco module.
  145056. *
  145057. * **Encoder**
  145058. *
  145059. * The encoder is not currently implemented.
  145060. *
  145061. * **Decoder**
  145062. *
  145063. * 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.
  145064. *
  145065. * To update the configuration, use the following code:
  145066. * ```javascript
  145067. * DracoCompression.Configuration = {
  145068. * decoder: {
  145069. * wasmUrl: "<url to the WebAssembly library>",
  145070. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  145071. * fallbackUrl: "<url to the fallback JavaScript library>",
  145072. * }
  145073. * };
  145074. * ```
  145075. *
  145076. * 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.
  145077. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  145078. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  145079. *
  145080. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  145081. * ```javascript
  145082. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  145083. * ```
  145084. *
  145085. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  145086. */
  145087. export class DracoCompression implements IDisposable {
  145088. private _workerPoolPromise?;
  145089. private _decoderModulePromise?;
  145090. /**
  145091. * The configuration. Defaults to the following urls:
  145092. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  145093. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  145094. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  145095. */
  145096. static Configuration: IDracoCompressionConfiguration;
  145097. /**
  145098. * Returns true if the decoder configuration is available.
  145099. */
  145100. static get DecoderAvailable(): boolean;
  145101. /**
  145102. * Default number of workers to create when creating the draco compression object.
  145103. */
  145104. static DefaultNumWorkers: number;
  145105. private static GetDefaultNumWorkers;
  145106. private static _Default;
  145107. /**
  145108. * Default instance for the draco compression object.
  145109. */
  145110. static get Default(): DracoCompression;
  145111. /**
  145112. * Constructor
  145113. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  145114. */
  145115. constructor(numWorkers?: number);
  145116. /**
  145117. * Stop all async operations and release resources.
  145118. */
  145119. dispose(): void;
  145120. /**
  145121. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  145122. * @returns a promise that resolves when ready
  145123. */
  145124. whenReadyAsync(): Promise<void>;
  145125. /**
  145126. * Decode Draco compressed mesh data to vertex data.
  145127. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  145128. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  145129. * @returns A promise that resolves with the decoded vertex data
  145130. */
  145131. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  145132. [kind: string]: number;
  145133. }): Promise<VertexData>;
  145134. }
  145135. }
  145136. declare module BABYLON {
  145137. /**
  145138. * Class for building Constructive Solid Geometry
  145139. */
  145140. export class CSG {
  145141. private polygons;
  145142. /**
  145143. * The world matrix
  145144. */
  145145. matrix: Matrix;
  145146. /**
  145147. * Stores the position
  145148. */
  145149. position: Vector3;
  145150. /**
  145151. * Stores the rotation
  145152. */
  145153. rotation: Vector3;
  145154. /**
  145155. * Stores the rotation quaternion
  145156. */
  145157. rotationQuaternion: Nullable<Quaternion>;
  145158. /**
  145159. * Stores the scaling vector
  145160. */
  145161. scaling: Vector3;
  145162. /**
  145163. * Convert the Mesh to CSG
  145164. * @param mesh The Mesh to convert to CSG
  145165. * @returns A new CSG from the Mesh
  145166. */
  145167. static FromMesh(mesh: Mesh): CSG;
  145168. /**
  145169. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  145170. * @param polygons Polygons used to construct a CSG solid
  145171. */
  145172. private static FromPolygons;
  145173. /**
  145174. * Clones, or makes a deep copy, of the CSG
  145175. * @returns A new CSG
  145176. */
  145177. clone(): CSG;
  145178. /**
  145179. * Unions this CSG with another CSG
  145180. * @param csg The CSG to union against this CSG
  145181. * @returns The unioned CSG
  145182. */
  145183. union(csg: CSG): CSG;
  145184. /**
  145185. * Unions this CSG with another CSG in place
  145186. * @param csg The CSG to union against this CSG
  145187. */
  145188. unionInPlace(csg: CSG): void;
  145189. /**
  145190. * Subtracts this CSG with another CSG
  145191. * @param csg The CSG to subtract against this CSG
  145192. * @returns A new CSG
  145193. */
  145194. subtract(csg: CSG): CSG;
  145195. /**
  145196. * Subtracts this CSG with another CSG in place
  145197. * @param csg The CSG to subtact against this CSG
  145198. */
  145199. subtractInPlace(csg: CSG): void;
  145200. /**
  145201. * Intersect this CSG with another CSG
  145202. * @param csg The CSG to intersect against this CSG
  145203. * @returns A new CSG
  145204. */
  145205. intersect(csg: CSG): CSG;
  145206. /**
  145207. * Intersects this CSG with another CSG in place
  145208. * @param csg The CSG to intersect against this CSG
  145209. */
  145210. intersectInPlace(csg: CSG): void;
  145211. /**
  145212. * Return a new CSG solid with solid and empty space switched. This solid is
  145213. * not modified.
  145214. * @returns A new CSG solid with solid and empty space switched
  145215. */
  145216. inverse(): CSG;
  145217. /**
  145218. * Inverses the CSG in place
  145219. */
  145220. inverseInPlace(): void;
  145221. /**
  145222. * This is used to keep meshes transformations so they can be restored
  145223. * when we build back a Babylon Mesh
  145224. * NB : All CSG operations are performed in world coordinates
  145225. * @param csg The CSG to copy the transform attributes from
  145226. * @returns This CSG
  145227. */
  145228. copyTransformAttributes(csg: CSG): CSG;
  145229. /**
  145230. * Build Raw mesh from CSG
  145231. * Coordinates here are in world space
  145232. * @param name The name of the mesh geometry
  145233. * @param scene The Scene
  145234. * @param keepSubMeshes Specifies if the submeshes should be kept
  145235. * @returns A new Mesh
  145236. */
  145237. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  145238. /**
  145239. * Build Mesh from CSG taking material and transforms into account
  145240. * @param name The name of the Mesh
  145241. * @param material The material of the Mesh
  145242. * @param scene The Scene
  145243. * @param keepSubMeshes Specifies if submeshes should be kept
  145244. * @returns The new Mesh
  145245. */
  145246. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  145247. }
  145248. }
  145249. declare module BABYLON {
  145250. /**
  145251. * Class used to create a trail following a mesh
  145252. */
  145253. export class TrailMesh extends Mesh {
  145254. private _generator;
  145255. private _autoStart;
  145256. private _running;
  145257. private _diameter;
  145258. private _length;
  145259. private _sectionPolygonPointsCount;
  145260. private _sectionVectors;
  145261. private _sectionNormalVectors;
  145262. private _beforeRenderObserver;
  145263. /**
  145264. * @constructor
  145265. * @param name The value used by scene.getMeshByName() to do a lookup.
  145266. * @param generator The mesh or transform node to generate a trail.
  145267. * @param scene The scene to add this mesh to.
  145268. * @param diameter Diameter of trailing mesh. Default is 1.
  145269. * @param length Length of trailing mesh. Default is 60.
  145270. * @param autoStart Automatically start trailing mesh. Default true.
  145271. */
  145272. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  145273. /**
  145274. * "TrailMesh"
  145275. * @returns "TrailMesh"
  145276. */
  145277. getClassName(): string;
  145278. private _createMesh;
  145279. /**
  145280. * Start trailing mesh.
  145281. */
  145282. start(): void;
  145283. /**
  145284. * Stop trailing mesh.
  145285. */
  145286. stop(): void;
  145287. /**
  145288. * Update trailing mesh geometry.
  145289. */
  145290. update(): void;
  145291. /**
  145292. * Returns a new TrailMesh object.
  145293. * @param name is a string, the name given to the new mesh
  145294. * @param newGenerator use new generator object for cloned trail mesh
  145295. * @returns a new mesh
  145296. */
  145297. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  145298. /**
  145299. * Serializes this trail mesh
  145300. * @param serializationObject object to write serialization to
  145301. */
  145302. serialize(serializationObject: any): void;
  145303. /**
  145304. * Parses a serialized trail mesh
  145305. * @param parsedMesh the serialized mesh
  145306. * @param scene the scene to create the trail mesh in
  145307. * @returns the created trail mesh
  145308. */
  145309. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  145310. }
  145311. }
  145312. declare module BABYLON {
  145313. /**
  145314. * Class containing static functions to help procedurally build meshes
  145315. */
  145316. export class TiledBoxBuilder {
  145317. /**
  145318. * Creates a box mesh
  145319. * 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)
  145320. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  145321. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  145322. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  145323. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  145324. * @param name defines the name of the mesh
  145325. * @param options defines the options used to create the mesh
  145326. * @param scene defines the hosting scene
  145327. * @returns the box mesh
  145328. */
  145329. static CreateTiledBox(name: string, options: {
  145330. pattern?: number;
  145331. width?: number;
  145332. height?: number;
  145333. depth?: number;
  145334. tileSize?: number;
  145335. tileWidth?: number;
  145336. tileHeight?: number;
  145337. alignHorizontal?: number;
  145338. alignVertical?: number;
  145339. faceUV?: Vector4[];
  145340. faceColors?: Color4[];
  145341. sideOrientation?: number;
  145342. updatable?: boolean;
  145343. }, scene?: Nullable<Scene>): Mesh;
  145344. }
  145345. }
  145346. declare module BABYLON {
  145347. /**
  145348. * Class containing static functions to help procedurally build meshes
  145349. */
  145350. export class TorusKnotBuilder {
  145351. /**
  145352. * Creates a torus knot mesh
  145353. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  145354. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  145355. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  145356. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  145357. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  145358. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  145359. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  145360. * @param name defines the name of the mesh
  145361. * @param options defines the options used to create the mesh
  145362. * @param scene defines the hosting scene
  145363. * @returns the torus knot mesh
  145364. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  145365. */
  145366. static CreateTorusKnot(name: string, options: {
  145367. radius?: number;
  145368. tube?: number;
  145369. radialSegments?: number;
  145370. tubularSegments?: number;
  145371. p?: number;
  145372. q?: number;
  145373. updatable?: boolean;
  145374. sideOrientation?: number;
  145375. frontUVs?: Vector4;
  145376. backUVs?: Vector4;
  145377. }, scene: any): Mesh;
  145378. }
  145379. }
  145380. declare module BABYLON {
  145381. /**
  145382. * Polygon
  145383. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  145384. */
  145385. export class Polygon {
  145386. /**
  145387. * Creates a rectangle
  145388. * @param xmin bottom X coord
  145389. * @param ymin bottom Y coord
  145390. * @param xmax top X coord
  145391. * @param ymax top Y coord
  145392. * @returns points that make the resulting rectation
  145393. */
  145394. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  145395. /**
  145396. * Creates a circle
  145397. * @param radius radius of circle
  145398. * @param cx scale in x
  145399. * @param cy scale in y
  145400. * @param numberOfSides number of sides that make up the circle
  145401. * @returns points that make the resulting circle
  145402. */
  145403. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  145404. /**
  145405. * Creates a polygon from input string
  145406. * @param input Input polygon data
  145407. * @returns the parsed points
  145408. */
  145409. static Parse(input: string): Vector2[];
  145410. /**
  145411. * Starts building a polygon from x and y coordinates
  145412. * @param x x coordinate
  145413. * @param y y coordinate
  145414. * @returns the started path2
  145415. */
  145416. static StartingAt(x: number, y: number): Path2;
  145417. }
  145418. /**
  145419. * Builds a polygon
  145420. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  145421. */
  145422. export class PolygonMeshBuilder {
  145423. private _points;
  145424. private _outlinepoints;
  145425. private _holes;
  145426. private _name;
  145427. private _scene;
  145428. private _epoints;
  145429. private _eholes;
  145430. private _addToepoint;
  145431. /**
  145432. * Babylon reference to the earcut plugin.
  145433. */
  145434. bjsEarcut: any;
  145435. /**
  145436. * Creates a PolygonMeshBuilder
  145437. * @param name name of the builder
  145438. * @param contours Path of the polygon
  145439. * @param scene scene to add to when creating the mesh
  145440. * @param earcutInjection can be used to inject your own earcut reference
  145441. */
  145442. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  145443. /**
  145444. * Adds a whole within the polygon
  145445. * @param hole Array of points defining the hole
  145446. * @returns this
  145447. */
  145448. addHole(hole: Vector2[]): PolygonMeshBuilder;
  145449. /**
  145450. * Creates the polygon
  145451. * @param updatable If the mesh should be updatable
  145452. * @param depth The depth of the mesh created
  145453. * @returns the created mesh
  145454. */
  145455. build(updatable?: boolean, depth?: number): Mesh;
  145456. /**
  145457. * Creates the polygon
  145458. * @param depth The depth of the mesh created
  145459. * @returns the created VertexData
  145460. */
  145461. buildVertexData(depth?: number): VertexData;
  145462. /**
  145463. * Adds a side to the polygon
  145464. * @param positions points that make the polygon
  145465. * @param normals normals of the polygon
  145466. * @param uvs uvs of the polygon
  145467. * @param indices indices of the polygon
  145468. * @param bounds bounds of the polygon
  145469. * @param points points of the polygon
  145470. * @param depth depth of the polygon
  145471. * @param flip flip of the polygon
  145472. */
  145473. private addSide;
  145474. }
  145475. }
  145476. declare module BABYLON {
  145477. /**
  145478. * Class containing static functions to help procedurally build meshes
  145479. */
  145480. export class PolygonBuilder {
  145481. /**
  145482. * Creates a polygon mesh
  145483. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  145484. * * 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
  145485. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  145486. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  145487. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  145488. * * Remember you can only change the shape positions, not their number when updating a polygon
  145489. * @param name defines the name of the mesh
  145490. * @param options defines the options used to create the mesh
  145491. * @param scene defines the hosting scene
  145492. * @param earcutInjection can be used to inject your own earcut reference
  145493. * @returns the polygon mesh
  145494. */
  145495. static CreatePolygon(name: string, options: {
  145496. shape: Vector3[];
  145497. holes?: Vector3[][];
  145498. depth?: number;
  145499. faceUV?: Vector4[];
  145500. faceColors?: Color4[];
  145501. updatable?: boolean;
  145502. sideOrientation?: number;
  145503. frontUVs?: Vector4;
  145504. backUVs?: Vector4;
  145505. wrap?: boolean;
  145506. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  145507. /**
  145508. * Creates an extruded polygon mesh, with depth in the Y direction.
  145509. * * 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)
  145510. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  145511. * @param name defines the name of the mesh
  145512. * @param options defines the options used to create the mesh
  145513. * @param scene defines the hosting scene
  145514. * @param earcutInjection can be used to inject your own earcut reference
  145515. * @returns the polygon mesh
  145516. */
  145517. static ExtrudePolygon(name: string, options: {
  145518. shape: Vector3[];
  145519. holes?: Vector3[][];
  145520. depth?: number;
  145521. faceUV?: Vector4[];
  145522. faceColors?: Color4[];
  145523. updatable?: boolean;
  145524. sideOrientation?: number;
  145525. frontUVs?: Vector4;
  145526. backUVs?: Vector4;
  145527. wrap?: boolean;
  145528. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  145529. }
  145530. }
  145531. declare module BABYLON {
  145532. /**
  145533. * Class containing static functions to help procedurally build meshes
  145534. */
  145535. export class LatheBuilder {
  145536. /**
  145537. * Creates lathe mesh.
  145538. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  145539. * * 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
  145540. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  145541. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  145542. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  145543. * * 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
  145544. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  145545. * * 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
  145546. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  145547. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  145548. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  145549. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  145550. * @param name defines the name of the mesh
  145551. * @param options defines the options used to create the mesh
  145552. * @param scene defines the hosting scene
  145553. * @returns the lathe mesh
  145554. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  145555. */
  145556. static CreateLathe(name: string, options: {
  145557. shape: Vector3[];
  145558. radius?: number;
  145559. tessellation?: number;
  145560. clip?: number;
  145561. arc?: number;
  145562. closed?: boolean;
  145563. updatable?: boolean;
  145564. sideOrientation?: number;
  145565. frontUVs?: Vector4;
  145566. backUVs?: Vector4;
  145567. cap?: number;
  145568. invertUV?: boolean;
  145569. }, scene?: Nullable<Scene>): Mesh;
  145570. }
  145571. }
  145572. declare module BABYLON {
  145573. /**
  145574. * Class containing static functions to help procedurally build meshes
  145575. */
  145576. export class TiledPlaneBuilder {
  145577. /**
  145578. * Creates a tiled plane mesh
  145579. * * The parameter `pattern` will, depending on value, do nothing or
  145580. * * * flip (reflect about central vertical) alternate tiles across and up
  145581. * * * flip every tile on alternate rows
  145582. * * * rotate (180 degs) alternate tiles across and up
  145583. * * * rotate every tile on alternate rows
  145584. * * * flip and rotate alternate tiles across and up
  145585. * * * flip and rotate every tile on alternate rows
  145586. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  145587. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  145588. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  145589. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  145590. * * 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)
  145591. * * 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)
  145592. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  145593. * @param name defines the name of the mesh
  145594. * @param options defines the options used to create the mesh
  145595. * @param scene defines the hosting scene
  145596. * @returns the box mesh
  145597. */
  145598. static CreateTiledPlane(name: string, options: {
  145599. pattern?: number;
  145600. tileSize?: number;
  145601. tileWidth?: number;
  145602. tileHeight?: number;
  145603. size?: number;
  145604. width?: number;
  145605. height?: number;
  145606. alignHorizontal?: number;
  145607. alignVertical?: number;
  145608. sideOrientation?: number;
  145609. frontUVs?: Vector4;
  145610. backUVs?: Vector4;
  145611. updatable?: boolean;
  145612. }, scene?: Nullable<Scene>): Mesh;
  145613. }
  145614. }
  145615. declare module BABYLON {
  145616. /**
  145617. * Class containing static functions to help procedurally build meshes
  145618. */
  145619. export class TubeBuilder {
  145620. /**
  145621. * Creates a tube mesh.
  145622. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  145623. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  145624. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  145625. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  145626. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  145627. * * 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)
  145628. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  145629. * * 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
  145630. * * 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
  145631. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  145632. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  145633. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  145634. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  145635. * @param name defines the name of the mesh
  145636. * @param options defines the options used to create the mesh
  145637. * @param scene defines the hosting scene
  145638. * @returns the tube mesh
  145639. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  145640. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  145641. */
  145642. static CreateTube(name: string, options: {
  145643. path: Vector3[];
  145644. radius?: number;
  145645. tessellation?: number;
  145646. radiusFunction?: {
  145647. (i: number, distance: number): number;
  145648. };
  145649. cap?: number;
  145650. arc?: number;
  145651. updatable?: boolean;
  145652. sideOrientation?: number;
  145653. frontUVs?: Vector4;
  145654. backUVs?: Vector4;
  145655. instance?: Mesh;
  145656. invertUV?: boolean;
  145657. }, scene?: Nullable<Scene>): Mesh;
  145658. }
  145659. }
  145660. declare module BABYLON {
  145661. /**
  145662. * Class containing static functions to help procedurally build meshes
  145663. */
  145664. export class IcoSphereBuilder {
  145665. /**
  145666. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  145667. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  145668. * * 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`)
  145669. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  145670. * * 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
  145671. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  145672. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  145673. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  145674. * @param name defines the name of the mesh
  145675. * @param options defines the options used to create the mesh
  145676. * @param scene defines the hosting scene
  145677. * @returns the icosahedron mesh
  145678. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  145679. */
  145680. static CreateIcoSphere(name: string, options: {
  145681. radius?: number;
  145682. radiusX?: number;
  145683. radiusY?: number;
  145684. radiusZ?: number;
  145685. flat?: boolean;
  145686. subdivisions?: number;
  145687. sideOrientation?: number;
  145688. frontUVs?: Vector4;
  145689. backUVs?: Vector4;
  145690. updatable?: boolean;
  145691. }, scene?: Nullable<Scene>): Mesh;
  145692. }
  145693. }
  145694. declare module BABYLON {
  145695. /**
  145696. * Class containing static functions to help procedurally build meshes
  145697. */
  145698. export class DecalBuilder {
  145699. /**
  145700. * Creates a decal mesh.
  145701. * 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
  145702. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  145703. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  145704. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  145705. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  145706. * @param name defines the name of the mesh
  145707. * @param sourceMesh defines the mesh where the decal must be applied
  145708. * @param options defines the options used to create the mesh
  145709. * @param scene defines the hosting scene
  145710. * @returns the decal mesh
  145711. * @see https://doc.babylonjs.com/how_to/decals
  145712. */
  145713. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  145714. position?: Vector3;
  145715. normal?: Vector3;
  145716. size?: Vector3;
  145717. angle?: number;
  145718. }): Mesh;
  145719. }
  145720. }
  145721. declare module BABYLON {
  145722. /**
  145723. * Class containing static functions to help procedurally build meshes
  145724. */
  145725. export class MeshBuilder {
  145726. /**
  145727. * Creates a box mesh
  145728. * * The parameter `size` sets the size (float) of each box side (default 1)
  145729. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  145730. * * 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)
  145731. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  145732. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  145733. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  145734. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  145735. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  145736. * @param name defines the name of the mesh
  145737. * @param options defines the options used to create the mesh
  145738. * @param scene defines the hosting scene
  145739. * @returns the box mesh
  145740. */
  145741. static CreateBox(name: string, options: {
  145742. size?: number;
  145743. width?: number;
  145744. height?: number;
  145745. depth?: number;
  145746. faceUV?: Vector4[];
  145747. faceColors?: Color4[];
  145748. sideOrientation?: number;
  145749. frontUVs?: Vector4;
  145750. backUVs?: Vector4;
  145751. wrap?: boolean;
  145752. topBaseAt?: number;
  145753. bottomBaseAt?: number;
  145754. updatable?: boolean;
  145755. }, scene?: Nullable<Scene>): Mesh;
  145756. /**
  145757. * Creates a tiled box mesh
  145758. * * faceTiles sets the pattern, tile size and number of tiles for a face
  145759. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  145760. * @param name defines the name of the mesh
  145761. * @param options defines the options used to create the mesh
  145762. * @param scene defines the hosting scene
  145763. * @returns the tiled box mesh
  145764. */
  145765. static CreateTiledBox(name: string, options: {
  145766. pattern?: number;
  145767. size?: number;
  145768. width?: number;
  145769. height?: number;
  145770. depth: number;
  145771. tileSize?: number;
  145772. tileWidth?: number;
  145773. tileHeight?: number;
  145774. faceUV?: Vector4[];
  145775. faceColors?: Color4[];
  145776. alignHorizontal?: number;
  145777. alignVertical?: number;
  145778. sideOrientation?: number;
  145779. updatable?: boolean;
  145780. }, scene?: Nullable<Scene>): Mesh;
  145781. /**
  145782. * Creates a sphere mesh
  145783. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  145784. * * 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`)
  145785. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  145786. * * 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
  145787. * * 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)
  145788. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  145789. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  145790. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  145791. * @param name defines the name of the mesh
  145792. * @param options defines the options used to create the mesh
  145793. * @param scene defines the hosting scene
  145794. * @returns the sphere mesh
  145795. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  145796. */
  145797. static CreateSphere(name: string, options: {
  145798. segments?: number;
  145799. diameter?: number;
  145800. diameterX?: number;
  145801. diameterY?: number;
  145802. diameterZ?: number;
  145803. arc?: number;
  145804. slice?: number;
  145805. sideOrientation?: number;
  145806. frontUVs?: Vector4;
  145807. backUVs?: Vector4;
  145808. updatable?: boolean;
  145809. }, scene?: Nullable<Scene>): Mesh;
  145810. /**
  145811. * Creates a plane polygonal mesh. By default, this is a disc
  145812. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  145813. * * 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
  145814. * * 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
  145815. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  145816. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  145817. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  145818. * @param name defines the name of the mesh
  145819. * @param options defines the options used to create the mesh
  145820. * @param scene defines the hosting scene
  145821. * @returns the plane polygonal mesh
  145822. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  145823. */
  145824. static CreateDisc(name: string, options: {
  145825. radius?: number;
  145826. tessellation?: number;
  145827. arc?: number;
  145828. updatable?: boolean;
  145829. sideOrientation?: number;
  145830. frontUVs?: Vector4;
  145831. backUVs?: Vector4;
  145832. }, scene?: Nullable<Scene>): Mesh;
  145833. /**
  145834. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  145835. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  145836. * * 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`)
  145837. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  145838. * * 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
  145839. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  145840. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  145841. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  145842. * @param name defines the name of the mesh
  145843. * @param options defines the options used to create the mesh
  145844. * @param scene defines the hosting scene
  145845. * @returns the icosahedron mesh
  145846. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  145847. */
  145848. static CreateIcoSphere(name: string, options: {
  145849. radius?: number;
  145850. radiusX?: number;
  145851. radiusY?: number;
  145852. radiusZ?: number;
  145853. flat?: boolean;
  145854. subdivisions?: number;
  145855. sideOrientation?: number;
  145856. frontUVs?: Vector4;
  145857. backUVs?: Vector4;
  145858. updatable?: boolean;
  145859. }, scene?: Nullable<Scene>): Mesh;
  145860. /**
  145861. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  145862. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  145863. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  145864. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  145865. * * 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
  145866. * * 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
  145867. * * 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
  145868. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  145869. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  145870. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  145871. * * 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
  145872. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  145873. * * 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
  145874. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  145875. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  145876. * @param name defines the name of the mesh
  145877. * @param options defines the options used to create the mesh
  145878. * @param scene defines the hosting scene
  145879. * @returns the ribbon mesh
  145880. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  145881. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  145882. */
  145883. static CreateRibbon(name: string, options: {
  145884. pathArray: Vector3[][];
  145885. closeArray?: boolean;
  145886. closePath?: boolean;
  145887. offset?: number;
  145888. updatable?: boolean;
  145889. sideOrientation?: number;
  145890. frontUVs?: Vector4;
  145891. backUVs?: Vector4;
  145892. instance?: Mesh;
  145893. invertUV?: boolean;
  145894. uvs?: Vector2[];
  145895. colors?: Color4[];
  145896. }, scene?: Nullable<Scene>): Mesh;
  145897. /**
  145898. * Creates a cylinder or a cone mesh
  145899. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  145900. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  145901. * * 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.
  145902. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  145903. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  145904. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  145905. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  145906. * * 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).
  145907. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  145908. * * 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).
  145909. * * 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
  145910. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  145911. * * 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
  145912. * * 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.
  145913. * * If `enclose` is false, a ring surface is one element.
  145914. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  145915. * * 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
  145916. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  145917. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  145918. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  145919. * @param name defines the name of the mesh
  145920. * @param options defines the options used to create the mesh
  145921. * @param scene defines the hosting scene
  145922. * @returns the cylinder mesh
  145923. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  145924. */
  145925. static CreateCylinder(name: string, options: {
  145926. height?: number;
  145927. diameterTop?: number;
  145928. diameterBottom?: number;
  145929. diameter?: number;
  145930. tessellation?: number;
  145931. subdivisions?: number;
  145932. arc?: number;
  145933. faceColors?: Color4[];
  145934. faceUV?: Vector4[];
  145935. updatable?: boolean;
  145936. hasRings?: boolean;
  145937. enclose?: boolean;
  145938. cap?: number;
  145939. sideOrientation?: number;
  145940. frontUVs?: Vector4;
  145941. backUVs?: Vector4;
  145942. }, scene?: Nullable<Scene>): Mesh;
  145943. /**
  145944. * Creates a torus mesh
  145945. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  145946. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  145947. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  145948. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  145949. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  145950. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  145951. * @param name defines the name of the mesh
  145952. * @param options defines the options used to create the mesh
  145953. * @param scene defines the hosting scene
  145954. * @returns the torus mesh
  145955. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  145956. */
  145957. static CreateTorus(name: string, options: {
  145958. diameter?: number;
  145959. thickness?: number;
  145960. tessellation?: number;
  145961. updatable?: boolean;
  145962. sideOrientation?: number;
  145963. frontUVs?: Vector4;
  145964. backUVs?: Vector4;
  145965. }, scene?: Nullable<Scene>): Mesh;
  145966. /**
  145967. * Creates a torus knot mesh
  145968. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  145969. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  145970. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  145971. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  145972. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  145973. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  145974. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  145975. * @param name defines the name of the mesh
  145976. * @param options defines the options used to create the mesh
  145977. * @param scene defines the hosting scene
  145978. * @returns the torus knot mesh
  145979. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  145980. */
  145981. static CreateTorusKnot(name: string, options: {
  145982. radius?: number;
  145983. tube?: number;
  145984. radialSegments?: number;
  145985. tubularSegments?: number;
  145986. p?: number;
  145987. q?: number;
  145988. updatable?: boolean;
  145989. sideOrientation?: number;
  145990. frontUVs?: Vector4;
  145991. backUVs?: Vector4;
  145992. }, scene?: Nullable<Scene>): Mesh;
  145993. /**
  145994. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  145995. * * 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
  145996. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  145997. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  145998. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  145999. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  146000. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  146001. * * 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
  146002. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  146003. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  146004. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  146005. * @param name defines the name of the new line system
  146006. * @param options defines the options used to create the line system
  146007. * @param scene defines the hosting scene
  146008. * @returns a new line system mesh
  146009. */
  146010. static CreateLineSystem(name: string, options: {
  146011. lines: Vector3[][];
  146012. updatable?: boolean;
  146013. instance?: Nullable<LinesMesh>;
  146014. colors?: Nullable<Color4[][]>;
  146015. useVertexAlpha?: boolean;
  146016. }, scene: Nullable<Scene>): LinesMesh;
  146017. /**
  146018. * Creates a line mesh
  146019. * 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
  146020. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  146021. * * The parameter `points` is an array successive Vector3
  146022. * * 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
  146023. * * The optional parameter `colors` is an array of successive Color4, one per line point
  146024. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  146025. * * When updating an instance, remember that only point positions can change, not the number of points
  146026. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  146027. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  146028. * @param name defines the name of the new line system
  146029. * @param options defines the options used to create the line system
  146030. * @param scene defines the hosting scene
  146031. * @returns a new line mesh
  146032. */
  146033. static CreateLines(name: string, options: {
  146034. points: Vector3[];
  146035. updatable?: boolean;
  146036. instance?: Nullable<LinesMesh>;
  146037. colors?: Color4[];
  146038. useVertexAlpha?: boolean;
  146039. }, scene?: Nullable<Scene>): LinesMesh;
  146040. /**
  146041. * Creates a dashed line mesh
  146042. * * 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
  146043. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  146044. * * The parameter `points` is an array successive Vector3
  146045. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  146046. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  146047. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  146048. * * 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
  146049. * * When updating an instance, remember that only point positions can change, not the number of points
  146050. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  146051. * @param name defines the name of the mesh
  146052. * @param options defines the options used to create the mesh
  146053. * @param scene defines the hosting scene
  146054. * @returns the dashed line mesh
  146055. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  146056. */
  146057. static CreateDashedLines(name: string, options: {
  146058. points: Vector3[];
  146059. dashSize?: number;
  146060. gapSize?: number;
  146061. dashNb?: number;
  146062. updatable?: boolean;
  146063. instance?: LinesMesh;
  146064. }, scene?: Nullable<Scene>): LinesMesh;
  146065. /**
  146066. * 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.
  146067. * * 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.
  146068. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  146069. * * 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.
  146070. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  146071. * * 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
  146072. * * 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
  146073. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  146074. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  146075. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  146076. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  146077. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  146078. * @param name defines the name of the mesh
  146079. * @param options defines the options used to create the mesh
  146080. * @param scene defines the hosting scene
  146081. * @returns the extruded shape mesh
  146082. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  146083. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  146084. */
  146085. static ExtrudeShape(name: string, options: {
  146086. shape: Vector3[];
  146087. path: Vector3[];
  146088. scale?: number;
  146089. rotation?: number;
  146090. cap?: number;
  146091. updatable?: boolean;
  146092. sideOrientation?: number;
  146093. frontUVs?: Vector4;
  146094. backUVs?: Vector4;
  146095. instance?: Mesh;
  146096. invertUV?: boolean;
  146097. }, scene?: Nullable<Scene>): Mesh;
  146098. /**
  146099. * Creates an custom extruded shape mesh.
  146100. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  146101. * * 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.
  146102. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  146103. * * 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
  146104. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  146105. * * 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
  146106. * * It must returns a float value that will be the scale value applied to the shape on each path point
  146107. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  146108. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  146109. * * 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
  146110. * * 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
  146111. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  146112. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  146113. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  146114. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  146115. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  146116. * @param name defines the name of the mesh
  146117. * @param options defines the options used to create the mesh
  146118. * @param scene defines the hosting scene
  146119. * @returns the custom extruded shape mesh
  146120. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  146121. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  146122. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  146123. */
  146124. static ExtrudeShapeCustom(name: string, options: {
  146125. shape: Vector3[];
  146126. path: Vector3[];
  146127. scaleFunction?: any;
  146128. rotationFunction?: any;
  146129. ribbonCloseArray?: boolean;
  146130. ribbonClosePath?: boolean;
  146131. cap?: number;
  146132. updatable?: boolean;
  146133. sideOrientation?: number;
  146134. frontUVs?: Vector4;
  146135. backUVs?: Vector4;
  146136. instance?: Mesh;
  146137. invertUV?: boolean;
  146138. }, scene?: Nullable<Scene>): Mesh;
  146139. /**
  146140. * Creates lathe mesh.
  146141. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  146142. * * 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
  146143. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  146144. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  146145. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  146146. * * 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
  146147. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  146148. * * 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
  146149. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  146150. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  146151. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  146152. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  146153. * @param name defines the name of the mesh
  146154. * @param options defines the options used to create the mesh
  146155. * @param scene defines the hosting scene
  146156. * @returns the lathe mesh
  146157. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  146158. */
  146159. static CreateLathe(name: string, options: {
  146160. shape: Vector3[];
  146161. radius?: number;
  146162. tessellation?: number;
  146163. clip?: number;
  146164. arc?: number;
  146165. closed?: boolean;
  146166. updatable?: boolean;
  146167. sideOrientation?: number;
  146168. frontUVs?: Vector4;
  146169. backUVs?: Vector4;
  146170. cap?: number;
  146171. invertUV?: boolean;
  146172. }, scene?: Nullable<Scene>): Mesh;
  146173. /**
  146174. * Creates a tiled plane mesh
  146175. * * You can set a limited pattern arrangement with the tiles
  146176. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  146177. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  146178. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  146179. * @param name defines the name of the mesh
  146180. * @param options defines the options used to create the mesh
  146181. * @param scene defines the hosting scene
  146182. * @returns the plane mesh
  146183. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  146184. */
  146185. static CreateTiledPlane(name: string, options: {
  146186. pattern?: number;
  146187. tileSize?: number;
  146188. tileWidth?: number;
  146189. tileHeight?: number;
  146190. size?: number;
  146191. width?: number;
  146192. height?: number;
  146193. alignHorizontal?: number;
  146194. alignVertical?: number;
  146195. sideOrientation?: number;
  146196. frontUVs?: Vector4;
  146197. backUVs?: Vector4;
  146198. updatable?: boolean;
  146199. }, scene?: Nullable<Scene>): Mesh;
  146200. /**
  146201. * Creates a plane mesh
  146202. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  146203. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  146204. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  146205. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  146206. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  146207. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  146208. * @param name defines the name of the mesh
  146209. * @param options defines the options used to create the mesh
  146210. * @param scene defines the hosting scene
  146211. * @returns the plane mesh
  146212. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  146213. */
  146214. static CreatePlane(name: string, options: {
  146215. size?: number;
  146216. width?: number;
  146217. height?: number;
  146218. sideOrientation?: number;
  146219. frontUVs?: Vector4;
  146220. backUVs?: Vector4;
  146221. updatable?: boolean;
  146222. sourcePlane?: Plane;
  146223. }, scene?: Nullable<Scene>): Mesh;
  146224. /**
  146225. * Creates a ground mesh
  146226. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  146227. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  146228. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  146229. * @param name defines the name of the mesh
  146230. * @param options defines the options used to create the mesh
  146231. * @param scene defines the hosting scene
  146232. * @returns the ground mesh
  146233. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  146234. */
  146235. static CreateGround(name: string, options: {
  146236. width?: number;
  146237. height?: number;
  146238. subdivisions?: number;
  146239. subdivisionsX?: number;
  146240. subdivisionsY?: number;
  146241. updatable?: boolean;
  146242. }, scene?: Nullable<Scene>): Mesh;
  146243. /**
  146244. * Creates a tiled ground mesh
  146245. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  146246. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  146247. * * 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
  146248. * * 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
  146249. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  146250. * @param name defines the name of the mesh
  146251. * @param options defines the options used to create the mesh
  146252. * @param scene defines the hosting scene
  146253. * @returns the tiled ground mesh
  146254. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  146255. */
  146256. static CreateTiledGround(name: string, options: {
  146257. xmin: number;
  146258. zmin: number;
  146259. xmax: number;
  146260. zmax: number;
  146261. subdivisions?: {
  146262. w: number;
  146263. h: number;
  146264. };
  146265. precision?: {
  146266. w: number;
  146267. h: number;
  146268. };
  146269. updatable?: boolean;
  146270. }, scene?: Nullable<Scene>): Mesh;
  146271. /**
  146272. * Creates a ground mesh from a height map
  146273. * * The parameter `url` sets the URL of the height map image resource.
  146274. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  146275. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  146276. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  146277. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  146278. * * 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.
  146279. * * 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).
  146280. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  146281. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  146282. * @param name defines the name of the mesh
  146283. * @param url defines the url to the height map
  146284. * @param options defines the options used to create the mesh
  146285. * @param scene defines the hosting scene
  146286. * @returns the ground mesh
  146287. * @see https://doc.babylonjs.com/babylon101/height_map
  146288. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  146289. */
  146290. static CreateGroundFromHeightMap(name: string, url: string, options: {
  146291. width?: number;
  146292. height?: number;
  146293. subdivisions?: number;
  146294. minHeight?: number;
  146295. maxHeight?: number;
  146296. colorFilter?: Color3;
  146297. alphaFilter?: number;
  146298. updatable?: boolean;
  146299. onReady?: (mesh: GroundMesh) => void;
  146300. }, scene?: Nullable<Scene>): GroundMesh;
  146301. /**
  146302. * Creates a polygon mesh
  146303. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  146304. * * 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
  146305. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  146306. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  146307. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  146308. * * Remember you can only change the shape positions, not their number when updating a polygon
  146309. * @param name defines the name of the mesh
  146310. * @param options defines the options used to create the mesh
  146311. * @param scene defines the hosting scene
  146312. * @param earcutInjection can be used to inject your own earcut reference
  146313. * @returns the polygon mesh
  146314. */
  146315. static CreatePolygon(name: string, options: {
  146316. shape: Vector3[];
  146317. holes?: Vector3[][];
  146318. depth?: number;
  146319. faceUV?: Vector4[];
  146320. faceColors?: Color4[];
  146321. updatable?: boolean;
  146322. sideOrientation?: number;
  146323. frontUVs?: Vector4;
  146324. backUVs?: Vector4;
  146325. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  146326. /**
  146327. * Creates an extruded polygon mesh, with depth in the Y direction.
  146328. * * 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)
  146329. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  146330. * @param name defines the name of the mesh
  146331. * @param options defines the options used to create the mesh
  146332. * @param scene defines the hosting scene
  146333. * @param earcutInjection can be used to inject your own earcut reference
  146334. * @returns the polygon mesh
  146335. */
  146336. static ExtrudePolygon(name: string, options: {
  146337. shape: Vector3[];
  146338. holes?: Vector3[][];
  146339. depth?: number;
  146340. faceUV?: Vector4[];
  146341. faceColors?: Color4[];
  146342. updatable?: boolean;
  146343. sideOrientation?: number;
  146344. frontUVs?: Vector4;
  146345. backUVs?: Vector4;
  146346. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  146347. /**
  146348. * Creates a tube mesh.
  146349. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  146350. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  146351. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  146352. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  146353. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  146354. * * 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)
  146355. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  146356. * * 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
  146357. * * 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
  146358. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  146359. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  146360. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  146361. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  146362. * @param name defines the name of the mesh
  146363. * @param options defines the options used to create the mesh
  146364. * @param scene defines the hosting scene
  146365. * @returns the tube mesh
  146366. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  146367. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  146368. */
  146369. static CreateTube(name: string, options: {
  146370. path: Vector3[];
  146371. radius?: number;
  146372. tessellation?: number;
  146373. radiusFunction?: {
  146374. (i: number, distance: number): number;
  146375. };
  146376. cap?: number;
  146377. arc?: number;
  146378. updatable?: boolean;
  146379. sideOrientation?: number;
  146380. frontUVs?: Vector4;
  146381. backUVs?: Vector4;
  146382. instance?: Mesh;
  146383. invertUV?: boolean;
  146384. }, scene?: Nullable<Scene>): Mesh;
  146385. /**
  146386. * Creates a polyhedron mesh
  146387. * * 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
  146388. * * The parameter `size` (positive float, default 1) sets the polygon size
  146389. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  146390. * * 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`
  146391. * * 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
  146392. * * 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)`)
  146393. * * 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
  146394. * * 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
  146395. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  146396. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  146397. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  146398. * @param name defines the name of the mesh
  146399. * @param options defines the options used to create the mesh
  146400. * @param scene defines the hosting scene
  146401. * @returns the polyhedron mesh
  146402. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  146403. */
  146404. static CreatePolyhedron(name: string, options: {
  146405. type?: number;
  146406. size?: number;
  146407. sizeX?: number;
  146408. sizeY?: number;
  146409. sizeZ?: number;
  146410. custom?: any;
  146411. faceUV?: Vector4[];
  146412. faceColors?: Color4[];
  146413. flat?: boolean;
  146414. updatable?: boolean;
  146415. sideOrientation?: number;
  146416. frontUVs?: Vector4;
  146417. backUVs?: Vector4;
  146418. }, scene?: Nullable<Scene>): Mesh;
  146419. /**
  146420. * Creates a decal mesh.
  146421. * 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
  146422. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  146423. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  146424. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  146425. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  146426. * @param name defines the name of the mesh
  146427. * @param sourceMesh defines the mesh where the decal must be applied
  146428. * @param options defines the options used to create the mesh
  146429. * @param scene defines the hosting scene
  146430. * @returns the decal mesh
  146431. * @see https://doc.babylonjs.com/how_to/decals
  146432. */
  146433. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  146434. position?: Vector3;
  146435. normal?: Vector3;
  146436. size?: Vector3;
  146437. angle?: number;
  146438. }): Mesh;
  146439. /**
  146440. * Creates a Capsule Mesh
  146441. * @param name defines the name of the mesh.
  146442. * @param options the constructors options used to shape the mesh.
  146443. * @param scene defines the scene the mesh is scoped to.
  146444. * @returns the capsule mesh
  146445. * @see https://doc.babylonjs.com/how_to/capsule_shape
  146446. */
  146447. static CreateCapsule(name: string, options?: ICreateCapsuleOptions, scene?: Nullable<Scene>): Mesh;
  146448. }
  146449. }
  146450. declare module BABYLON {
  146451. /**
  146452. * A simplifier interface for future simplification implementations
  146453. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  146454. */
  146455. export interface ISimplifier {
  146456. /**
  146457. * Simplification of a given mesh according to the given settings.
  146458. * Since this requires computation, it is assumed that the function runs async.
  146459. * @param settings The settings of the simplification, including quality and distance
  146460. * @param successCallback A callback that will be called after the mesh was simplified.
  146461. * @param errorCallback in case of an error, this callback will be called. optional.
  146462. */
  146463. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  146464. }
  146465. /**
  146466. * Expected simplification settings.
  146467. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  146468. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  146469. */
  146470. export interface ISimplificationSettings {
  146471. /**
  146472. * Gets or sets the expected quality
  146473. */
  146474. quality: number;
  146475. /**
  146476. * Gets or sets the distance when this optimized version should be used
  146477. */
  146478. distance: number;
  146479. /**
  146480. * Gets an already optimized mesh
  146481. */
  146482. optimizeMesh?: boolean;
  146483. }
  146484. /**
  146485. * Class used to specify simplification options
  146486. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  146487. */
  146488. export class SimplificationSettings implements ISimplificationSettings {
  146489. /** expected quality */
  146490. quality: number;
  146491. /** distance when this optimized version should be used */
  146492. distance: number;
  146493. /** already optimized mesh */
  146494. optimizeMesh?: boolean | undefined;
  146495. /**
  146496. * Creates a SimplificationSettings
  146497. * @param quality expected quality
  146498. * @param distance distance when this optimized version should be used
  146499. * @param optimizeMesh already optimized mesh
  146500. */
  146501. constructor(
  146502. /** expected quality */
  146503. quality: number,
  146504. /** distance when this optimized version should be used */
  146505. distance: number,
  146506. /** already optimized mesh */
  146507. optimizeMesh?: boolean | undefined);
  146508. }
  146509. /**
  146510. * Interface used to define a simplification task
  146511. */
  146512. export interface ISimplificationTask {
  146513. /**
  146514. * Array of settings
  146515. */
  146516. settings: Array<ISimplificationSettings>;
  146517. /**
  146518. * Simplification type
  146519. */
  146520. simplificationType: SimplificationType;
  146521. /**
  146522. * Mesh to simplify
  146523. */
  146524. mesh: Mesh;
  146525. /**
  146526. * Callback called on success
  146527. */
  146528. successCallback?: () => void;
  146529. /**
  146530. * Defines if parallel processing can be used
  146531. */
  146532. parallelProcessing: boolean;
  146533. }
  146534. /**
  146535. * Queue used to order the simplification tasks
  146536. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  146537. */
  146538. export class SimplificationQueue {
  146539. private _simplificationArray;
  146540. /**
  146541. * Gets a boolean indicating that the process is still running
  146542. */
  146543. running: boolean;
  146544. /**
  146545. * Creates a new queue
  146546. */
  146547. constructor();
  146548. /**
  146549. * Adds a new simplification task
  146550. * @param task defines a task to add
  146551. */
  146552. addTask(task: ISimplificationTask): void;
  146553. /**
  146554. * Execute next task
  146555. */
  146556. executeNext(): void;
  146557. /**
  146558. * Execute a simplification task
  146559. * @param task defines the task to run
  146560. */
  146561. runSimplification(task: ISimplificationTask): void;
  146562. private getSimplifier;
  146563. }
  146564. /**
  146565. * The implemented types of simplification
  146566. * At the moment only Quadratic Error Decimation is implemented
  146567. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  146568. */
  146569. export enum SimplificationType {
  146570. /** Quadratic error decimation */
  146571. QUADRATIC = 0
  146572. }
  146573. /**
  146574. * An implementation of the Quadratic Error simplification algorithm.
  146575. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  146576. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  146577. * @author RaananW
  146578. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  146579. */
  146580. export class QuadraticErrorSimplification implements ISimplifier {
  146581. private _mesh;
  146582. private triangles;
  146583. private vertices;
  146584. private references;
  146585. private _reconstructedMesh;
  146586. /** Gets or sets the number pf sync interations */
  146587. syncIterations: number;
  146588. /** Gets or sets the aggressiveness of the simplifier */
  146589. aggressiveness: number;
  146590. /** Gets or sets the number of allowed iterations for decimation */
  146591. decimationIterations: number;
  146592. /** Gets or sets the espilon to use for bounding box computation */
  146593. boundingBoxEpsilon: number;
  146594. /**
  146595. * Creates a new QuadraticErrorSimplification
  146596. * @param _mesh defines the target mesh
  146597. */
  146598. constructor(_mesh: Mesh);
  146599. /**
  146600. * Simplification of a given mesh according to the given settings.
  146601. * Since this requires computation, it is assumed that the function runs async.
  146602. * @param settings The settings of the simplification, including quality and distance
  146603. * @param successCallback A callback that will be called after the mesh was simplified.
  146604. */
  146605. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  146606. private runDecimation;
  146607. private initWithMesh;
  146608. private init;
  146609. private reconstructMesh;
  146610. private initDecimatedMesh;
  146611. private isFlipped;
  146612. private updateTriangles;
  146613. private identifyBorder;
  146614. private updateMesh;
  146615. private vertexError;
  146616. private calculateError;
  146617. }
  146618. }
  146619. declare module BABYLON {
  146620. interface Scene {
  146621. /** @hidden (Backing field) */
  146622. _simplificationQueue: SimplificationQueue;
  146623. /**
  146624. * Gets or sets the simplification queue attached to the scene
  146625. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  146626. */
  146627. simplificationQueue: SimplificationQueue;
  146628. }
  146629. interface Mesh {
  146630. /**
  146631. * Simplify the mesh according to the given array of settings.
  146632. * Function will return immediately and will simplify async
  146633. * @param settings a collection of simplification settings
  146634. * @param parallelProcessing should all levels calculate parallel or one after the other
  146635. * @param simplificationType the type of simplification to run
  146636. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  146637. * @returns the current mesh
  146638. */
  146639. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  146640. }
  146641. /**
  146642. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  146643. * created in a scene
  146644. */
  146645. export class SimplicationQueueSceneComponent implements ISceneComponent {
  146646. /**
  146647. * The component name helpfull to identify the component in the list of scene components.
  146648. */
  146649. readonly name: string;
  146650. /**
  146651. * The scene the component belongs to.
  146652. */
  146653. scene: Scene;
  146654. /**
  146655. * Creates a new instance of the component for the given scene
  146656. * @param scene Defines the scene to register the component in
  146657. */
  146658. constructor(scene: Scene);
  146659. /**
  146660. * Registers the component in a given scene
  146661. */
  146662. register(): void;
  146663. /**
  146664. * Rebuilds the elements related to this component in case of
  146665. * context lost for instance.
  146666. */
  146667. rebuild(): void;
  146668. /**
  146669. * Disposes the component and the associated ressources
  146670. */
  146671. dispose(): void;
  146672. private _beforeCameraUpdate;
  146673. }
  146674. }
  146675. declare module BABYLON {
  146676. interface Mesh {
  146677. /**
  146678. * Gets or sets a boolean defining if we want picking to pick thin instances as well
  146679. */
  146680. thinInstanceEnablePicking: boolean;
  146681. /**
  146682. * Creates a new thin instance
  146683. * @param matrix the matrix or array of matrices (position, rotation, scale) of the thin instance(s) to create
  146684. * @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
  146685. * @returns the thin instance index number. If you pass an array of matrices, other instance indexes are index+1, index+2, etc
  146686. */
  146687. thinInstanceAdd(matrix: DeepImmutableObject<Matrix> | Array<DeepImmutableObject<Matrix>>, refresh: boolean): number;
  146688. /**
  146689. * Adds the transformation (matrix) of the current mesh as a thin instance
  146690. * @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
  146691. * @returns the thin instance index number
  146692. */
  146693. thinInstanceAddSelf(refresh: boolean): number;
  146694. /**
  146695. * Registers a custom attribute to be used with thin instances
  146696. * @param kind name of the attribute
  146697. * @param stride size in floats of the attribute
  146698. */
  146699. thinInstanceRegisterAttribute(kind: string, stride: number): void;
  146700. /**
  146701. * Sets the matrix of a thin instance
  146702. * @param index index of the thin instance
  146703. * @param matrix matrix to set
  146704. * @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
  146705. */
  146706. thinInstanceSetMatrixAt(index: number, matrix: DeepImmutableObject<Matrix>, refresh: boolean): void;
  146707. /**
  146708. * Sets the value of a custom attribute for a thin instance
  146709. * @param kind name of the attribute
  146710. * @param index index of the thin instance
  146711. * @param value value to set
  146712. * @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
  146713. */
  146714. thinInstanceSetAttributeAt(kind: string, index: number, value: Array<number>, refresh: boolean): void;
  146715. /**
  146716. * 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.
  146717. */
  146718. thinInstanceCount: number;
  146719. /**
  146720. * Sets a buffer to be used with thin instances. This method is a faster way to setup multiple instances than calling thinInstanceAdd repeatedly
  146721. * @param kind name of the attribute. Use "matrix" to setup the buffer of matrices
  146722. * @param buffer buffer to set
  146723. * @param stride size in floats of each value of the buffer
  146724. * @param staticBuffer indicates that the buffer is static, so that you won't change it after it is set (better performances - false by default)
  146725. */
  146726. thinInstanceSetBuffer(kind: string, buffer: Nullable<Float32Array>, stride: number, staticBuffer: boolean): void;
  146727. /**
  146728. * Gets the list of world matrices
  146729. * @return an array containing all the world matrices from the thin instances
  146730. */
  146731. thinInstanceGetWorldMatrices(): Matrix[];
  146732. /**
  146733. * Synchronize the gpu buffers with a thin instance buffer. Call this method if you update later on the buffers passed to thinInstanceSetBuffer
  146734. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  146735. */
  146736. thinInstanceBufferUpdated(kind: string): void;
  146737. /**
  146738. * Applies a partial update to a buffer directly on the GPU
  146739. * Note that the buffer located on the CPU is NOT updated! It's up to you to update it (or not) with the same data you pass to this method
  146740. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  146741. * @param data the data to set in the GPU buffer
  146742. * @param offset the offset in the GPU buffer where to update the data
  146743. */
  146744. thinInstancePartialBufferUpdate(kind: string, data: Float32Array, offset: number): void;
  146745. /**
  146746. * Refreshes the bounding info, taking into account all the thin instances defined
  146747. * @param forceRefreshParentInfo true to force recomputing the mesh bounding info and use it to compute the aggregated bounding info
  146748. */
  146749. thinInstanceRefreshBoundingInfo(forceRefreshParentInfo: boolean): void;
  146750. /** @hidden */
  146751. _thinInstanceInitializeUserStorage(): void;
  146752. /** @hidden */
  146753. _thinInstanceUpdateBufferSize(kind: string, numInstances: number): void;
  146754. /** @hidden */
  146755. _userThinInstanceBuffersStorage: {
  146756. data: {
  146757. [key: string]: Float32Array;
  146758. };
  146759. sizes: {
  146760. [key: string]: number;
  146761. };
  146762. vertexBuffers: {
  146763. [key: string]: Nullable<VertexBuffer>;
  146764. };
  146765. strides: {
  146766. [key: string]: number;
  146767. };
  146768. };
  146769. }
  146770. }
  146771. declare module BABYLON {
  146772. /**
  146773. * Navigation plugin interface to add navigation constrained by a navigation mesh
  146774. */
  146775. export interface INavigationEnginePlugin {
  146776. /**
  146777. * plugin name
  146778. */
  146779. name: string;
  146780. /**
  146781. * Creates a navigation mesh
  146782. * @param meshes array of all the geometry used to compute the navigatio mesh
  146783. * @param parameters bunch of parameters used to filter geometry
  146784. */
  146785. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  146786. /**
  146787. * Create a navigation mesh debug mesh
  146788. * @param scene is where the mesh will be added
  146789. * @returns debug display mesh
  146790. */
  146791. createDebugNavMesh(scene: Scene): Mesh;
  146792. /**
  146793. * Get a navigation mesh constrained position, closest to the parameter position
  146794. * @param position world position
  146795. * @returns the closest point to position constrained by the navigation mesh
  146796. */
  146797. getClosestPoint(position: Vector3): Vector3;
  146798. /**
  146799. * Get a navigation mesh constrained position, closest to the parameter position
  146800. * @param position world position
  146801. * @param result output the closest point to position constrained by the navigation mesh
  146802. */
  146803. getClosestPointToRef(position: Vector3, result: Vector3): void;
  146804. /**
  146805. * Get a navigation mesh constrained position, within a particular radius
  146806. * @param position world position
  146807. * @param maxRadius the maximum distance to the constrained world position
  146808. * @returns the closest point to position constrained by the navigation mesh
  146809. */
  146810. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  146811. /**
  146812. * Get a navigation mesh constrained position, within a particular radius
  146813. * @param position world position
  146814. * @param maxRadius the maximum distance to the constrained world position
  146815. * @param result output the closest point to position constrained by the navigation mesh
  146816. */
  146817. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  146818. /**
  146819. * Compute the final position from a segment made of destination-position
  146820. * @param position world position
  146821. * @param destination world position
  146822. * @returns the resulting point along the navmesh
  146823. */
  146824. moveAlong(position: Vector3, destination: Vector3): Vector3;
  146825. /**
  146826. * Compute the final position from a segment made of destination-position
  146827. * @param position world position
  146828. * @param destination world position
  146829. * @param result output the resulting point along the navmesh
  146830. */
  146831. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  146832. /**
  146833. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  146834. * @param start world position
  146835. * @param end world position
  146836. * @returns array containing world position composing the path
  146837. */
  146838. computePath(start: Vector3, end: Vector3): Vector3[];
  146839. /**
  146840. * If this plugin is supported
  146841. * @returns true if plugin is supported
  146842. */
  146843. isSupported(): boolean;
  146844. /**
  146845. * Create a new Crowd so you can add agents
  146846. * @param maxAgents the maximum agent count in the crowd
  146847. * @param maxAgentRadius the maximum radius an agent can have
  146848. * @param scene to attach the crowd to
  146849. * @returns the crowd you can add agents to
  146850. */
  146851. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  146852. /**
  146853. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  146854. * The queries will try to find a solution within those bounds
  146855. * default is (1,1,1)
  146856. * @param extent x,y,z value that define the extent around the queries point of reference
  146857. */
  146858. setDefaultQueryExtent(extent: Vector3): void;
  146859. /**
  146860. * Get the Bounding box extent specified by setDefaultQueryExtent
  146861. * @returns the box extent values
  146862. */
  146863. getDefaultQueryExtent(): Vector3;
  146864. /**
  146865. * build the navmesh from a previously saved state using getNavmeshData
  146866. * @param data the Uint8Array returned by getNavmeshData
  146867. */
  146868. buildFromNavmeshData(data: Uint8Array): void;
  146869. /**
  146870. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  146871. * @returns data the Uint8Array that can be saved and reused
  146872. */
  146873. getNavmeshData(): Uint8Array;
  146874. /**
  146875. * Get the Bounding box extent result specified by setDefaultQueryExtent
  146876. * @param result output the box extent values
  146877. */
  146878. getDefaultQueryExtentToRef(result: Vector3): void;
  146879. /**
  146880. * Release all resources
  146881. */
  146882. dispose(): void;
  146883. }
  146884. /**
  146885. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  146886. */
  146887. export interface ICrowd {
  146888. /**
  146889. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  146890. * You can attach anything to that node. The node position is updated in the scene update tick.
  146891. * @param pos world position that will be constrained by the navigation mesh
  146892. * @param parameters agent parameters
  146893. * @param transform hooked to the agent that will be update by the scene
  146894. * @returns agent index
  146895. */
  146896. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  146897. /**
  146898. * Returns the agent position in world space
  146899. * @param index agent index returned by addAgent
  146900. * @returns world space position
  146901. */
  146902. getAgentPosition(index: number): Vector3;
  146903. /**
  146904. * Gets the agent position result in world space
  146905. * @param index agent index returned by addAgent
  146906. * @param result output world space position
  146907. */
  146908. getAgentPositionToRef(index: number, result: Vector3): void;
  146909. /**
  146910. * Gets the agent velocity in world space
  146911. * @param index agent index returned by addAgent
  146912. * @returns world space velocity
  146913. */
  146914. getAgentVelocity(index: number): Vector3;
  146915. /**
  146916. * Gets the agent velocity result in world space
  146917. * @param index agent index returned by addAgent
  146918. * @param result output world space velocity
  146919. */
  146920. getAgentVelocityToRef(index: number, result: Vector3): void;
  146921. /**
  146922. * remove a particular agent previously created
  146923. * @param index agent index returned by addAgent
  146924. */
  146925. removeAgent(index: number): void;
  146926. /**
  146927. * get the list of all agents attached to this crowd
  146928. * @returns list of agent indices
  146929. */
  146930. getAgents(): number[];
  146931. /**
  146932. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  146933. * @param deltaTime in seconds
  146934. */
  146935. update(deltaTime: number): void;
  146936. /**
  146937. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  146938. * @param index agent index returned by addAgent
  146939. * @param destination targeted world position
  146940. */
  146941. agentGoto(index: number, destination: Vector3): void;
  146942. /**
  146943. * Teleport the agent to a new position
  146944. * @param index agent index returned by addAgent
  146945. * @param destination targeted world position
  146946. */
  146947. agentTeleport(index: number, destination: Vector3): void;
  146948. /**
  146949. * Update agent parameters
  146950. * @param index agent index returned by addAgent
  146951. * @param parameters agent parameters
  146952. */
  146953. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  146954. /**
  146955. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  146956. * The queries will try to find a solution within those bounds
  146957. * default is (1,1,1)
  146958. * @param extent x,y,z value that define the extent around the queries point of reference
  146959. */
  146960. setDefaultQueryExtent(extent: Vector3): void;
  146961. /**
  146962. * Get the Bounding box extent specified by setDefaultQueryExtent
  146963. * @returns the box extent values
  146964. */
  146965. getDefaultQueryExtent(): Vector3;
  146966. /**
  146967. * Get the Bounding box extent result specified by setDefaultQueryExtent
  146968. * @param result output the box extent values
  146969. */
  146970. getDefaultQueryExtentToRef(result: Vector3): void;
  146971. /**
  146972. * Release all resources
  146973. */
  146974. dispose(): void;
  146975. }
  146976. /**
  146977. * Configures an agent
  146978. */
  146979. export interface IAgentParameters {
  146980. /**
  146981. * Agent radius. [Limit: >= 0]
  146982. */
  146983. radius: number;
  146984. /**
  146985. * Agent height. [Limit: > 0]
  146986. */
  146987. height: number;
  146988. /**
  146989. * Maximum allowed acceleration. [Limit: >= 0]
  146990. */
  146991. maxAcceleration: number;
  146992. /**
  146993. * Maximum allowed speed. [Limit: >= 0]
  146994. */
  146995. maxSpeed: number;
  146996. /**
  146997. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  146998. */
  146999. collisionQueryRange: number;
  147000. /**
  147001. * The path visibility optimization range. [Limit: > 0]
  147002. */
  147003. pathOptimizationRange: number;
  147004. /**
  147005. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  147006. */
  147007. separationWeight: number;
  147008. }
  147009. /**
  147010. * Configures the navigation mesh creation
  147011. */
  147012. export interface INavMeshParameters {
  147013. /**
  147014. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  147015. */
  147016. cs: number;
  147017. /**
  147018. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  147019. */
  147020. ch: number;
  147021. /**
  147022. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  147023. */
  147024. walkableSlopeAngle: number;
  147025. /**
  147026. * Minimum floor to 'ceiling' height that will still allow the floor area to
  147027. * be considered walkable. [Limit: >= 3] [Units: vx]
  147028. */
  147029. walkableHeight: number;
  147030. /**
  147031. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  147032. */
  147033. walkableClimb: number;
  147034. /**
  147035. * The distance to erode/shrink the walkable area of the heightfield away from
  147036. * obstructions. [Limit: >=0] [Units: vx]
  147037. */
  147038. walkableRadius: number;
  147039. /**
  147040. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  147041. */
  147042. maxEdgeLen: number;
  147043. /**
  147044. * The maximum distance a simplfied contour's border edges should deviate
  147045. * the original raw contour. [Limit: >=0] [Units: vx]
  147046. */
  147047. maxSimplificationError: number;
  147048. /**
  147049. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  147050. */
  147051. minRegionArea: number;
  147052. /**
  147053. * Any regions with a span count smaller than this value will, if possible,
  147054. * be merged with larger regions. [Limit: >=0] [Units: vx]
  147055. */
  147056. mergeRegionArea: number;
  147057. /**
  147058. * The maximum number of vertices allowed for polygons generated during the
  147059. * contour to polygon conversion process. [Limit: >= 3]
  147060. */
  147061. maxVertsPerPoly: number;
  147062. /**
  147063. * Sets the sampling distance to use when generating the detail mesh.
  147064. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  147065. */
  147066. detailSampleDist: number;
  147067. /**
  147068. * The maximum distance the detail mesh surface should deviate from heightfield
  147069. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  147070. */
  147071. detailSampleMaxError: number;
  147072. }
  147073. }
  147074. declare module BABYLON {
  147075. /**
  147076. * RecastJS navigation plugin
  147077. */
  147078. export class RecastJSPlugin implements INavigationEnginePlugin {
  147079. /**
  147080. * Reference to the Recast library
  147081. */
  147082. bjsRECAST: any;
  147083. /**
  147084. * plugin name
  147085. */
  147086. name: string;
  147087. /**
  147088. * the first navmesh created. We might extend this to support multiple navmeshes
  147089. */
  147090. navMesh: any;
  147091. /**
  147092. * Initializes the recastJS plugin
  147093. * @param recastInjection can be used to inject your own recast reference
  147094. */
  147095. constructor(recastInjection?: any);
  147096. /**
  147097. * Creates a navigation mesh
  147098. * @param meshes array of all the geometry used to compute the navigatio mesh
  147099. * @param parameters bunch of parameters used to filter geometry
  147100. */
  147101. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  147102. /**
  147103. * Create a navigation mesh debug mesh
  147104. * @param scene is where the mesh will be added
  147105. * @returns debug display mesh
  147106. */
  147107. createDebugNavMesh(scene: Scene): Mesh;
  147108. /**
  147109. * Get a navigation mesh constrained position, closest to the parameter position
  147110. * @param position world position
  147111. * @returns the closest point to position constrained by the navigation mesh
  147112. */
  147113. getClosestPoint(position: Vector3): Vector3;
  147114. /**
  147115. * Get a navigation mesh constrained position, closest to the parameter position
  147116. * @param position world position
  147117. * @param result output the closest point to position constrained by the navigation mesh
  147118. */
  147119. getClosestPointToRef(position: Vector3, result: Vector3): void;
  147120. /**
  147121. * Get a navigation mesh constrained position, within a particular radius
  147122. * @param position world position
  147123. * @param maxRadius the maximum distance to the constrained world position
  147124. * @returns the closest point to position constrained by the navigation mesh
  147125. */
  147126. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  147127. /**
  147128. * Get a navigation mesh constrained position, within a particular radius
  147129. * @param position world position
  147130. * @param maxRadius the maximum distance to the constrained world position
  147131. * @param result output the closest point to position constrained by the navigation mesh
  147132. */
  147133. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  147134. /**
  147135. * Compute the final position from a segment made of destination-position
  147136. * @param position world position
  147137. * @param destination world position
  147138. * @returns the resulting point along the navmesh
  147139. */
  147140. moveAlong(position: Vector3, destination: Vector3): Vector3;
  147141. /**
  147142. * Compute the final position from a segment made of destination-position
  147143. * @param position world position
  147144. * @param destination world position
  147145. * @param result output the resulting point along the navmesh
  147146. */
  147147. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  147148. /**
  147149. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  147150. * @param start world position
  147151. * @param end world position
  147152. * @returns array containing world position composing the path
  147153. */
  147154. computePath(start: Vector3, end: Vector3): Vector3[];
  147155. /**
  147156. * Create a new Crowd so you can add agents
  147157. * @param maxAgents the maximum agent count in the crowd
  147158. * @param maxAgentRadius the maximum radius an agent can have
  147159. * @param scene to attach the crowd to
  147160. * @returns the crowd you can add agents to
  147161. */
  147162. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  147163. /**
  147164. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  147165. * The queries will try to find a solution within those bounds
  147166. * default is (1,1,1)
  147167. * @param extent x,y,z value that define the extent around the queries point of reference
  147168. */
  147169. setDefaultQueryExtent(extent: Vector3): void;
  147170. /**
  147171. * Get the Bounding box extent specified by setDefaultQueryExtent
  147172. * @returns the box extent values
  147173. */
  147174. getDefaultQueryExtent(): Vector3;
  147175. /**
  147176. * build the navmesh from a previously saved state using getNavmeshData
  147177. * @param data the Uint8Array returned by getNavmeshData
  147178. */
  147179. buildFromNavmeshData(data: Uint8Array): void;
  147180. /**
  147181. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  147182. * @returns data the Uint8Array that can be saved and reused
  147183. */
  147184. getNavmeshData(): Uint8Array;
  147185. /**
  147186. * Get the Bounding box extent result specified by setDefaultQueryExtent
  147187. * @param result output the box extent values
  147188. */
  147189. getDefaultQueryExtentToRef(result: Vector3): void;
  147190. /**
  147191. * Disposes
  147192. */
  147193. dispose(): void;
  147194. /**
  147195. * If this plugin is supported
  147196. * @returns true if plugin is supported
  147197. */
  147198. isSupported(): boolean;
  147199. }
  147200. /**
  147201. * Recast detour crowd implementation
  147202. */
  147203. export class RecastJSCrowd implements ICrowd {
  147204. /**
  147205. * Recast/detour plugin
  147206. */
  147207. bjsRECASTPlugin: RecastJSPlugin;
  147208. /**
  147209. * Link to the detour crowd
  147210. */
  147211. recastCrowd: any;
  147212. /**
  147213. * One transform per agent
  147214. */
  147215. transforms: TransformNode[];
  147216. /**
  147217. * All agents created
  147218. */
  147219. agents: number[];
  147220. /**
  147221. * Link to the scene is kept to unregister the crowd from the scene
  147222. */
  147223. private _scene;
  147224. /**
  147225. * Observer for crowd updates
  147226. */
  147227. private _onBeforeAnimationsObserver;
  147228. /**
  147229. * Constructor
  147230. * @param plugin recastJS plugin
  147231. * @param maxAgents the maximum agent count in the crowd
  147232. * @param maxAgentRadius the maximum radius an agent can have
  147233. * @param scene to attach the crowd to
  147234. * @returns the crowd you can add agents to
  147235. */
  147236. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  147237. /**
  147238. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  147239. * You can attach anything to that node. The node position is updated in the scene update tick.
  147240. * @param pos world position that will be constrained by the navigation mesh
  147241. * @param parameters agent parameters
  147242. * @param transform hooked to the agent that will be update by the scene
  147243. * @returns agent index
  147244. */
  147245. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  147246. /**
  147247. * Returns the agent position in world space
  147248. * @param index agent index returned by addAgent
  147249. * @returns world space position
  147250. */
  147251. getAgentPosition(index: number): Vector3;
  147252. /**
  147253. * Returns the agent position result in world space
  147254. * @param index agent index returned by addAgent
  147255. * @param result output world space position
  147256. */
  147257. getAgentPositionToRef(index: number, result: Vector3): void;
  147258. /**
  147259. * Returns the agent velocity in world space
  147260. * @param index agent index returned by addAgent
  147261. * @returns world space velocity
  147262. */
  147263. getAgentVelocity(index: number): Vector3;
  147264. /**
  147265. * Returns the agent velocity result in world space
  147266. * @param index agent index returned by addAgent
  147267. * @param result output world space velocity
  147268. */
  147269. getAgentVelocityToRef(index: number, result: Vector3): void;
  147270. /**
  147271. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  147272. * @param index agent index returned by addAgent
  147273. * @param destination targeted world position
  147274. */
  147275. agentGoto(index: number, destination: Vector3): void;
  147276. /**
  147277. * Teleport the agent to a new position
  147278. * @param index agent index returned by addAgent
  147279. * @param destination targeted world position
  147280. */
  147281. agentTeleport(index: number, destination: Vector3): void;
  147282. /**
  147283. * Update agent parameters
  147284. * @param index agent index returned by addAgent
  147285. * @param parameters agent parameters
  147286. */
  147287. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  147288. /**
  147289. * remove a particular agent previously created
  147290. * @param index agent index returned by addAgent
  147291. */
  147292. removeAgent(index: number): void;
  147293. /**
  147294. * get the list of all agents attached to this crowd
  147295. * @returns list of agent indices
  147296. */
  147297. getAgents(): number[];
  147298. /**
  147299. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  147300. * @param deltaTime in seconds
  147301. */
  147302. update(deltaTime: number): void;
  147303. /**
  147304. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  147305. * The queries will try to find a solution within those bounds
  147306. * default is (1,1,1)
  147307. * @param extent x,y,z value that define the extent around the queries point of reference
  147308. */
  147309. setDefaultQueryExtent(extent: Vector3): void;
  147310. /**
  147311. * Get the Bounding box extent specified by setDefaultQueryExtent
  147312. * @returns the box extent values
  147313. */
  147314. getDefaultQueryExtent(): Vector3;
  147315. /**
  147316. * Get the Bounding box extent result specified by setDefaultQueryExtent
  147317. * @param result output the box extent values
  147318. */
  147319. getDefaultQueryExtentToRef(result: Vector3): void;
  147320. /**
  147321. * Release all resources
  147322. */
  147323. dispose(): void;
  147324. }
  147325. }
  147326. declare module BABYLON {
  147327. /**
  147328. * Class used to enable access to IndexedDB
  147329. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  147330. */
  147331. export class Database implements IOfflineProvider {
  147332. private _callbackManifestChecked;
  147333. private _currentSceneUrl;
  147334. private _db;
  147335. private _enableSceneOffline;
  147336. private _enableTexturesOffline;
  147337. private _manifestVersionFound;
  147338. private _mustUpdateRessources;
  147339. private _hasReachedQuota;
  147340. private _isSupported;
  147341. private _idbFactory;
  147342. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  147343. private static IsUASupportingBlobStorage;
  147344. /**
  147345. * Gets a boolean indicating if Database storate is enabled (off by default)
  147346. */
  147347. static IDBStorageEnabled: boolean;
  147348. /**
  147349. * Gets a boolean indicating if scene must be saved in the database
  147350. */
  147351. get enableSceneOffline(): boolean;
  147352. /**
  147353. * Gets a boolean indicating if textures must be saved in the database
  147354. */
  147355. get enableTexturesOffline(): boolean;
  147356. /**
  147357. * Creates a new Database
  147358. * @param urlToScene defines the url to load the scene
  147359. * @param callbackManifestChecked defines the callback to use when manifest is checked
  147360. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  147361. */
  147362. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  147363. private static _ParseURL;
  147364. private static _ReturnFullUrlLocation;
  147365. private _checkManifestFile;
  147366. /**
  147367. * Open the database and make it available
  147368. * @param successCallback defines the callback to call on success
  147369. * @param errorCallback defines the callback to call on error
  147370. */
  147371. open(successCallback: () => void, errorCallback: () => void): void;
  147372. /**
  147373. * Loads an image from the database
  147374. * @param url defines the url to load from
  147375. * @param image defines the target DOM image
  147376. */
  147377. loadImage(url: string, image: HTMLImageElement): void;
  147378. private _loadImageFromDBAsync;
  147379. private _saveImageIntoDBAsync;
  147380. private _checkVersionFromDB;
  147381. private _loadVersionFromDBAsync;
  147382. private _saveVersionIntoDBAsync;
  147383. /**
  147384. * Loads a file from database
  147385. * @param url defines the URL to load from
  147386. * @param sceneLoaded defines a callback to call on success
  147387. * @param progressCallBack defines a callback to call when progress changed
  147388. * @param errorCallback defines a callback to call on error
  147389. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  147390. */
  147391. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  147392. private _loadFileAsync;
  147393. private _saveFileAsync;
  147394. /**
  147395. * Validates if xhr data is correct
  147396. * @param xhr defines the request to validate
  147397. * @param dataType defines the expected data type
  147398. * @returns true if data is correct
  147399. */
  147400. private static _ValidateXHRData;
  147401. }
  147402. }
  147403. declare module BABYLON {
  147404. /** @hidden */
  147405. export var gpuUpdateParticlesPixelShader: {
  147406. name: string;
  147407. shader: string;
  147408. };
  147409. }
  147410. declare module BABYLON {
  147411. /** @hidden */
  147412. export var gpuUpdateParticlesVertexShader: {
  147413. name: string;
  147414. shader: string;
  147415. };
  147416. }
  147417. declare module BABYLON {
  147418. /** @hidden */
  147419. export var clipPlaneFragmentDeclaration2: {
  147420. name: string;
  147421. shader: string;
  147422. };
  147423. }
  147424. declare module BABYLON {
  147425. /** @hidden */
  147426. export var gpuRenderParticlesPixelShader: {
  147427. name: string;
  147428. shader: string;
  147429. };
  147430. }
  147431. declare module BABYLON {
  147432. /** @hidden */
  147433. export var clipPlaneVertexDeclaration2: {
  147434. name: string;
  147435. shader: string;
  147436. };
  147437. }
  147438. declare module BABYLON {
  147439. /** @hidden */
  147440. export var gpuRenderParticlesVertexShader: {
  147441. name: string;
  147442. shader: string;
  147443. };
  147444. }
  147445. declare module BABYLON {
  147446. /**
  147447. * This represents a GPU particle system in Babylon
  147448. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  147449. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  147450. */
  147451. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  147452. /**
  147453. * The layer mask we are rendering the particles through.
  147454. */
  147455. layerMask: number;
  147456. private _capacity;
  147457. private _activeCount;
  147458. private _currentActiveCount;
  147459. private _accumulatedCount;
  147460. private _renderEffect;
  147461. private _updateEffect;
  147462. private _buffer0;
  147463. private _buffer1;
  147464. private _spriteBuffer;
  147465. private _updateVAO;
  147466. private _renderVAO;
  147467. private _targetIndex;
  147468. private _sourceBuffer;
  147469. private _targetBuffer;
  147470. private _currentRenderId;
  147471. private _started;
  147472. private _stopped;
  147473. private _timeDelta;
  147474. private _randomTexture;
  147475. private _randomTexture2;
  147476. private _attributesStrideSize;
  147477. private _updateEffectOptions;
  147478. private _randomTextureSize;
  147479. private _actualFrame;
  147480. private _customEffect;
  147481. private readonly _rawTextureWidth;
  147482. /**
  147483. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  147484. */
  147485. static get IsSupported(): boolean;
  147486. /**
  147487. * An event triggered when the system is disposed.
  147488. */
  147489. onDisposeObservable: Observable<IParticleSystem>;
  147490. /**
  147491. * Gets the maximum number of particles active at the same time.
  147492. * @returns The max number of active particles.
  147493. */
  147494. getCapacity(): number;
  147495. /**
  147496. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  147497. * to override the particles.
  147498. */
  147499. forceDepthWrite: boolean;
  147500. /**
  147501. * Gets or set the number of active particles
  147502. */
  147503. get activeParticleCount(): number;
  147504. set activeParticleCount(value: number);
  147505. private _preWarmDone;
  147506. /**
  147507. * Specifies if the particles are updated in emitter local space or world space.
  147508. */
  147509. isLocal: boolean;
  147510. /** Gets or sets a matrix to use to compute projection */
  147511. defaultProjectionMatrix: Matrix;
  147512. /**
  147513. * Is this system ready to be used/rendered
  147514. * @return true if the system is ready
  147515. */
  147516. isReady(): boolean;
  147517. /**
  147518. * Gets if the system has been started. (Note: this will still be true after stop is called)
  147519. * @returns True if it has been started, otherwise false.
  147520. */
  147521. isStarted(): boolean;
  147522. /**
  147523. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  147524. * @returns True if it has been stopped, otherwise false.
  147525. */
  147526. isStopped(): boolean;
  147527. /**
  147528. * Gets a boolean indicating that the system is stopping
  147529. * @returns true if the system is currently stopping
  147530. */
  147531. isStopping(): boolean;
  147532. /**
  147533. * Gets the number of particles active at the same time.
  147534. * @returns The number of active particles.
  147535. */
  147536. getActiveCount(): number;
  147537. /**
  147538. * Starts the particle system and begins to emit
  147539. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  147540. */
  147541. start(delay?: number): void;
  147542. /**
  147543. * Stops the particle system.
  147544. */
  147545. stop(): void;
  147546. /**
  147547. * Remove all active particles
  147548. */
  147549. reset(): void;
  147550. /**
  147551. * Returns the string "GPUParticleSystem"
  147552. * @returns a string containing the class name
  147553. */
  147554. getClassName(): string;
  147555. /**
  147556. * Gets the custom effect used to render the particles
  147557. * @param blendMode Blend mode for which the effect should be retrieved
  147558. * @returns The effect
  147559. */
  147560. getCustomEffect(blendMode?: number): Nullable<Effect>;
  147561. /**
  147562. * Sets the custom effect used to render the particles
  147563. * @param effect The effect to set
  147564. * @param blendMode Blend mode for which the effect should be set
  147565. */
  147566. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  147567. /** @hidden */
  147568. protected _onBeforeDrawParticlesObservable: Nullable<Observable<Nullable<Effect>>>;
  147569. /**
  147570. * Observable that will be called just before the particles are drawn
  147571. */
  147572. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  147573. /**
  147574. * Gets the name of the particle vertex shader
  147575. */
  147576. get vertexShaderName(): string;
  147577. private _colorGradientsTexture;
  147578. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  147579. /**
  147580. * Adds a new color gradient
  147581. * @param gradient defines the gradient to use (between 0 and 1)
  147582. * @param color1 defines the color to affect to the specified gradient
  147583. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  147584. * @returns the current particle system
  147585. */
  147586. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  147587. private _refreshColorGradient;
  147588. /** Force the system to rebuild all gradients that need to be resync */
  147589. forceRefreshGradients(): void;
  147590. /**
  147591. * Remove a specific color gradient
  147592. * @param gradient defines the gradient to remove
  147593. * @returns the current particle system
  147594. */
  147595. removeColorGradient(gradient: number): GPUParticleSystem;
  147596. private _angularSpeedGradientsTexture;
  147597. private _sizeGradientsTexture;
  147598. private _velocityGradientsTexture;
  147599. private _limitVelocityGradientsTexture;
  147600. private _dragGradientsTexture;
  147601. private _addFactorGradient;
  147602. /**
  147603. * Adds a new size gradient
  147604. * @param gradient defines the gradient to use (between 0 and 1)
  147605. * @param factor defines the size factor to affect to the specified gradient
  147606. * @returns the current particle system
  147607. */
  147608. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  147609. /**
  147610. * Remove a specific size gradient
  147611. * @param gradient defines the gradient to remove
  147612. * @returns the current particle system
  147613. */
  147614. removeSizeGradient(gradient: number): GPUParticleSystem;
  147615. private _refreshFactorGradient;
  147616. /**
  147617. * Adds a new angular speed gradient
  147618. * @param gradient defines the gradient to use (between 0 and 1)
  147619. * @param factor defines the angular speed to affect to the specified gradient
  147620. * @returns the current particle system
  147621. */
  147622. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  147623. /**
  147624. * Remove a specific angular speed gradient
  147625. * @param gradient defines the gradient to remove
  147626. * @returns the current particle system
  147627. */
  147628. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  147629. /**
  147630. * Adds a new velocity gradient
  147631. * @param gradient defines the gradient to use (between 0 and 1)
  147632. * @param factor defines the velocity to affect to the specified gradient
  147633. * @returns the current particle system
  147634. */
  147635. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  147636. /**
  147637. * Remove a specific velocity gradient
  147638. * @param gradient defines the gradient to remove
  147639. * @returns the current particle system
  147640. */
  147641. removeVelocityGradient(gradient: number): GPUParticleSystem;
  147642. /**
  147643. * Adds a new limit velocity gradient
  147644. * @param gradient defines the gradient to use (between 0 and 1)
  147645. * @param factor defines the limit velocity value to affect to the specified gradient
  147646. * @returns the current particle system
  147647. */
  147648. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  147649. /**
  147650. * Remove a specific limit velocity gradient
  147651. * @param gradient defines the gradient to remove
  147652. * @returns the current particle system
  147653. */
  147654. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  147655. /**
  147656. * Adds a new drag gradient
  147657. * @param gradient defines the gradient to use (between 0 and 1)
  147658. * @param factor defines the drag value to affect to the specified gradient
  147659. * @returns the current particle system
  147660. */
  147661. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  147662. /**
  147663. * Remove a specific drag gradient
  147664. * @param gradient defines the gradient to remove
  147665. * @returns the current particle system
  147666. */
  147667. removeDragGradient(gradient: number): GPUParticleSystem;
  147668. /**
  147669. * Not supported by GPUParticleSystem
  147670. * @param gradient defines the gradient to use (between 0 and 1)
  147671. * @param factor defines the emit rate value to affect to the specified gradient
  147672. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  147673. * @returns the current particle system
  147674. */
  147675. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  147676. /**
  147677. * Not supported by GPUParticleSystem
  147678. * @param gradient defines the gradient to remove
  147679. * @returns the current particle system
  147680. */
  147681. removeEmitRateGradient(gradient: number): IParticleSystem;
  147682. /**
  147683. * Not supported by GPUParticleSystem
  147684. * @param gradient defines the gradient to use (between 0 and 1)
  147685. * @param factor defines the start size value to affect to the specified gradient
  147686. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  147687. * @returns the current particle system
  147688. */
  147689. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  147690. /**
  147691. * Not supported by GPUParticleSystem
  147692. * @param gradient defines the gradient to remove
  147693. * @returns the current particle system
  147694. */
  147695. removeStartSizeGradient(gradient: number): IParticleSystem;
  147696. /**
  147697. * Not supported by GPUParticleSystem
  147698. * @param gradient defines the gradient to use (between 0 and 1)
  147699. * @param min defines the color remap minimal range
  147700. * @param max defines the color remap maximal range
  147701. * @returns the current particle system
  147702. */
  147703. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  147704. /**
  147705. * Not supported by GPUParticleSystem
  147706. * @param gradient defines the gradient to remove
  147707. * @returns the current particle system
  147708. */
  147709. removeColorRemapGradient(): IParticleSystem;
  147710. /**
  147711. * Not supported by GPUParticleSystem
  147712. * @param gradient defines the gradient to use (between 0 and 1)
  147713. * @param min defines the alpha remap minimal range
  147714. * @param max defines the alpha remap maximal range
  147715. * @returns the current particle system
  147716. */
  147717. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  147718. /**
  147719. * Not supported by GPUParticleSystem
  147720. * @param gradient defines the gradient to remove
  147721. * @returns the current particle system
  147722. */
  147723. removeAlphaRemapGradient(): IParticleSystem;
  147724. /**
  147725. * Not supported by GPUParticleSystem
  147726. * @param gradient defines the gradient to use (between 0 and 1)
  147727. * @param color defines the color to affect to the specified gradient
  147728. * @returns the current particle system
  147729. */
  147730. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  147731. /**
  147732. * Not supported by GPUParticleSystem
  147733. * @param gradient defines the gradient to remove
  147734. * @returns the current particle system
  147735. */
  147736. removeRampGradient(): IParticleSystem;
  147737. /**
  147738. * Not supported by GPUParticleSystem
  147739. * @returns the list of ramp gradients
  147740. */
  147741. getRampGradients(): Nullable<Array<Color3Gradient>>;
  147742. /**
  147743. * Not supported by GPUParticleSystem
  147744. * Gets or sets a boolean indicating that ramp gradients must be used
  147745. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  147746. */
  147747. get useRampGradients(): boolean;
  147748. set useRampGradients(value: boolean);
  147749. /**
  147750. * Not supported by GPUParticleSystem
  147751. * @param gradient defines the gradient to use (between 0 and 1)
  147752. * @param factor defines the life time factor to affect to the specified gradient
  147753. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  147754. * @returns the current particle system
  147755. */
  147756. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  147757. /**
  147758. * Not supported by GPUParticleSystem
  147759. * @param gradient defines the gradient to remove
  147760. * @returns the current particle system
  147761. */
  147762. removeLifeTimeGradient(gradient: number): IParticleSystem;
  147763. /**
  147764. * Instantiates a GPU particle system.
  147765. * 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.
  147766. * @param name The name of the particle system
  147767. * @param options The options used to create the system
  147768. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  147769. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  147770. * @param customEffect a custom effect used to change the way particles are rendered by default
  147771. */
  147772. constructor(name: string, options: Partial<{
  147773. capacity: number;
  147774. randomTextureSize: number;
  147775. }>, sceneOrEngine: Scene | ThinEngine, isAnimationSheetEnabled?: boolean, customEffect?: Nullable<Effect>);
  147776. protected _reset(): void;
  147777. private _createUpdateVAO;
  147778. private _createRenderVAO;
  147779. private _initialize;
  147780. /** @hidden */
  147781. _recreateUpdateEffect(): void;
  147782. private _getEffect;
  147783. /**
  147784. * Fill the defines array according to the current settings of the particle system
  147785. * @param defines Array to be updated
  147786. * @param blendMode blend mode to take into account when updating the array
  147787. */
  147788. fillDefines(defines: Array<string>, blendMode?: number): void;
  147789. /**
  147790. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  147791. * @param uniforms Uniforms array to fill
  147792. * @param attributes Attributes array to fill
  147793. * @param samplers Samplers array to fill
  147794. */
  147795. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  147796. /** @hidden */
  147797. _recreateRenderEffect(): Effect;
  147798. /**
  147799. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  147800. * @param preWarm defines if we are in the pre-warmimg phase
  147801. */
  147802. animate(preWarm?: boolean): void;
  147803. private _createFactorGradientTexture;
  147804. private _createSizeGradientTexture;
  147805. private _createAngularSpeedGradientTexture;
  147806. private _createVelocityGradientTexture;
  147807. private _createLimitVelocityGradientTexture;
  147808. private _createDragGradientTexture;
  147809. private _createColorGradientTexture;
  147810. /**
  147811. * Renders the particle system in its current state
  147812. * @param preWarm defines if the system should only update the particles but not render them
  147813. * @returns the current number of particles
  147814. */
  147815. render(preWarm?: boolean): number;
  147816. /**
  147817. * Rebuilds the particle system
  147818. */
  147819. rebuild(): void;
  147820. private _releaseBuffers;
  147821. private _releaseVAOs;
  147822. /**
  147823. * Disposes the particle system and free the associated resources
  147824. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  147825. */
  147826. dispose(disposeTexture?: boolean): void;
  147827. /**
  147828. * Clones the particle system.
  147829. * @param name The name of the cloned object
  147830. * @param newEmitter The new emitter to use
  147831. * @returns the cloned particle system
  147832. */
  147833. clone(name: string, newEmitter: any): GPUParticleSystem;
  147834. /**
  147835. * Serializes the particle system to a JSON object
  147836. * @param serializeTexture defines if the texture must be serialized as well
  147837. * @returns the JSON object
  147838. */
  147839. serialize(serializeTexture?: boolean): any;
  147840. /**
  147841. * Parses a JSON object to create a GPU particle system.
  147842. * @param parsedParticleSystem The JSON object to parse
  147843. * @param sceneOrEngine The scene or the engine to create the particle system in
  147844. * @param rootUrl The root url to use to load external dependencies like texture
  147845. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  147846. * @returns the parsed GPU particle system
  147847. */
  147848. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  147849. }
  147850. }
  147851. declare module BABYLON {
  147852. /**
  147853. * Represents a set of particle systems working together to create a specific effect
  147854. */
  147855. export class ParticleSystemSet implements IDisposable {
  147856. /**
  147857. * Gets or sets base Assets URL
  147858. */
  147859. static BaseAssetsUrl: string;
  147860. private _emitterCreationOptions;
  147861. private _emitterNode;
  147862. /**
  147863. * Gets the particle system list
  147864. */
  147865. systems: IParticleSystem[];
  147866. /**
  147867. * Gets the emitter node used with this set
  147868. */
  147869. get emitterNode(): Nullable<TransformNode>;
  147870. /**
  147871. * Creates a new emitter mesh as a sphere
  147872. * @param options defines the options used to create the sphere
  147873. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  147874. * @param scene defines the hosting scene
  147875. */
  147876. setEmitterAsSphere(options: {
  147877. diameter: number;
  147878. segments: number;
  147879. color: Color3;
  147880. }, renderingGroupId: number, scene: Scene): void;
  147881. /**
  147882. * Starts all particle systems of the set
  147883. * @param emitter defines an optional mesh to use as emitter for the particle systems
  147884. */
  147885. start(emitter?: AbstractMesh): void;
  147886. /**
  147887. * Release all associated resources
  147888. */
  147889. dispose(): void;
  147890. /**
  147891. * Serialize the set into a JSON compatible object
  147892. * @param serializeTexture defines if the texture must be serialized as well
  147893. * @returns a JSON compatible representation of the set
  147894. */
  147895. serialize(serializeTexture?: boolean): any;
  147896. /**
  147897. * Parse a new ParticleSystemSet from a serialized source
  147898. * @param data defines a JSON compatible representation of the set
  147899. * @param scene defines the hosting scene
  147900. * @param gpu defines if we want GPU particles or CPU particles
  147901. * @returns a new ParticleSystemSet
  147902. */
  147903. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  147904. }
  147905. }
  147906. declare module BABYLON {
  147907. /**
  147908. * This class is made for on one-liner static method to help creating particle system set.
  147909. */
  147910. export class ParticleHelper {
  147911. /**
  147912. * Gets or sets base Assets URL
  147913. */
  147914. static BaseAssetsUrl: string;
  147915. /** Define the Url to load snippets */
  147916. static SnippetUrl: string;
  147917. /**
  147918. * Create a default particle system that you can tweak
  147919. * @param emitter defines the emitter to use
  147920. * @param capacity defines the system capacity (default is 500 particles)
  147921. * @param scene defines the hosting scene
  147922. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  147923. * @returns the new Particle system
  147924. */
  147925. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  147926. /**
  147927. * This is the main static method (one-liner) of this helper to create different particle systems
  147928. * @param type This string represents the type to the particle system to create
  147929. * @param scene The scene where the particle system should live
  147930. * @param gpu If the system will use gpu
  147931. * @returns the ParticleSystemSet created
  147932. */
  147933. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  147934. /**
  147935. * Static function used to export a particle system to a ParticleSystemSet variable.
  147936. * Please note that the emitter shape is not exported
  147937. * @param systems defines the particle systems to export
  147938. * @returns the created particle system set
  147939. */
  147940. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  147941. /**
  147942. * Creates a particle system from a snippet saved in a remote file
  147943. * @param name defines the name of the particle system to create (can be null or empty to use the one from the json data)
  147944. * @param url defines the url to load from
  147945. * @param scene defines the hosting scene
  147946. * @param gpu If the system will use gpu
  147947. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  147948. * @returns a promise that will resolve to the new particle system
  147949. */
  147950. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  147951. /**
  147952. * Creates a particle system from a snippet saved by the particle system editor
  147953. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  147954. * @param scene defines the hosting scene
  147955. * @param gpu If the system will use gpu
  147956. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  147957. * @returns a promise that will resolve to the new particle system
  147958. */
  147959. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  147960. }
  147961. }
  147962. declare module BABYLON {
  147963. interface Engine {
  147964. /**
  147965. * Create an effect to use with particle systems.
  147966. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration, except if you pass
  147967. * the particle system for which you want to create a custom effect in the last parameter
  147968. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  147969. * @param uniformsNames defines a list of attribute names
  147970. * @param samplers defines an array of string used to represent textures
  147971. * @param defines defines the string containing the defines to use to compile the shaders
  147972. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  147973. * @param onCompiled defines a function to call when the effect creation is successful
  147974. * @param onError defines a function to call when the effect creation has failed
  147975. * @param particleSystem the particle system you want to create the effect for
  147976. * @returns the new Effect
  147977. */
  147978. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, particleSystem?: IParticleSystem): Effect;
  147979. }
  147980. interface Mesh {
  147981. /**
  147982. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  147983. * @returns an array of IParticleSystem
  147984. */
  147985. getEmittedParticleSystems(): IParticleSystem[];
  147986. /**
  147987. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  147988. * @returns an array of IParticleSystem
  147989. */
  147990. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  147991. }
  147992. }
  147993. declare module BABYLON {
  147994. /** Defines the 4 color options */
  147995. export enum PointColor {
  147996. /** color value */
  147997. Color = 2,
  147998. /** uv value */
  147999. UV = 1,
  148000. /** random value */
  148001. Random = 0,
  148002. /** stated value */
  148003. Stated = 3
  148004. }
  148005. /**
  148006. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  148007. * 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.
  148008. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  148009. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  148010. *
  148011. * Full documentation here : TO BE ENTERED
  148012. */
  148013. export class PointsCloudSystem implements IDisposable {
  148014. /**
  148015. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  148016. * Example : var p = SPS.particles[i];
  148017. */
  148018. particles: CloudPoint[];
  148019. /**
  148020. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  148021. */
  148022. nbParticles: number;
  148023. /**
  148024. * This a counter for your own usage. It's not set by any SPS functions.
  148025. */
  148026. counter: number;
  148027. /**
  148028. * The PCS name. This name is also given to the underlying mesh.
  148029. */
  148030. name: string;
  148031. /**
  148032. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  148033. */
  148034. mesh: Mesh;
  148035. /**
  148036. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  148037. * Please read :
  148038. */
  148039. vars: any;
  148040. /**
  148041. * @hidden
  148042. */
  148043. _size: number;
  148044. private _scene;
  148045. private _promises;
  148046. private _positions;
  148047. private _indices;
  148048. private _normals;
  148049. private _colors;
  148050. private _uvs;
  148051. private _indices32;
  148052. private _positions32;
  148053. private _colors32;
  148054. private _uvs32;
  148055. private _updatable;
  148056. private _isVisibilityBoxLocked;
  148057. private _alwaysVisible;
  148058. private _groups;
  148059. private _groupCounter;
  148060. private _computeParticleColor;
  148061. private _computeParticleTexture;
  148062. private _computeParticleRotation;
  148063. private _computeBoundingBox;
  148064. private _isReady;
  148065. /**
  148066. * Creates a PCS (Points Cloud System) object
  148067. * @param name (String) is the PCS name, this will be the underlying mesh name
  148068. * @param pointSize (number) is the size for each point
  148069. * @param scene (Scene) is the scene in which the PCS is added
  148070. * @param options defines the options of the PCS e.g.
  148071. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  148072. */
  148073. constructor(name: string, pointSize: number, scene: Scene, options?: {
  148074. updatable?: boolean;
  148075. });
  148076. /**
  148077. * Builds the PCS underlying mesh. Returns a standard Mesh.
  148078. * If no points were added to the PCS, the returned mesh is just a single point.
  148079. * @returns a promise for the created mesh
  148080. */
  148081. buildMeshAsync(): Promise<Mesh>;
  148082. /**
  148083. * @hidden
  148084. */
  148085. private _buildMesh;
  148086. private _addParticle;
  148087. private _randomUnitVector;
  148088. private _getColorIndicesForCoord;
  148089. private _setPointsColorOrUV;
  148090. private _colorFromTexture;
  148091. private _calculateDensity;
  148092. /**
  148093. * Adds points to the PCS in random positions within a unit sphere
  148094. * @param nb (positive integer) the number of particles to be created from this model
  148095. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  148096. * @returns the number of groups in the system
  148097. */
  148098. addPoints(nb: number, pointFunction?: any): number;
  148099. /**
  148100. * Adds points to the PCS from the surface of the model shape
  148101. * @param mesh is any Mesh object that will be used as a surface model for the points
  148102. * @param nb (positive integer) the number of particles to be created from this model
  148103. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  148104. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  148105. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  148106. * @returns the number of groups in the system
  148107. */
  148108. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  148109. /**
  148110. * Adds points to the PCS inside the model shape
  148111. * @param mesh is any Mesh object that will be used as a surface model for the points
  148112. * @param nb (positive integer) the number of particles to be created from this model
  148113. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  148114. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  148115. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  148116. * @returns the number of groups in the system
  148117. */
  148118. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  148119. /**
  148120. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  148121. * This method calls `updateParticle()` for each particle of the SPS.
  148122. * For an animated SPS, it is usually called within the render loop.
  148123. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  148124. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  148125. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  148126. * @returns the PCS.
  148127. */
  148128. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  148129. /**
  148130. * Disposes the PCS.
  148131. */
  148132. dispose(): void;
  148133. /**
  148134. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  148135. * doc :
  148136. * @returns the PCS.
  148137. */
  148138. refreshVisibleSize(): PointsCloudSystem;
  148139. /**
  148140. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  148141. * @param size the size (float) of the visibility box
  148142. * note : this doesn't lock the PCS mesh bounding box.
  148143. * doc :
  148144. */
  148145. setVisibilityBox(size: number): void;
  148146. /**
  148147. * Gets whether the PCS is always visible or not
  148148. * doc :
  148149. */
  148150. get isAlwaysVisible(): boolean;
  148151. /**
  148152. * Sets the PCS as always visible or not
  148153. * doc :
  148154. */
  148155. set isAlwaysVisible(val: boolean);
  148156. /**
  148157. * Tells to `setParticles()` to compute the particle rotations or not
  148158. * Default value : false. The PCS is faster when it's set to false
  148159. * Note : particle rotations are only applied to parent particles
  148160. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  148161. */
  148162. set computeParticleRotation(val: boolean);
  148163. /**
  148164. * Tells to `setParticles()` to compute the particle colors or not.
  148165. * Default value : true. The PCS is faster when it's set to false.
  148166. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  148167. */
  148168. set computeParticleColor(val: boolean);
  148169. set computeParticleTexture(val: boolean);
  148170. /**
  148171. * Gets if `setParticles()` computes the particle colors or not.
  148172. * Default value : false. The PCS is faster when it's set to false.
  148173. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  148174. */
  148175. get computeParticleColor(): boolean;
  148176. /**
  148177. * Gets if `setParticles()` computes the particle textures or not.
  148178. * Default value : false. The PCS is faster when it's set to false.
  148179. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  148180. */
  148181. get computeParticleTexture(): boolean;
  148182. /**
  148183. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  148184. */
  148185. set computeBoundingBox(val: boolean);
  148186. /**
  148187. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  148188. */
  148189. get computeBoundingBox(): boolean;
  148190. /**
  148191. * This function does nothing. It may be overwritten to set all the particle first values.
  148192. * The PCS doesn't call this function, you may have to call it by your own.
  148193. * doc :
  148194. */
  148195. initParticles(): void;
  148196. /**
  148197. * This function does nothing. It may be overwritten to recycle a particle
  148198. * The PCS doesn't call this function, you can to call it
  148199. * doc :
  148200. * @param particle The particle to recycle
  148201. * @returns the recycled particle
  148202. */
  148203. recycleParticle(particle: CloudPoint): CloudPoint;
  148204. /**
  148205. * Updates a particle : this function should be overwritten by the user.
  148206. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  148207. * doc :
  148208. * @example : just set a particle position or velocity and recycle conditions
  148209. * @param particle The particle to update
  148210. * @returns the updated particle
  148211. */
  148212. updateParticle(particle: CloudPoint): CloudPoint;
  148213. /**
  148214. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  148215. * This does nothing and may be overwritten by the user.
  148216. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  148217. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  148218. * @param update the boolean update value actually passed to setParticles()
  148219. */
  148220. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  148221. /**
  148222. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  148223. * This will be passed three parameters.
  148224. * This does nothing and may be overwritten by the user.
  148225. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  148226. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  148227. * @param update the boolean update value actually passed to setParticles()
  148228. */
  148229. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  148230. }
  148231. }
  148232. declare module BABYLON {
  148233. /**
  148234. * Represents one particle of a points cloud system.
  148235. */
  148236. export class CloudPoint {
  148237. /**
  148238. * particle global index
  148239. */
  148240. idx: number;
  148241. /**
  148242. * The color of the particle
  148243. */
  148244. color: Nullable<Color4>;
  148245. /**
  148246. * The world space position of the particle.
  148247. */
  148248. position: Vector3;
  148249. /**
  148250. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  148251. */
  148252. rotation: Vector3;
  148253. /**
  148254. * The world space rotation quaternion of the particle.
  148255. */
  148256. rotationQuaternion: Nullable<Quaternion>;
  148257. /**
  148258. * The uv of the particle.
  148259. */
  148260. uv: Nullable<Vector2>;
  148261. /**
  148262. * The current speed of the particle.
  148263. */
  148264. velocity: Vector3;
  148265. /**
  148266. * The pivot point in the particle local space.
  148267. */
  148268. pivot: Vector3;
  148269. /**
  148270. * Must the particle be translated from its pivot point in its local space ?
  148271. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  148272. * Default : false
  148273. */
  148274. translateFromPivot: boolean;
  148275. /**
  148276. * Index of this particle in the global "positions" array (Internal use)
  148277. * @hidden
  148278. */
  148279. _pos: number;
  148280. /**
  148281. * @hidden Index of this particle in the global "indices" array (Internal use)
  148282. */
  148283. _ind: number;
  148284. /**
  148285. * Group this particle belongs to
  148286. */
  148287. _group: PointsGroup;
  148288. /**
  148289. * Group id of this particle
  148290. */
  148291. groupId: number;
  148292. /**
  148293. * Index of the particle in its group id (Internal use)
  148294. */
  148295. idxInGroup: number;
  148296. /**
  148297. * @hidden Particle BoundingInfo object (Internal use)
  148298. */
  148299. _boundingInfo: BoundingInfo;
  148300. /**
  148301. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  148302. */
  148303. _pcs: PointsCloudSystem;
  148304. /**
  148305. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  148306. */
  148307. _stillInvisible: boolean;
  148308. /**
  148309. * @hidden Last computed particle rotation matrix
  148310. */
  148311. _rotationMatrix: number[];
  148312. /**
  148313. * Parent particle Id, if any.
  148314. * Default null.
  148315. */
  148316. parentId: Nullable<number>;
  148317. /**
  148318. * @hidden Internal global position in the PCS.
  148319. */
  148320. _globalPosition: Vector3;
  148321. /**
  148322. * Creates a Point Cloud object.
  148323. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  148324. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  148325. * @param group (PointsGroup) is the group the particle belongs to
  148326. * @param groupId (integer) is the group identifier in the PCS.
  148327. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  148328. * @param pcs defines the PCS it is associated to
  148329. */
  148330. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  148331. /**
  148332. * get point size
  148333. */
  148334. get size(): Vector3;
  148335. /**
  148336. * Set point size
  148337. */
  148338. set size(scale: Vector3);
  148339. /**
  148340. * Legacy support, changed quaternion to rotationQuaternion
  148341. */
  148342. get quaternion(): Nullable<Quaternion>;
  148343. /**
  148344. * Legacy support, changed quaternion to rotationQuaternion
  148345. */
  148346. set quaternion(q: Nullable<Quaternion>);
  148347. /**
  148348. * Returns a boolean. True if the particle intersects a mesh, else false
  148349. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  148350. * @param target is the object (point or mesh) what the intersection is computed against
  148351. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  148352. * @returns true if it intersects
  148353. */
  148354. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  148355. /**
  148356. * get the rotation matrix of the particle
  148357. * @hidden
  148358. */
  148359. getRotationMatrix(m: Matrix): void;
  148360. }
  148361. /**
  148362. * Represents a group of points in a points cloud system
  148363. * * PCS internal tool, don't use it manually.
  148364. */
  148365. export class PointsGroup {
  148366. /**
  148367. * The group id
  148368. * @hidden
  148369. */
  148370. groupID: number;
  148371. /**
  148372. * image data for group (internal use)
  148373. * @hidden
  148374. */
  148375. _groupImageData: Nullable<ArrayBufferView>;
  148376. /**
  148377. * Image Width (internal use)
  148378. * @hidden
  148379. */
  148380. _groupImgWidth: number;
  148381. /**
  148382. * Image Height (internal use)
  148383. * @hidden
  148384. */
  148385. _groupImgHeight: number;
  148386. /**
  148387. * Custom position function (internal use)
  148388. * @hidden
  148389. */
  148390. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  148391. /**
  148392. * density per facet for surface points
  148393. * @hidden
  148394. */
  148395. _groupDensity: number[];
  148396. /**
  148397. * Only when points are colored by texture carries pointer to texture list array
  148398. * @hidden
  148399. */
  148400. _textureNb: number;
  148401. /**
  148402. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  148403. * PCS internal tool, don't use it manually.
  148404. * @hidden
  148405. */
  148406. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  148407. }
  148408. }
  148409. declare module BABYLON {
  148410. interface Scene {
  148411. /** @hidden (Backing field) */
  148412. _physicsEngine: Nullable<IPhysicsEngine>;
  148413. /** @hidden */
  148414. _physicsTimeAccumulator: number;
  148415. /**
  148416. * Gets the current physics engine
  148417. * @returns a IPhysicsEngine or null if none attached
  148418. */
  148419. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  148420. /**
  148421. * Enables physics to the current scene
  148422. * @param gravity defines the scene's gravity for the physics engine
  148423. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  148424. * @return a boolean indicating if the physics engine was initialized
  148425. */
  148426. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  148427. /**
  148428. * Disables and disposes the physics engine associated with the scene
  148429. */
  148430. disablePhysicsEngine(): void;
  148431. /**
  148432. * Gets a boolean indicating if there is an active physics engine
  148433. * @returns a boolean indicating if there is an active physics engine
  148434. */
  148435. isPhysicsEnabled(): boolean;
  148436. /**
  148437. * Deletes a physics compound impostor
  148438. * @param compound defines the compound to delete
  148439. */
  148440. deleteCompoundImpostor(compound: any): void;
  148441. /**
  148442. * An event triggered when physic simulation is about to be run
  148443. */
  148444. onBeforePhysicsObservable: Observable<Scene>;
  148445. /**
  148446. * An event triggered when physic simulation has been done
  148447. */
  148448. onAfterPhysicsObservable: Observable<Scene>;
  148449. }
  148450. interface AbstractMesh {
  148451. /** @hidden */
  148452. _physicsImpostor: Nullable<PhysicsImpostor>;
  148453. /**
  148454. * Gets or sets impostor used for physic simulation
  148455. * @see https://doc.babylonjs.com/features/physics_engine
  148456. */
  148457. physicsImpostor: Nullable<PhysicsImpostor>;
  148458. /**
  148459. * Gets the current physics impostor
  148460. * @see https://doc.babylonjs.com/features/physics_engine
  148461. * @returns a physics impostor or null
  148462. */
  148463. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  148464. /** Apply a physic impulse to the mesh
  148465. * @param force defines the force to apply
  148466. * @param contactPoint defines where to apply the force
  148467. * @returns the current mesh
  148468. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  148469. */
  148470. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  148471. /**
  148472. * Creates a physic joint between two meshes
  148473. * @param otherMesh defines the other mesh to use
  148474. * @param pivot1 defines the pivot to use on this mesh
  148475. * @param pivot2 defines the pivot to use on the other mesh
  148476. * @param options defines additional options (can be plugin dependent)
  148477. * @returns the current mesh
  148478. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  148479. */
  148480. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  148481. /** @hidden */
  148482. _disposePhysicsObserver: Nullable<Observer<Node>>;
  148483. }
  148484. /**
  148485. * Defines the physics engine scene component responsible to manage a physics engine
  148486. */
  148487. export class PhysicsEngineSceneComponent implements ISceneComponent {
  148488. /**
  148489. * The component name helpful to identify the component in the list of scene components.
  148490. */
  148491. readonly name: string;
  148492. /**
  148493. * The scene the component belongs to.
  148494. */
  148495. scene: Scene;
  148496. /**
  148497. * Creates a new instance of the component for the given scene
  148498. * @param scene Defines the scene to register the component in
  148499. */
  148500. constructor(scene: Scene);
  148501. /**
  148502. * Registers the component in a given scene
  148503. */
  148504. register(): void;
  148505. /**
  148506. * Rebuilds the elements related to this component in case of
  148507. * context lost for instance.
  148508. */
  148509. rebuild(): void;
  148510. /**
  148511. * Disposes the component and the associated ressources
  148512. */
  148513. dispose(): void;
  148514. }
  148515. }
  148516. declare module BABYLON {
  148517. /**
  148518. * A helper for physics simulations
  148519. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  148520. */
  148521. export class PhysicsHelper {
  148522. private _scene;
  148523. private _physicsEngine;
  148524. /**
  148525. * Initializes the Physics helper
  148526. * @param scene Babylon.js scene
  148527. */
  148528. constructor(scene: Scene);
  148529. /**
  148530. * Applies a radial explosion impulse
  148531. * @param origin the origin of the explosion
  148532. * @param radiusOrEventOptions the radius or the options of radial explosion
  148533. * @param strength the explosion strength
  148534. * @param falloff possible options: Constant & Linear. Defaults to Constant
  148535. * @returns A physics radial explosion event, or null
  148536. */
  148537. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  148538. /**
  148539. * Applies a radial explosion force
  148540. * @param origin the origin of the explosion
  148541. * @param radiusOrEventOptions the radius or the options of radial explosion
  148542. * @param strength the explosion strength
  148543. * @param falloff possible options: Constant & Linear. Defaults to Constant
  148544. * @returns A physics radial explosion event, or null
  148545. */
  148546. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  148547. /**
  148548. * Creates a gravitational field
  148549. * @param origin the origin of the explosion
  148550. * @param radiusOrEventOptions the radius or the options of radial explosion
  148551. * @param strength the explosion strength
  148552. * @param falloff possible options: Constant & Linear. Defaults to Constant
  148553. * @returns A physics gravitational field event, or null
  148554. */
  148555. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  148556. /**
  148557. * Creates a physics updraft event
  148558. * @param origin the origin of the updraft
  148559. * @param radiusOrEventOptions the radius or the options of the updraft
  148560. * @param strength the strength of the updraft
  148561. * @param height the height of the updraft
  148562. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  148563. * @returns A physics updraft event, or null
  148564. */
  148565. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  148566. /**
  148567. * Creates a physics vortex event
  148568. * @param origin the of the vortex
  148569. * @param radiusOrEventOptions the radius or the options of the vortex
  148570. * @param strength the strength of the vortex
  148571. * @param height the height of the vortex
  148572. * @returns a Physics vortex event, or null
  148573. * A physics vortex event or null
  148574. */
  148575. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  148576. }
  148577. /**
  148578. * Represents a physics radial explosion event
  148579. */
  148580. class PhysicsRadialExplosionEvent {
  148581. private _scene;
  148582. private _options;
  148583. private _sphere;
  148584. private _dataFetched;
  148585. /**
  148586. * Initializes a radial explosioin event
  148587. * @param _scene BabylonJS scene
  148588. * @param _options The options for the vortex event
  148589. */
  148590. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  148591. /**
  148592. * Returns the data related to the radial explosion event (sphere).
  148593. * @returns The radial explosion event data
  148594. */
  148595. getData(): PhysicsRadialExplosionEventData;
  148596. /**
  148597. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  148598. * @param impostor A physics imposter
  148599. * @param origin the origin of the explosion
  148600. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  148601. */
  148602. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  148603. /**
  148604. * Triggers affecterd impostors callbacks
  148605. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  148606. */
  148607. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  148608. /**
  148609. * Disposes the sphere.
  148610. * @param force Specifies if the sphere should be disposed by force
  148611. */
  148612. dispose(force?: boolean): void;
  148613. /*** Helpers ***/
  148614. private _prepareSphere;
  148615. private _intersectsWithSphere;
  148616. }
  148617. /**
  148618. * Represents a gravitational field event
  148619. */
  148620. class PhysicsGravitationalFieldEvent {
  148621. private _physicsHelper;
  148622. private _scene;
  148623. private _origin;
  148624. private _options;
  148625. private _tickCallback;
  148626. private _sphere;
  148627. private _dataFetched;
  148628. /**
  148629. * Initializes the physics gravitational field event
  148630. * @param _physicsHelper A physics helper
  148631. * @param _scene BabylonJS scene
  148632. * @param _origin The origin position of the gravitational field event
  148633. * @param _options The options for the vortex event
  148634. */
  148635. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  148636. /**
  148637. * Returns the data related to the gravitational field event (sphere).
  148638. * @returns A gravitational field event
  148639. */
  148640. getData(): PhysicsGravitationalFieldEventData;
  148641. /**
  148642. * Enables the gravitational field.
  148643. */
  148644. enable(): void;
  148645. /**
  148646. * Disables the gravitational field.
  148647. */
  148648. disable(): void;
  148649. /**
  148650. * Disposes the sphere.
  148651. * @param force The force to dispose from the gravitational field event
  148652. */
  148653. dispose(force?: boolean): void;
  148654. private _tick;
  148655. }
  148656. /**
  148657. * Represents a physics updraft event
  148658. */
  148659. class PhysicsUpdraftEvent {
  148660. private _scene;
  148661. private _origin;
  148662. private _options;
  148663. private _physicsEngine;
  148664. private _originTop;
  148665. private _originDirection;
  148666. private _tickCallback;
  148667. private _cylinder;
  148668. private _cylinderPosition;
  148669. private _dataFetched;
  148670. /**
  148671. * Initializes the physics updraft event
  148672. * @param _scene BabylonJS scene
  148673. * @param _origin The origin position of the updraft
  148674. * @param _options The options for the updraft event
  148675. */
  148676. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  148677. /**
  148678. * Returns the data related to the updraft event (cylinder).
  148679. * @returns A physics updraft event
  148680. */
  148681. getData(): PhysicsUpdraftEventData;
  148682. /**
  148683. * Enables the updraft.
  148684. */
  148685. enable(): void;
  148686. /**
  148687. * Disables the updraft.
  148688. */
  148689. disable(): void;
  148690. /**
  148691. * Disposes the cylinder.
  148692. * @param force Specifies if the updraft should be disposed by force
  148693. */
  148694. dispose(force?: boolean): void;
  148695. private getImpostorHitData;
  148696. private _tick;
  148697. /*** Helpers ***/
  148698. private _prepareCylinder;
  148699. private _intersectsWithCylinder;
  148700. }
  148701. /**
  148702. * Represents a physics vortex event
  148703. */
  148704. class PhysicsVortexEvent {
  148705. private _scene;
  148706. private _origin;
  148707. private _options;
  148708. private _physicsEngine;
  148709. private _originTop;
  148710. private _tickCallback;
  148711. private _cylinder;
  148712. private _cylinderPosition;
  148713. private _dataFetched;
  148714. /**
  148715. * Initializes the physics vortex event
  148716. * @param _scene The BabylonJS scene
  148717. * @param _origin The origin position of the vortex
  148718. * @param _options The options for the vortex event
  148719. */
  148720. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  148721. /**
  148722. * Returns the data related to the vortex event (cylinder).
  148723. * @returns The physics vortex event data
  148724. */
  148725. getData(): PhysicsVortexEventData;
  148726. /**
  148727. * Enables the vortex.
  148728. */
  148729. enable(): void;
  148730. /**
  148731. * Disables the cortex.
  148732. */
  148733. disable(): void;
  148734. /**
  148735. * Disposes the sphere.
  148736. * @param force
  148737. */
  148738. dispose(force?: boolean): void;
  148739. private getImpostorHitData;
  148740. private _tick;
  148741. /*** Helpers ***/
  148742. private _prepareCylinder;
  148743. private _intersectsWithCylinder;
  148744. }
  148745. /**
  148746. * Options fot the radial explosion event
  148747. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  148748. */
  148749. export class PhysicsRadialExplosionEventOptions {
  148750. /**
  148751. * The radius of the sphere for the radial explosion.
  148752. */
  148753. radius: number;
  148754. /**
  148755. * The strenth of the explosion.
  148756. */
  148757. strength: number;
  148758. /**
  148759. * The strenght of the force in correspondence to the distance of the affected object
  148760. */
  148761. falloff: PhysicsRadialImpulseFalloff;
  148762. /**
  148763. * Sphere options for the radial explosion.
  148764. */
  148765. sphere: {
  148766. segments: number;
  148767. diameter: number;
  148768. };
  148769. /**
  148770. * Sphere options for the radial explosion.
  148771. */
  148772. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  148773. }
  148774. /**
  148775. * Options fot the updraft event
  148776. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  148777. */
  148778. export class PhysicsUpdraftEventOptions {
  148779. /**
  148780. * The radius of the cylinder for the vortex
  148781. */
  148782. radius: number;
  148783. /**
  148784. * The strenth of the updraft.
  148785. */
  148786. strength: number;
  148787. /**
  148788. * The height of the cylinder for the updraft.
  148789. */
  148790. height: number;
  148791. /**
  148792. * The mode for the the updraft.
  148793. */
  148794. updraftMode: PhysicsUpdraftMode;
  148795. }
  148796. /**
  148797. * Options fot the vortex event
  148798. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  148799. */
  148800. export class PhysicsVortexEventOptions {
  148801. /**
  148802. * The radius of the cylinder for the vortex
  148803. */
  148804. radius: number;
  148805. /**
  148806. * The strenth of the vortex.
  148807. */
  148808. strength: number;
  148809. /**
  148810. * The height of the cylinder for the vortex.
  148811. */
  148812. height: number;
  148813. /**
  148814. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  148815. */
  148816. centripetalForceThreshold: number;
  148817. /**
  148818. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  148819. */
  148820. centripetalForceMultiplier: number;
  148821. /**
  148822. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  148823. */
  148824. centrifugalForceMultiplier: number;
  148825. /**
  148826. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  148827. */
  148828. updraftForceMultiplier: number;
  148829. }
  148830. /**
  148831. * The strenght of the force in correspondence to the distance of the affected object
  148832. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  148833. */
  148834. export enum PhysicsRadialImpulseFalloff {
  148835. /** Defines that impulse is constant in strength across it's whole radius */
  148836. Constant = 0,
  148837. /** Defines that impulse gets weaker if it's further from the origin */
  148838. Linear = 1
  148839. }
  148840. /**
  148841. * The strength of the force in correspondence to the distance of the affected object
  148842. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  148843. */
  148844. export enum PhysicsUpdraftMode {
  148845. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  148846. Center = 0,
  148847. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  148848. Perpendicular = 1
  148849. }
  148850. /**
  148851. * Interface for a physics hit data
  148852. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  148853. */
  148854. export interface PhysicsHitData {
  148855. /**
  148856. * The force applied at the contact point
  148857. */
  148858. force: Vector3;
  148859. /**
  148860. * The contact point
  148861. */
  148862. contactPoint: Vector3;
  148863. /**
  148864. * The distance from the origin to the contact point
  148865. */
  148866. distanceFromOrigin: number;
  148867. }
  148868. /**
  148869. * Interface for radial explosion event data
  148870. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  148871. */
  148872. export interface PhysicsRadialExplosionEventData {
  148873. /**
  148874. * A sphere used for the radial explosion event
  148875. */
  148876. sphere: Mesh;
  148877. }
  148878. /**
  148879. * Interface for gravitational field event data
  148880. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  148881. */
  148882. export interface PhysicsGravitationalFieldEventData {
  148883. /**
  148884. * A sphere mesh used for the gravitational field event
  148885. */
  148886. sphere: Mesh;
  148887. }
  148888. /**
  148889. * Interface for updraft event data
  148890. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  148891. */
  148892. export interface PhysicsUpdraftEventData {
  148893. /**
  148894. * A cylinder used for the updraft event
  148895. */
  148896. cylinder: Mesh;
  148897. }
  148898. /**
  148899. * Interface for vortex event data
  148900. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  148901. */
  148902. export interface PhysicsVortexEventData {
  148903. /**
  148904. * A cylinder used for the vortex event
  148905. */
  148906. cylinder: Mesh;
  148907. }
  148908. /**
  148909. * Interface for an affected physics impostor
  148910. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  148911. */
  148912. export interface PhysicsAffectedImpostorWithData {
  148913. /**
  148914. * The impostor affected by the effect
  148915. */
  148916. impostor: PhysicsImpostor;
  148917. /**
  148918. * The data about the hit/horce from the explosion
  148919. */
  148920. hitData: PhysicsHitData;
  148921. }
  148922. }
  148923. declare module BABYLON {
  148924. /** @hidden */
  148925. export var blackAndWhitePixelShader: {
  148926. name: string;
  148927. shader: string;
  148928. };
  148929. }
  148930. declare module BABYLON {
  148931. /**
  148932. * Post process used to render in black and white
  148933. */
  148934. export class BlackAndWhitePostProcess extends PostProcess {
  148935. /**
  148936. * Linear about to convert he result to black and white (default: 1)
  148937. */
  148938. degree: number;
  148939. /**
  148940. * Gets a string identifying the name of the class
  148941. * @returns "BlackAndWhitePostProcess" string
  148942. */
  148943. getClassName(): string;
  148944. /**
  148945. * Creates a black and white post process
  148946. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  148947. * @param name The name of the effect.
  148948. * @param options The required width/height ratio to downsize to before computing the render pass.
  148949. * @param camera The camera to apply the render pass to.
  148950. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  148951. * @param engine The engine which the post process will be applied. (default: current engine)
  148952. * @param reusable If the post process can be reused on the same frame. (default: false)
  148953. */
  148954. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  148955. /** @hidden */
  148956. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlackAndWhitePostProcess>;
  148957. }
  148958. }
  148959. declare module BABYLON {
  148960. /**
  148961. * This represents a set of one or more post processes in Babylon.
  148962. * A post process can be used to apply a shader to a texture after it is rendered.
  148963. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  148964. */
  148965. export class PostProcessRenderEffect {
  148966. private _postProcesses;
  148967. private _getPostProcesses;
  148968. private _singleInstance;
  148969. private _cameras;
  148970. private _indicesForCamera;
  148971. /**
  148972. * Name of the effect
  148973. * @hidden
  148974. */
  148975. _name: string;
  148976. /**
  148977. * Instantiates a post process render effect.
  148978. * A post process can be used to apply a shader to a texture after it is rendered.
  148979. * @param engine The engine the effect is tied to
  148980. * @param name The name of the effect
  148981. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  148982. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  148983. */
  148984. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  148985. /**
  148986. * Checks if all the post processes in the effect are supported.
  148987. */
  148988. get isSupported(): boolean;
  148989. /**
  148990. * Updates the current state of the effect
  148991. * @hidden
  148992. */
  148993. _update(): void;
  148994. /**
  148995. * Attaches the effect on cameras
  148996. * @param cameras The camera to attach to.
  148997. * @hidden
  148998. */
  148999. _attachCameras(cameras: Camera): void;
  149000. /**
  149001. * Attaches the effect on cameras
  149002. * @param cameras The camera to attach to.
  149003. * @hidden
  149004. */
  149005. _attachCameras(cameras: Camera[]): void;
  149006. /**
  149007. * Detaches the effect on cameras
  149008. * @param cameras The camera to detatch from.
  149009. * @hidden
  149010. */
  149011. _detachCameras(cameras: Camera): void;
  149012. /**
  149013. * Detatches the effect on cameras
  149014. * @param cameras The camera to detatch from.
  149015. * @hidden
  149016. */
  149017. _detachCameras(cameras: Camera[]): void;
  149018. /**
  149019. * Enables the effect on given cameras
  149020. * @param cameras The camera to enable.
  149021. * @hidden
  149022. */
  149023. _enable(cameras: Camera): void;
  149024. /**
  149025. * Enables the effect on given cameras
  149026. * @param cameras The camera to enable.
  149027. * @hidden
  149028. */
  149029. _enable(cameras: Nullable<Camera[]>): void;
  149030. /**
  149031. * Disables the effect on the given cameras
  149032. * @param cameras The camera to disable.
  149033. * @hidden
  149034. */
  149035. _disable(cameras: Camera): void;
  149036. /**
  149037. * Disables the effect on the given cameras
  149038. * @param cameras The camera to disable.
  149039. * @hidden
  149040. */
  149041. _disable(cameras: Nullable<Camera[]>): void;
  149042. /**
  149043. * Gets a list of the post processes contained in the effect.
  149044. * @param camera The camera to get the post processes on.
  149045. * @returns The list of the post processes in the effect.
  149046. */
  149047. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  149048. }
  149049. }
  149050. declare module BABYLON {
  149051. /** @hidden */
  149052. export var extractHighlightsPixelShader: {
  149053. name: string;
  149054. shader: string;
  149055. };
  149056. }
  149057. declare module BABYLON {
  149058. /**
  149059. * 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.
  149060. */
  149061. export class ExtractHighlightsPostProcess extends PostProcess {
  149062. /**
  149063. * The luminance threshold, pixels below this value will be set to black.
  149064. */
  149065. threshold: number;
  149066. /** @hidden */
  149067. _exposure: number;
  149068. /**
  149069. * Post process which has the input texture to be used when performing highlight extraction
  149070. * @hidden
  149071. */
  149072. _inputPostProcess: Nullable<PostProcess>;
  149073. /**
  149074. * Gets a string identifying the name of the class
  149075. * @returns "ExtractHighlightsPostProcess" string
  149076. */
  149077. getClassName(): string;
  149078. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  149079. }
  149080. }
  149081. declare module BABYLON {
  149082. /** @hidden */
  149083. export var bloomMergePixelShader: {
  149084. name: string;
  149085. shader: string;
  149086. };
  149087. }
  149088. declare module BABYLON {
  149089. /**
  149090. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  149091. */
  149092. export class BloomMergePostProcess extends PostProcess {
  149093. /** Weight of the bloom to be added to the original input. */
  149094. weight: number;
  149095. /**
  149096. * Gets a string identifying the name of the class
  149097. * @returns "BloomMergePostProcess" string
  149098. */
  149099. getClassName(): string;
  149100. /**
  149101. * Creates a new instance of @see BloomMergePostProcess
  149102. * @param name The name of the effect.
  149103. * @param originalFromInput Post process which's input will be used for the merge.
  149104. * @param blurred Blurred highlights post process which's output will be used.
  149105. * @param weight Weight of the bloom to be added to the original input.
  149106. * @param options The required width/height ratio to downsize to before computing the render pass.
  149107. * @param camera The camera to apply the render pass to.
  149108. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  149109. * @param engine The engine which the post process will be applied. (default: current engine)
  149110. * @param reusable If the post process can be reused on the same frame. (default: false)
  149111. * @param textureType Type of textures used when performing the post process. (default: 0)
  149112. * @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)
  149113. */
  149114. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  149115. /** Weight of the bloom to be added to the original input. */
  149116. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  149117. }
  149118. }
  149119. declare module BABYLON {
  149120. /**
  149121. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  149122. */
  149123. export class BloomEffect extends PostProcessRenderEffect {
  149124. private bloomScale;
  149125. /**
  149126. * @hidden Internal
  149127. */
  149128. _effects: Array<PostProcess>;
  149129. /**
  149130. * @hidden Internal
  149131. */
  149132. _downscale: ExtractHighlightsPostProcess;
  149133. private _blurX;
  149134. private _blurY;
  149135. private _merge;
  149136. /**
  149137. * The luminance threshold to find bright areas of the image to bloom.
  149138. */
  149139. get threshold(): number;
  149140. set threshold(value: number);
  149141. /**
  149142. * The strength of the bloom.
  149143. */
  149144. get weight(): number;
  149145. set weight(value: number);
  149146. /**
  149147. * Specifies the size of the bloom blur kernel, relative to the final output size
  149148. */
  149149. get kernel(): number;
  149150. set kernel(value: number);
  149151. /**
  149152. * Creates a new instance of @see BloomEffect
  149153. * @param scene The scene the effect belongs to.
  149154. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  149155. * @param bloomKernel The size of the kernel to be used when applying the blur.
  149156. * @param bloomWeight The the strength of bloom.
  149157. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  149158. * @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)
  149159. */
  149160. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  149161. /**
  149162. * Disposes each of the internal effects for a given camera.
  149163. * @param camera The camera to dispose the effect on.
  149164. */
  149165. disposeEffects(camera: Camera): void;
  149166. /**
  149167. * @hidden Internal
  149168. */
  149169. _updateEffects(): void;
  149170. /**
  149171. * Internal
  149172. * @returns if all the contained post processes are ready.
  149173. * @hidden
  149174. */
  149175. _isReady(): boolean;
  149176. }
  149177. }
  149178. declare module BABYLON {
  149179. /** @hidden */
  149180. export var chromaticAberrationPixelShader: {
  149181. name: string;
  149182. shader: string;
  149183. };
  149184. }
  149185. declare module BABYLON {
  149186. /**
  149187. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  149188. */
  149189. export class ChromaticAberrationPostProcess extends PostProcess {
  149190. /**
  149191. * The amount of seperation of rgb channels (default: 30)
  149192. */
  149193. aberrationAmount: number;
  149194. /**
  149195. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  149196. */
  149197. radialIntensity: number;
  149198. /**
  149199. * 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))
  149200. */
  149201. direction: Vector2;
  149202. /**
  149203. * 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))
  149204. */
  149205. centerPosition: Vector2;
  149206. /** The width of the screen to apply the effect on */
  149207. screenWidth: number;
  149208. /** The height of the screen to apply the effect on */
  149209. screenHeight: number;
  149210. /**
  149211. * Gets a string identifying the name of the class
  149212. * @returns "ChromaticAberrationPostProcess" string
  149213. */
  149214. getClassName(): string;
  149215. /**
  149216. * Creates a new instance ChromaticAberrationPostProcess
  149217. * @param name The name of the effect.
  149218. * @param screenWidth The width of the screen to apply the effect on.
  149219. * @param screenHeight The height of the screen to apply the effect on.
  149220. * @param options The required width/height ratio to downsize to before computing the render pass.
  149221. * @param camera The camera to apply the render pass to.
  149222. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  149223. * @param engine The engine which the post process will be applied. (default: current engine)
  149224. * @param reusable If the post process can be reused on the same frame. (default: false)
  149225. * @param textureType Type of textures used when performing the post process. (default: 0)
  149226. * @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)
  149227. */
  149228. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  149229. /** @hidden */
  149230. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ChromaticAberrationPostProcess>;
  149231. }
  149232. }
  149233. declare module BABYLON {
  149234. /** @hidden */
  149235. export var circleOfConfusionPixelShader: {
  149236. name: string;
  149237. shader: string;
  149238. };
  149239. }
  149240. declare module BABYLON {
  149241. /**
  149242. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  149243. */
  149244. export class CircleOfConfusionPostProcess extends PostProcess {
  149245. /**
  149246. * 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.
  149247. */
  149248. lensSize: number;
  149249. /**
  149250. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  149251. */
  149252. fStop: number;
  149253. /**
  149254. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  149255. */
  149256. focusDistance: number;
  149257. /**
  149258. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  149259. */
  149260. focalLength: number;
  149261. /**
  149262. * Gets a string identifying the name of the class
  149263. * @returns "CircleOfConfusionPostProcess" string
  149264. */
  149265. getClassName(): string;
  149266. private _depthTexture;
  149267. /**
  149268. * Creates a new instance CircleOfConfusionPostProcess
  149269. * @param name The name of the effect.
  149270. * @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.
  149271. * @param options The required width/height ratio to downsize to before computing the render pass.
  149272. * @param camera The camera to apply the render pass to.
  149273. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  149274. * @param engine The engine which the post process will be applied. (default: current engine)
  149275. * @param reusable If the post process can be reused on the same frame. (default: false)
  149276. * @param textureType Type of textures used when performing the post process. (default: 0)
  149277. * @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)
  149278. */
  149279. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  149280. /**
  149281. * 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.
  149282. */
  149283. set depthTexture(value: RenderTargetTexture);
  149284. }
  149285. }
  149286. declare module BABYLON {
  149287. /** @hidden */
  149288. export var colorCorrectionPixelShader: {
  149289. name: string;
  149290. shader: string;
  149291. };
  149292. }
  149293. declare module BABYLON {
  149294. /**
  149295. *
  149296. * This post-process allows the modification of rendered colors by using
  149297. * a 'look-up table' (LUT). This effect is also called Color Grading.
  149298. *
  149299. * The object needs to be provided an url to a texture containing the color
  149300. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  149301. * Use an image editing software to tweak the LUT to match your needs.
  149302. *
  149303. * For an example of a color LUT, see here:
  149304. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  149305. * For explanations on color grading, see here:
  149306. * @see http://udn.epicgames.com/Three/ColorGrading.html
  149307. *
  149308. */
  149309. export class ColorCorrectionPostProcess extends PostProcess {
  149310. private _colorTableTexture;
  149311. /**
  149312. * Gets the color table url used to create the LUT texture
  149313. */
  149314. colorTableUrl: string;
  149315. /**
  149316. * Gets a string identifying the name of the class
  149317. * @returns "ColorCorrectionPostProcess" string
  149318. */
  149319. getClassName(): string;
  149320. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  149321. /** @hidden */
  149322. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ColorCorrectionPostProcess>;
  149323. }
  149324. }
  149325. declare module BABYLON {
  149326. /** @hidden */
  149327. export var convolutionPixelShader: {
  149328. name: string;
  149329. shader: string;
  149330. };
  149331. }
  149332. declare module BABYLON {
  149333. /**
  149334. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  149335. * input texture to perform effects such as edge detection or sharpening
  149336. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  149337. */
  149338. export class ConvolutionPostProcess extends PostProcess {
  149339. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  149340. kernel: number[];
  149341. /**
  149342. * Gets a string identifying the name of the class
  149343. * @returns "ConvolutionPostProcess" string
  149344. */
  149345. getClassName(): string;
  149346. /**
  149347. * Creates a new instance ConvolutionPostProcess
  149348. * @param name The name of the effect.
  149349. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  149350. * @param options The required width/height ratio to downsize to before computing the render pass.
  149351. * @param camera The camera to apply the render pass to.
  149352. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  149353. * @param engine The engine which the post process will be applied. (default: current engine)
  149354. * @param reusable If the post process can be reused on the same frame. (default: false)
  149355. * @param textureType Type of textures used when performing the post process. (default: 0)
  149356. */
  149357. constructor(name: string, kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  149358. /** @hidden */
  149359. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ConvolutionPostProcess>;
  149360. /**
  149361. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  149362. */
  149363. static EdgeDetect0Kernel: number[];
  149364. /**
  149365. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  149366. */
  149367. static EdgeDetect1Kernel: number[];
  149368. /**
  149369. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  149370. */
  149371. static EdgeDetect2Kernel: number[];
  149372. /**
  149373. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  149374. */
  149375. static SharpenKernel: number[];
  149376. /**
  149377. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  149378. */
  149379. static EmbossKernel: number[];
  149380. /**
  149381. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  149382. */
  149383. static GaussianKernel: number[];
  149384. }
  149385. }
  149386. declare module BABYLON {
  149387. /**
  149388. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  149389. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  149390. * based on samples that have a large difference in distance than the center pixel.
  149391. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  149392. */
  149393. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  149394. /**
  149395. * The direction the blur should be applied
  149396. */
  149397. direction: Vector2;
  149398. /**
  149399. * Gets a string identifying the name of the class
  149400. * @returns "DepthOfFieldBlurPostProcess" string
  149401. */
  149402. getClassName(): string;
  149403. /**
  149404. * Creates a new instance CircleOfConfusionPostProcess
  149405. * @param name The name of the effect.
  149406. * @param scene The scene the effect belongs to.
  149407. * @param direction The direction the blur should be applied.
  149408. * @param kernel The size of the kernel used to blur.
  149409. * @param options The required width/height ratio to downsize to before computing the render pass.
  149410. * @param camera The camera to apply the render pass to.
  149411. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  149412. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  149413. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  149414. * @param engine The engine which the post process will be applied. (default: current engine)
  149415. * @param reusable If the post process can be reused on the same frame. (default: false)
  149416. * @param textureType Type of textures used when performing the post process. (default: 0)
  149417. * @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)
  149418. */
  149419. 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);
  149420. }
  149421. }
  149422. declare module BABYLON {
  149423. /** @hidden */
  149424. export var depthOfFieldMergePixelShader: {
  149425. name: string;
  149426. shader: string;
  149427. };
  149428. }
  149429. declare module BABYLON {
  149430. /**
  149431. * Options to be set when merging outputs from the default pipeline.
  149432. */
  149433. export class DepthOfFieldMergePostProcessOptions {
  149434. /**
  149435. * The original image to merge on top of
  149436. */
  149437. originalFromInput: PostProcess;
  149438. /**
  149439. * Parameters to perform the merge of the depth of field effect
  149440. */
  149441. depthOfField?: {
  149442. circleOfConfusion: PostProcess;
  149443. blurSteps: Array<PostProcess>;
  149444. };
  149445. /**
  149446. * Parameters to perform the merge of bloom effect
  149447. */
  149448. bloom?: {
  149449. blurred: PostProcess;
  149450. weight: number;
  149451. };
  149452. }
  149453. /**
  149454. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  149455. */
  149456. export class DepthOfFieldMergePostProcess extends PostProcess {
  149457. private blurSteps;
  149458. /**
  149459. * Gets a string identifying the name of the class
  149460. * @returns "DepthOfFieldMergePostProcess" string
  149461. */
  149462. getClassName(): string;
  149463. /**
  149464. * Creates a new instance of DepthOfFieldMergePostProcess
  149465. * @param name The name of the effect.
  149466. * @param originalFromInput Post process which's input will be used for the merge.
  149467. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  149468. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  149469. * @param options The required width/height ratio to downsize to before computing the render pass.
  149470. * @param camera The camera to apply the render pass to.
  149471. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  149472. * @param engine The engine which the post process will be applied. (default: current engine)
  149473. * @param reusable If the post process can be reused on the same frame. (default: false)
  149474. * @param textureType Type of textures used when performing the post process. (default: 0)
  149475. * @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)
  149476. */
  149477. 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);
  149478. /**
  149479. * Updates the effect with the current post process compile time values and recompiles the shader.
  149480. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  149481. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  149482. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  149483. * @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
  149484. * @param onCompiled Called when the shader has been compiled.
  149485. * @param onError Called if there is an error when compiling a shader.
  149486. */
  149487. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  149488. }
  149489. }
  149490. declare module BABYLON {
  149491. /**
  149492. * Specifies the level of max blur that should be applied when using the depth of field effect
  149493. */
  149494. export enum DepthOfFieldEffectBlurLevel {
  149495. /**
  149496. * Subtle blur
  149497. */
  149498. Low = 0,
  149499. /**
  149500. * Medium blur
  149501. */
  149502. Medium = 1,
  149503. /**
  149504. * Large blur
  149505. */
  149506. High = 2
  149507. }
  149508. /**
  149509. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  149510. */
  149511. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  149512. private _circleOfConfusion;
  149513. /**
  149514. * @hidden Internal, blurs from high to low
  149515. */
  149516. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  149517. private _depthOfFieldBlurY;
  149518. private _dofMerge;
  149519. /**
  149520. * @hidden Internal post processes in depth of field effect
  149521. */
  149522. _effects: Array<PostProcess>;
  149523. /**
  149524. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  149525. */
  149526. set focalLength(value: number);
  149527. get focalLength(): number;
  149528. /**
  149529. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  149530. */
  149531. set fStop(value: number);
  149532. get fStop(): number;
  149533. /**
  149534. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  149535. */
  149536. set focusDistance(value: number);
  149537. get focusDistance(): number;
  149538. /**
  149539. * 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.
  149540. */
  149541. set lensSize(value: number);
  149542. get lensSize(): number;
  149543. /**
  149544. * Creates a new instance DepthOfFieldEffect
  149545. * @param scene The scene the effect belongs to.
  149546. * @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.
  149547. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  149548. * @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)
  149549. */
  149550. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  149551. /**
  149552. * Get the current class name of the current effet
  149553. * @returns "DepthOfFieldEffect"
  149554. */
  149555. getClassName(): string;
  149556. /**
  149557. * 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.
  149558. */
  149559. set depthTexture(value: RenderTargetTexture);
  149560. /**
  149561. * Disposes each of the internal effects for a given camera.
  149562. * @param camera The camera to dispose the effect on.
  149563. */
  149564. disposeEffects(camera: Camera): void;
  149565. /**
  149566. * @hidden Internal
  149567. */
  149568. _updateEffects(): void;
  149569. /**
  149570. * Internal
  149571. * @returns if all the contained post processes are ready.
  149572. * @hidden
  149573. */
  149574. _isReady(): boolean;
  149575. }
  149576. }
  149577. declare module BABYLON {
  149578. /** @hidden */
  149579. export var displayPassPixelShader: {
  149580. name: string;
  149581. shader: string;
  149582. };
  149583. }
  149584. declare module BABYLON {
  149585. /**
  149586. * DisplayPassPostProcess which produces an output the same as it's input
  149587. */
  149588. export class DisplayPassPostProcess extends PostProcess {
  149589. /**
  149590. * Gets a string identifying the name of the class
  149591. * @returns "DisplayPassPostProcess" string
  149592. */
  149593. getClassName(): string;
  149594. /**
  149595. * Creates the DisplayPassPostProcess
  149596. * @param name The name of the effect.
  149597. * @param options The required width/height ratio to downsize to before computing the render pass.
  149598. * @param camera The camera to apply the render pass to.
  149599. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  149600. * @param engine The engine which the post process will be applied. (default: current engine)
  149601. * @param reusable If the post process can be reused on the same frame. (default: false)
  149602. */
  149603. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  149604. /** @hidden */
  149605. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<DisplayPassPostProcess>;
  149606. }
  149607. }
  149608. declare module BABYLON {
  149609. /** @hidden */
  149610. export var filterPixelShader: {
  149611. name: string;
  149612. shader: string;
  149613. };
  149614. }
  149615. declare module BABYLON {
  149616. /**
  149617. * Applies a kernel filter to the image
  149618. */
  149619. export class FilterPostProcess extends PostProcess {
  149620. /** The matrix to be applied to the image */
  149621. kernelMatrix: Matrix;
  149622. /**
  149623. * Gets a string identifying the name of the class
  149624. * @returns "FilterPostProcess" string
  149625. */
  149626. getClassName(): string;
  149627. /**
  149628. *
  149629. * @param name The name of the effect.
  149630. * @param kernelMatrix The matrix to be applied to the image
  149631. * @param options The required width/height ratio to downsize to before computing the render pass.
  149632. * @param camera The camera to apply the render pass to.
  149633. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  149634. * @param engine The engine which the post process will be applied. (default: current engine)
  149635. * @param reusable If the post process can be reused on the same frame. (default: false)
  149636. */
  149637. constructor(name: string, kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  149638. /** @hidden */
  149639. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<FilterPostProcess>;
  149640. }
  149641. }
  149642. declare module BABYLON {
  149643. /** @hidden */
  149644. export var fxaaPixelShader: {
  149645. name: string;
  149646. shader: string;
  149647. };
  149648. }
  149649. declare module BABYLON {
  149650. /** @hidden */
  149651. export var fxaaVertexShader: {
  149652. name: string;
  149653. shader: string;
  149654. };
  149655. }
  149656. declare module BABYLON {
  149657. /**
  149658. * Fxaa post process
  149659. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  149660. */
  149661. export class FxaaPostProcess extends PostProcess {
  149662. /**
  149663. * Gets a string identifying the name of the class
  149664. * @returns "FxaaPostProcess" string
  149665. */
  149666. getClassName(): string;
  149667. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  149668. private _getDefines;
  149669. /** @hidden */
  149670. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): FxaaPostProcess;
  149671. }
  149672. }
  149673. declare module BABYLON {
  149674. /** @hidden */
  149675. export var grainPixelShader: {
  149676. name: string;
  149677. shader: string;
  149678. };
  149679. }
  149680. declare module BABYLON {
  149681. /**
  149682. * The GrainPostProcess adds noise to the image at mid luminance levels
  149683. */
  149684. export class GrainPostProcess extends PostProcess {
  149685. /**
  149686. * The intensity of the grain added (default: 30)
  149687. */
  149688. intensity: number;
  149689. /**
  149690. * If the grain should be randomized on every frame
  149691. */
  149692. animated: boolean;
  149693. /**
  149694. * Gets a string identifying the name of the class
  149695. * @returns "GrainPostProcess" string
  149696. */
  149697. getClassName(): string;
  149698. /**
  149699. * Creates a new instance of @see GrainPostProcess
  149700. * @param name The name of the effect.
  149701. * @param options The required width/height ratio to downsize to before computing the render pass.
  149702. * @param camera The camera to apply the render pass to.
  149703. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  149704. * @param engine The engine which the post process will be applied. (default: current engine)
  149705. * @param reusable If the post process can be reused on the same frame. (default: false)
  149706. * @param textureType Type of textures used when performing the post process. (default: 0)
  149707. * @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)
  149708. */
  149709. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  149710. /** @hidden */
  149711. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): GrainPostProcess;
  149712. }
  149713. }
  149714. declare module BABYLON {
  149715. /** @hidden */
  149716. export var highlightsPixelShader: {
  149717. name: string;
  149718. shader: string;
  149719. };
  149720. }
  149721. declare module BABYLON {
  149722. /**
  149723. * Extracts highlights from the image
  149724. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  149725. */
  149726. export class HighlightsPostProcess extends PostProcess {
  149727. /**
  149728. * Gets a string identifying the name of the class
  149729. * @returns "HighlightsPostProcess" string
  149730. */
  149731. getClassName(): string;
  149732. /**
  149733. * Extracts highlights from the image
  149734. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  149735. * @param name The name of the effect.
  149736. * @param options The required width/height ratio to downsize to before computing the render pass.
  149737. * @param camera The camera to apply the render pass to.
  149738. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  149739. * @param engine The engine which the post process will be applied. (default: current engine)
  149740. * @param reusable If the post process can be reused on the same frame. (default: false)
  149741. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  149742. */
  149743. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  149744. }
  149745. }
  149746. declare module BABYLON {
  149747. /** @hidden */
  149748. export var mrtFragmentDeclaration: {
  149749. name: string;
  149750. shader: string;
  149751. };
  149752. }
  149753. declare module BABYLON {
  149754. /** @hidden */
  149755. export var geometryPixelShader: {
  149756. name: string;
  149757. shader: string;
  149758. };
  149759. }
  149760. declare module BABYLON {
  149761. /** @hidden */
  149762. export var geometryVertexShader: {
  149763. name: string;
  149764. shader: string;
  149765. };
  149766. }
  149767. declare module BABYLON {
  149768. /** @hidden */
  149769. interface ISavedTransformationMatrix {
  149770. world: Matrix;
  149771. viewProjection: Matrix;
  149772. }
  149773. /**
  149774. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  149775. */
  149776. export class GeometryBufferRenderer {
  149777. /**
  149778. * Constant used to retrieve the position texture index in the G-Buffer textures array
  149779. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  149780. */
  149781. static readonly POSITION_TEXTURE_TYPE: number;
  149782. /**
  149783. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  149784. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  149785. */
  149786. static readonly VELOCITY_TEXTURE_TYPE: number;
  149787. /**
  149788. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  149789. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  149790. */
  149791. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  149792. /**
  149793. * Dictionary used to store the previous transformation matrices of each rendered mesh
  149794. * in order to compute objects velocities when enableVelocity is set to "true"
  149795. * @hidden
  149796. */
  149797. _previousTransformationMatrices: {
  149798. [index: number]: ISavedTransformationMatrix;
  149799. };
  149800. /**
  149801. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  149802. * in order to compute objects velocities when enableVelocity is set to "true"
  149803. * @hidden
  149804. */
  149805. _previousBonesTransformationMatrices: {
  149806. [index: number]: Float32Array;
  149807. };
  149808. /**
  149809. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  149810. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  149811. */
  149812. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  149813. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  149814. renderTransparentMeshes: boolean;
  149815. private _scene;
  149816. private _resizeObserver;
  149817. private _multiRenderTarget;
  149818. private _ratio;
  149819. private _enablePosition;
  149820. private _enableVelocity;
  149821. private _enableReflectivity;
  149822. private _positionIndex;
  149823. private _velocityIndex;
  149824. private _reflectivityIndex;
  149825. protected _effect: Effect;
  149826. protected _cachedDefines: string;
  149827. /**
  149828. * Set the render list (meshes to be rendered) used in the G buffer.
  149829. */
  149830. set renderList(meshes: Mesh[]);
  149831. /**
  149832. * Gets wether or not G buffer are supported by the running hardware.
  149833. * This requires draw buffer supports
  149834. */
  149835. get isSupported(): boolean;
  149836. /**
  149837. * Returns the index of the given texture type in the G-Buffer textures array
  149838. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  149839. * @returns the index of the given texture type in the G-Buffer textures array
  149840. */
  149841. getTextureIndex(textureType: number): number;
  149842. /**
  149843. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  149844. */
  149845. get enablePosition(): boolean;
  149846. /**
  149847. * Sets whether or not objects positions are enabled for the G buffer.
  149848. */
  149849. set enablePosition(enable: boolean);
  149850. /**
  149851. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  149852. */
  149853. get enableVelocity(): boolean;
  149854. /**
  149855. * Sets wether or not objects velocities are enabled for the G buffer.
  149856. */
  149857. set enableVelocity(enable: boolean);
  149858. /**
  149859. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  149860. */
  149861. get enableReflectivity(): boolean;
  149862. /**
  149863. * Sets wether or not objects roughness are enabled for the G buffer.
  149864. */
  149865. set enableReflectivity(enable: boolean);
  149866. /**
  149867. * Gets the scene associated with the buffer.
  149868. */
  149869. get scene(): Scene;
  149870. /**
  149871. * Gets the ratio used by the buffer during its creation.
  149872. * How big is the buffer related to the main canvas.
  149873. */
  149874. get ratio(): number;
  149875. /** @hidden */
  149876. static _SceneComponentInitialization: (scene: Scene) => void;
  149877. /**
  149878. * Creates a new G Buffer for the scene
  149879. * @param scene The scene the buffer belongs to
  149880. * @param ratio How big is the buffer related to the main canvas.
  149881. */
  149882. constructor(scene: Scene, ratio?: number);
  149883. /**
  149884. * Checks wether everything is ready to render a submesh to the G buffer.
  149885. * @param subMesh the submesh to check readiness for
  149886. * @param useInstances is the mesh drawn using instance or not
  149887. * @returns true if ready otherwise false
  149888. */
  149889. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  149890. /**
  149891. * Gets the current underlying G Buffer.
  149892. * @returns the buffer
  149893. */
  149894. getGBuffer(): MultiRenderTarget;
  149895. /**
  149896. * Gets the number of samples used to render the buffer (anti aliasing).
  149897. */
  149898. get samples(): number;
  149899. /**
  149900. * Sets the number of samples used to render the buffer (anti aliasing).
  149901. */
  149902. set samples(value: number);
  149903. /**
  149904. * Disposes the renderer and frees up associated resources.
  149905. */
  149906. dispose(): void;
  149907. protected _createRenderTargets(): void;
  149908. private _copyBonesTransformationMatrices;
  149909. }
  149910. }
  149911. declare module BABYLON {
  149912. interface Scene {
  149913. /** @hidden (Backing field) */
  149914. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  149915. /**
  149916. * Gets or Sets the current geometry buffer associated to the scene.
  149917. */
  149918. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  149919. /**
  149920. * Enables a GeometryBufferRender and associates it with the scene
  149921. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  149922. * @returns the GeometryBufferRenderer
  149923. */
  149924. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  149925. /**
  149926. * Disables the GeometryBufferRender associated with the scene
  149927. */
  149928. disableGeometryBufferRenderer(): void;
  149929. }
  149930. /**
  149931. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  149932. * in several rendering techniques.
  149933. */
  149934. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  149935. /**
  149936. * The component name helpful to identify the component in the list of scene components.
  149937. */
  149938. readonly name: string;
  149939. /**
  149940. * The scene the component belongs to.
  149941. */
  149942. scene: Scene;
  149943. /**
  149944. * Creates a new instance of the component for the given scene
  149945. * @param scene Defines the scene to register the component in
  149946. */
  149947. constructor(scene: Scene);
  149948. /**
  149949. * Registers the component in a given scene
  149950. */
  149951. register(): void;
  149952. /**
  149953. * Rebuilds the elements related to this component in case of
  149954. * context lost for instance.
  149955. */
  149956. rebuild(): void;
  149957. /**
  149958. * Disposes the component and the associated ressources
  149959. */
  149960. dispose(): void;
  149961. private _gatherRenderTargets;
  149962. }
  149963. }
  149964. declare module BABYLON {
  149965. /** @hidden */
  149966. export var motionBlurPixelShader: {
  149967. name: string;
  149968. shader: string;
  149969. };
  149970. }
  149971. declare module BABYLON {
  149972. /**
  149973. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  149974. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  149975. * As an example, all you have to do is to create the post-process:
  149976. * var mb = new BABYLON.MotionBlurPostProcess(
  149977. * 'mb', // The name of the effect.
  149978. * scene, // The scene containing the objects to blur according to their velocity.
  149979. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  149980. * camera // The camera to apply the render pass to.
  149981. * );
  149982. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  149983. */
  149984. export class MotionBlurPostProcess extends PostProcess {
  149985. /**
  149986. * Defines how much the image is blurred by the movement. Default value is equal to 1
  149987. */
  149988. motionStrength: number;
  149989. /**
  149990. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  149991. */
  149992. get motionBlurSamples(): number;
  149993. /**
  149994. * Sets the number of iterations to be used for motion blur quality
  149995. */
  149996. set motionBlurSamples(samples: number);
  149997. private _motionBlurSamples;
  149998. private _geometryBufferRenderer;
  149999. /**
  150000. * Gets a string identifying the name of the class
  150001. * @returns "MotionBlurPostProcess" string
  150002. */
  150003. getClassName(): string;
  150004. /**
  150005. * Creates a new instance MotionBlurPostProcess
  150006. * @param name The name of the effect.
  150007. * @param scene The scene containing the objects to blur according to their velocity.
  150008. * @param options The required width/height ratio to downsize to before computing the render pass.
  150009. * @param camera The camera to apply the render pass to.
  150010. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  150011. * @param engine The engine which the post process will be applied. (default: current engine)
  150012. * @param reusable If the post process can be reused on the same frame. (default: false)
  150013. * @param textureType Type of textures used when performing the post process. (default: 0)
  150014. * @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)
  150015. */
  150016. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  150017. /**
  150018. * Excludes the given skinned mesh from computing bones velocities.
  150019. * 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.
  150020. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  150021. */
  150022. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  150023. /**
  150024. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  150025. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  150026. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  150027. */
  150028. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  150029. /**
  150030. * Disposes the post process.
  150031. * @param camera The camera to dispose the post process on.
  150032. */
  150033. dispose(camera?: Camera): void;
  150034. /** @hidden */
  150035. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<MotionBlurPostProcess>;
  150036. }
  150037. }
  150038. declare module BABYLON {
  150039. /** @hidden */
  150040. export var refractionPixelShader: {
  150041. name: string;
  150042. shader: string;
  150043. };
  150044. }
  150045. declare module BABYLON {
  150046. /**
  150047. * Post process which applies a refractin texture
  150048. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  150049. */
  150050. export class RefractionPostProcess extends PostProcess {
  150051. private _refTexture;
  150052. private _ownRefractionTexture;
  150053. /** the base color of the refraction (used to taint the rendering) */
  150054. color: Color3;
  150055. /** simulated refraction depth */
  150056. depth: number;
  150057. /** the coefficient of the base color (0 to remove base color tainting) */
  150058. colorLevel: number;
  150059. /** Gets the url used to load the refraction texture */
  150060. refractionTextureUrl: string;
  150061. /**
  150062. * Gets or sets the refraction texture
  150063. * Please note that you are responsible for disposing the texture if you set it manually
  150064. */
  150065. get refractionTexture(): Texture;
  150066. set refractionTexture(value: Texture);
  150067. /**
  150068. * Gets a string identifying the name of the class
  150069. * @returns "RefractionPostProcess" string
  150070. */
  150071. getClassName(): string;
  150072. /**
  150073. * Initializes the RefractionPostProcess
  150074. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  150075. * @param name The name of the effect.
  150076. * @param refractionTextureUrl Url of the refraction texture to use
  150077. * @param color the base color of the refraction (used to taint the rendering)
  150078. * @param depth simulated refraction depth
  150079. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  150080. * @param camera The camera to apply the render pass to.
  150081. * @param options The required width/height ratio to downsize to before computing the render pass.
  150082. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  150083. * @param engine The engine which the post process will be applied. (default: current engine)
  150084. * @param reusable If the post process can be reused on the same frame. (default: false)
  150085. */
  150086. constructor(name: string, refractionTextureUrl: string, color: Color3, depth: number, colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  150087. /**
  150088. * Disposes of the post process
  150089. * @param camera Camera to dispose post process on
  150090. */
  150091. dispose(camera: Camera): void;
  150092. /** @hidden */
  150093. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): RefractionPostProcess;
  150094. }
  150095. }
  150096. declare module BABYLON {
  150097. /** @hidden */
  150098. export var sharpenPixelShader: {
  150099. name: string;
  150100. shader: string;
  150101. };
  150102. }
  150103. declare module BABYLON {
  150104. /**
  150105. * The SharpenPostProcess applies a sharpen kernel to every pixel
  150106. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  150107. */
  150108. export class SharpenPostProcess extends PostProcess {
  150109. /**
  150110. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  150111. */
  150112. colorAmount: number;
  150113. /**
  150114. * How much sharpness should be applied (default: 0.3)
  150115. */
  150116. edgeAmount: number;
  150117. /**
  150118. * Gets a string identifying the name of the class
  150119. * @returns "SharpenPostProcess" string
  150120. */
  150121. getClassName(): string;
  150122. /**
  150123. * Creates a new instance ConvolutionPostProcess
  150124. * @param name The name of the effect.
  150125. * @param options The required width/height ratio to downsize to before computing the render pass.
  150126. * @param camera The camera to apply the render pass to.
  150127. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  150128. * @param engine The engine which the post process will be applied. (default: current engine)
  150129. * @param reusable If the post process can be reused on the same frame. (default: false)
  150130. * @param textureType Type of textures used when performing the post process. (default: 0)
  150131. * @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)
  150132. */
  150133. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  150134. /** @hidden */
  150135. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): SharpenPostProcess;
  150136. }
  150137. }
  150138. declare module BABYLON {
  150139. /**
  150140. * PostProcessRenderPipeline
  150141. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  150142. */
  150143. export class PostProcessRenderPipeline {
  150144. private engine;
  150145. private _renderEffects;
  150146. private _renderEffectsForIsolatedPass;
  150147. /**
  150148. * List of inspectable custom properties (used by the Inspector)
  150149. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  150150. */
  150151. inspectableCustomProperties: IInspectable[];
  150152. /**
  150153. * @hidden
  150154. */
  150155. protected _cameras: Camera[];
  150156. /** @hidden */
  150157. _name: string;
  150158. /**
  150159. * Gets pipeline name
  150160. */
  150161. get name(): string;
  150162. /** Gets the list of attached cameras */
  150163. get cameras(): Camera[];
  150164. /**
  150165. * Initializes a PostProcessRenderPipeline
  150166. * @param engine engine to add the pipeline to
  150167. * @param name name of the pipeline
  150168. */
  150169. constructor(engine: Engine, name: string);
  150170. /**
  150171. * Gets the class name
  150172. * @returns "PostProcessRenderPipeline"
  150173. */
  150174. getClassName(): string;
  150175. /**
  150176. * If all the render effects in the pipeline are supported
  150177. */
  150178. get isSupported(): boolean;
  150179. /**
  150180. * Adds an effect to the pipeline
  150181. * @param renderEffect the effect to add
  150182. */
  150183. addEffect(renderEffect: PostProcessRenderEffect): void;
  150184. /** @hidden */
  150185. _rebuild(): void;
  150186. /** @hidden */
  150187. _enableEffect(renderEffectName: string, cameras: Camera): void;
  150188. /** @hidden */
  150189. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  150190. /** @hidden */
  150191. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  150192. /** @hidden */
  150193. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  150194. /** @hidden */
  150195. _attachCameras(cameras: Camera, unique: boolean): void;
  150196. /** @hidden */
  150197. _attachCameras(cameras: Camera[], unique: boolean): void;
  150198. /** @hidden */
  150199. _detachCameras(cameras: Camera): void;
  150200. /** @hidden */
  150201. _detachCameras(cameras: Nullable<Camera[]>): void;
  150202. /** @hidden */
  150203. _update(): void;
  150204. /** @hidden */
  150205. _reset(): void;
  150206. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  150207. /**
  150208. * Sets the required values to the prepass renderer.
  150209. * @param prePassRenderer defines the prepass renderer to setup.
  150210. * @returns true if the pre pass is needed.
  150211. */
  150212. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  150213. /**
  150214. * Disposes of the pipeline
  150215. */
  150216. dispose(): void;
  150217. }
  150218. }
  150219. declare module BABYLON {
  150220. /**
  150221. * PostProcessRenderPipelineManager class
  150222. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  150223. */
  150224. export class PostProcessRenderPipelineManager {
  150225. private _renderPipelines;
  150226. /**
  150227. * Initializes a PostProcessRenderPipelineManager
  150228. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  150229. */
  150230. constructor();
  150231. /**
  150232. * Gets the list of supported render pipelines
  150233. */
  150234. get supportedPipelines(): PostProcessRenderPipeline[];
  150235. /**
  150236. * Adds a pipeline to the manager
  150237. * @param renderPipeline The pipeline to add
  150238. */
  150239. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  150240. /**
  150241. * Attaches a camera to the pipeline
  150242. * @param renderPipelineName The name of the pipeline to attach to
  150243. * @param cameras the camera to attach
  150244. * @param unique if the camera can be attached multiple times to the pipeline
  150245. */
  150246. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  150247. /**
  150248. * Detaches a camera from the pipeline
  150249. * @param renderPipelineName The name of the pipeline to detach from
  150250. * @param cameras the camera to detach
  150251. */
  150252. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  150253. /**
  150254. * Enables an effect by name on a pipeline
  150255. * @param renderPipelineName the name of the pipeline to enable the effect in
  150256. * @param renderEffectName the name of the effect to enable
  150257. * @param cameras the cameras that the effect should be enabled on
  150258. */
  150259. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  150260. /**
  150261. * Disables an effect by name on a pipeline
  150262. * @param renderPipelineName the name of the pipeline to disable the effect in
  150263. * @param renderEffectName the name of the effect to disable
  150264. * @param cameras the cameras that the effect should be disabled on
  150265. */
  150266. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  150267. /**
  150268. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  150269. */
  150270. update(): void;
  150271. /** @hidden */
  150272. _rebuild(): void;
  150273. /**
  150274. * Disposes of the manager and pipelines
  150275. */
  150276. dispose(): void;
  150277. }
  150278. }
  150279. declare module BABYLON {
  150280. interface Scene {
  150281. /** @hidden (Backing field) */
  150282. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  150283. /**
  150284. * Gets the postprocess render pipeline manager
  150285. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  150286. * @see https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  150287. */
  150288. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  150289. }
  150290. /**
  150291. * Defines the Render Pipeline scene component responsible to rendering pipelines
  150292. */
  150293. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  150294. /**
  150295. * The component name helpfull to identify the component in the list of scene components.
  150296. */
  150297. readonly name: string;
  150298. /**
  150299. * The scene the component belongs to.
  150300. */
  150301. scene: Scene;
  150302. /**
  150303. * Creates a new instance of the component for the given scene
  150304. * @param scene Defines the scene to register the component in
  150305. */
  150306. constructor(scene: Scene);
  150307. /**
  150308. * Registers the component in a given scene
  150309. */
  150310. register(): void;
  150311. /**
  150312. * Rebuilds the elements related to this component in case of
  150313. * context lost for instance.
  150314. */
  150315. rebuild(): void;
  150316. /**
  150317. * Disposes the component and the associated ressources
  150318. */
  150319. dispose(): void;
  150320. private _gatherRenderTargets;
  150321. }
  150322. }
  150323. declare module BABYLON {
  150324. /**
  150325. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  150326. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  150327. */
  150328. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  150329. private _scene;
  150330. private _camerasToBeAttached;
  150331. /**
  150332. * ID of the sharpen post process,
  150333. */
  150334. private readonly SharpenPostProcessId;
  150335. /**
  150336. * @ignore
  150337. * ID of the image processing post process;
  150338. */
  150339. readonly ImageProcessingPostProcessId: string;
  150340. /**
  150341. * @ignore
  150342. * ID of the Fast Approximate Anti-Aliasing post process;
  150343. */
  150344. readonly FxaaPostProcessId: string;
  150345. /**
  150346. * ID of the chromatic aberration post process,
  150347. */
  150348. private readonly ChromaticAberrationPostProcessId;
  150349. /**
  150350. * ID of the grain post process
  150351. */
  150352. private readonly GrainPostProcessId;
  150353. /**
  150354. * Sharpen post process which will apply a sharpen convolution to enhance edges
  150355. */
  150356. sharpen: SharpenPostProcess;
  150357. private _sharpenEffect;
  150358. private bloom;
  150359. /**
  150360. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  150361. */
  150362. depthOfField: DepthOfFieldEffect;
  150363. /**
  150364. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  150365. */
  150366. fxaa: FxaaPostProcess;
  150367. /**
  150368. * Image post processing pass used to perform operations such as tone mapping or color grading.
  150369. */
  150370. imageProcessing: ImageProcessingPostProcess;
  150371. /**
  150372. * Chromatic aberration post process which will shift rgb colors in the image
  150373. */
  150374. chromaticAberration: ChromaticAberrationPostProcess;
  150375. private _chromaticAberrationEffect;
  150376. /**
  150377. * Grain post process which add noise to the image
  150378. */
  150379. grain: GrainPostProcess;
  150380. private _grainEffect;
  150381. /**
  150382. * Glow post process which adds a glow to emissive areas of the image
  150383. */
  150384. private _glowLayer;
  150385. /**
  150386. * Animations which can be used to tweak settings over a period of time
  150387. */
  150388. animations: Animation[];
  150389. private _imageProcessingConfigurationObserver;
  150390. private _sharpenEnabled;
  150391. private _bloomEnabled;
  150392. private _depthOfFieldEnabled;
  150393. private _depthOfFieldBlurLevel;
  150394. private _fxaaEnabled;
  150395. private _imageProcessingEnabled;
  150396. private _defaultPipelineTextureType;
  150397. private _bloomScale;
  150398. private _chromaticAberrationEnabled;
  150399. private _grainEnabled;
  150400. private _buildAllowed;
  150401. /**
  150402. * Gets active scene
  150403. */
  150404. get scene(): Scene;
  150405. /**
  150406. * Enable or disable the sharpen process from the pipeline
  150407. */
  150408. set sharpenEnabled(enabled: boolean);
  150409. get sharpenEnabled(): boolean;
  150410. private _resizeObserver;
  150411. private _hardwareScaleLevel;
  150412. private _bloomKernel;
  150413. /**
  150414. * Specifies the size of the bloom blur kernel, relative to the final output size
  150415. */
  150416. get bloomKernel(): number;
  150417. set bloomKernel(value: number);
  150418. /**
  150419. * Specifies the weight of the bloom in the final rendering
  150420. */
  150421. private _bloomWeight;
  150422. /**
  150423. * Specifies the luma threshold for the area that will be blurred by the bloom
  150424. */
  150425. private _bloomThreshold;
  150426. private _hdr;
  150427. /**
  150428. * The strength of the bloom.
  150429. */
  150430. set bloomWeight(value: number);
  150431. get bloomWeight(): number;
  150432. /**
  150433. * The strength of the bloom.
  150434. */
  150435. set bloomThreshold(value: number);
  150436. get bloomThreshold(): number;
  150437. /**
  150438. * The scale of the bloom, lower value will provide better performance.
  150439. */
  150440. set bloomScale(value: number);
  150441. get bloomScale(): number;
  150442. /**
  150443. * Enable or disable the bloom from the pipeline
  150444. */
  150445. set bloomEnabled(enabled: boolean);
  150446. get bloomEnabled(): boolean;
  150447. private _rebuildBloom;
  150448. /**
  150449. * If the depth of field is enabled.
  150450. */
  150451. get depthOfFieldEnabled(): boolean;
  150452. set depthOfFieldEnabled(enabled: boolean);
  150453. /**
  150454. * Blur level of the depth of field effect. (Higher blur will effect performance)
  150455. */
  150456. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  150457. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  150458. /**
  150459. * If the anti aliasing is enabled.
  150460. */
  150461. set fxaaEnabled(enabled: boolean);
  150462. get fxaaEnabled(): boolean;
  150463. private _samples;
  150464. /**
  150465. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  150466. */
  150467. set samples(sampleCount: number);
  150468. get samples(): number;
  150469. /**
  150470. * If image processing is enabled.
  150471. */
  150472. set imageProcessingEnabled(enabled: boolean);
  150473. get imageProcessingEnabled(): boolean;
  150474. /**
  150475. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  150476. */
  150477. set glowLayerEnabled(enabled: boolean);
  150478. get glowLayerEnabled(): boolean;
  150479. /**
  150480. * Gets the glow layer (or null if not defined)
  150481. */
  150482. get glowLayer(): Nullable<GlowLayer>;
  150483. /**
  150484. * Enable or disable the chromaticAberration process from the pipeline
  150485. */
  150486. set chromaticAberrationEnabled(enabled: boolean);
  150487. get chromaticAberrationEnabled(): boolean;
  150488. /**
  150489. * Enable or disable the grain process from the pipeline
  150490. */
  150491. set grainEnabled(enabled: boolean);
  150492. get grainEnabled(): boolean;
  150493. /**
  150494. * @constructor
  150495. * @param name - The rendering pipeline name (default: "")
  150496. * @param hdr - If high dynamic range textures should be used (default: true)
  150497. * @param scene - The scene linked to this pipeline (default: the last created scene)
  150498. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  150499. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  150500. */
  150501. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  150502. /**
  150503. * Get the class name
  150504. * @returns "DefaultRenderingPipeline"
  150505. */
  150506. getClassName(): string;
  150507. /**
  150508. * Force the compilation of the entire pipeline.
  150509. */
  150510. prepare(): void;
  150511. private _hasCleared;
  150512. private _prevPostProcess;
  150513. private _prevPrevPostProcess;
  150514. private _setAutoClearAndTextureSharing;
  150515. private _depthOfFieldSceneObserver;
  150516. private _buildPipeline;
  150517. private _disposePostProcesses;
  150518. /**
  150519. * Adds a camera to the pipeline
  150520. * @param camera the camera to be added
  150521. */
  150522. addCamera(camera: Camera): void;
  150523. /**
  150524. * Removes a camera from the pipeline
  150525. * @param camera the camera to remove
  150526. */
  150527. removeCamera(camera: Camera): void;
  150528. /**
  150529. * Dispose of the pipeline and stop all post processes
  150530. */
  150531. dispose(): void;
  150532. /**
  150533. * Serialize the rendering pipeline (Used when exporting)
  150534. * @returns the serialized object
  150535. */
  150536. serialize(): any;
  150537. /**
  150538. * Parse the serialized pipeline
  150539. * @param source Source pipeline.
  150540. * @param scene The scene to load the pipeline to.
  150541. * @param rootUrl The URL of the serialized pipeline.
  150542. * @returns An instantiated pipeline from the serialized object.
  150543. */
  150544. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  150545. }
  150546. }
  150547. declare module BABYLON {
  150548. /** @hidden */
  150549. export var lensHighlightsPixelShader: {
  150550. name: string;
  150551. shader: string;
  150552. };
  150553. }
  150554. declare module BABYLON {
  150555. /** @hidden */
  150556. export var depthOfFieldPixelShader: {
  150557. name: string;
  150558. shader: string;
  150559. };
  150560. }
  150561. declare module BABYLON {
  150562. /**
  150563. * BABYLON.JS Chromatic Aberration GLSL Shader
  150564. * Author: Olivier Guyot
  150565. * Separates very slightly R, G and B colors on the edges of the screen
  150566. * Inspired by Francois Tarlier & Martins Upitis
  150567. */
  150568. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  150569. /**
  150570. * @ignore
  150571. * The chromatic aberration PostProcess id in the pipeline
  150572. */
  150573. LensChromaticAberrationEffect: string;
  150574. /**
  150575. * @ignore
  150576. * The highlights enhancing PostProcess id in the pipeline
  150577. */
  150578. HighlightsEnhancingEffect: string;
  150579. /**
  150580. * @ignore
  150581. * The depth-of-field PostProcess id in the pipeline
  150582. */
  150583. LensDepthOfFieldEffect: string;
  150584. private _scene;
  150585. private _depthTexture;
  150586. private _grainTexture;
  150587. private _chromaticAberrationPostProcess;
  150588. private _highlightsPostProcess;
  150589. private _depthOfFieldPostProcess;
  150590. private _edgeBlur;
  150591. private _grainAmount;
  150592. private _chromaticAberration;
  150593. private _distortion;
  150594. private _highlightsGain;
  150595. private _highlightsThreshold;
  150596. private _dofDistance;
  150597. private _dofAperture;
  150598. private _dofDarken;
  150599. private _dofPentagon;
  150600. private _blurNoise;
  150601. /**
  150602. * @constructor
  150603. *
  150604. * Effect parameters are as follow:
  150605. * {
  150606. * chromatic_aberration: number; // from 0 to x (1 for realism)
  150607. * edge_blur: number; // from 0 to x (1 for realism)
  150608. * distortion: number; // from 0 to x (1 for realism)
  150609. * grain_amount: number; // from 0 to 1
  150610. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  150611. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  150612. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  150613. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  150614. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  150615. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  150616. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  150617. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  150618. * }
  150619. * Note: if an effect parameter is unset, effect is disabled
  150620. *
  150621. * @param name The rendering pipeline name
  150622. * @param parameters - An object containing all parameters (see above)
  150623. * @param scene The scene linked to this pipeline
  150624. * @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)
  150625. * @param cameras The array of cameras that the rendering pipeline will be attached to
  150626. */
  150627. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  150628. /**
  150629. * Get the class name
  150630. * @returns "LensRenderingPipeline"
  150631. */
  150632. getClassName(): string;
  150633. /**
  150634. * Gets associated scene
  150635. */
  150636. get scene(): Scene;
  150637. /**
  150638. * Gets or sets the edge blur
  150639. */
  150640. get edgeBlur(): number;
  150641. set edgeBlur(value: number);
  150642. /**
  150643. * Gets or sets the grain amount
  150644. */
  150645. get grainAmount(): number;
  150646. set grainAmount(value: number);
  150647. /**
  150648. * Gets or sets the chromatic aberration amount
  150649. */
  150650. get chromaticAberration(): number;
  150651. set chromaticAberration(value: number);
  150652. /**
  150653. * Gets or sets the depth of field aperture
  150654. */
  150655. get dofAperture(): number;
  150656. set dofAperture(value: number);
  150657. /**
  150658. * Gets or sets the edge distortion
  150659. */
  150660. get edgeDistortion(): number;
  150661. set edgeDistortion(value: number);
  150662. /**
  150663. * Gets or sets the depth of field distortion
  150664. */
  150665. get dofDistortion(): number;
  150666. set dofDistortion(value: number);
  150667. /**
  150668. * Gets or sets the darken out of focus amount
  150669. */
  150670. get darkenOutOfFocus(): number;
  150671. set darkenOutOfFocus(value: number);
  150672. /**
  150673. * Gets or sets a boolean indicating if blur noise is enabled
  150674. */
  150675. get blurNoise(): boolean;
  150676. set blurNoise(value: boolean);
  150677. /**
  150678. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  150679. */
  150680. get pentagonBokeh(): boolean;
  150681. set pentagonBokeh(value: boolean);
  150682. /**
  150683. * Gets or sets the highlight grain amount
  150684. */
  150685. get highlightsGain(): number;
  150686. set highlightsGain(value: number);
  150687. /**
  150688. * Gets or sets the highlight threshold
  150689. */
  150690. get highlightsThreshold(): number;
  150691. set highlightsThreshold(value: number);
  150692. /**
  150693. * Sets the amount of blur at the edges
  150694. * @param amount blur amount
  150695. */
  150696. setEdgeBlur(amount: number): void;
  150697. /**
  150698. * Sets edge blur to 0
  150699. */
  150700. disableEdgeBlur(): void;
  150701. /**
  150702. * Sets the amout of grain
  150703. * @param amount Amount of grain
  150704. */
  150705. setGrainAmount(amount: number): void;
  150706. /**
  150707. * Set grain amount to 0
  150708. */
  150709. disableGrain(): void;
  150710. /**
  150711. * Sets the chromatic aberration amount
  150712. * @param amount amount of chromatic aberration
  150713. */
  150714. setChromaticAberration(amount: number): void;
  150715. /**
  150716. * Sets chromatic aberration amount to 0
  150717. */
  150718. disableChromaticAberration(): void;
  150719. /**
  150720. * Sets the EdgeDistortion amount
  150721. * @param amount amount of EdgeDistortion
  150722. */
  150723. setEdgeDistortion(amount: number): void;
  150724. /**
  150725. * Sets edge distortion to 0
  150726. */
  150727. disableEdgeDistortion(): void;
  150728. /**
  150729. * Sets the FocusDistance amount
  150730. * @param amount amount of FocusDistance
  150731. */
  150732. setFocusDistance(amount: number): void;
  150733. /**
  150734. * Disables depth of field
  150735. */
  150736. disableDepthOfField(): void;
  150737. /**
  150738. * Sets the Aperture amount
  150739. * @param amount amount of Aperture
  150740. */
  150741. setAperture(amount: number): void;
  150742. /**
  150743. * Sets the DarkenOutOfFocus amount
  150744. * @param amount amount of DarkenOutOfFocus
  150745. */
  150746. setDarkenOutOfFocus(amount: number): void;
  150747. private _pentagonBokehIsEnabled;
  150748. /**
  150749. * Creates a pentagon bokeh effect
  150750. */
  150751. enablePentagonBokeh(): void;
  150752. /**
  150753. * Disables the pentagon bokeh effect
  150754. */
  150755. disablePentagonBokeh(): void;
  150756. /**
  150757. * Enables noise blur
  150758. */
  150759. enableNoiseBlur(): void;
  150760. /**
  150761. * Disables noise blur
  150762. */
  150763. disableNoiseBlur(): void;
  150764. /**
  150765. * Sets the HighlightsGain amount
  150766. * @param amount amount of HighlightsGain
  150767. */
  150768. setHighlightsGain(amount: number): void;
  150769. /**
  150770. * Sets the HighlightsThreshold amount
  150771. * @param amount amount of HighlightsThreshold
  150772. */
  150773. setHighlightsThreshold(amount: number): void;
  150774. /**
  150775. * Disables highlights
  150776. */
  150777. disableHighlights(): void;
  150778. /**
  150779. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  150780. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  150781. */
  150782. dispose(disableDepthRender?: boolean): void;
  150783. private _createChromaticAberrationPostProcess;
  150784. private _createHighlightsPostProcess;
  150785. private _createDepthOfFieldPostProcess;
  150786. private _createGrainTexture;
  150787. }
  150788. }
  150789. declare module BABYLON {
  150790. /** @hidden */
  150791. export var ssao2PixelShader: {
  150792. name: string;
  150793. shader: string;
  150794. };
  150795. }
  150796. declare module BABYLON {
  150797. /** @hidden */
  150798. export var ssaoCombinePixelShader: {
  150799. name: string;
  150800. shader: string;
  150801. };
  150802. }
  150803. declare module BABYLON {
  150804. /**
  150805. * Render pipeline to produce ssao effect
  150806. */
  150807. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  150808. /**
  150809. * @ignore
  150810. * The PassPostProcess id in the pipeline that contains the original scene color
  150811. */
  150812. SSAOOriginalSceneColorEffect: string;
  150813. /**
  150814. * @ignore
  150815. * The SSAO PostProcess id in the pipeline
  150816. */
  150817. SSAORenderEffect: string;
  150818. /**
  150819. * @ignore
  150820. * The horizontal blur PostProcess id in the pipeline
  150821. */
  150822. SSAOBlurHRenderEffect: string;
  150823. /**
  150824. * @ignore
  150825. * The vertical blur PostProcess id in the pipeline
  150826. */
  150827. SSAOBlurVRenderEffect: string;
  150828. /**
  150829. * @ignore
  150830. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  150831. */
  150832. SSAOCombineRenderEffect: string;
  150833. /**
  150834. * The output strength of the SSAO post-process. Default value is 1.0.
  150835. */
  150836. totalStrength: number;
  150837. /**
  150838. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  150839. */
  150840. maxZ: number;
  150841. /**
  150842. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  150843. */
  150844. minZAspect: number;
  150845. private _samples;
  150846. /**
  150847. * Number of samples used for the SSAO calculations. Default value is 8
  150848. */
  150849. set samples(n: number);
  150850. get samples(): number;
  150851. private _textureSamples;
  150852. /**
  150853. * Number of samples to use for antialiasing
  150854. */
  150855. set textureSamples(n: number);
  150856. get textureSamples(): number;
  150857. /**
  150858. * Force rendering the geometry through geometry buffer
  150859. */
  150860. private _forceGeometryBuffer;
  150861. /**
  150862. * Ratio object used for SSAO ratio and blur ratio
  150863. */
  150864. private _ratio;
  150865. /**
  150866. * Dynamically generated sphere sampler.
  150867. */
  150868. private _sampleSphere;
  150869. /**
  150870. * Blur filter offsets
  150871. */
  150872. private _samplerOffsets;
  150873. private _expensiveBlur;
  150874. /**
  150875. * If bilateral blur should be used
  150876. */
  150877. set expensiveBlur(b: boolean);
  150878. get expensiveBlur(): boolean;
  150879. /**
  150880. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  150881. */
  150882. radius: number;
  150883. /**
  150884. * The base color of the SSAO post-process
  150885. * The final result is "base + ssao" between [0, 1]
  150886. */
  150887. base: number;
  150888. /**
  150889. * Support test.
  150890. */
  150891. static get IsSupported(): boolean;
  150892. private _scene;
  150893. private _randomTexture;
  150894. private _originalColorPostProcess;
  150895. private _ssaoPostProcess;
  150896. private _blurHPostProcess;
  150897. private _blurVPostProcess;
  150898. private _ssaoCombinePostProcess;
  150899. private _prePassRenderer;
  150900. /**
  150901. * Gets active scene
  150902. */
  150903. get scene(): Scene;
  150904. /**
  150905. * @constructor
  150906. * @param name The rendering pipeline name
  150907. * @param scene The scene linked to this pipeline
  150908. * @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 }
  150909. * @param cameras The array of cameras that the rendering pipeline will be attached to
  150910. * @param forceGeometryBuffer Set to true if you want to use the legacy geometry buffer renderer
  150911. */
  150912. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[], forceGeometryBuffer?: boolean);
  150913. /**
  150914. * Get the class name
  150915. * @returns "SSAO2RenderingPipeline"
  150916. */
  150917. getClassName(): string;
  150918. /**
  150919. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  150920. */
  150921. dispose(disableGeometryBufferRenderer?: boolean): void;
  150922. private _createBlurPostProcess;
  150923. /** @hidden */
  150924. _rebuild(): void;
  150925. private _bits;
  150926. private _radicalInverse_VdC;
  150927. private _hammersley;
  150928. private _hemisphereSample_uniform;
  150929. private _generateHemisphere;
  150930. private _getDefinesForSSAO;
  150931. private _createSSAOPostProcess;
  150932. private _createSSAOCombinePostProcess;
  150933. private _createRandomTexture;
  150934. /**
  150935. * Serialize the rendering pipeline (Used when exporting)
  150936. * @returns the serialized object
  150937. */
  150938. serialize(): any;
  150939. /**
  150940. * Parse the serialized pipeline
  150941. * @param source Source pipeline.
  150942. * @param scene The scene to load the pipeline to.
  150943. * @param rootUrl The URL of the serialized pipeline.
  150944. * @returns An instantiated pipeline from the serialized object.
  150945. */
  150946. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  150947. /**
  150948. * Sets the required values to the prepass renderer.
  150949. * @param prePassRenderer defines the prepass renderer to setup
  150950. * @returns true if the pre pass is needed.
  150951. */
  150952. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  150953. }
  150954. }
  150955. declare module BABYLON {
  150956. /** @hidden */
  150957. export var ssaoPixelShader: {
  150958. name: string;
  150959. shader: string;
  150960. };
  150961. }
  150962. declare module BABYLON {
  150963. /**
  150964. * Render pipeline to produce ssao effect
  150965. */
  150966. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  150967. /**
  150968. * @ignore
  150969. * The PassPostProcess id in the pipeline that contains the original scene color
  150970. */
  150971. SSAOOriginalSceneColorEffect: string;
  150972. /**
  150973. * @ignore
  150974. * The SSAO PostProcess id in the pipeline
  150975. */
  150976. SSAORenderEffect: string;
  150977. /**
  150978. * @ignore
  150979. * The horizontal blur PostProcess id in the pipeline
  150980. */
  150981. SSAOBlurHRenderEffect: string;
  150982. /**
  150983. * @ignore
  150984. * The vertical blur PostProcess id in the pipeline
  150985. */
  150986. SSAOBlurVRenderEffect: string;
  150987. /**
  150988. * @ignore
  150989. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  150990. */
  150991. SSAOCombineRenderEffect: string;
  150992. /**
  150993. * The output strength of the SSAO post-process. Default value is 1.0.
  150994. */
  150995. totalStrength: number;
  150996. /**
  150997. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  150998. */
  150999. radius: number;
  151000. /**
  151001. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  151002. * Must not be equal to fallOff and superior to fallOff.
  151003. * Default value is 0.0075
  151004. */
  151005. area: number;
  151006. /**
  151007. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  151008. * Must not be equal to area and inferior to area.
  151009. * Default value is 0.000001
  151010. */
  151011. fallOff: number;
  151012. /**
  151013. * The base color of the SSAO post-process
  151014. * The final result is "base + ssao" between [0, 1]
  151015. */
  151016. base: number;
  151017. private _scene;
  151018. private _depthTexture;
  151019. private _randomTexture;
  151020. private _originalColorPostProcess;
  151021. private _ssaoPostProcess;
  151022. private _blurHPostProcess;
  151023. private _blurVPostProcess;
  151024. private _ssaoCombinePostProcess;
  151025. private _firstUpdate;
  151026. /**
  151027. * Gets active scene
  151028. */
  151029. get scene(): Scene;
  151030. /**
  151031. * @constructor
  151032. * @param name - The rendering pipeline name
  151033. * @param scene - The scene linked to this pipeline
  151034. * @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 }
  151035. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  151036. */
  151037. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  151038. /**
  151039. * Get the class name
  151040. * @returns "SSAORenderingPipeline"
  151041. */
  151042. getClassName(): string;
  151043. /**
  151044. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  151045. */
  151046. dispose(disableDepthRender?: boolean): void;
  151047. private _createBlurPostProcess;
  151048. /** @hidden */
  151049. _rebuild(): void;
  151050. private _createSSAOPostProcess;
  151051. private _createSSAOCombinePostProcess;
  151052. private _createRandomTexture;
  151053. }
  151054. }
  151055. declare module BABYLON {
  151056. /** @hidden */
  151057. export var screenSpaceReflectionPixelShader: {
  151058. name: string;
  151059. shader: string;
  151060. };
  151061. }
  151062. declare module BABYLON {
  151063. /**
  151064. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  151065. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  151066. */
  151067. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  151068. /**
  151069. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  151070. */
  151071. threshold: number;
  151072. /**
  151073. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  151074. */
  151075. strength: number;
  151076. /**
  151077. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  151078. */
  151079. reflectionSpecularFalloffExponent: number;
  151080. /**
  151081. * 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]
  151082. */
  151083. step: number;
  151084. /**
  151085. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  151086. */
  151087. roughnessFactor: number;
  151088. private _geometryBufferRenderer;
  151089. private _enableSmoothReflections;
  151090. private _reflectionSamples;
  151091. private _smoothSteps;
  151092. /**
  151093. * Gets a string identifying the name of the class
  151094. * @returns "ScreenSpaceReflectionPostProcess" string
  151095. */
  151096. getClassName(): string;
  151097. /**
  151098. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  151099. * @param name The name of the effect.
  151100. * @param scene The scene containing the objects to calculate reflections.
  151101. * @param options The required width/height ratio to downsize to before computing the render pass.
  151102. * @param camera The camera to apply the render pass to.
  151103. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  151104. * @param engine The engine which the post process will be applied. (default: current engine)
  151105. * @param reusable If the post process can be reused on the same frame. (default: false)
  151106. * @param textureType Type of textures used when performing the post process. (default: 0)
  151107. * @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)
  151108. */
  151109. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  151110. /**
  151111. * Gets wether or not smoothing reflections is enabled.
  151112. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  151113. */
  151114. get enableSmoothReflections(): boolean;
  151115. /**
  151116. * Sets wether or not smoothing reflections is enabled.
  151117. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  151118. */
  151119. set enableSmoothReflections(enabled: boolean);
  151120. /**
  151121. * Gets the number of samples taken while computing reflections. More samples count is high,
  151122. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  151123. */
  151124. get reflectionSamples(): number;
  151125. /**
  151126. * Sets the number of samples taken while computing reflections. More samples count is high,
  151127. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  151128. */
  151129. set reflectionSamples(samples: number);
  151130. /**
  151131. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  151132. * more the post-process will require GPU power and can generate a drop in FPS.
  151133. * Default value (5.0) work pretty well in all cases but can be adjusted.
  151134. */
  151135. get smoothSteps(): number;
  151136. set smoothSteps(steps: number);
  151137. private _updateEffectDefines;
  151138. /** @hidden */
  151139. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceReflectionPostProcess;
  151140. }
  151141. }
  151142. declare module BABYLON {
  151143. /** @hidden */
  151144. export var standardPixelShader: {
  151145. name: string;
  151146. shader: string;
  151147. };
  151148. }
  151149. declare module BABYLON {
  151150. /**
  151151. * Standard rendering pipeline
  151152. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  151153. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  151154. */
  151155. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  151156. /**
  151157. * Public members
  151158. */
  151159. /**
  151160. * Post-process which contains the original scene color before the pipeline applies all the effects
  151161. */
  151162. originalPostProcess: Nullable<PostProcess>;
  151163. /**
  151164. * Post-process used to down scale an image x4
  151165. */
  151166. downSampleX4PostProcess: Nullable<PostProcess>;
  151167. /**
  151168. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  151169. */
  151170. brightPassPostProcess: Nullable<PostProcess>;
  151171. /**
  151172. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  151173. */
  151174. blurHPostProcesses: PostProcess[];
  151175. /**
  151176. * Post-process array storing all the vertical blur post-processes used by the pipeline
  151177. */
  151178. blurVPostProcesses: PostProcess[];
  151179. /**
  151180. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  151181. */
  151182. textureAdderPostProcess: Nullable<PostProcess>;
  151183. /**
  151184. * Post-process used to create volumetric lighting effect
  151185. */
  151186. volumetricLightPostProcess: Nullable<PostProcess>;
  151187. /**
  151188. * Post-process used to smooth the previous volumetric light post-process on the X axis
  151189. */
  151190. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  151191. /**
  151192. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  151193. */
  151194. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  151195. /**
  151196. * Post-process used to merge the volumetric light effect and the real scene color
  151197. */
  151198. volumetricLightMergePostProces: Nullable<PostProcess>;
  151199. /**
  151200. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  151201. */
  151202. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  151203. /**
  151204. * Base post-process used to calculate the average luminance of the final image for HDR
  151205. */
  151206. luminancePostProcess: Nullable<PostProcess>;
  151207. /**
  151208. * Post-processes used to create down sample post-processes in order to get
  151209. * the average luminance of the final image for HDR
  151210. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  151211. */
  151212. luminanceDownSamplePostProcesses: PostProcess[];
  151213. /**
  151214. * Post-process used to create a HDR effect (light adaptation)
  151215. */
  151216. hdrPostProcess: Nullable<PostProcess>;
  151217. /**
  151218. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  151219. */
  151220. textureAdderFinalPostProcess: Nullable<PostProcess>;
  151221. /**
  151222. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  151223. */
  151224. lensFlareFinalPostProcess: Nullable<PostProcess>;
  151225. /**
  151226. * Post-process used to merge the final HDR post-process and the real scene color
  151227. */
  151228. hdrFinalPostProcess: Nullable<PostProcess>;
  151229. /**
  151230. * Post-process used to create a lens flare effect
  151231. */
  151232. lensFlarePostProcess: Nullable<PostProcess>;
  151233. /**
  151234. * Post-process that merges the result of the lens flare post-process and the real scene color
  151235. */
  151236. lensFlareComposePostProcess: Nullable<PostProcess>;
  151237. /**
  151238. * Post-process used to create a motion blur effect
  151239. */
  151240. motionBlurPostProcess: Nullable<PostProcess>;
  151241. /**
  151242. * Post-process used to create a depth of field effect
  151243. */
  151244. depthOfFieldPostProcess: Nullable<PostProcess>;
  151245. /**
  151246. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  151247. */
  151248. fxaaPostProcess: Nullable<FxaaPostProcess>;
  151249. /**
  151250. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  151251. */
  151252. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  151253. /**
  151254. * Represents the brightness threshold in order to configure the illuminated surfaces
  151255. */
  151256. brightThreshold: number;
  151257. /**
  151258. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  151259. */
  151260. blurWidth: number;
  151261. /**
  151262. * Sets if the blur for highlighted surfaces must be only horizontal
  151263. */
  151264. horizontalBlur: boolean;
  151265. /**
  151266. * Gets the overall exposure used by the pipeline
  151267. */
  151268. get exposure(): number;
  151269. /**
  151270. * Sets the overall exposure used by the pipeline
  151271. */
  151272. set exposure(value: number);
  151273. /**
  151274. * Texture used typically to simulate "dirty" on camera lens
  151275. */
  151276. lensTexture: Nullable<Texture>;
  151277. /**
  151278. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  151279. */
  151280. volumetricLightCoefficient: number;
  151281. /**
  151282. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  151283. */
  151284. volumetricLightPower: number;
  151285. /**
  151286. * Used the set the blur intensity to smooth the volumetric lights
  151287. */
  151288. volumetricLightBlurScale: number;
  151289. /**
  151290. * Light (spot or directional) used to generate the volumetric lights rays
  151291. * The source light must have a shadow generate so the pipeline can get its
  151292. * depth map
  151293. */
  151294. sourceLight: Nullable<SpotLight | DirectionalLight>;
  151295. /**
  151296. * For eye adaptation, represents the minimum luminance the eye can see
  151297. */
  151298. hdrMinimumLuminance: number;
  151299. /**
  151300. * For eye adaptation, represents the decrease luminance speed
  151301. */
  151302. hdrDecreaseRate: number;
  151303. /**
  151304. * For eye adaptation, represents the increase luminance speed
  151305. */
  151306. hdrIncreaseRate: number;
  151307. /**
  151308. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  151309. */
  151310. get hdrAutoExposure(): boolean;
  151311. /**
  151312. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  151313. */
  151314. set hdrAutoExposure(value: boolean);
  151315. /**
  151316. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  151317. */
  151318. lensColorTexture: Nullable<Texture>;
  151319. /**
  151320. * The overall strengh for the lens flare effect
  151321. */
  151322. lensFlareStrength: number;
  151323. /**
  151324. * Dispersion coefficient for lens flare ghosts
  151325. */
  151326. lensFlareGhostDispersal: number;
  151327. /**
  151328. * Main lens flare halo width
  151329. */
  151330. lensFlareHaloWidth: number;
  151331. /**
  151332. * Based on the lens distortion effect, defines how much the lens flare result
  151333. * is distorted
  151334. */
  151335. lensFlareDistortionStrength: number;
  151336. /**
  151337. * Configures the blur intensity used for for lens flare (halo)
  151338. */
  151339. lensFlareBlurWidth: number;
  151340. /**
  151341. * Lens star texture must be used to simulate rays on the flares and is available
  151342. * in the documentation
  151343. */
  151344. lensStarTexture: Nullable<Texture>;
  151345. /**
  151346. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  151347. * flare effect by taking account of the dirt texture
  151348. */
  151349. lensFlareDirtTexture: Nullable<Texture>;
  151350. /**
  151351. * Represents the focal length for the depth of field effect
  151352. */
  151353. depthOfFieldDistance: number;
  151354. /**
  151355. * Represents the blur intensity for the blurred part of the depth of field effect
  151356. */
  151357. depthOfFieldBlurWidth: number;
  151358. /**
  151359. * Gets how much the image is blurred by the movement while using the motion blur post-process
  151360. */
  151361. get motionStrength(): number;
  151362. /**
  151363. * Sets how much the image is blurred by the movement while using the motion blur post-process
  151364. */
  151365. set motionStrength(strength: number);
  151366. /**
  151367. * Gets wether or not the motion blur post-process is object based or screen based.
  151368. */
  151369. get objectBasedMotionBlur(): boolean;
  151370. /**
  151371. * Sets wether or not the motion blur post-process should be object based or screen based
  151372. */
  151373. set objectBasedMotionBlur(value: boolean);
  151374. /**
  151375. * List of animations for the pipeline (IAnimatable implementation)
  151376. */
  151377. animations: Animation[];
  151378. /**
  151379. * Private members
  151380. */
  151381. private _scene;
  151382. private _currentDepthOfFieldSource;
  151383. private _basePostProcess;
  151384. private _fixedExposure;
  151385. private _currentExposure;
  151386. private _hdrAutoExposure;
  151387. private _hdrCurrentLuminance;
  151388. private _motionStrength;
  151389. private _isObjectBasedMotionBlur;
  151390. private _floatTextureType;
  151391. private _camerasToBeAttached;
  151392. private _ratio;
  151393. private _bloomEnabled;
  151394. private _depthOfFieldEnabled;
  151395. private _vlsEnabled;
  151396. private _lensFlareEnabled;
  151397. private _hdrEnabled;
  151398. private _motionBlurEnabled;
  151399. private _fxaaEnabled;
  151400. private _screenSpaceReflectionsEnabled;
  151401. private _motionBlurSamples;
  151402. private _volumetricLightStepsCount;
  151403. private _samples;
  151404. /**
  151405. * @ignore
  151406. * Specifies if the bloom pipeline is enabled
  151407. */
  151408. get BloomEnabled(): boolean;
  151409. set BloomEnabled(enabled: boolean);
  151410. /**
  151411. * @ignore
  151412. * Specifies if the depth of field pipeline is enabed
  151413. */
  151414. get DepthOfFieldEnabled(): boolean;
  151415. set DepthOfFieldEnabled(enabled: boolean);
  151416. /**
  151417. * @ignore
  151418. * Specifies if the lens flare pipeline is enabed
  151419. */
  151420. get LensFlareEnabled(): boolean;
  151421. set LensFlareEnabled(enabled: boolean);
  151422. /**
  151423. * @ignore
  151424. * Specifies if the HDR pipeline is enabled
  151425. */
  151426. get HDREnabled(): boolean;
  151427. set HDREnabled(enabled: boolean);
  151428. /**
  151429. * @ignore
  151430. * Specifies if the volumetric lights scattering effect is enabled
  151431. */
  151432. get VLSEnabled(): boolean;
  151433. set VLSEnabled(enabled: boolean);
  151434. /**
  151435. * @ignore
  151436. * Specifies if the motion blur effect is enabled
  151437. */
  151438. get MotionBlurEnabled(): boolean;
  151439. set MotionBlurEnabled(enabled: boolean);
  151440. /**
  151441. * Specifies if anti-aliasing is enabled
  151442. */
  151443. get fxaaEnabled(): boolean;
  151444. set fxaaEnabled(enabled: boolean);
  151445. /**
  151446. * Specifies if screen space reflections are enabled.
  151447. */
  151448. get screenSpaceReflectionsEnabled(): boolean;
  151449. set screenSpaceReflectionsEnabled(enabled: boolean);
  151450. /**
  151451. * Specifies the number of steps used to calculate the volumetric lights
  151452. * Typically in interval [50, 200]
  151453. */
  151454. get volumetricLightStepsCount(): number;
  151455. set volumetricLightStepsCount(count: number);
  151456. /**
  151457. * Specifies the number of samples used for the motion blur effect
  151458. * Typically in interval [16, 64]
  151459. */
  151460. get motionBlurSamples(): number;
  151461. set motionBlurSamples(samples: number);
  151462. /**
  151463. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  151464. */
  151465. get samples(): number;
  151466. set samples(sampleCount: number);
  151467. /**
  151468. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  151469. * @constructor
  151470. * @param name The rendering pipeline name
  151471. * @param scene The scene linked to this pipeline
  151472. * @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)
  151473. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  151474. * @param cameras The array of cameras that the rendering pipeline will be attached to
  151475. */
  151476. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  151477. private _buildPipeline;
  151478. private _createDownSampleX4PostProcess;
  151479. private _createBrightPassPostProcess;
  151480. private _createBlurPostProcesses;
  151481. private _createTextureAdderPostProcess;
  151482. private _createVolumetricLightPostProcess;
  151483. private _createLuminancePostProcesses;
  151484. private _createHdrPostProcess;
  151485. private _createLensFlarePostProcess;
  151486. private _createDepthOfFieldPostProcess;
  151487. private _createMotionBlurPostProcess;
  151488. private _getDepthTexture;
  151489. private _disposePostProcesses;
  151490. /**
  151491. * Dispose of the pipeline and stop all post processes
  151492. */
  151493. dispose(): void;
  151494. /**
  151495. * Serialize the rendering pipeline (Used when exporting)
  151496. * @returns the serialized object
  151497. */
  151498. serialize(): any;
  151499. /**
  151500. * Parse the serialized pipeline
  151501. * @param source Source pipeline.
  151502. * @param scene The scene to load the pipeline to.
  151503. * @param rootUrl The URL of the serialized pipeline.
  151504. * @returns An instantiated pipeline from the serialized object.
  151505. */
  151506. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  151507. /**
  151508. * Luminance steps
  151509. */
  151510. static LuminanceSteps: number;
  151511. }
  151512. }
  151513. declare module BABYLON {
  151514. /** @hidden */
  151515. export var stereoscopicInterlacePixelShader: {
  151516. name: string;
  151517. shader: string;
  151518. };
  151519. }
  151520. declare module BABYLON {
  151521. /**
  151522. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  151523. */
  151524. export class StereoscopicInterlacePostProcessI extends PostProcess {
  151525. private _stepSize;
  151526. private _passedProcess;
  151527. /**
  151528. * Gets a string identifying the name of the class
  151529. * @returns "StereoscopicInterlacePostProcessI" string
  151530. */
  151531. getClassName(): string;
  151532. /**
  151533. * Initializes a StereoscopicInterlacePostProcessI
  151534. * @param name The name of the effect.
  151535. * @param rigCameras The rig cameras to be appled to the post process
  151536. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  151537. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  151538. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  151539. * @param engine The engine which the post process will be applied. (default: current engine)
  151540. * @param reusable If the post process can be reused on the same frame. (default: false)
  151541. */
  151542. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  151543. }
  151544. /**
  151545. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  151546. */
  151547. export class StereoscopicInterlacePostProcess extends PostProcess {
  151548. private _stepSize;
  151549. private _passedProcess;
  151550. /**
  151551. * Gets a string identifying the name of the class
  151552. * @returns "StereoscopicInterlacePostProcess" string
  151553. */
  151554. getClassName(): string;
  151555. /**
  151556. * Initializes a StereoscopicInterlacePostProcess
  151557. * @param name The name of the effect.
  151558. * @param rigCameras The rig cameras to be appled to the post process
  151559. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  151560. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  151561. * @param engine The engine which the post process will be applied. (default: current engine)
  151562. * @param reusable If the post process can be reused on the same frame. (default: false)
  151563. */
  151564. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  151565. }
  151566. }
  151567. declare module BABYLON {
  151568. /** @hidden */
  151569. export var tonemapPixelShader: {
  151570. name: string;
  151571. shader: string;
  151572. };
  151573. }
  151574. declare module BABYLON {
  151575. /** Defines operator used for tonemapping */
  151576. export enum TonemappingOperator {
  151577. /** Hable */
  151578. Hable = 0,
  151579. /** Reinhard */
  151580. Reinhard = 1,
  151581. /** HejiDawson */
  151582. HejiDawson = 2,
  151583. /** Photographic */
  151584. Photographic = 3
  151585. }
  151586. /**
  151587. * Defines a post process to apply tone mapping
  151588. */
  151589. export class TonemapPostProcess extends PostProcess {
  151590. private _operator;
  151591. /** Defines the required exposure adjustement */
  151592. exposureAdjustment: number;
  151593. /**
  151594. * Gets a string identifying the name of the class
  151595. * @returns "TonemapPostProcess" string
  151596. */
  151597. getClassName(): string;
  151598. /**
  151599. * Creates a new TonemapPostProcess
  151600. * @param name defines the name of the postprocess
  151601. * @param _operator defines the operator to use
  151602. * @param exposureAdjustment defines the required exposure adjustement
  151603. * @param camera defines the camera to use (can be null)
  151604. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  151605. * @param engine defines the hosting engine (can be ignore if camera is set)
  151606. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  151607. */
  151608. constructor(name: string, _operator: TonemappingOperator,
  151609. /** Defines the required exposure adjustement */
  151610. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  151611. }
  151612. }
  151613. declare module BABYLON {
  151614. /** @hidden */
  151615. export var volumetricLightScatteringPixelShader: {
  151616. name: string;
  151617. shader: string;
  151618. };
  151619. }
  151620. declare module BABYLON {
  151621. /** @hidden */
  151622. export var volumetricLightScatteringPassVertexShader: {
  151623. name: string;
  151624. shader: string;
  151625. };
  151626. }
  151627. declare module BABYLON {
  151628. /** @hidden */
  151629. export var volumetricLightScatteringPassPixelShader: {
  151630. name: string;
  151631. shader: string;
  151632. };
  151633. }
  151634. declare module BABYLON {
  151635. /**
  151636. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  151637. */
  151638. export class VolumetricLightScatteringPostProcess extends PostProcess {
  151639. private _volumetricLightScatteringPass;
  151640. private _volumetricLightScatteringRTT;
  151641. private _viewPort;
  151642. private _screenCoordinates;
  151643. private _cachedDefines;
  151644. /**
  151645. * If not undefined, the mesh position is computed from the attached node position
  151646. */
  151647. attachedNode: {
  151648. position: Vector3;
  151649. };
  151650. /**
  151651. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  151652. */
  151653. customMeshPosition: Vector3;
  151654. /**
  151655. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  151656. */
  151657. useCustomMeshPosition: boolean;
  151658. /**
  151659. * If the post-process should inverse the light scattering direction
  151660. */
  151661. invert: boolean;
  151662. /**
  151663. * The internal mesh used by the post-process
  151664. */
  151665. mesh: Mesh;
  151666. /**
  151667. * @hidden
  151668. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  151669. */
  151670. get useDiffuseColor(): boolean;
  151671. set useDiffuseColor(useDiffuseColor: boolean);
  151672. /**
  151673. * Array containing the excluded meshes not rendered in the internal pass
  151674. */
  151675. excludedMeshes: AbstractMesh[];
  151676. /**
  151677. * Controls the overall intensity of the post-process
  151678. */
  151679. exposure: number;
  151680. /**
  151681. * Dissipates each sample's contribution in range [0, 1]
  151682. */
  151683. decay: number;
  151684. /**
  151685. * Controls the overall intensity of each sample
  151686. */
  151687. weight: number;
  151688. /**
  151689. * Controls the density of each sample
  151690. */
  151691. density: number;
  151692. /**
  151693. * @constructor
  151694. * @param name The post-process name
  151695. * @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)
  151696. * @param camera The camera that the post-process will be attached to
  151697. * @param mesh The mesh used to create the light scattering
  151698. * @param samples The post-process quality, default 100
  151699. * @param samplingModeThe post-process filtering mode
  151700. * @param engine The babylon engine
  151701. * @param reusable If the post-process is reusable
  151702. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  151703. */
  151704. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  151705. /**
  151706. * Returns the string "VolumetricLightScatteringPostProcess"
  151707. * @returns "VolumetricLightScatteringPostProcess"
  151708. */
  151709. getClassName(): string;
  151710. private _isReady;
  151711. /**
  151712. * Sets the new light position for light scattering effect
  151713. * @param position The new custom light position
  151714. */
  151715. setCustomMeshPosition(position: Vector3): void;
  151716. /**
  151717. * Returns the light position for light scattering effect
  151718. * @return Vector3 The custom light position
  151719. */
  151720. getCustomMeshPosition(): Vector3;
  151721. /**
  151722. * Disposes the internal assets and detaches the post-process from the camera
  151723. */
  151724. dispose(camera: Camera): void;
  151725. /**
  151726. * Returns the render target texture used by the post-process
  151727. * @return the render target texture used by the post-process
  151728. */
  151729. getPass(): RenderTargetTexture;
  151730. private _meshExcluded;
  151731. private _createPass;
  151732. private _updateMeshScreenCoordinates;
  151733. /**
  151734. * Creates a default mesh for the Volumeric Light Scattering post-process
  151735. * @param name The mesh name
  151736. * @param scene The scene where to create the mesh
  151737. * @return the default mesh
  151738. */
  151739. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  151740. }
  151741. }
  151742. declare module BABYLON {
  151743. /** @hidden */
  151744. export var screenSpaceCurvaturePixelShader: {
  151745. name: string;
  151746. shader: string;
  151747. };
  151748. }
  151749. declare module BABYLON {
  151750. /**
  151751. * The Screen Space curvature effect can help highlighting ridge and valley of a model.
  151752. */
  151753. export class ScreenSpaceCurvaturePostProcess extends PostProcess {
  151754. /**
  151755. * Defines how much ridge the curvature effect displays.
  151756. */
  151757. ridge: number;
  151758. /**
  151759. * Defines how much valley the curvature effect displays.
  151760. */
  151761. valley: number;
  151762. private _geometryBufferRenderer;
  151763. /**
  151764. * Gets a string identifying the name of the class
  151765. * @returns "ScreenSpaceCurvaturePostProcess" string
  151766. */
  151767. getClassName(): string;
  151768. /**
  151769. * Creates a new instance ScreenSpaceCurvaturePostProcess
  151770. * @param name The name of the effect.
  151771. * @param scene The scene containing the objects to blur according to their velocity.
  151772. * @param options The required width/height ratio to downsize to before computing the render pass.
  151773. * @param camera The camera to apply the render pass to.
  151774. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  151775. * @param engine The engine which the post process will be applied. (default: current engine)
  151776. * @param reusable If the post process can be reused on the same frame. (default: false)
  151777. * @param textureType Type of textures used when performing the post process. (default: 0)
  151778. * @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)
  151779. */
  151780. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  151781. /**
  151782. * Support test.
  151783. */
  151784. static get IsSupported(): boolean;
  151785. /** @hidden */
  151786. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceCurvaturePostProcess;
  151787. }
  151788. }
  151789. declare module BABYLON {
  151790. interface Scene {
  151791. /** @hidden (Backing field) */
  151792. _boundingBoxRenderer: BoundingBoxRenderer;
  151793. /** @hidden (Backing field) */
  151794. _forceShowBoundingBoxes: boolean;
  151795. /**
  151796. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  151797. */
  151798. forceShowBoundingBoxes: boolean;
  151799. /**
  151800. * Gets the bounding box renderer associated with the scene
  151801. * @returns a BoundingBoxRenderer
  151802. */
  151803. getBoundingBoxRenderer(): BoundingBoxRenderer;
  151804. }
  151805. interface AbstractMesh {
  151806. /** @hidden (Backing field) */
  151807. _showBoundingBox: boolean;
  151808. /**
  151809. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  151810. */
  151811. showBoundingBox: boolean;
  151812. }
  151813. /**
  151814. * Component responsible of rendering the bounding box of the meshes in a scene.
  151815. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  151816. */
  151817. export class BoundingBoxRenderer implements ISceneComponent {
  151818. /**
  151819. * The component name helpfull to identify the component in the list of scene components.
  151820. */
  151821. readonly name: string;
  151822. /**
  151823. * The scene the component belongs to.
  151824. */
  151825. scene: Scene;
  151826. /**
  151827. * Color of the bounding box lines placed in front of an object
  151828. */
  151829. frontColor: Color3;
  151830. /**
  151831. * Color of the bounding box lines placed behind an object
  151832. */
  151833. backColor: Color3;
  151834. /**
  151835. * Defines if the renderer should show the back lines or not
  151836. */
  151837. showBackLines: boolean;
  151838. /**
  151839. * Observable raised before rendering a bounding box
  151840. */
  151841. onBeforeBoxRenderingObservable: Observable<BoundingBox>;
  151842. /**
  151843. * Observable raised after rendering a bounding box
  151844. */
  151845. onAfterBoxRenderingObservable: Observable<BoundingBox>;
  151846. /**
  151847. * @hidden
  151848. */
  151849. renderList: SmartArray<BoundingBox>;
  151850. private _colorShader;
  151851. private _vertexBuffers;
  151852. private _indexBuffer;
  151853. private _fillIndexBuffer;
  151854. private _fillIndexData;
  151855. /**
  151856. * Instantiates a new bounding box renderer in a scene.
  151857. * @param scene the scene the renderer renders in
  151858. */
  151859. constructor(scene: Scene);
  151860. /**
  151861. * Registers the component in a given scene
  151862. */
  151863. register(): void;
  151864. private _evaluateSubMesh;
  151865. private _activeMesh;
  151866. private _prepareRessources;
  151867. private _createIndexBuffer;
  151868. /**
  151869. * Rebuilds the elements related to this component in case of
  151870. * context lost for instance.
  151871. */
  151872. rebuild(): void;
  151873. /**
  151874. * @hidden
  151875. */
  151876. reset(): void;
  151877. /**
  151878. * Render the bounding boxes of a specific rendering group
  151879. * @param renderingGroupId defines the rendering group to render
  151880. */
  151881. render(renderingGroupId: number): void;
  151882. /**
  151883. * In case of occlusion queries, we can render the occlusion bounding box through this method
  151884. * @param mesh Define the mesh to render the occlusion bounding box for
  151885. */
  151886. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  151887. /**
  151888. * Dispose and release the resources attached to this renderer.
  151889. */
  151890. dispose(): void;
  151891. }
  151892. }
  151893. declare module BABYLON {
  151894. interface Scene {
  151895. /** @hidden (Backing field) */
  151896. _depthRenderer: {
  151897. [id: string]: DepthRenderer;
  151898. };
  151899. /**
  151900. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  151901. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  151902. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  151903. * @returns the created depth renderer
  151904. */
  151905. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  151906. /**
  151907. * Disables a depth renderer for a given camera
  151908. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  151909. */
  151910. disableDepthRenderer(camera?: Nullable<Camera>): void;
  151911. }
  151912. /**
  151913. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  151914. * in several rendering techniques.
  151915. */
  151916. export class DepthRendererSceneComponent implements ISceneComponent {
  151917. /**
  151918. * The component name helpfull to identify the component in the list of scene components.
  151919. */
  151920. readonly name: string;
  151921. /**
  151922. * The scene the component belongs to.
  151923. */
  151924. scene: Scene;
  151925. /**
  151926. * Creates a new instance of the component for the given scene
  151927. * @param scene Defines the scene to register the component in
  151928. */
  151929. constructor(scene: Scene);
  151930. /**
  151931. * Registers the component in a given scene
  151932. */
  151933. register(): void;
  151934. /**
  151935. * Rebuilds the elements related to this component in case of
  151936. * context lost for instance.
  151937. */
  151938. rebuild(): void;
  151939. /**
  151940. * Disposes the component and the associated ressources
  151941. */
  151942. dispose(): void;
  151943. private _gatherRenderTargets;
  151944. private _gatherActiveCameraRenderTargets;
  151945. }
  151946. }
  151947. declare module BABYLON {
  151948. interface AbstractScene {
  151949. /** @hidden (Backing field) */
  151950. _prePassRenderer: Nullable<PrePassRenderer>;
  151951. /**
  151952. * Gets or Sets the current prepass renderer associated to the scene.
  151953. */
  151954. prePassRenderer: Nullable<PrePassRenderer>;
  151955. /**
  151956. * Enables the prepass and associates it with the scene
  151957. * @returns the PrePassRenderer
  151958. */
  151959. enablePrePassRenderer(): Nullable<PrePassRenderer>;
  151960. /**
  151961. * Disables the prepass associated with the scene
  151962. */
  151963. disablePrePassRenderer(): void;
  151964. }
  151965. /**
  151966. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  151967. * in several rendering techniques.
  151968. */
  151969. export class PrePassRendererSceneComponent implements ISceneSerializableComponent {
  151970. /**
  151971. * The component name helpful to identify the component in the list of scene components.
  151972. */
  151973. readonly name: string;
  151974. /**
  151975. * The scene the component belongs to.
  151976. */
  151977. scene: Scene;
  151978. /**
  151979. * Creates a new instance of the component for the given scene
  151980. * @param scene Defines the scene to register the component in
  151981. */
  151982. constructor(scene: Scene);
  151983. /**
  151984. * Registers the component in a given scene
  151985. */
  151986. register(): void;
  151987. private _beforeCameraDraw;
  151988. private _afterCameraDraw;
  151989. private _beforeClearStage;
  151990. /**
  151991. * Serializes the component data to the specified json object
  151992. * @param serializationObject The object to serialize to
  151993. */
  151994. serialize(serializationObject: any): void;
  151995. /**
  151996. * Adds all the elements from the container to the scene
  151997. * @param container the container holding the elements
  151998. */
  151999. addFromContainer(container: AbstractScene): void;
  152000. /**
  152001. * Removes all the elements in the container from the scene
  152002. * @param container contains the elements to remove
  152003. * @param dispose if the removed element should be disposed (default: false)
  152004. */
  152005. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  152006. /**
  152007. * Rebuilds the elements related to this component in case of
  152008. * context lost for instance.
  152009. */
  152010. rebuild(): void;
  152011. /**
  152012. * Disposes the component and the associated ressources
  152013. */
  152014. dispose(): void;
  152015. }
  152016. }
  152017. declare module BABYLON {
  152018. /** @hidden */
  152019. export var outlinePixelShader: {
  152020. name: string;
  152021. shader: string;
  152022. };
  152023. }
  152024. declare module BABYLON {
  152025. /** @hidden */
  152026. export var outlineVertexShader: {
  152027. name: string;
  152028. shader: string;
  152029. };
  152030. }
  152031. declare module BABYLON {
  152032. interface Scene {
  152033. /** @hidden */
  152034. _outlineRenderer: OutlineRenderer;
  152035. /**
  152036. * Gets the outline renderer associated with the scene
  152037. * @returns a OutlineRenderer
  152038. */
  152039. getOutlineRenderer(): OutlineRenderer;
  152040. }
  152041. interface AbstractMesh {
  152042. /** @hidden (Backing field) */
  152043. _renderOutline: boolean;
  152044. /**
  152045. * Gets or sets a boolean indicating if the outline must be rendered as well
  152046. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  152047. */
  152048. renderOutline: boolean;
  152049. /** @hidden (Backing field) */
  152050. _renderOverlay: boolean;
  152051. /**
  152052. * Gets or sets a boolean indicating if the overlay must be rendered as well
  152053. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  152054. */
  152055. renderOverlay: boolean;
  152056. }
  152057. /**
  152058. * This class is responsible to draw bothe outline/overlay of meshes.
  152059. * It should not be used directly but through the available method on mesh.
  152060. */
  152061. export class OutlineRenderer implements ISceneComponent {
  152062. /**
  152063. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  152064. */
  152065. private static _StencilReference;
  152066. /**
  152067. * The name of the component. Each component must have a unique name.
  152068. */
  152069. name: string;
  152070. /**
  152071. * The scene the component belongs to.
  152072. */
  152073. scene: Scene;
  152074. /**
  152075. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  152076. */
  152077. zOffset: number;
  152078. private _engine;
  152079. private _effect;
  152080. private _cachedDefines;
  152081. private _savedDepthWrite;
  152082. /**
  152083. * Instantiates a new outline renderer. (There could be only one per scene).
  152084. * @param scene Defines the scene it belongs to
  152085. */
  152086. constructor(scene: Scene);
  152087. /**
  152088. * Register the component to one instance of a scene.
  152089. */
  152090. register(): void;
  152091. /**
  152092. * Rebuilds the elements related to this component in case of
  152093. * context lost for instance.
  152094. */
  152095. rebuild(): void;
  152096. /**
  152097. * Disposes the component and the associated ressources.
  152098. */
  152099. dispose(): void;
  152100. /**
  152101. * Renders the outline in the canvas.
  152102. * @param subMesh Defines the sumesh to render
  152103. * @param batch Defines the batch of meshes in case of instances
  152104. * @param useOverlay Defines if the rendering is for the overlay or the outline
  152105. */
  152106. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  152107. /**
  152108. * Returns whether or not the outline renderer is ready for a given submesh.
  152109. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  152110. * @param subMesh Defines the submesh to check readyness for
  152111. * @param useInstances Defines wheter wee are trying to render instances or not
  152112. * @returns true if ready otherwise false
  152113. */
  152114. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  152115. private _beforeRenderingMesh;
  152116. private _afterRenderingMesh;
  152117. }
  152118. }
  152119. declare module BABYLON {
  152120. /**
  152121. * Defines the basic options interface of a Sprite Frame Source Size.
  152122. */
  152123. export interface ISpriteJSONSpriteSourceSize {
  152124. /**
  152125. * number of the original width of the Frame
  152126. */
  152127. w: number;
  152128. /**
  152129. * number of the original height of the Frame
  152130. */
  152131. h: number;
  152132. }
  152133. /**
  152134. * Defines the basic options interface of a Sprite Frame Data.
  152135. */
  152136. export interface ISpriteJSONSpriteFrameData {
  152137. /**
  152138. * number of the x offset of the Frame
  152139. */
  152140. x: number;
  152141. /**
  152142. * number of the y offset of the Frame
  152143. */
  152144. y: number;
  152145. /**
  152146. * number of the width of the Frame
  152147. */
  152148. w: number;
  152149. /**
  152150. * number of the height of the Frame
  152151. */
  152152. h: number;
  152153. }
  152154. /**
  152155. * Defines the basic options interface of a JSON Sprite.
  152156. */
  152157. export interface ISpriteJSONSprite {
  152158. /**
  152159. * string name of the Frame
  152160. */
  152161. filename: string;
  152162. /**
  152163. * ISpriteJSONSpriteFrame basic object of the frame data
  152164. */
  152165. frame: ISpriteJSONSpriteFrameData;
  152166. /**
  152167. * boolean to flag is the frame was rotated.
  152168. */
  152169. rotated: boolean;
  152170. /**
  152171. * boolean to flag is the frame was trimmed.
  152172. */
  152173. trimmed: boolean;
  152174. /**
  152175. * ISpriteJSONSpriteFrame basic object of the source data
  152176. */
  152177. spriteSourceSize: ISpriteJSONSpriteFrameData;
  152178. /**
  152179. * ISpriteJSONSpriteFrame basic object of the source data
  152180. */
  152181. sourceSize: ISpriteJSONSpriteSourceSize;
  152182. }
  152183. /**
  152184. * Defines the basic options interface of a JSON atlas.
  152185. */
  152186. export interface ISpriteJSONAtlas {
  152187. /**
  152188. * Array of objects that contain the frame data.
  152189. */
  152190. frames: Array<ISpriteJSONSprite>;
  152191. /**
  152192. * object basic object containing the sprite meta data.
  152193. */
  152194. meta?: object;
  152195. }
  152196. }
  152197. declare module BABYLON {
  152198. /** @hidden */
  152199. export var spriteMapPixelShader: {
  152200. name: string;
  152201. shader: string;
  152202. };
  152203. }
  152204. declare module BABYLON {
  152205. /** @hidden */
  152206. export var spriteMapVertexShader: {
  152207. name: string;
  152208. shader: string;
  152209. };
  152210. }
  152211. declare module BABYLON {
  152212. /**
  152213. * Defines the basic options interface of a SpriteMap
  152214. */
  152215. export interface ISpriteMapOptions {
  152216. /**
  152217. * Vector2 of the number of cells in the grid.
  152218. */
  152219. stageSize?: Vector2;
  152220. /**
  152221. * Vector2 of the size of the output plane in World Units.
  152222. */
  152223. outputSize?: Vector2;
  152224. /**
  152225. * Vector3 of the position of the output plane in World Units.
  152226. */
  152227. outputPosition?: Vector3;
  152228. /**
  152229. * Vector3 of the rotation of the output plane.
  152230. */
  152231. outputRotation?: Vector3;
  152232. /**
  152233. * number of layers that the system will reserve in resources.
  152234. */
  152235. layerCount?: number;
  152236. /**
  152237. * number of max animation frames a single cell will reserve in resources.
  152238. */
  152239. maxAnimationFrames?: number;
  152240. /**
  152241. * number cell index of the base tile when the system compiles.
  152242. */
  152243. baseTile?: number;
  152244. /**
  152245. * boolean flip the sprite after its been repositioned by the framing data.
  152246. */
  152247. flipU?: boolean;
  152248. /**
  152249. * Vector3 scalar of the global RGB values of the SpriteMap.
  152250. */
  152251. colorMultiply?: Vector3;
  152252. }
  152253. /**
  152254. * Defines the IDisposable interface in order to be cleanable from resources.
  152255. */
  152256. export interface ISpriteMap extends IDisposable {
  152257. /**
  152258. * String name of the SpriteMap.
  152259. */
  152260. name: string;
  152261. /**
  152262. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  152263. */
  152264. atlasJSON: ISpriteJSONAtlas;
  152265. /**
  152266. * Texture of the SpriteMap.
  152267. */
  152268. spriteSheet: Texture;
  152269. /**
  152270. * The parameters to initialize the SpriteMap with.
  152271. */
  152272. options: ISpriteMapOptions;
  152273. }
  152274. /**
  152275. * Class used to manage a grid restricted sprite deployment on an Output plane.
  152276. */
  152277. export class SpriteMap implements ISpriteMap {
  152278. /** The Name of the spriteMap */
  152279. name: string;
  152280. /** The JSON file with the frame and meta data */
  152281. atlasJSON: ISpriteJSONAtlas;
  152282. /** The systems Sprite Sheet Texture */
  152283. spriteSheet: Texture;
  152284. /** Arguments passed with the Constructor */
  152285. options: ISpriteMapOptions;
  152286. /** Public Sprite Storage array, parsed from atlasJSON */
  152287. sprites: Array<ISpriteJSONSprite>;
  152288. /** Returns the Number of Sprites in the System */
  152289. get spriteCount(): number;
  152290. /** Returns the Position of Output Plane*/
  152291. get position(): Vector3;
  152292. /** Returns the Position of Output Plane*/
  152293. set position(v: Vector3);
  152294. /** Returns the Rotation of Output Plane*/
  152295. get rotation(): Vector3;
  152296. /** Returns the Rotation of Output Plane*/
  152297. set rotation(v: Vector3);
  152298. /** Sets the AnimationMap*/
  152299. get animationMap(): RawTexture;
  152300. /** Sets the AnimationMap*/
  152301. set animationMap(v: RawTexture);
  152302. /** Scene that the SpriteMap was created in */
  152303. private _scene;
  152304. /** Texture Buffer of Float32 that holds tile frame data*/
  152305. private _frameMap;
  152306. /** Texture Buffers of Float32 that holds tileMap data*/
  152307. private _tileMaps;
  152308. /** Texture Buffer of Float32 that holds Animation Data*/
  152309. private _animationMap;
  152310. /** Custom ShaderMaterial Central to the System*/
  152311. private _material;
  152312. /** Custom ShaderMaterial Central to the System*/
  152313. private _output;
  152314. /** Systems Time Ticker*/
  152315. private _time;
  152316. /**
  152317. * Creates a new SpriteMap
  152318. * @param name defines the SpriteMaps Name
  152319. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  152320. * @param spriteSheet is the Texture that the Sprites are on.
  152321. * @param options a basic deployment configuration
  152322. * @param scene The Scene that the map is deployed on
  152323. */
  152324. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  152325. /**
  152326. * Returns tileID location
  152327. * @returns Vector2 the cell position ID
  152328. */
  152329. getTileID(): Vector2;
  152330. /**
  152331. * Gets the UV location of the mouse over the SpriteMap.
  152332. * @returns Vector2 the UV position of the mouse interaction
  152333. */
  152334. getMousePosition(): Vector2;
  152335. /**
  152336. * Creates the "frame" texture Buffer
  152337. * -------------------------------------
  152338. * Structure of frames
  152339. * "filename": "Falling-Water-2.png",
  152340. * "frame": {"x":69,"y":103,"w":24,"h":32},
  152341. * "rotated": true,
  152342. * "trimmed": true,
  152343. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  152344. * "sourceSize": {"w":32,"h":32}
  152345. * @returns RawTexture of the frameMap
  152346. */
  152347. private _createFrameBuffer;
  152348. /**
  152349. * Creates the tileMap texture Buffer
  152350. * @param buffer normally and array of numbers, or a false to generate from scratch
  152351. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  152352. * @returns RawTexture of the tileMap
  152353. */
  152354. private _createTileBuffer;
  152355. /**
  152356. * Modifies the data of the tileMaps
  152357. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  152358. * @param pos is the iVector2 Coordinates of the Tile
  152359. * @param tile The SpriteIndex of the new Tile
  152360. */
  152361. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  152362. /**
  152363. * Creates the animationMap texture Buffer
  152364. * @param buffer normally and array of numbers, or a false to generate from scratch
  152365. * @returns RawTexture of the animationMap
  152366. */
  152367. private _createTileAnimationBuffer;
  152368. /**
  152369. * Modifies the data of the animationMap
  152370. * @param cellID is the Index of the Sprite
  152371. * @param _frame is the target Animation frame
  152372. * @param toCell is the Target Index of the next frame of the animation
  152373. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  152374. * @param speed is a global scalar of the time variable on the map.
  152375. */
  152376. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  152377. /**
  152378. * Exports the .tilemaps file
  152379. */
  152380. saveTileMaps(): void;
  152381. /**
  152382. * Imports the .tilemaps file
  152383. * @param url of the .tilemaps file
  152384. */
  152385. loadTileMaps(url: string): void;
  152386. /**
  152387. * Release associated resources
  152388. */
  152389. dispose(): void;
  152390. }
  152391. }
  152392. declare module BABYLON {
  152393. /**
  152394. * Class used to manage multiple sprites of different sizes on the same spritesheet
  152395. * @see https://doc.babylonjs.com/babylon101/sprites
  152396. */
  152397. export class SpritePackedManager extends SpriteManager {
  152398. /** defines the packed manager's name */
  152399. name: string;
  152400. /**
  152401. * Creates a new sprite manager from a packed sprite sheet
  152402. * @param name defines the manager's name
  152403. * @param imgUrl defines the sprite sheet url
  152404. * @param capacity defines the maximum allowed number of sprites
  152405. * @param scene defines the hosting scene
  152406. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  152407. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  152408. * @param samplingMode defines the smapling mode to use with spritesheet
  152409. * @param fromPacked set to true; do not alter
  152410. */
  152411. constructor(
  152412. /** defines the packed manager's name */
  152413. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  152414. }
  152415. }
  152416. declare module BABYLON {
  152417. /**
  152418. * Defines the list of states available for a task inside a AssetsManager
  152419. */
  152420. export enum AssetTaskState {
  152421. /**
  152422. * Initialization
  152423. */
  152424. INIT = 0,
  152425. /**
  152426. * Running
  152427. */
  152428. RUNNING = 1,
  152429. /**
  152430. * Done
  152431. */
  152432. DONE = 2,
  152433. /**
  152434. * Error
  152435. */
  152436. ERROR = 3
  152437. }
  152438. /**
  152439. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  152440. */
  152441. export abstract class AbstractAssetTask {
  152442. /**
  152443. * Task name
  152444. */ name: string;
  152445. /**
  152446. * Callback called when the task is successful
  152447. */
  152448. onSuccess: (task: any) => void;
  152449. /**
  152450. * Callback called when the task is not successful
  152451. */
  152452. onError: (task: any, message?: string, exception?: any) => void;
  152453. /**
  152454. * Creates a new AssetsManager
  152455. * @param name defines the name of the task
  152456. */
  152457. constructor(
  152458. /**
  152459. * Task name
  152460. */ name: string);
  152461. private _isCompleted;
  152462. private _taskState;
  152463. private _errorObject;
  152464. /**
  152465. * Get if the task is completed
  152466. */
  152467. get isCompleted(): boolean;
  152468. /**
  152469. * Gets the current state of the task
  152470. */
  152471. get taskState(): AssetTaskState;
  152472. /**
  152473. * Gets the current error object (if task is in error)
  152474. */
  152475. get errorObject(): {
  152476. message?: string;
  152477. exception?: any;
  152478. };
  152479. /**
  152480. * Internal only
  152481. * @hidden
  152482. */
  152483. _setErrorObject(message?: string, exception?: any): void;
  152484. /**
  152485. * Execute the current task
  152486. * @param scene defines the scene where you want your assets to be loaded
  152487. * @param onSuccess is a callback called when the task is successfully executed
  152488. * @param onError is a callback called if an error occurs
  152489. */
  152490. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  152491. /**
  152492. * Execute the current task
  152493. * @param scene defines the scene where you want your assets to be loaded
  152494. * @param onSuccess is a callback called when the task is successfully executed
  152495. * @param onError is a callback called if an error occurs
  152496. */
  152497. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  152498. /**
  152499. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  152500. * This can be used with failed tasks that have the reason for failure fixed.
  152501. */
  152502. reset(): void;
  152503. private onErrorCallback;
  152504. private onDoneCallback;
  152505. }
  152506. /**
  152507. * Define the interface used by progress events raised during assets loading
  152508. */
  152509. export interface IAssetsProgressEvent {
  152510. /**
  152511. * Defines the number of remaining tasks to process
  152512. */
  152513. remainingCount: number;
  152514. /**
  152515. * Defines the total number of tasks
  152516. */
  152517. totalCount: number;
  152518. /**
  152519. * Defines the task that was just processed
  152520. */
  152521. task: AbstractAssetTask;
  152522. }
  152523. /**
  152524. * Class used to share progress information about assets loading
  152525. */
  152526. export class AssetsProgressEvent implements IAssetsProgressEvent {
  152527. /**
  152528. * Defines the number of remaining tasks to process
  152529. */
  152530. remainingCount: number;
  152531. /**
  152532. * Defines the total number of tasks
  152533. */
  152534. totalCount: number;
  152535. /**
  152536. * Defines the task that was just processed
  152537. */
  152538. task: AbstractAssetTask;
  152539. /**
  152540. * Creates a AssetsProgressEvent
  152541. * @param remainingCount defines the number of remaining tasks to process
  152542. * @param totalCount defines the total number of tasks
  152543. * @param task defines the task that was just processed
  152544. */
  152545. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  152546. }
  152547. /**
  152548. * Define a task used by AssetsManager to load assets into a container
  152549. */
  152550. export class ContainerAssetTask extends AbstractAssetTask {
  152551. /**
  152552. * Defines the name of the task
  152553. */
  152554. name: string;
  152555. /**
  152556. * Defines the list of mesh's names you want to load
  152557. */
  152558. meshesNames: any;
  152559. /**
  152560. * Defines the root url to use as a base to load your meshes and associated resources
  152561. */
  152562. rootUrl: string;
  152563. /**
  152564. * Defines the filename or File of the scene to load from
  152565. */
  152566. sceneFilename: string | File;
  152567. /**
  152568. * Get the loaded asset container
  152569. */
  152570. loadedContainer: AssetContainer;
  152571. /**
  152572. * Gets the list of loaded meshes
  152573. */
  152574. loadedMeshes: Array<AbstractMesh>;
  152575. /**
  152576. * Gets the list of loaded particle systems
  152577. */
  152578. loadedParticleSystems: Array<IParticleSystem>;
  152579. /**
  152580. * Gets the list of loaded skeletons
  152581. */
  152582. loadedSkeletons: Array<Skeleton>;
  152583. /**
  152584. * Gets the list of loaded animation groups
  152585. */
  152586. loadedAnimationGroups: Array<AnimationGroup>;
  152587. /**
  152588. * Callback called when the task is successful
  152589. */
  152590. onSuccess: (task: ContainerAssetTask) => void;
  152591. /**
  152592. * Callback called when the task is successful
  152593. */
  152594. onError: (task: ContainerAssetTask, message?: string, exception?: any) => void;
  152595. /**
  152596. * Creates a new ContainerAssetTask
  152597. * @param name defines the name of the task
  152598. * @param meshesNames defines the list of mesh's names you want to load
  152599. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  152600. * @param sceneFilename defines the filename or File of the scene to load from
  152601. */
  152602. constructor(
  152603. /**
  152604. * Defines the name of the task
  152605. */
  152606. name: string,
  152607. /**
  152608. * Defines the list of mesh's names you want to load
  152609. */
  152610. meshesNames: any,
  152611. /**
  152612. * Defines the root url to use as a base to load your meshes and associated resources
  152613. */
  152614. rootUrl: string,
  152615. /**
  152616. * Defines the filename or File of the scene to load from
  152617. */
  152618. sceneFilename: string | File);
  152619. /**
  152620. * Execute the current task
  152621. * @param scene defines the scene where you want your assets to be loaded
  152622. * @param onSuccess is a callback called when the task is successfully executed
  152623. * @param onError is a callback called if an error occurs
  152624. */
  152625. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  152626. }
  152627. /**
  152628. * Define a task used by AssetsManager to load meshes
  152629. */
  152630. export class MeshAssetTask extends AbstractAssetTask {
  152631. /**
  152632. * Defines the name of the task
  152633. */
  152634. name: string;
  152635. /**
  152636. * Defines the list of mesh's names you want to load
  152637. */
  152638. meshesNames: any;
  152639. /**
  152640. * Defines the root url to use as a base to load your meshes and associated resources
  152641. */
  152642. rootUrl: string;
  152643. /**
  152644. * Defines the filename or File of the scene to load from
  152645. */
  152646. sceneFilename: string | File;
  152647. /**
  152648. * Gets the list of loaded meshes
  152649. */
  152650. loadedMeshes: Array<AbstractMesh>;
  152651. /**
  152652. * Gets the list of loaded particle systems
  152653. */
  152654. loadedParticleSystems: Array<IParticleSystem>;
  152655. /**
  152656. * Gets the list of loaded skeletons
  152657. */
  152658. loadedSkeletons: Array<Skeleton>;
  152659. /**
  152660. * Gets the list of loaded animation groups
  152661. */
  152662. loadedAnimationGroups: Array<AnimationGroup>;
  152663. /**
  152664. * Callback called when the task is successful
  152665. */
  152666. onSuccess: (task: MeshAssetTask) => void;
  152667. /**
  152668. * Callback called when the task is successful
  152669. */
  152670. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  152671. /**
  152672. * Creates a new MeshAssetTask
  152673. * @param name defines the name of the task
  152674. * @param meshesNames defines the list of mesh's names you want to load
  152675. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  152676. * @param sceneFilename defines the filename or File of the scene to load from
  152677. */
  152678. constructor(
  152679. /**
  152680. * Defines the name of the task
  152681. */
  152682. name: string,
  152683. /**
  152684. * Defines the list of mesh's names you want to load
  152685. */
  152686. meshesNames: any,
  152687. /**
  152688. * Defines the root url to use as a base to load your meshes and associated resources
  152689. */
  152690. rootUrl: string,
  152691. /**
  152692. * Defines the filename or File of the scene to load from
  152693. */
  152694. sceneFilename: string | File);
  152695. /**
  152696. * Execute the current task
  152697. * @param scene defines the scene where you want your assets to be loaded
  152698. * @param onSuccess is a callback called when the task is successfully executed
  152699. * @param onError is a callback called if an error occurs
  152700. */
  152701. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  152702. }
  152703. /**
  152704. * Define a task used by AssetsManager to load text content
  152705. */
  152706. export class TextFileAssetTask extends AbstractAssetTask {
  152707. /**
  152708. * Defines the name of the task
  152709. */
  152710. name: string;
  152711. /**
  152712. * Defines the location of the file to load
  152713. */
  152714. url: string;
  152715. /**
  152716. * Gets the loaded text string
  152717. */
  152718. text: string;
  152719. /**
  152720. * Callback called when the task is successful
  152721. */
  152722. onSuccess: (task: TextFileAssetTask) => void;
  152723. /**
  152724. * Callback called when the task is successful
  152725. */
  152726. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  152727. /**
  152728. * Creates a new TextFileAssetTask object
  152729. * @param name defines the name of the task
  152730. * @param url defines the location of the file to load
  152731. */
  152732. constructor(
  152733. /**
  152734. * Defines the name of the task
  152735. */
  152736. name: string,
  152737. /**
  152738. * Defines the location of the file to load
  152739. */
  152740. url: string);
  152741. /**
  152742. * Execute the current task
  152743. * @param scene defines the scene where you want your assets to be loaded
  152744. * @param onSuccess is a callback called when the task is successfully executed
  152745. * @param onError is a callback called if an error occurs
  152746. */
  152747. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  152748. }
  152749. /**
  152750. * Define a task used by AssetsManager to load binary data
  152751. */
  152752. export class BinaryFileAssetTask extends AbstractAssetTask {
  152753. /**
  152754. * Defines the name of the task
  152755. */
  152756. name: string;
  152757. /**
  152758. * Defines the location of the file to load
  152759. */
  152760. url: string;
  152761. /**
  152762. * Gets the lodaded data (as an array buffer)
  152763. */
  152764. data: ArrayBuffer;
  152765. /**
  152766. * Callback called when the task is successful
  152767. */
  152768. onSuccess: (task: BinaryFileAssetTask) => void;
  152769. /**
  152770. * Callback called when the task is successful
  152771. */
  152772. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  152773. /**
  152774. * Creates a new BinaryFileAssetTask object
  152775. * @param name defines the name of the new task
  152776. * @param url defines the location of the file to load
  152777. */
  152778. constructor(
  152779. /**
  152780. * Defines the name of the task
  152781. */
  152782. name: string,
  152783. /**
  152784. * Defines the location of the file to load
  152785. */
  152786. url: string);
  152787. /**
  152788. * Execute the current task
  152789. * @param scene defines the scene where you want your assets to be loaded
  152790. * @param onSuccess is a callback called when the task is successfully executed
  152791. * @param onError is a callback called if an error occurs
  152792. */
  152793. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  152794. }
  152795. /**
  152796. * Define a task used by AssetsManager to load images
  152797. */
  152798. export class ImageAssetTask extends AbstractAssetTask {
  152799. /**
  152800. * Defines the name of the task
  152801. */
  152802. name: string;
  152803. /**
  152804. * Defines the location of the image to load
  152805. */
  152806. url: string;
  152807. /**
  152808. * Gets the loaded images
  152809. */
  152810. image: HTMLImageElement;
  152811. /**
  152812. * Callback called when the task is successful
  152813. */
  152814. onSuccess: (task: ImageAssetTask) => void;
  152815. /**
  152816. * Callback called when the task is successful
  152817. */
  152818. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  152819. /**
  152820. * Creates a new ImageAssetTask
  152821. * @param name defines the name of the task
  152822. * @param url defines the location of the image to load
  152823. */
  152824. constructor(
  152825. /**
  152826. * Defines the name of the task
  152827. */
  152828. name: string,
  152829. /**
  152830. * Defines the location of the image to load
  152831. */
  152832. url: string);
  152833. /**
  152834. * Execute the current task
  152835. * @param scene defines the scene where you want your assets to be loaded
  152836. * @param onSuccess is a callback called when the task is successfully executed
  152837. * @param onError is a callback called if an error occurs
  152838. */
  152839. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  152840. }
  152841. /**
  152842. * Defines the interface used by texture loading tasks
  152843. */
  152844. export interface ITextureAssetTask<TEX extends BaseTexture> {
  152845. /**
  152846. * Gets the loaded texture
  152847. */
  152848. texture: TEX;
  152849. }
  152850. /**
  152851. * Define a task used by AssetsManager to load 2D textures
  152852. */
  152853. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  152854. /**
  152855. * Defines the name of the task
  152856. */
  152857. name: string;
  152858. /**
  152859. * Defines the location of the file to load
  152860. */
  152861. url: string;
  152862. /**
  152863. * Defines if mipmap should not be generated (default is false)
  152864. */
  152865. noMipmap?: boolean | undefined;
  152866. /**
  152867. * Defines if texture must be inverted on Y axis (default is true)
  152868. */
  152869. invertY: boolean;
  152870. /**
  152871. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  152872. */
  152873. samplingMode: number;
  152874. /**
  152875. * Gets the loaded texture
  152876. */
  152877. texture: Texture;
  152878. /**
  152879. * Callback called when the task is successful
  152880. */
  152881. onSuccess: (task: TextureAssetTask) => void;
  152882. /**
  152883. * Callback called when the task is successful
  152884. */
  152885. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  152886. /**
  152887. * Creates a new TextureAssetTask object
  152888. * @param name defines the name of the task
  152889. * @param url defines the location of the file to load
  152890. * @param noMipmap defines if mipmap should not be generated (default is false)
  152891. * @param invertY defines if texture must be inverted on Y axis (default is true)
  152892. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  152893. */
  152894. constructor(
  152895. /**
  152896. * Defines the name of the task
  152897. */
  152898. name: string,
  152899. /**
  152900. * Defines the location of the file to load
  152901. */
  152902. url: string,
  152903. /**
  152904. * Defines if mipmap should not be generated (default is false)
  152905. */
  152906. noMipmap?: boolean | undefined,
  152907. /**
  152908. * Defines if texture must be inverted on Y axis (default is true)
  152909. */
  152910. invertY?: boolean,
  152911. /**
  152912. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  152913. */
  152914. samplingMode?: number);
  152915. /**
  152916. * Execute the current task
  152917. * @param scene defines the scene where you want your assets to be loaded
  152918. * @param onSuccess is a callback called when the task is successfully executed
  152919. * @param onError is a callback called if an error occurs
  152920. */
  152921. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  152922. }
  152923. /**
  152924. * Define a task used by AssetsManager to load cube textures
  152925. */
  152926. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  152927. /**
  152928. * Defines the name of the task
  152929. */
  152930. name: string;
  152931. /**
  152932. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  152933. */
  152934. url: string;
  152935. /**
  152936. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  152937. */
  152938. extensions?: string[] | undefined;
  152939. /**
  152940. * Defines if mipmaps should not be generated (default is false)
  152941. */
  152942. noMipmap?: boolean | undefined;
  152943. /**
  152944. * Defines the explicit list of files (undefined by default)
  152945. */
  152946. files?: string[] | undefined;
  152947. /**
  152948. * Gets the loaded texture
  152949. */
  152950. texture: CubeTexture;
  152951. /**
  152952. * Callback called when the task is successful
  152953. */
  152954. onSuccess: (task: CubeTextureAssetTask) => void;
  152955. /**
  152956. * Callback called when the task is successful
  152957. */
  152958. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  152959. /**
  152960. * Creates a new CubeTextureAssetTask
  152961. * @param name defines the name of the task
  152962. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  152963. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  152964. * @param noMipmap defines if mipmaps should not be generated (default is false)
  152965. * @param files defines the explicit list of files (undefined by default)
  152966. */
  152967. constructor(
  152968. /**
  152969. * Defines the name of the task
  152970. */
  152971. name: string,
  152972. /**
  152973. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  152974. */
  152975. url: string,
  152976. /**
  152977. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  152978. */
  152979. extensions?: string[] | undefined,
  152980. /**
  152981. * Defines if mipmaps should not be generated (default is false)
  152982. */
  152983. noMipmap?: boolean | undefined,
  152984. /**
  152985. * Defines the explicit list of files (undefined by default)
  152986. */
  152987. files?: string[] | undefined);
  152988. /**
  152989. * Execute the current task
  152990. * @param scene defines the scene where you want your assets to be loaded
  152991. * @param onSuccess is a callback called when the task is successfully executed
  152992. * @param onError is a callback called if an error occurs
  152993. */
  152994. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  152995. }
  152996. /**
  152997. * Define a task used by AssetsManager to load HDR cube textures
  152998. */
  152999. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  153000. /**
  153001. * Defines the name of the task
  153002. */
  153003. name: string;
  153004. /**
  153005. * Defines the location of the file to load
  153006. */
  153007. url: string;
  153008. /**
  153009. * Defines the desired size (the more it increases the longer the generation will be)
  153010. */
  153011. size: number;
  153012. /**
  153013. * Defines if mipmaps should not be generated (default is false)
  153014. */
  153015. noMipmap: boolean;
  153016. /**
  153017. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  153018. */
  153019. generateHarmonics: boolean;
  153020. /**
  153021. * 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)
  153022. */
  153023. gammaSpace: boolean;
  153024. /**
  153025. * Internal Use Only
  153026. */
  153027. reserved: boolean;
  153028. /**
  153029. * Gets the loaded texture
  153030. */
  153031. texture: HDRCubeTexture;
  153032. /**
  153033. * Callback called when the task is successful
  153034. */
  153035. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  153036. /**
  153037. * Callback called when the task is successful
  153038. */
  153039. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  153040. /**
  153041. * Creates a new HDRCubeTextureAssetTask object
  153042. * @param name defines the name of the task
  153043. * @param url defines the location of the file to load
  153044. * @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.
  153045. * @param noMipmap defines if mipmaps should not be generated (default is false)
  153046. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  153047. * @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)
  153048. * @param reserved Internal use only
  153049. */
  153050. constructor(
  153051. /**
  153052. * Defines the name of the task
  153053. */
  153054. name: string,
  153055. /**
  153056. * Defines the location of the file to load
  153057. */
  153058. url: string,
  153059. /**
  153060. * Defines the desired size (the more it increases the longer the generation will be)
  153061. */
  153062. size: number,
  153063. /**
  153064. * Defines if mipmaps should not be generated (default is false)
  153065. */
  153066. noMipmap?: boolean,
  153067. /**
  153068. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  153069. */
  153070. generateHarmonics?: boolean,
  153071. /**
  153072. * 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)
  153073. */
  153074. gammaSpace?: boolean,
  153075. /**
  153076. * Internal Use Only
  153077. */
  153078. reserved?: boolean);
  153079. /**
  153080. * Execute the current task
  153081. * @param scene defines the scene where you want your assets to be loaded
  153082. * @param onSuccess is a callback called when the task is successfully executed
  153083. * @param onError is a callback called if an error occurs
  153084. */
  153085. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  153086. }
  153087. /**
  153088. * Define a task used by AssetsManager to load Equirectangular cube textures
  153089. */
  153090. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  153091. /**
  153092. * Defines the name of the task
  153093. */
  153094. name: string;
  153095. /**
  153096. * Defines the location of the file to load
  153097. */
  153098. url: string;
  153099. /**
  153100. * Defines the desired size (the more it increases the longer the generation will be)
  153101. */
  153102. size: number;
  153103. /**
  153104. * Defines if mipmaps should not be generated (default is false)
  153105. */
  153106. noMipmap: boolean;
  153107. /**
  153108. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  153109. * but the standard material would require them in Gamma space) (default is true)
  153110. */
  153111. gammaSpace: boolean;
  153112. /**
  153113. * Gets the loaded texture
  153114. */
  153115. texture: EquiRectangularCubeTexture;
  153116. /**
  153117. * Callback called when the task is successful
  153118. */
  153119. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  153120. /**
  153121. * Callback called when the task is successful
  153122. */
  153123. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  153124. /**
  153125. * Creates a new EquiRectangularCubeTextureAssetTask object
  153126. * @param name defines the name of the task
  153127. * @param url defines the location of the file to load
  153128. * @param size defines the desired size (the more it increases the longer the generation will be)
  153129. * If the size is omitted this implies you are using a preprocessed cubemap.
  153130. * @param noMipmap defines if mipmaps should not be generated (default is false)
  153131. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  153132. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  153133. * (default is true)
  153134. */
  153135. constructor(
  153136. /**
  153137. * Defines the name of the task
  153138. */
  153139. name: string,
  153140. /**
  153141. * Defines the location of the file to load
  153142. */
  153143. url: string,
  153144. /**
  153145. * Defines the desired size (the more it increases the longer the generation will be)
  153146. */
  153147. size: number,
  153148. /**
  153149. * Defines if mipmaps should not be generated (default is false)
  153150. */
  153151. noMipmap?: boolean,
  153152. /**
  153153. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  153154. * but the standard material would require them in Gamma space) (default is true)
  153155. */
  153156. gammaSpace?: boolean);
  153157. /**
  153158. * Execute the current task
  153159. * @param scene defines the scene where you want your assets to be loaded
  153160. * @param onSuccess is a callback called when the task is successfully executed
  153161. * @param onError is a callback called if an error occurs
  153162. */
  153163. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  153164. }
  153165. /**
  153166. * This class can be used to easily import assets into a scene
  153167. * @see https://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  153168. */
  153169. export class AssetsManager {
  153170. private _scene;
  153171. private _isLoading;
  153172. protected _tasks: AbstractAssetTask[];
  153173. protected _waitingTasksCount: number;
  153174. protected _totalTasksCount: number;
  153175. /**
  153176. * Callback called when all tasks are processed
  153177. */
  153178. onFinish: (tasks: AbstractAssetTask[]) => void;
  153179. /**
  153180. * Callback called when a task is successful
  153181. */
  153182. onTaskSuccess: (task: AbstractAssetTask) => void;
  153183. /**
  153184. * Callback called when a task had an error
  153185. */
  153186. onTaskError: (task: AbstractAssetTask) => void;
  153187. /**
  153188. * Callback called when a task is done (whatever the result is)
  153189. */
  153190. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  153191. /**
  153192. * Observable called when all tasks are processed
  153193. */
  153194. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  153195. /**
  153196. * Observable called when a task had an error
  153197. */
  153198. onTaskErrorObservable: Observable<AbstractAssetTask>;
  153199. /**
  153200. * Observable called when all tasks were executed
  153201. */
  153202. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  153203. /**
  153204. * Observable called when a task is done (whatever the result is)
  153205. */
  153206. onProgressObservable: Observable<IAssetsProgressEvent>;
  153207. /**
  153208. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  153209. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  153210. */
  153211. useDefaultLoadingScreen: boolean;
  153212. /**
  153213. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  153214. * when all assets have been downloaded.
  153215. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  153216. */
  153217. autoHideLoadingUI: boolean;
  153218. /**
  153219. * Creates a new AssetsManager
  153220. * @param scene defines the scene to work on
  153221. */
  153222. constructor(scene: Scene);
  153223. /**
  153224. * Add a ContainerAssetTask to the list of active tasks
  153225. * @param taskName defines the name of the new task
  153226. * @param meshesNames defines the name of meshes to load
  153227. * @param rootUrl defines the root url to use to locate files
  153228. * @param sceneFilename defines the filename of the scene file
  153229. * @returns a new ContainerAssetTask object
  153230. */
  153231. addContainerTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): ContainerAssetTask;
  153232. /**
  153233. * Add a MeshAssetTask to the list of active tasks
  153234. * @param taskName defines the name of the new task
  153235. * @param meshesNames defines the name of meshes to load
  153236. * @param rootUrl defines the root url to use to locate files
  153237. * @param sceneFilename defines the filename of the scene file
  153238. * @returns a new MeshAssetTask object
  153239. */
  153240. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  153241. /**
  153242. * Add a TextFileAssetTask to the list of active tasks
  153243. * @param taskName defines the name of the new task
  153244. * @param url defines the url of the file to load
  153245. * @returns a new TextFileAssetTask object
  153246. */
  153247. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  153248. /**
  153249. * Add a BinaryFileAssetTask to the list of active tasks
  153250. * @param taskName defines the name of the new task
  153251. * @param url defines the url of the file to load
  153252. * @returns a new BinaryFileAssetTask object
  153253. */
  153254. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  153255. /**
  153256. * Add a ImageAssetTask to the list of active tasks
  153257. * @param taskName defines the name of the new task
  153258. * @param url defines the url of the file to load
  153259. * @returns a new ImageAssetTask object
  153260. */
  153261. addImageTask(taskName: string, url: string): ImageAssetTask;
  153262. /**
  153263. * Add a TextureAssetTask to the list of active tasks
  153264. * @param taskName defines the name of the new task
  153265. * @param url defines the url of the file to load
  153266. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  153267. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  153268. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  153269. * @returns a new TextureAssetTask object
  153270. */
  153271. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  153272. /**
  153273. * Add a CubeTextureAssetTask to the list of active tasks
  153274. * @param taskName defines the name of the new task
  153275. * @param url defines the url of the file to load
  153276. * @param extensions defines the extension to use to load the cube map (can be null)
  153277. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  153278. * @param files defines the list of files to load (can be null)
  153279. * @returns a new CubeTextureAssetTask object
  153280. */
  153281. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  153282. /**
  153283. *
  153284. * Add a HDRCubeTextureAssetTask to the list of active tasks
  153285. * @param taskName defines the name of the new task
  153286. * @param url defines the url of the file to load
  153287. * @param size defines the size you want for the cubemap (can be null)
  153288. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  153289. * @param generateHarmonics defines if you want to automatically generate (true by default)
  153290. * @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)
  153291. * @param reserved Internal use only
  153292. * @returns a new HDRCubeTextureAssetTask object
  153293. */
  153294. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  153295. /**
  153296. *
  153297. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  153298. * @param taskName defines the name of the new task
  153299. * @param url defines the url of the file to load
  153300. * @param size defines the size you want for the cubemap (can be null)
  153301. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  153302. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  153303. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  153304. * @returns a new EquiRectangularCubeTextureAssetTask object
  153305. */
  153306. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  153307. /**
  153308. * Remove a task from the assets manager.
  153309. * @param task the task to remove
  153310. */
  153311. removeTask(task: AbstractAssetTask): void;
  153312. private _decreaseWaitingTasksCount;
  153313. private _runTask;
  153314. /**
  153315. * Reset the AssetsManager and remove all tasks
  153316. * @return the current instance of the AssetsManager
  153317. */
  153318. reset(): AssetsManager;
  153319. /**
  153320. * Start the loading process
  153321. * @return the current instance of the AssetsManager
  153322. */
  153323. load(): AssetsManager;
  153324. /**
  153325. * Start the loading process as an async operation
  153326. * @return a promise returning the list of failed tasks
  153327. */
  153328. loadAsync(): Promise<void>;
  153329. }
  153330. }
  153331. declare module BABYLON {
  153332. /**
  153333. * Wrapper class for promise with external resolve and reject.
  153334. */
  153335. export class Deferred<T> {
  153336. /**
  153337. * The promise associated with this deferred object.
  153338. */
  153339. readonly promise: Promise<T>;
  153340. private _resolve;
  153341. private _reject;
  153342. /**
  153343. * The resolve method of the promise associated with this deferred object.
  153344. */
  153345. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  153346. /**
  153347. * The reject method of the promise associated with this deferred object.
  153348. */
  153349. get reject(): (reason?: any) => void;
  153350. /**
  153351. * Constructor for this deferred object.
  153352. */
  153353. constructor();
  153354. }
  153355. }
  153356. declare module BABYLON {
  153357. /**
  153358. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  153359. */
  153360. export class MeshExploder {
  153361. private _centerMesh;
  153362. private _meshes;
  153363. private _meshesOrigins;
  153364. private _toCenterVectors;
  153365. private _scaledDirection;
  153366. private _newPosition;
  153367. private _centerPosition;
  153368. /**
  153369. * Explodes meshes from a center mesh.
  153370. * @param meshes The meshes to explode.
  153371. * @param centerMesh The mesh to be center of explosion.
  153372. */
  153373. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  153374. private _setCenterMesh;
  153375. /**
  153376. * Get class name
  153377. * @returns "MeshExploder"
  153378. */
  153379. getClassName(): string;
  153380. /**
  153381. * "Exploded meshes"
  153382. * @returns Array of meshes with the centerMesh at index 0.
  153383. */
  153384. getMeshes(): Array<Mesh>;
  153385. /**
  153386. * Explodes meshes giving a specific direction
  153387. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  153388. */
  153389. explode(direction?: number): void;
  153390. }
  153391. }
  153392. declare module BABYLON {
  153393. /**
  153394. * Class used to help managing file picking and drag'n'drop
  153395. */
  153396. export class FilesInput {
  153397. /**
  153398. * List of files ready to be loaded
  153399. */
  153400. static get FilesToLoad(): {
  153401. [key: string]: File;
  153402. };
  153403. /**
  153404. * Callback called when a file is processed
  153405. */
  153406. onProcessFileCallback: (file: File, name: string, extension: string) => boolean;
  153407. private _engine;
  153408. private _currentScene;
  153409. private _sceneLoadedCallback;
  153410. private _progressCallback;
  153411. private _additionalRenderLoopLogicCallback;
  153412. private _textureLoadingCallback;
  153413. private _startingProcessingFilesCallback;
  153414. private _onReloadCallback;
  153415. private _errorCallback;
  153416. private _elementToMonitor;
  153417. private _sceneFileToLoad;
  153418. private _filesToLoad;
  153419. /**
  153420. * Creates a new FilesInput
  153421. * @param engine defines the rendering engine
  153422. * @param scene defines the hosting scene
  153423. * @param sceneLoadedCallback callback called when scene is loaded
  153424. * @param progressCallback callback called to track progress
  153425. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  153426. * @param textureLoadingCallback callback called when a texture is loading
  153427. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  153428. * @param onReloadCallback callback called when a reload is requested
  153429. * @param errorCallback callback call if an error occurs
  153430. */
  153431. 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>);
  153432. private _dragEnterHandler;
  153433. private _dragOverHandler;
  153434. private _dropHandler;
  153435. /**
  153436. * Calls this function to listen to drag'n'drop events on a specific DOM element
  153437. * @param elementToMonitor defines the DOM element to track
  153438. */
  153439. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  153440. /** Gets the current list of files to load */
  153441. get filesToLoad(): File[];
  153442. /**
  153443. * Release all associated resources
  153444. */
  153445. dispose(): void;
  153446. private renderFunction;
  153447. private drag;
  153448. private drop;
  153449. private _traverseFolder;
  153450. private _processFiles;
  153451. /**
  153452. * Load files from a drop event
  153453. * @param event defines the drop event to use as source
  153454. */
  153455. loadFiles(event: any): void;
  153456. private _processReload;
  153457. /**
  153458. * Reload the current scene from the loaded files
  153459. */
  153460. reload(): void;
  153461. }
  153462. }
  153463. declare module BABYLON {
  153464. /**
  153465. * Defines the root class used to create scene optimization to use with SceneOptimizer
  153466. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  153467. */
  153468. export class SceneOptimization {
  153469. /**
  153470. * Defines the priority of this optimization (0 by default which means first in the list)
  153471. */
  153472. priority: number;
  153473. /**
  153474. * Gets a string describing the action executed by the current optimization
  153475. * @returns description string
  153476. */
  153477. getDescription(): string;
  153478. /**
  153479. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  153480. * @param scene defines the current scene where to apply this optimization
  153481. * @param optimizer defines the current optimizer
  153482. * @returns true if everything that can be done was applied
  153483. */
  153484. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  153485. /**
  153486. * Creates the SceneOptimization object
  153487. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  153488. * @param desc defines the description associated with the optimization
  153489. */
  153490. constructor(
  153491. /**
  153492. * Defines the priority of this optimization (0 by default which means first in the list)
  153493. */
  153494. priority?: number);
  153495. }
  153496. /**
  153497. * Defines an optimization used to reduce the size of render target textures
  153498. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  153499. */
  153500. export class TextureOptimization extends SceneOptimization {
  153501. /**
  153502. * Defines the priority of this optimization (0 by default which means first in the list)
  153503. */
  153504. priority: number;
  153505. /**
  153506. * 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
  153507. */
  153508. maximumSize: number;
  153509. /**
  153510. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  153511. */
  153512. step: number;
  153513. /**
  153514. * Gets a string describing the action executed by the current optimization
  153515. * @returns description string
  153516. */
  153517. getDescription(): string;
  153518. /**
  153519. * Creates the TextureOptimization object
  153520. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  153521. * @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
  153522. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  153523. */
  153524. constructor(
  153525. /**
  153526. * Defines the priority of this optimization (0 by default which means first in the list)
  153527. */
  153528. priority?: number,
  153529. /**
  153530. * 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
  153531. */
  153532. maximumSize?: number,
  153533. /**
  153534. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  153535. */
  153536. step?: number);
  153537. /**
  153538. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  153539. * @param scene defines the current scene where to apply this optimization
  153540. * @param optimizer defines the current optimizer
  153541. * @returns true if everything that can be done was applied
  153542. */
  153543. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  153544. }
  153545. /**
  153546. * Defines an optimization used to increase or decrease the rendering resolution
  153547. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  153548. */
  153549. export class HardwareScalingOptimization extends SceneOptimization {
  153550. /**
  153551. * Defines the priority of this optimization (0 by default which means first in the list)
  153552. */
  153553. priority: number;
  153554. /**
  153555. * Defines the maximum scale to use (2 by default)
  153556. */
  153557. maximumScale: number;
  153558. /**
  153559. * Defines the step to use between two passes (0.5 by default)
  153560. */
  153561. step: number;
  153562. private _currentScale;
  153563. private _directionOffset;
  153564. /**
  153565. * Gets a string describing the action executed by the current optimization
  153566. * @return description string
  153567. */
  153568. getDescription(): string;
  153569. /**
  153570. * Creates the HardwareScalingOptimization object
  153571. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  153572. * @param maximumScale defines the maximum scale to use (2 by default)
  153573. * @param step defines the step to use between two passes (0.5 by default)
  153574. */
  153575. constructor(
  153576. /**
  153577. * Defines the priority of this optimization (0 by default which means first in the list)
  153578. */
  153579. priority?: number,
  153580. /**
  153581. * Defines the maximum scale to use (2 by default)
  153582. */
  153583. maximumScale?: number,
  153584. /**
  153585. * Defines the step to use between two passes (0.5 by default)
  153586. */
  153587. step?: number);
  153588. /**
  153589. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  153590. * @param scene defines the current scene where to apply this optimization
  153591. * @param optimizer defines the current optimizer
  153592. * @returns true if everything that can be done was applied
  153593. */
  153594. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  153595. }
  153596. /**
  153597. * Defines an optimization used to remove shadows
  153598. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  153599. */
  153600. export class ShadowsOptimization extends SceneOptimization {
  153601. /**
  153602. * Gets a string describing the action executed by the current optimization
  153603. * @return description string
  153604. */
  153605. getDescription(): string;
  153606. /**
  153607. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  153608. * @param scene defines the current scene where to apply this optimization
  153609. * @param optimizer defines the current optimizer
  153610. * @returns true if everything that can be done was applied
  153611. */
  153612. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  153613. }
  153614. /**
  153615. * Defines an optimization used to turn post-processes off
  153616. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  153617. */
  153618. export class PostProcessesOptimization extends SceneOptimization {
  153619. /**
  153620. * Gets a string describing the action executed by the current optimization
  153621. * @return description string
  153622. */
  153623. getDescription(): string;
  153624. /**
  153625. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  153626. * @param scene defines the current scene where to apply this optimization
  153627. * @param optimizer defines the current optimizer
  153628. * @returns true if everything that can be done was applied
  153629. */
  153630. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  153631. }
  153632. /**
  153633. * Defines an optimization used to turn lens flares off
  153634. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  153635. */
  153636. export class LensFlaresOptimization extends SceneOptimization {
  153637. /**
  153638. * Gets a string describing the action executed by the current optimization
  153639. * @return description string
  153640. */
  153641. getDescription(): string;
  153642. /**
  153643. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  153644. * @param scene defines the current scene where to apply this optimization
  153645. * @param optimizer defines the current optimizer
  153646. * @returns true if everything that can be done was applied
  153647. */
  153648. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  153649. }
  153650. /**
  153651. * Defines an optimization based on user defined callback.
  153652. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  153653. */
  153654. export class CustomOptimization extends SceneOptimization {
  153655. /**
  153656. * Callback called to apply the custom optimization.
  153657. */
  153658. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  153659. /**
  153660. * Callback called to get custom description
  153661. */
  153662. onGetDescription: () => string;
  153663. /**
  153664. * Gets a string describing the action executed by the current optimization
  153665. * @returns description string
  153666. */
  153667. getDescription(): string;
  153668. /**
  153669. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  153670. * @param scene defines the current scene where to apply this optimization
  153671. * @param optimizer defines the current optimizer
  153672. * @returns true if everything that can be done was applied
  153673. */
  153674. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  153675. }
  153676. /**
  153677. * Defines an optimization used to turn particles off
  153678. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  153679. */
  153680. export class ParticlesOptimization extends SceneOptimization {
  153681. /**
  153682. * Gets a string describing the action executed by the current optimization
  153683. * @return description string
  153684. */
  153685. getDescription(): string;
  153686. /**
  153687. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  153688. * @param scene defines the current scene where to apply this optimization
  153689. * @param optimizer defines the current optimizer
  153690. * @returns true if everything that can be done was applied
  153691. */
  153692. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  153693. }
  153694. /**
  153695. * Defines an optimization used to turn render targets off
  153696. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  153697. */
  153698. export class RenderTargetsOptimization extends SceneOptimization {
  153699. /**
  153700. * Gets a string describing the action executed by the current optimization
  153701. * @return description string
  153702. */
  153703. getDescription(): string;
  153704. /**
  153705. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  153706. * @param scene defines the current scene where to apply this optimization
  153707. * @param optimizer defines the current optimizer
  153708. * @returns true if everything that can be done was applied
  153709. */
  153710. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  153711. }
  153712. /**
  153713. * Defines an optimization used to merge meshes with compatible materials
  153714. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  153715. */
  153716. export class MergeMeshesOptimization extends SceneOptimization {
  153717. private static _UpdateSelectionTree;
  153718. /**
  153719. * Gets or sets a boolean which defines if optimization octree has to be updated
  153720. */
  153721. static get UpdateSelectionTree(): boolean;
  153722. /**
  153723. * Gets or sets a boolean which defines if optimization octree has to be updated
  153724. */
  153725. static set UpdateSelectionTree(value: boolean);
  153726. /**
  153727. * Gets a string describing the action executed by the current optimization
  153728. * @return description string
  153729. */
  153730. getDescription(): string;
  153731. private _canBeMerged;
  153732. /**
  153733. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  153734. * @param scene defines the current scene where to apply this optimization
  153735. * @param optimizer defines the current optimizer
  153736. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  153737. * @returns true if everything that can be done was applied
  153738. */
  153739. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  153740. }
  153741. /**
  153742. * Defines a list of options used by SceneOptimizer
  153743. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  153744. */
  153745. export class SceneOptimizerOptions {
  153746. /**
  153747. * Defines the target frame rate to reach (60 by default)
  153748. */
  153749. targetFrameRate: number;
  153750. /**
  153751. * Defines the interval between two checkes (2000ms by default)
  153752. */
  153753. trackerDuration: number;
  153754. /**
  153755. * Gets the list of optimizations to apply
  153756. */
  153757. optimizations: SceneOptimization[];
  153758. /**
  153759. * Creates a new list of options used by SceneOptimizer
  153760. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  153761. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  153762. */
  153763. constructor(
  153764. /**
  153765. * Defines the target frame rate to reach (60 by default)
  153766. */
  153767. targetFrameRate?: number,
  153768. /**
  153769. * Defines the interval between two checkes (2000ms by default)
  153770. */
  153771. trackerDuration?: number);
  153772. /**
  153773. * Add a new optimization
  153774. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  153775. * @returns the current SceneOptimizerOptions
  153776. */
  153777. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  153778. /**
  153779. * Add a new custom optimization
  153780. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  153781. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  153782. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  153783. * @returns the current SceneOptimizerOptions
  153784. */
  153785. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  153786. /**
  153787. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  153788. * @param targetFrameRate defines the target frame rate (60 by default)
  153789. * @returns a SceneOptimizerOptions object
  153790. */
  153791. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  153792. /**
  153793. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  153794. * @param targetFrameRate defines the target frame rate (60 by default)
  153795. * @returns a SceneOptimizerOptions object
  153796. */
  153797. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  153798. /**
  153799. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  153800. * @param targetFrameRate defines the target frame rate (60 by default)
  153801. * @returns a SceneOptimizerOptions object
  153802. */
  153803. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  153804. }
  153805. /**
  153806. * Class used to run optimizations in order to reach a target frame rate
  153807. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  153808. */
  153809. export class SceneOptimizer implements IDisposable {
  153810. private _isRunning;
  153811. private _options;
  153812. private _scene;
  153813. private _currentPriorityLevel;
  153814. private _targetFrameRate;
  153815. private _trackerDuration;
  153816. private _currentFrameRate;
  153817. private _sceneDisposeObserver;
  153818. private _improvementMode;
  153819. /**
  153820. * Defines an observable called when the optimizer reaches the target frame rate
  153821. */
  153822. onSuccessObservable: Observable<SceneOptimizer>;
  153823. /**
  153824. * Defines an observable called when the optimizer enables an optimization
  153825. */
  153826. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  153827. /**
  153828. * Defines an observable called when the optimizer is not able to reach the target frame rate
  153829. */
  153830. onFailureObservable: Observable<SceneOptimizer>;
  153831. /**
  153832. * Gets a boolean indicating if the optimizer is in improvement mode
  153833. */
  153834. get isInImprovementMode(): boolean;
  153835. /**
  153836. * Gets the current priority level (0 at start)
  153837. */
  153838. get currentPriorityLevel(): number;
  153839. /**
  153840. * Gets the current frame rate checked by the SceneOptimizer
  153841. */
  153842. get currentFrameRate(): number;
  153843. /**
  153844. * Gets or sets the current target frame rate (60 by default)
  153845. */
  153846. get targetFrameRate(): number;
  153847. /**
  153848. * Gets or sets the current target frame rate (60 by default)
  153849. */
  153850. set targetFrameRate(value: number);
  153851. /**
  153852. * Gets or sets the current interval between two checks (every 2000ms by default)
  153853. */
  153854. get trackerDuration(): number;
  153855. /**
  153856. * Gets or sets the current interval between two checks (every 2000ms by default)
  153857. */
  153858. set trackerDuration(value: number);
  153859. /**
  153860. * Gets the list of active optimizations
  153861. */
  153862. get optimizations(): SceneOptimization[];
  153863. /**
  153864. * Creates a new SceneOptimizer
  153865. * @param scene defines the scene to work on
  153866. * @param options defines the options to use with the SceneOptimizer
  153867. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  153868. * @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)
  153869. */
  153870. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  153871. /**
  153872. * Stops the current optimizer
  153873. */
  153874. stop(): void;
  153875. /**
  153876. * Reset the optimizer to initial step (current priority level = 0)
  153877. */
  153878. reset(): void;
  153879. /**
  153880. * Start the optimizer. By default it will try to reach a specific framerate
  153881. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  153882. */
  153883. start(): void;
  153884. private _checkCurrentState;
  153885. /**
  153886. * Release all resources
  153887. */
  153888. dispose(): void;
  153889. /**
  153890. * Helper function to create a SceneOptimizer with one single line of code
  153891. * @param scene defines the scene to work on
  153892. * @param options defines the options to use with the SceneOptimizer
  153893. * @param onSuccess defines a callback to call on success
  153894. * @param onFailure defines a callback to call on failure
  153895. * @returns the new SceneOptimizer object
  153896. */
  153897. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  153898. }
  153899. }
  153900. declare module BABYLON {
  153901. /**
  153902. * Class used to serialize a scene into a string
  153903. */
  153904. export class SceneSerializer {
  153905. /**
  153906. * Clear cache used by a previous serialization
  153907. */
  153908. static ClearCache(): void;
  153909. /**
  153910. * Serialize a scene into a JSON compatible object
  153911. * @param scene defines the scene to serialize
  153912. * @returns a JSON compatible object
  153913. */
  153914. static Serialize(scene: Scene): any;
  153915. /**
  153916. * Serialize a mesh into a JSON compatible object
  153917. * @param toSerialize defines the mesh to serialize
  153918. * @param withParents defines if parents must be serialized as well
  153919. * @param withChildren defines if children must be serialized as well
  153920. * @returns a JSON compatible object
  153921. */
  153922. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  153923. }
  153924. }
  153925. declare module BABYLON {
  153926. /**
  153927. * Class used to host texture specific utilities
  153928. */
  153929. export class TextureTools {
  153930. /**
  153931. * Uses the GPU to create a copy texture rescaled at a given size
  153932. * @param texture Texture to copy from
  153933. * @param width defines the desired width
  153934. * @param height defines the desired height
  153935. * @param useBilinearMode defines if bilinear mode has to be used
  153936. * @return the generated texture
  153937. */
  153938. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  153939. }
  153940. }
  153941. declare module BABYLON {
  153942. /**
  153943. * This represents the different options available for the video capture.
  153944. */
  153945. export interface VideoRecorderOptions {
  153946. /** Defines the mime type of the video. */
  153947. mimeType: string;
  153948. /** Defines the FPS the video should be recorded at. */
  153949. fps: number;
  153950. /** Defines the chunk size for the recording data. */
  153951. recordChunckSize: number;
  153952. /** The audio tracks to attach to the recording. */
  153953. audioTracks?: MediaStreamTrack[];
  153954. }
  153955. /**
  153956. * This can help with recording videos from BabylonJS.
  153957. * This is based on the available WebRTC functionalities of the browser.
  153958. *
  153959. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_video
  153960. */
  153961. export class VideoRecorder {
  153962. private static readonly _defaultOptions;
  153963. /**
  153964. * Returns whether or not the VideoRecorder is available in your browser.
  153965. * @param engine Defines the Babylon Engine.
  153966. * @returns true if supported otherwise false.
  153967. */
  153968. static IsSupported(engine: Engine): boolean;
  153969. private readonly _options;
  153970. private _canvas;
  153971. private _mediaRecorder;
  153972. private _recordedChunks;
  153973. private _fileName;
  153974. private _resolve;
  153975. private _reject;
  153976. /**
  153977. * True when a recording is already in progress.
  153978. */
  153979. get isRecording(): boolean;
  153980. /**
  153981. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  153982. * @param engine Defines the BabylonJS Engine you wish to record.
  153983. * @param options Defines options that can be used to customize the capture.
  153984. */
  153985. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  153986. /**
  153987. * Stops the current recording before the default capture timeout passed in the startRecording function.
  153988. */
  153989. stopRecording(): void;
  153990. /**
  153991. * Starts recording the canvas for a max duration specified in parameters.
  153992. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  153993. * If null no automatic download will start and you can rely on the promise to get the data back.
  153994. * @param maxDuration Defines the maximum recording time in seconds.
  153995. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  153996. * @return A promise callback at the end of the recording with the video data in Blob.
  153997. */
  153998. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  153999. /**
  154000. * Releases internal resources used during the recording.
  154001. */
  154002. dispose(): void;
  154003. private _handleDataAvailable;
  154004. private _handleError;
  154005. private _handleStop;
  154006. }
  154007. }
  154008. declare module BABYLON {
  154009. /**
  154010. * Class containing a set of static utilities functions for screenshots
  154011. */
  154012. export class ScreenshotTools {
  154013. /**
  154014. * Captures a screenshot of the current rendering
  154015. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  154016. * @param engine defines the rendering engine
  154017. * @param camera defines the source camera
  154018. * @param size This parameter can be set to a single number or to an object with the
  154019. * following (optional) properties: precision, width, height. If a single number is passed,
  154020. * it will be used for both width and height. If an object is passed, the screenshot size
  154021. * will be derived from the parameters. The precision property is a multiplier allowing
  154022. * rendering at a higher or lower resolution
  154023. * @param successCallback defines the callback receives a single parameter which contains the
  154024. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  154025. * src parameter of an <img> to display it
  154026. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  154027. * Check your browser for supported MIME types
  154028. */
  154029. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  154030. /**
  154031. * Captures a screenshot of the current rendering
  154032. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  154033. * @param engine defines the rendering engine
  154034. * @param camera defines the source camera
  154035. * @param size This parameter can be set to a single number or to an object with the
  154036. * following (optional) properties: precision, width, height. If a single number is passed,
  154037. * it will be used for both width and height. If an object is passed, the screenshot size
  154038. * will be derived from the parameters. The precision property is a multiplier allowing
  154039. * rendering at a higher or lower resolution
  154040. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  154041. * Check your browser for supported MIME types
  154042. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  154043. * to the src parameter of an <img> to display it
  154044. */
  154045. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  154046. /**
  154047. * Generates an image screenshot from the specified camera.
  154048. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  154049. * @param engine The engine to use for rendering
  154050. * @param camera The camera to use for rendering
  154051. * @param size This parameter can be set to a single number or to an object with the
  154052. * following (optional) properties: precision, width, height. If a single number is passed,
  154053. * it will be used for both width and height. If an object is passed, the screenshot size
  154054. * will be derived from the parameters. The precision property is a multiplier allowing
  154055. * rendering at a higher or lower resolution
  154056. * @param successCallback The callback receives a single parameter which contains the
  154057. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  154058. * src parameter of an <img> to display it
  154059. * @param mimeType The MIME type of the screenshot image (default: image/png).
  154060. * Check your browser for supported MIME types
  154061. * @param samples Texture samples (default: 1)
  154062. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  154063. * @param fileName A name for for the downloaded file.
  154064. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  154065. * @param enableStencilBuffer Whether the stencil buffer should be enabled or not (default: false)
  154066. */
  154067. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean, enableStencilBuffer?: boolean): void;
  154068. /**
  154069. * Generates an image screenshot from the specified camera.
  154070. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  154071. * @param engine The engine to use for rendering
  154072. * @param camera The camera to use for rendering
  154073. * @param size This parameter can be set to a single number or to an object with the
  154074. * following (optional) properties: precision, width, height. If a single number is passed,
  154075. * it will be used for both width and height. If an object is passed, the screenshot size
  154076. * will be derived from the parameters. The precision property is a multiplier allowing
  154077. * rendering at a higher or lower resolution
  154078. * @param mimeType The MIME type of the screenshot image (default: image/png).
  154079. * Check your browser for supported MIME types
  154080. * @param samples Texture samples (default: 1)
  154081. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  154082. * @param fileName A name for for the downloaded file.
  154083. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  154084. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  154085. * to the src parameter of an <img> to display it
  154086. */
  154087. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  154088. /**
  154089. * Gets height and width for screenshot size
  154090. * @private
  154091. */
  154092. private static _getScreenshotSize;
  154093. }
  154094. }
  154095. declare module BABYLON {
  154096. /**
  154097. * Interface for a data buffer
  154098. */
  154099. export interface IDataBuffer {
  154100. /**
  154101. * Reads bytes from the data buffer.
  154102. * @param byteOffset The byte offset to read
  154103. * @param byteLength The byte length to read
  154104. * @returns A promise that resolves when the bytes are read
  154105. */
  154106. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  154107. /**
  154108. * The byte length of the buffer.
  154109. */
  154110. readonly byteLength: number;
  154111. }
  154112. /**
  154113. * Utility class for reading from a data buffer
  154114. */
  154115. export class DataReader {
  154116. /**
  154117. * The data buffer associated with this data reader.
  154118. */
  154119. readonly buffer: IDataBuffer;
  154120. /**
  154121. * The current byte offset from the beginning of the data buffer.
  154122. */
  154123. byteOffset: number;
  154124. private _dataView;
  154125. private _dataByteOffset;
  154126. /**
  154127. * Constructor
  154128. * @param buffer The buffer to read
  154129. */
  154130. constructor(buffer: IDataBuffer);
  154131. /**
  154132. * Loads the given byte length.
  154133. * @param byteLength The byte length to load
  154134. * @returns A promise that resolves when the load is complete
  154135. */
  154136. loadAsync(byteLength: number): Promise<void>;
  154137. /**
  154138. * Read a unsigned 32-bit integer from the currently loaded data range.
  154139. * @returns The 32-bit integer read
  154140. */
  154141. readUint32(): number;
  154142. /**
  154143. * Read a byte array from the currently loaded data range.
  154144. * @param byteLength The byte length to read
  154145. * @returns The byte array read
  154146. */
  154147. readUint8Array(byteLength: number): Uint8Array;
  154148. /**
  154149. * Read a string from the currently loaded data range.
  154150. * @param byteLength The byte length to read
  154151. * @returns The string read
  154152. */
  154153. readString(byteLength: number): string;
  154154. /**
  154155. * Skips the given byte length the currently loaded data range.
  154156. * @param byteLength The byte length to skip
  154157. */
  154158. skipBytes(byteLength: number): void;
  154159. }
  154160. }
  154161. declare module BABYLON {
  154162. /**
  154163. * Class for storing data to local storage if available or in-memory storage otherwise
  154164. */
  154165. export class DataStorage {
  154166. private static _Storage;
  154167. private static _GetStorage;
  154168. /**
  154169. * Reads a string from the data storage
  154170. * @param key The key to read
  154171. * @param defaultValue The value if the key doesn't exist
  154172. * @returns The string value
  154173. */
  154174. static ReadString(key: string, defaultValue: string): string;
  154175. /**
  154176. * Writes a string to the data storage
  154177. * @param key The key to write
  154178. * @param value The value to write
  154179. */
  154180. static WriteString(key: string, value: string): void;
  154181. /**
  154182. * Reads a boolean from the data storage
  154183. * @param key The key to read
  154184. * @param defaultValue The value if the key doesn't exist
  154185. * @returns The boolean value
  154186. */
  154187. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  154188. /**
  154189. * Writes a boolean to the data storage
  154190. * @param key The key to write
  154191. * @param value The value to write
  154192. */
  154193. static WriteBoolean(key: string, value: boolean): void;
  154194. /**
  154195. * Reads a number from the data storage
  154196. * @param key The key to read
  154197. * @param defaultValue The value if the key doesn't exist
  154198. * @returns The number value
  154199. */
  154200. static ReadNumber(key: string, defaultValue: number): number;
  154201. /**
  154202. * Writes a number to the data storage
  154203. * @param key The key to write
  154204. * @param value The value to write
  154205. */
  154206. static WriteNumber(key: string, value: number): void;
  154207. }
  154208. }
  154209. declare module BABYLON {
  154210. /**
  154211. * Class used to record delta files between 2 scene states
  154212. */
  154213. export class SceneRecorder {
  154214. private _trackedScene;
  154215. private _savedJSON;
  154216. /**
  154217. * Track a given scene. This means the current scene state will be considered the original state
  154218. * @param scene defines the scene to track
  154219. */
  154220. track(scene: Scene): void;
  154221. /**
  154222. * Get the delta between current state and original state
  154223. * @returns a string containing the delta
  154224. */
  154225. getDelta(): any;
  154226. private _compareArray;
  154227. private _compareObjects;
  154228. private _compareCollections;
  154229. private static GetShadowGeneratorById;
  154230. /**
  154231. * Apply a given delta to a given scene
  154232. * @param deltaJSON defines the JSON containing the delta
  154233. * @param scene defines the scene to apply the delta to
  154234. */
  154235. static ApplyDelta(deltaJSON: any | string, scene: Scene): void;
  154236. private static _ApplyPropertiesToEntity;
  154237. private static _ApplyDeltaForEntity;
  154238. }
  154239. }
  154240. declare module BABYLON {
  154241. /**
  154242. * An interface for all Hit test features
  154243. */
  154244. export interface IWebXRHitTestFeature<T extends IWebXRLegacyHitResult> extends IWebXRFeature {
  154245. /**
  154246. * Triggered when new babylon (transformed) hit test results are available
  154247. */
  154248. onHitTestResultObservable: Observable<T[]>;
  154249. }
  154250. /**
  154251. * Options used for hit testing
  154252. */
  154253. export interface IWebXRLegacyHitTestOptions {
  154254. /**
  154255. * Only test when user interacted with the scene. Default - hit test every frame
  154256. */
  154257. testOnPointerDownOnly?: boolean;
  154258. /**
  154259. * The node to use to transform the local results to world coordinates
  154260. */
  154261. worldParentNode?: TransformNode;
  154262. }
  154263. /**
  154264. * Interface defining the babylon result of raycasting/hit-test
  154265. */
  154266. export interface IWebXRLegacyHitResult {
  154267. /**
  154268. * Transformation matrix that can be applied to a node that will put it in the hit point location
  154269. */
  154270. transformationMatrix: Matrix;
  154271. /**
  154272. * The native hit test result
  154273. */
  154274. xrHitResult: XRHitResult | XRHitTestResult;
  154275. }
  154276. /**
  154277. * The currently-working hit-test module.
  154278. * Hit test (or Ray-casting) is used to interact with the real world.
  154279. * For further information read here - https://github.com/immersive-web/hit-test
  154280. */
  154281. export class WebXRHitTestLegacy extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRLegacyHitResult> {
  154282. /**
  154283. * options to use when constructing this feature
  154284. */
  154285. readonly options: IWebXRLegacyHitTestOptions;
  154286. private _direction;
  154287. private _mat;
  154288. private _onSelectEnabled;
  154289. private _origin;
  154290. /**
  154291. * The module's name
  154292. */
  154293. static readonly Name: string;
  154294. /**
  154295. * The (Babylon) version of this module.
  154296. * This is an integer representing the implementation version.
  154297. * This number does not correspond to the WebXR specs version
  154298. */
  154299. static readonly Version: number;
  154300. /**
  154301. * Populated with the last native XR Hit Results
  154302. */
  154303. lastNativeXRHitResults: XRHitResult[];
  154304. /**
  154305. * Triggered when new babylon (transformed) hit test results are available
  154306. */
  154307. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  154308. /**
  154309. * Creates a new instance of the (legacy version) hit test feature
  154310. * @param _xrSessionManager an instance of WebXRSessionManager
  154311. * @param options options to use when constructing this feature
  154312. */
  154313. constructor(_xrSessionManager: WebXRSessionManager,
  154314. /**
  154315. * options to use when constructing this feature
  154316. */
  154317. options?: IWebXRLegacyHitTestOptions);
  154318. /**
  154319. * execute a hit test with an XR Ray
  154320. *
  154321. * @param xrSession a native xrSession that will execute this hit test
  154322. * @param xrRay the ray (position and direction) to use for ray-casting
  154323. * @param referenceSpace native XR reference space to use for the hit-test
  154324. * @param filter filter function that will filter the results
  154325. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  154326. */
  154327. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  154328. /**
  154329. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  154330. * @param event the (select) event to use to select with
  154331. * @param referenceSpace the reference space to use for this hit test
  154332. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  154333. */
  154334. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  154335. /**
  154336. * attach this feature
  154337. * Will usually be called by the features manager
  154338. *
  154339. * @returns true if successful.
  154340. */
  154341. attach(): boolean;
  154342. /**
  154343. * detach this feature.
  154344. * Will usually be called by the features manager
  154345. *
  154346. * @returns true if successful.
  154347. */
  154348. detach(): boolean;
  154349. /**
  154350. * Dispose this feature and all of the resources attached
  154351. */
  154352. dispose(): void;
  154353. protected _onXRFrame(frame: XRFrame): void;
  154354. private _onHitTestResults;
  154355. private _onSelect;
  154356. }
  154357. }
  154358. declare module BABYLON {
  154359. /**
  154360. * Options used for hit testing (version 2)
  154361. */
  154362. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  154363. /**
  154364. * Do not create a permanent hit test. Will usually be used when only
  154365. * transient inputs are needed.
  154366. */
  154367. disablePermanentHitTest?: boolean;
  154368. /**
  154369. * Enable transient (for example touch-based) hit test inspections
  154370. */
  154371. enableTransientHitTest?: boolean;
  154372. /**
  154373. * Offset ray for the permanent hit test
  154374. */
  154375. offsetRay?: Vector3;
  154376. /**
  154377. * Offset ray for the transient hit test
  154378. */
  154379. transientOffsetRay?: Vector3;
  154380. /**
  154381. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  154382. */
  154383. useReferenceSpace?: boolean;
  154384. /**
  154385. * Override the default entity type(s) of the hit-test result
  154386. */
  154387. entityTypes?: XRHitTestTrackableType[];
  154388. }
  154389. /**
  154390. * Interface defining the babylon result of hit-test
  154391. */
  154392. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  154393. /**
  154394. * The input source that generated this hit test (if transient)
  154395. */
  154396. inputSource?: XRInputSource;
  154397. /**
  154398. * Is this a transient hit test
  154399. */
  154400. isTransient?: boolean;
  154401. /**
  154402. * Position of the hit test result
  154403. */
  154404. position: Vector3;
  154405. /**
  154406. * Rotation of the hit test result
  154407. */
  154408. rotationQuaternion: Quaternion;
  154409. /**
  154410. * The native hit test result
  154411. */
  154412. xrHitResult: XRHitTestResult;
  154413. }
  154414. /**
  154415. * The currently-working hit-test module.
  154416. * Hit test (or Ray-casting) is used to interact with the real world.
  154417. * For further information read here - https://github.com/immersive-web/hit-test
  154418. *
  154419. * Tested on chrome (mobile) 80.
  154420. */
  154421. export class WebXRHitTest extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRHitResult> {
  154422. /**
  154423. * options to use when constructing this feature
  154424. */
  154425. readonly options: IWebXRHitTestOptions;
  154426. private _tmpMat;
  154427. private _tmpPos;
  154428. private _tmpQuat;
  154429. private _transientXrHitTestSource;
  154430. private _xrHitTestSource;
  154431. private initHitTestSource;
  154432. /**
  154433. * The module's name
  154434. */
  154435. static readonly Name: string;
  154436. /**
  154437. * The (Babylon) version of this module.
  154438. * This is an integer representing the implementation version.
  154439. * This number does not correspond to the WebXR specs version
  154440. */
  154441. static readonly Version: number;
  154442. /**
  154443. * When set to true, each hit test will have its own position/rotation objects
  154444. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  154445. * the developers will clone them or copy them as they see fit.
  154446. */
  154447. autoCloneTransformation: boolean;
  154448. /**
  154449. * Triggered when new babylon (transformed) hit test results are available
  154450. * Note - this will be called when results come back from the device. It can be an empty array!!
  154451. */
  154452. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  154453. /**
  154454. * Use this to temporarily pause hit test checks.
  154455. */
  154456. paused: boolean;
  154457. /**
  154458. * Creates a new instance of the hit test feature
  154459. * @param _xrSessionManager an instance of WebXRSessionManager
  154460. * @param options options to use when constructing this feature
  154461. */
  154462. constructor(_xrSessionManager: WebXRSessionManager,
  154463. /**
  154464. * options to use when constructing this feature
  154465. */
  154466. options?: IWebXRHitTestOptions);
  154467. /**
  154468. * attach this feature
  154469. * Will usually be called by the features manager
  154470. *
  154471. * @returns true if successful.
  154472. */
  154473. attach(): boolean;
  154474. /**
  154475. * detach this feature.
  154476. * Will usually be called by the features manager
  154477. *
  154478. * @returns true if successful.
  154479. */
  154480. detach(): boolean;
  154481. /**
  154482. * Dispose this feature and all of the resources attached
  154483. */
  154484. dispose(): void;
  154485. protected _onXRFrame(frame: XRFrame): void;
  154486. private _processWebXRHitTestResult;
  154487. }
  154488. }
  154489. declare module BABYLON {
  154490. /**
  154491. * Configuration options of the anchor system
  154492. */
  154493. export interface IWebXRAnchorSystemOptions {
  154494. /**
  154495. * a node that will be used to convert local to world coordinates
  154496. */
  154497. worldParentNode?: TransformNode;
  154498. /**
  154499. * If set to true a reference of the created anchors will be kept until the next session starts
  154500. * If not defined, anchors will be removed from the array when the feature is detached or the session ended.
  154501. */
  154502. doNotRemoveAnchorsOnSessionEnded?: boolean;
  154503. }
  154504. /**
  154505. * A babylon container for an XR Anchor
  154506. */
  154507. export interface IWebXRAnchor {
  154508. /**
  154509. * A babylon-assigned ID for this anchor
  154510. */
  154511. id: number;
  154512. /**
  154513. * Transformation matrix to apply to an object attached to this anchor
  154514. */
  154515. transformationMatrix: Matrix;
  154516. /**
  154517. * The native anchor object
  154518. */
  154519. xrAnchor: XRAnchor;
  154520. /**
  154521. * if defined, this object will be constantly updated by the anchor's position and rotation
  154522. */
  154523. attachedNode?: TransformNode;
  154524. }
  154525. /**
  154526. * An implementation of the anchor system for WebXR.
  154527. * For further information see https://github.com/immersive-web/anchors/
  154528. */
  154529. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  154530. private _options;
  154531. private _lastFrameDetected;
  154532. private _trackedAnchors;
  154533. private _referenceSpaceForFrameAnchors;
  154534. private _futureAnchors;
  154535. /**
  154536. * The module's name
  154537. */
  154538. static readonly Name: string;
  154539. /**
  154540. * The (Babylon) version of this module.
  154541. * This is an integer representing the implementation version.
  154542. * This number does not correspond to the WebXR specs version
  154543. */
  154544. static readonly Version: number;
  154545. /**
  154546. * Observers registered here will be executed when a new anchor was added to the session
  154547. */
  154548. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  154549. /**
  154550. * Observers registered here will be executed when an anchor was removed from the session
  154551. */
  154552. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  154553. /**
  154554. * Observers registered here will be executed when an existing anchor updates
  154555. * This can execute N times every frame
  154556. */
  154557. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  154558. /**
  154559. * Set the reference space to use for anchor creation, when not using a hit test.
  154560. * Will default to the session's reference space if not defined
  154561. */
  154562. set referenceSpaceForFrameAnchors(referenceSpace: XRReferenceSpace);
  154563. /**
  154564. * constructs a new anchor system
  154565. * @param _xrSessionManager an instance of WebXRSessionManager
  154566. * @param _options configuration object for this feature
  154567. */
  154568. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  154569. private _tmpVector;
  154570. private _tmpQuaternion;
  154571. private _populateTmpTransformation;
  154572. /**
  154573. * Create a new anchor point using a hit test result at a specific point in the scene
  154574. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  154575. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  154576. *
  154577. * @param hitTestResult The hit test result to use for this anchor creation
  154578. * @param position an optional position offset for this anchor
  154579. * @param rotationQuaternion an optional rotation offset for this anchor
  154580. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  154581. */
  154582. addAnchorPointUsingHitTestResultAsync(hitTestResult: IWebXRHitResult, position?: Vector3, rotationQuaternion?: Quaternion): Promise<XRAnchor>;
  154583. /**
  154584. * Add a new anchor at a specific position and rotation
  154585. * This function will add a new anchor per default in the next available frame. Unless forced, the createAnchor function
  154586. * will be called in the next xrFrame loop to make sure that the anchor can be created correctly.
  154587. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  154588. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  154589. *
  154590. * @param position the position in which to add an anchor
  154591. * @param rotationQuaternion an optional rotation for the anchor transformation
  154592. * @param forceCreateInCurrentFrame force the creation of this anchor in the current frame. Must be called inside xrFrame loop!
  154593. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  154594. */
  154595. addAnchorAtPositionAndRotationAsync(position: Vector3, rotationQuaternion?: Quaternion, forceCreateInCurrentFrame?: boolean): Promise<XRAnchor>;
  154596. /**
  154597. * detach this feature.
  154598. * Will usually be called by the features manager
  154599. *
  154600. * @returns true if successful.
  154601. */
  154602. detach(): boolean;
  154603. /**
  154604. * Dispose this feature and all of the resources attached
  154605. */
  154606. dispose(): void;
  154607. protected _onXRFrame(frame: XRFrame): void;
  154608. /**
  154609. * avoiding using Array.find for global support.
  154610. * @param xrAnchor the plane to find in the array
  154611. */
  154612. private _findIndexInAnchorArray;
  154613. private _updateAnchorWithXRFrame;
  154614. private _createAnchorAtTransformation;
  154615. }
  154616. }
  154617. declare module BABYLON {
  154618. /**
  154619. * Options used in the plane detector module
  154620. */
  154621. export interface IWebXRPlaneDetectorOptions {
  154622. /**
  154623. * The node to use to transform the local results to world coordinates
  154624. */
  154625. worldParentNode?: TransformNode;
  154626. /**
  154627. * If set to true a reference of the created planes will be kept until the next session starts
  154628. * If not defined, planes will be removed from the array when the feature is detached or the session ended.
  154629. */
  154630. doNotRemovePlanesOnSessionEnded?: boolean;
  154631. }
  154632. /**
  154633. * A babylon interface for a WebXR plane.
  154634. * A Plane is actually a polygon, built from N points in space
  154635. *
  154636. * Supported in chrome 79, not supported in canary 81 ATM
  154637. */
  154638. export interface IWebXRPlane {
  154639. /**
  154640. * a babylon-assigned ID for this polygon
  154641. */
  154642. id: number;
  154643. /**
  154644. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  154645. */
  154646. polygonDefinition: Array<Vector3>;
  154647. /**
  154648. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  154649. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  154650. */
  154651. transformationMatrix: Matrix;
  154652. /**
  154653. * the native xr-plane object
  154654. */
  154655. xrPlane: XRPlane;
  154656. }
  154657. /**
  154658. * The plane detector is used to detect planes in the real world when in AR
  154659. * For more information see https://github.com/immersive-web/real-world-geometry/
  154660. */
  154661. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  154662. private _options;
  154663. private _detectedPlanes;
  154664. private _enabled;
  154665. private _lastFrameDetected;
  154666. /**
  154667. * The module's name
  154668. */
  154669. static readonly Name: string;
  154670. /**
  154671. * The (Babylon) version of this module.
  154672. * This is an integer representing the implementation version.
  154673. * This number does not correspond to the WebXR specs version
  154674. */
  154675. static readonly Version: number;
  154676. /**
  154677. * Observers registered here will be executed when a new plane was added to the session
  154678. */
  154679. onPlaneAddedObservable: Observable<IWebXRPlane>;
  154680. /**
  154681. * Observers registered here will be executed when a plane is no longer detected in the session
  154682. */
  154683. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  154684. /**
  154685. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  154686. * This can execute N times every frame
  154687. */
  154688. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  154689. /**
  154690. * construct a new Plane Detector
  154691. * @param _xrSessionManager an instance of xr Session manager
  154692. * @param _options configuration to use when constructing this feature
  154693. */
  154694. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  154695. /**
  154696. * detach this feature.
  154697. * Will usually be called by the features manager
  154698. *
  154699. * @returns true if successful.
  154700. */
  154701. detach(): boolean;
  154702. /**
  154703. * Dispose this feature and all of the resources attached
  154704. */
  154705. dispose(): void;
  154706. protected _onXRFrame(frame: XRFrame): void;
  154707. private _init;
  154708. private _updatePlaneWithXRPlane;
  154709. /**
  154710. * avoiding using Array.find for global support.
  154711. * @param xrPlane the plane to find in the array
  154712. */
  154713. private findIndexInPlaneArray;
  154714. }
  154715. }
  154716. declare module BABYLON {
  154717. /**
  154718. * Options interface for the background remover plugin
  154719. */
  154720. export interface IWebXRBackgroundRemoverOptions {
  154721. /**
  154722. * Further background meshes to disable when entering AR
  154723. */
  154724. backgroundMeshes?: AbstractMesh[];
  154725. /**
  154726. * flags to configure the removal of the environment helper.
  154727. * If not set, the entire background will be removed. If set, flags should be set as well.
  154728. */
  154729. environmentHelperRemovalFlags?: {
  154730. /**
  154731. * Should the skybox be removed (default false)
  154732. */
  154733. skyBox?: boolean;
  154734. /**
  154735. * Should the ground be removed (default false)
  154736. */
  154737. ground?: boolean;
  154738. };
  154739. /**
  154740. * don't disable the environment helper
  154741. */
  154742. ignoreEnvironmentHelper?: boolean;
  154743. }
  154744. /**
  154745. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  154746. */
  154747. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  154748. /**
  154749. * read-only options to be used in this module
  154750. */
  154751. readonly options: IWebXRBackgroundRemoverOptions;
  154752. /**
  154753. * The module's name
  154754. */
  154755. static readonly Name: string;
  154756. /**
  154757. * The (Babylon) version of this module.
  154758. * This is an integer representing the implementation version.
  154759. * This number does not correspond to the WebXR specs version
  154760. */
  154761. static readonly Version: number;
  154762. /**
  154763. * registered observers will be triggered when the background state changes
  154764. */
  154765. onBackgroundStateChangedObservable: Observable<boolean>;
  154766. /**
  154767. * constructs a new background remover module
  154768. * @param _xrSessionManager the session manager for this module
  154769. * @param options read-only options to be used in this module
  154770. */
  154771. constructor(_xrSessionManager: WebXRSessionManager,
  154772. /**
  154773. * read-only options to be used in this module
  154774. */
  154775. options?: IWebXRBackgroundRemoverOptions);
  154776. /**
  154777. * attach this feature
  154778. * Will usually be called by the features manager
  154779. *
  154780. * @returns true if successful.
  154781. */
  154782. attach(): boolean;
  154783. /**
  154784. * detach this feature.
  154785. * Will usually be called by the features manager
  154786. *
  154787. * @returns true if successful.
  154788. */
  154789. detach(): boolean;
  154790. /**
  154791. * Dispose this feature and all of the resources attached
  154792. */
  154793. dispose(): void;
  154794. protected _onXRFrame(_xrFrame: XRFrame): void;
  154795. private _setBackgroundState;
  154796. }
  154797. }
  154798. declare module BABYLON {
  154799. /**
  154800. * Options for the controller physics feature
  154801. */
  154802. export class IWebXRControllerPhysicsOptions {
  154803. /**
  154804. * Should the headset get its own impostor
  154805. */
  154806. enableHeadsetImpostor?: boolean;
  154807. /**
  154808. * Optional parameters for the headset impostor
  154809. */
  154810. headsetImpostorParams?: {
  154811. /**
  154812. * The type of impostor to create. Default is sphere
  154813. */
  154814. impostorType: number;
  154815. /**
  154816. * the size of the impostor. Defaults to 10cm
  154817. */
  154818. impostorSize?: number | {
  154819. width: number;
  154820. height: number;
  154821. depth: number;
  154822. };
  154823. /**
  154824. * Friction definitions
  154825. */
  154826. friction?: number;
  154827. /**
  154828. * Restitution
  154829. */
  154830. restitution?: number;
  154831. };
  154832. /**
  154833. * The physics properties of the future impostors
  154834. */
  154835. physicsProperties?: {
  154836. /**
  154837. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  154838. * Note that this requires a physics engine that supports mesh impostors!
  154839. */
  154840. useControllerMesh?: boolean;
  154841. /**
  154842. * The type of impostor to create. Default is sphere
  154843. */
  154844. impostorType?: number;
  154845. /**
  154846. * the size of the impostor. Defaults to 10cm
  154847. */
  154848. impostorSize?: number | {
  154849. width: number;
  154850. height: number;
  154851. depth: number;
  154852. };
  154853. /**
  154854. * Friction definitions
  154855. */
  154856. friction?: number;
  154857. /**
  154858. * Restitution
  154859. */
  154860. restitution?: number;
  154861. };
  154862. /**
  154863. * the xr input to use with this pointer selection
  154864. */
  154865. xrInput: WebXRInput;
  154866. }
  154867. /**
  154868. * Add physics impostor to your webxr controllers,
  154869. * including naive calculation of their linear and angular velocity
  154870. */
  154871. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  154872. private readonly _options;
  154873. private _attachController;
  154874. private _controllers;
  154875. private _debugMode;
  154876. private _delta;
  154877. private _headsetImpostor?;
  154878. private _headsetMesh?;
  154879. private _lastTimestamp;
  154880. private _tmpQuaternion;
  154881. private _tmpVector;
  154882. /**
  154883. * The module's name
  154884. */
  154885. static readonly Name: string;
  154886. /**
  154887. * The (Babylon) version of this module.
  154888. * This is an integer representing the implementation version.
  154889. * This number does not correspond to the webxr specs version
  154890. */
  154891. static readonly Version: number;
  154892. /**
  154893. * Construct a new Controller Physics Feature
  154894. * @param _xrSessionManager the corresponding xr session manager
  154895. * @param _options options to create this feature with
  154896. */
  154897. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  154898. /**
  154899. * @hidden
  154900. * enable debugging - will show console outputs and the impostor mesh
  154901. */
  154902. _enablePhysicsDebug(): void;
  154903. /**
  154904. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  154905. * @param xrController the controller to add
  154906. */
  154907. addController(xrController: WebXRInputSource): void;
  154908. /**
  154909. * attach this feature
  154910. * Will usually be called by the features manager
  154911. *
  154912. * @returns true if successful.
  154913. */
  154914. attach(): boolean;
  154915. /**
  154916. * detach this feature.
  154917. * Will usually be called by the features manager
  154918. *
  154919. * @returns true if successful.
  154920. */
  154921. detach(): boolean;
  154922. /**
  154923. * Get the headset impostor, if enabled
  154924. * @returns the impostor
  154925. */
  154926. getHeadsetImpostor(): PhysicsImpostor | undefined;
  154927. /**
  154928. * Get the physics impostor of a specific controller.
  154929. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  154930. * @param controller the controller or the controller id of which to get the impostor
  154931. * @returns the impostor or null
  154932. */
  154933. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  154934. /**
  154935. * Update the physics properties provided in the constructor
  154936. * @param newProperties the new properties object
  154937. */
  154938. setPhysicsProperties(newProperties: {
  154939. impostorType?: number;
  154940. impostorSize?: number | {
  154941. width: number;
  154942. height: number;
  154943. depth: number;
  154944. };
  154945. friction?: number;
  154946. restitution?: number;
  154947. }): void;
  154948. protected _onXRFrame(_xrFrame: any): void;
  154949. private _detachController;
  154950. }
  154951. }
  154952. declare module BABYLON {
  154953. /**
  154954. * A babylon interface for a "WebXR" feature point.
  154955. * Represents the position and confidence value of a given feature point.
  154956. */
  154957. export interface IWebXRFeaturePoint {
  154958. /**
  154959. * Represents the position of the feature point in world space.
  154960. */
  154961. position: Vector3;
  154962. /**
  154963. * Represents the confidence value of the feature point in world space. 0 being least confident, and 1 being most confident.
  154964. */
  154965. confidenceValue: number;
  154966. }
  154967. /**
  154968. * The feature point system is used to detect feature points from real world geometry.
  154969. * This feature is currently experimental and only supported on BabylonNative, and should not be used in the browser.
  154970. * The newly introduced API can be seen in webxr.nativeextensions.d.ts and described in FeaturePoints.md.
  154971. */
  154972. export class WebXRFeaturePointSystem extends WebXRAbstractFeature {
  154973. private _enabled;
  154974. private _featurePointCloud;
  154975. /**
  154976. * The module's name
  154977. */
  154978. static readonly Name: string;
  154979. /**
  154980. * The (Babylon) version of this module.
  154981. * This is an integer representing the implementation version.
  154982. * This number does not correspond to the WebXR specs version
  154983. */
  154984. static readonly Version: number;
  154985. /**
  154986. * Observers registered here will be executed whenever new feature points are added (on XRFrame while the session is tracking).
  154987. * Will notify the observers about which feature points have been added.
  154988. */
  154989. readonly onFeaturePointsAddedObservable: Observable<number[]>;
  154990. /**
  154991. * Observers registered here will be executed whenever a feature point has been updated (on XRFrame while the session is tracking).
  154992. * Will notify the observers about which feature points have been updated.
  154993. */
  154994. readonly onFeaturePointsUpdatedObservable: Observable<number[]>;
  154995. /**
  154996. * The current feature point cloud maintained across frames.
  154997. */
  154998. get featurePointCloud(): Array<IWebXRFeaturePoint>;
  154999. /**
  155000. * construct the feature point system
  155001. * @param _xrSessionManager an instance of xr Session manager
  155002. */
  155003. constructor(_xrSessionManager: WebXRSessionManager);
  155004. /**
  155005. * Detach this feature.
  155006. * Will usually be called by the features manager
  155007. *
  155008. * @returns true if successful.
  155009. */
  155010. detach(): boolean;
  155011. /**
  155012. * Dispose this feature and all of the resources attached
  155013. */
  155014. dispose(): void;
  155015. /**
  155016. * On receiving a new XR frame if this feature is attached notify observers new feature point data is available.
  155017. */
  155018. protected _onXRFrame(frame: XRFrame): void;
  155019. /**
  155020. * Initializes the feature. If the feature point feature is not available for this environment do not mark the feature as enabled.
  155021. */
  155022. private _init;
  155023. }
  155024. }
  155025. declare module BABYLON {
  155026. /**
  155027. * Configuration interface for the hand tracking feature
  155028. */
  155029. export interface IWebXRHandTrackingOptions {
  155030. /**
  155031. * The xrInput that will be used as source for new hands
  155032. */
  155033. xrInput: WebXRInput;
  155034. /**
  155035. * Configuration object for the joint meshes
  155036. */
  155037. jointMeshes?: {
  155038. /**
  155039. * Should the meshes created be invisible (defaults to false)
  155040. */
  155041. invisible?: boolean;
  155042. /**
  155043. * A source mesh to be used to create instances. Defaults to a sphere.
  155044. * This mesh will be the source for all other (25) meshes.
  155045. * It should have the general size of a single unit, as the instances will be scaled according to the provided radius
  155046. */
  155047. sourceMesh?: Mesh;
  155048. /**
  155049. * Should the source mesh stay visible. Defaults to false
  155050. */
  155051. keepOriginalVisible?: boolean;
  155052. /**
  155053. * Scale factor for all instances (defaults to 2)
  155054. */
  155055. scaleFactor?: number;
  155056. /**
  155057. * Should each instance have its own physics impostor
  155058. */
  155059. enablePhysics?: boolean;
  155060. /**
  155061. * If enabled, override default physics properties
  155062. */
  155063. physicsProps?: {
  155064. friction?: number;
  155065. restitution?: number;
  155066. impostorType?: number;
  155067. };
  155068. /**
  155069. * For future use - a single hand-mesh that will be updated according to the XRHand data provided
  155070. */
  155071. handMesh?: AbstractMesh;
  155072. };
  155073. }
  155074. /**
  155075. * Parts of the hands divided to writs and finger names
  155076. */
  155077. export const enum HandPart {
  155078. /**
  155079. * HandPart - Wrist
  155080. */
  155081. WRIST = "wrist",
  155082. /**
  155083. * HandPart - The THumb
  155084. */
  155085. THUMB = "thumb",
  155086. /**
  155087. * HandPart - Index finger
  155088. */
  155089. INDEX = "index",
  155090. /**
  155091. * HandPart - Middle finger
  155092. */
  155093. MIDDLE = "middle",
  155094. /**
  155095. * HandPart - Ring finger
  155096. */
  155097. RING = "ring",
  155098. /**
  155099. * HandPart - Little finger
  155100. */
  155101. LITTLE = "little"
  155102. }
  155103. /**
  155104. * Representing a single hand (with its corresponding native XRHand object)
  155105. */
  155106. export class WebXRHand implements IDisposable {
  155107. /** the controller to which the hand correlates */
  155108. readonly xrController: WebXRInputSource;
  155109. /** the meshes to be used to track the hand joints */
  155110. readonly trackedMeshes: AbstractMesh[];
  155111. /**
  155112. * Hand-parts definition (key is HandPart)
  155113. */
  155114. handPartsDefinition: {
  155115. [key: string]: number[];
  155116. };
  155117. /**
  155118. * Populate the HandPartsDefinition object.
  155119. * This is called as a side effect since certain browsers don't have XRHand defined.
  155120. */
  155121. private generateHandPartsDefinition;
  155122. /**
  155123. * Construct a new hand object
  155124. * @param xrController the controller to which the hand correlates
  155125. * @param trackedMeshes the meshes to be used to track the hand joints
  155126. */
  155127. constructor(
  155128. /** the controller to which the hand correlates */
  155129. xrController: WebXRInputSource,
  155130. /** the meshes to be used to track the hand joints */
  155131. trackedMeshes: AbstractMesh[]);
  155132. /**
  155133. * Update this hand from the latest xr frame
  155134. * @param xrFrame xrFrame to update from
  155135. * @param referenceSpace The current viewer reference space
  155136. * @param scaleFactor optional scale factor for the meshes
  155137. */
  155138. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace, scaleFactor?: number): void;
  155139. /**
  155140. * Get meshes of part of the hand
  155141. * @param part the part of hand to get
  155142. * @returns An array of meshes that correlate to the hand part requested
  155143. */
  155144. getHandPartMeshes(part: HandPart): AbstractMesh[];
  155145. /**
  155146. * Dispose this Hand object
  155147. */
  155148. dispose(): void;
  155149. }
  155150. /**
  155151. * WebXR Hand Joint tracking feature, available for selected browsers and devices
  155152. */
  155153. export class WebXRHandTracking extends WebXRAbstractFeature {
  155154. /**
  155155. * options to use when constructing this feature
  155156. */
  155157. readonly options: IWebXRHandTrackingOptions;
  155158. private static _idCounter;
  155159. /**
  155160. * The module's name
  155161. */
  155162. static readonly Name: string;
  155163. /**
  155164. * The (Babylon) version of this module.
  155165. * This is an integer representing the implementation version.
  155166. * This number does not correspond to the WebXR specs version
  155167. */
  155168. static readonly Version: number;
  155169. /**
  155170. * This observable will notify registered observers when a new hand object was added and initialized
  155171. */
  155172. onHandAddedObservable: Observable<WebXRHand>;
  155173. /**
  155174. * This observable will notify its observers right before the hand object is disposed
  155175. */
  155176. onHandRemovedObservable: Observable<WebXRHand>;
  155177. private _hands;
  155178. /**
  155179. * Creates a new instance of the hit test feature
  155180. * @param _xrSessionManager an instance of WebXRSessionManager
  155181. * @param options options to use when constructing this feature
  155182. */
  155183. constructor(_xrSessionManager: WebXRSessionManager,
  155184. /**
  155185. * options to use when constructing this feature
  155186. */
  155187. options: IWebXRHandTrackingOptions);
  155188. /**
  155189. * Check if the needed objects are defined.
  155190. * This does not mean that the feature is enabled, but that the objects needed are well defined.
  155191. */
  155192. isCompatible(): boolean;
  155193. /**
  155194. * attach this feature
  155195. * Will usually be called by the features manager
  155196. *
  155197. * @returns true if successful.
  155198. */
  155199. attach(): boolean;
  155200. /**
  155201. * detach this feature.
  155202. * Will usually be called by the features manager
  155203. *
  155204. * @returns true if successful.
  155205. */
  155206. detach(): boolean;
  155207. /**
  155208. * Dispose this feature and all of the resources attached
  155209. */
  155210. dispose(): void;
  155211. /**
  155212. * Get the hand object according to the controller id
  155213. * @param controllerId the controller id to which we want to get the hand
  155214. * @returns null if not found or the WebXRHand object if found
  155215. */
  155216. getHandByControllerId(controllerId: string): Nullable<WebXRHand>;
  155217. /**
  155218. * Get a hand object according to the requested handedness
  155219. * @param handedness the handedness to request
  155220. * @returns null if not found or the WebXRHand object if found
  155221. */
  155222. getHandByHandedness(handedness: XRHandedness): Nullable<WebXRHand>;
  155223. protected _onXRFrame(_xrFrame: XRFrame): void;
  155224. private _attachHand;
  155225. private _detachHand;
  155226. }
  155227. }
  155228. declare module BABYLON {
  155229. /**
  155230. * The motion controller class for all microsoft mixed reality controllers
  155231. */
  155232. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  155233. protected readonly _mapping: {
  155234. defaultButton: {
  155235. valueNodeName: string;
  155236. unpressedNodeName: string;
  155237. pressedNodeName: string;
  155238. };
  155239. defaultAxis: {
  155240. valueNodeName: string;
  155241. minNodeName: string;
  155242. maxNodeName: string;
  155243. };
  155244. buttons: {
  155245. "xr-standard-trigger": {
  155246. rootNodeName: string;
  155247. componentProperty: string;
  155248. states: string[];
  155249. };
  155250. "xr-standard-squeeze": {
  155251. rootNodeName: string;
  155252. componentProperty: string;
  155253. states: string[];
  155254. };
  155255. "xr-standard-touchpad": {
  155256. rootNodeName: string;
  155257. labelAnchorNodeName: string;
  155258. touchPointNodeName: string;
  155259. };
  155260. "xr-standard-thumbstick": {
  155261. rootNodeName: string;
  155262. componentProperty: string;
  155263. states: string[];
  155264. };
  155265. };
  155266. axes: {
  155267. "xr-standard-touchpad": {
  155268. "x-axis": {
  155269. rootNodeName: string;
  155270. };
  155271. "y-axis": {
  155272. rootNodeName: string;
  155273. };
  155274. };
  155275. "xr-standard-thumbstick": {
  155276. "x-axis": {
  155277. rootNodeName: string;
  155278. };
  155279. "y-axis": {
  155280. rootNodeName: string;
  155281. };
  155282. };
  155283. };
  155284. };
  155285. /**
  155286. * The base url used to load the left and right controller models
  155287. */
  155288. static MODEL_BASE_URL: string;
  155289. /**
  155290. * The name of the left controller model file
  155291. */
  155292. static MODEL_LEFT_FILENAME: string;
  155293. /**
  155294. * The name of the right controller model file
  155295. */
  155296. static MODEL_RIGHT_FILENAME: string;
  155297. profileId: string;
  155298. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  155299. protected _getFilenameAndPath(): {
  155300. filename: string;
  155301. path: string;
  155302. };
  155303. protected _getModelLoadingConstraints(): boolean;
  155304. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  155305. protected _setRootMesh(meshes: AbstractMesh[]): void;
  155306. protected _updateModel(): void;
  155307. }
  155308. }
  155309. declare module BABYLON {
  155310. /**
  155311. * The motion controller class for oculus touch (quest, rift).
  155312. * This class supports legacy mapping as well the standard xr mapping
  155313. */
  155314. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  155315. private _forceLegacyControllers;
  155316. private _modelRootNode;
  155317. /**
  155318. * The base url used to load the left and right controller models
  155319. */
  155320. static MODEL_BASE_URL: string;
  155321. /**
  155322. * The name of the left controller model file
  155323. */
  155324. static MODEL_LEFT_FILENAME: string;
  155325. /**
  155326. * The name of the right controller model file
  155327. */
  155328. static MODEL_RIGHT_FILENAME: string;
  155329. /**
  155330. * Base Url for the Quest controller model.
  155331. */
  155332. static QUEST_MODEL_BASE_URL: string;
  155333. profileId: string;
  155334. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  155335. protected _getFilenameAndPath(): {
  155336. filename: string;
  155337. path: string;
  155338. };
  155339. protected _getModelLoadingConstraints(): boolean;
  155340. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  155341. protected _setRootMesh(meshes: AbstractMesh[]): void;
  155342. protected _updateModel(): void;
  155343. /**
  155344. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  155345. * between the touch and touch 2.
  155346. */
  155347. private _isQuest;
  155348. }
  155349. }
  155350. declare module BABYLON {
  155351. /**
  155352. * The motion controller class for the standard HTC-Vive controllers
  155353. */
  155354. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  155355. private _modelRootNode;
  155356. /**
  155357. * The base url used to load the left and right controller models
  155358. */
  155359. static MODEL_BASE_URL: string;
  155360. /**
  155361. * File name for the controller model.
  155362. */
  155363. static MODEL_FILENAME: string;
  155364. profileId: string;
  155365. /**
  155366. * Create a new Vive motion controller object
  155367. * @param scene the scene to use to create this controller
  155368. * @param gamepadObject the corresponding gamepad object
  155369. * @param handedness the handedness of the controller
  155370. */
  155371. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  155372. protected _getFilenameAndPath(): {
  155373. filename: string;
  155374. path: string;
  155375. };
  155376. protected _getModelLoadingConstraints(): boolean;
  155377. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  155378. protected _setRootMesh(meshes: AbstractMesh[]): void;
  155379. protected _updateModel(): void;
  155380. }
  155381. }
  155382. declare module BABYLON {
  155383. /**
  155384. * A cursor which tracks a point on a path
  155385. */
  155386. export class PathCursor {
  155387. private path;
  155388. /**
  155389. * Stores path cursor callbacks for when an onchange event is triggered
  155390. */
  155391. private _onchange;
  155392. /**
  155393. * The value of the path cursor
  155394. */
  155395. value: number;
  155396. /**
  155397. * The animation array of the path cursor
  155398. */
  155399. animations: Animation[];
  155400. /**
  155401. * Initializes the path cursor
  155402. * @param path The path to track
  155403. */
  155404. constructor(path: Path2);
  155405. /**
  155406. * Gets the cursor point on the path
  155407. * @returns A point on the path cursor at the cursor location
  155408. */
  155409. getPoint(): Vector3;
  155410. /**
  155411. * Moves the cursor ahead by the step amount
  155412. * @param step The amount to move the cursor forward
  155413. * @returns This path cursor
  155414. */
  155415. moveAhead(step?: number): PathCursor;
  155416. /**
  155417. * Moves the cursor behind by the step amount
  155418. * @param step The amount to move the cursor back
  155419. * @returns This path cursor
  155420. */
  155421. moveBack(step?: number): PathCursor;
  155422. /**
  155423. * Moves the cursor by the step amount
  155424. * If the step amount is greater than one, an exception is thrown
  155425. * @param step The amount to move the cursor
  155426. * @returns This path cursor
  155427. */
  155428. move(step: number): PathCursor;
  155429. /**
  155430. * Ensures that the value is limited between zero and one
  155431. * @returns This path cursor
  155432. */
  155433. private ensureLimits;
  155434. /**
  155435. * Runs onchange callbacks on change (used by the animation engine)
  155436. * @returns This path cursor
  155437. */
  155438. private raiseOnChange;
  155439. /**
  155440. * Executes a function on change
  155441. * @param f A path cursor onchange callback
  155442. * @returns This path cursor
  155443. */
  155444. onchange(f: (cursor: PathCursor) => void): PathCursor;
  155445. }
  155446. }
  155447. declare module BABYLON {
  155448. /** @hidden */
  155449. export var blurPixelShader: {
  155450. name: string;
  155451. shader: string;
  155452. };
  155453. }
  155454. declare module BABYLON {
  155455. /** @hidden */
  155456. export var pointCloudVertexDeclaration: {
  155457. name: string;
  155458. shader: string;
  155459. };
  155460. }
  155461. // Mixins
  155462. interface Window {
  155463. mozIndexedDB: IDBFactory;
  155464. webkitIndexedDB: IDBFactory;
  155465. msIndexedDB: IDBFactory;
  155466. webkitURL: typeof URL;
  155467. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  155468. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  155469. WebGLRenderingContext: WebGLRenderingContext;
  155470. MSGesture: MSGesture;
  155471. CANNON: any;
  155472. AudioContext: AudioContext;
  155473. webkitAudioContext: AudioContext;
  155474. PointerEvent: any;
  155475. Math: Math;
  155476. Uint8Array: Uint8ArrayConstructor;
  155477. Float32Array: Float32ArrayConstructor;
  155478. mozURL: typeof URL;
  155479. msURL: typeof URL;
  155480. VRFrameData: any; // WebVR, from specs 1.1
  155481. DracoDecoderModule: any;
  155482. setImmediate(handler: (...args: any[]) => void): number;
  155483. }
  155484. interface HTMLCanvasElement {
  155485. requestPointerLock(): void;
  155486. msRequestPointerLock?(): void;
  155487. mozRequestPointerLock?(): void;
  155488. webkitRequestPointerLock?(): void;
  155489. /** Track wether a record is in progress */
  155490. isRecording: boolean;
  155491. /** Capture Stream method defined by some browsers */
  155492. captureStream(fps?: number): MediaStream;
  155493. }
  155494. interface CanvasRenderingContext2D {
  155495. msImageSmoothingEnabled: boolean;
  155496. }
  155497. interface MouseEvent {
  155498. mozMovementX: number;
  155499. mozMovementY: number;
  155500. webkitMovementX: number;
  155501. webkitMovementY: number;
  155502. msMovementX: number;
  155503. msMovementY: number;
  155504. }
  155505. interface Navigator {
  155506. mozGetVRDevices: (any: any) => any;
  155507. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  155508. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  155509. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  155510. webkitGetGamepads(): Gamepad[];
  155511. msGetGamepads(): Gamepad[];
  155512. webkitGamepads(): Gamepad[];
  155513. }
  155514. interface HTMLVideoElement {
  155515. mozSrcObject: any;
  155516. }
  155517. interface Math {
  155518. fround(x: number): number;
  155519. imul(a: number, b: number): number;
  155520. }
  155521. interface WebGLRenderingContext {
  155522. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  155523. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  155524. vertexAttribDivisor(index: number, divisor: number): void;
  155525. createVertexArray(): any;
  155526. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  155527. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  155528. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  155529. renderbufferStorageMultisample?(target: number, samples: number, internalformat: number, width: number, height: number): void;
  155530. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  155531. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  155532. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  155533. // Queries
  155534. createQuery(): WebGLQuery;
  155535. deleteQuery(query: WebGLQuery): void;
  155536. beginQuery(target: number, query: WebGLQuery): void;
  155537. endQuery(target: number): void;
  155538. getQueryParameter(query: WebGLQuery, pname: number): any;
  155539. getQuery(target: number, pname: number): any;
  155540. MAX_SAMPLES: number;
  155541. RGBA8: number;
  155542. READ_FRAMEBUFFER: number;
  155543. DRAW_FRAMEBUFFER: number;
  155544. UNIFORM_BUFFER: number;
  155545. HALF_FLOAT_OES: number;
  155546. RGBA16F: number;
  155547. RGBA32F: number;
  155548. R32F: number;
  155549. RG32F: number;
  155550. RGB32F: number;
  155551. R16F: number;
  155552. RG16F: number;
  155553. RGB16F: number;
  155554. RED: number;
  155555. RG: number;
  155556. R8: number;
  155557. RG8: number;
  155558. UNSIGNED_INT_24_8: number;
  155559. DEPTH24_STENCIL8: number;
  155560. MIN: number;
  155561. MAX: number;
  155562. /* Multiple Render Targets */
  155563. drawBuffers(buffers: number[]): void;
  155564. readBuffer(src: number): void;
  155565. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  155566. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  155567. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  155568. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  155569. // Occlusion Query
  155570. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  155571. ANY_SAMPLES_PASSED: number;
  155572. QUERY_RESULT_AVAILABLE: number;
  155573. QUERY_RESULT: number;
  155574. }
  155575. interface WebGLProgram {
  155576. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  155577. }
  155578. interface EXT_disjoint_timer_query {
  155579. QUERY_COUNTER_BITS_EXT: number;
  155580. TIME_ELAPSED_EXT: number;
  155581. TIMESTAMP_EXT: number;
  155582. GPU_DISJOINT_EXT: number;
  155583. QUERY_RESULT_EXT: number;
  155584. QUERY_RESULT_AVAILABLE_EXT: number;
  155585. queryCounterEXT(query: WebGLQuery, target: number): void;
  155586. createQueryEXT(): WebGLQuery;
  155587. beginQueryEXT(target: number, query: WebGLQuery): void;
  155588. endQueryEXT(target: number): void;
  155589. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  155590. deleteQueryEXT(query: WebGLQuery): void;
  155591. }
  155592. interface WebGLUniformLocation {
  155593. _currentState: any;
  155594. }
  155595. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  155596. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  155597. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  155598. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  155599. interface WebGLRenderingContext {
  155600. readonly RASTERIZER_DISCARD: number;
  155601. readonly DEPTH_COMPONENT24: number;
  155602. readonly TEXTURE_3D: number;
  155603. readonly TEXTURE_2D_ARRAY: number;
  155604. readonly TEXTURE_COMPARE_FUNC: number;
  155605. readonly TEXTURE_COMPARE_MODE: number;
  155606. readonly COMPARE_REF_TO_TEXTURE: number;
  155607. readonly TEXTURE_WRAP_R: number;
  155608. readonly HALF_FLOAT: number;
  155609. readonly RGB8: number;
  155610. readonly RED_INTEGER: number;
  155611. readonly RG_INTEGER: number;
  155612. readonly RGB_INTEGER: number;
  155613. readonly RGBA_INTEGER: number;
  155614. readonly R8_SNORM: number;
  155615. readonly RG8_SNORM: number;
  155616. readonly RGB8_SNORM: number;
  155617. readonly RGBA8_SNORM: number;
  155618. readonly R8I: number;
  155619. readonly RG8I: number;
  155620. readonly RGB8I: number;
  155621. readonly RGBA8I: number;
  155622. readonly R8UI: number;
  155623. readonly RG8UI: number;
  155624. readonly RGB8UI: number;
  155625. readonly RGBA8UI: number;
  155626. readonly R16I: number;
  155627. readonly RG16I: number;
  155628. readonly RGB16I: number;
  155629. readonly RGBA16I: number;
  155630. readonly R16UI: number;
  155631. readonly RG16UI: number;
  155632. readonly RGB16UI: number;
  155633. readonly RGBA16UI: number;
  155634. readonly R32I: number;
  155635. readonly RG32I: number;
  155636. readonly RGB32I: number;
  155637. readonly RGBA32I: number;
  155638. readonly R32UI: number;
  155639. readonly RG32UI: number;
  155640. readonly RGB32UI: number;
  155641. readonly RGBA32UI: number;
  155642. readonly RGB10_A2UI: number;
  155643. readonly R11F_G11F_B10F: number;
  155644. readonly RGB9_E5: number;
  155645. readonly RGB10_A2: number;
  155646. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  155647. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  155648. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  155649. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  155650. readonly DEPTH_COMPONENT32F: number;
  155651. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  155652. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  155653. 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;
  155654. framebufferTextureLayer(target: number, attachment: number, texture: WebGLTexture | null, level: number, layer: number): void;
  155655. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  155656. readonly TRANSFORM_FEEDBACK: number;
  155657. readonly INTERLEAVED_ATTRIBS: number;
  155658. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  155659. createTransformFeedback(): WebGLTransformFeedback;
  155660. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  155661. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  155662. beginTransformFeedback(primitiveMode: number): void;
  155663. endTransformFeedback(): void;
  155664. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  155665. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  155666. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  155667. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  155668. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  155669. }
  155670. interface ImageBitmap {
  155671. readonly width: number;
  155672. readonly height: number;
  155673. close(): void;
  155674. }
  155675. interface WebGLQuery extends WebGLObject {
  155676. }
  155677. declare var WebGLQuery: {
  155678. prototype: WebGLQuery;
  155679. new(): WebGLQuery;
  155680. };
  155681. interface WebGLSampler extends WebGLObject {
  155682. }
  155683. declare var WebGLSampler: {
  155684. prototype: WebGLSampler;
  155685. new(): WebGLSampler;
  155686. };
  155687. interface WebGLSync extends WebGLObject {
  155688. }
  155689. declare var WebGLSync: {
  155690. prototype: WebGLSync;
  155691. new(): WebGLSync;
  155692. };
  155693. interface WebGLTransformFeedback extends WebGLObject {
  155694. }
  155695. declare var WebGLTransformFeedback: {
  155696. prototype: WebGLTransformFeedback;
  155697. new(): WebGLTransformFeedback;
  155698. };
  155699. interface WebGLVertexArrayObject extends WebGLObject {
  155700. }
  155701. declare var WebGLVertexArrayObject: {
  155702. prototype: WebGLVertexArrayObject;
  155703. new(): WebGLVertexArrayObject;
  155704. };
  155705. // Type definitions for WebVR API
  155706. // Project: https://w3c.github.io/webvr/
  155707. // Definitions by: six a <https://github.com/lostfictions>
  155708. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  155709. interface VRDisplay extends EventTarget {
  155710. /**
  155711. * Dictionary of capabilities describing the VRDisplay.
  155712. */
  155713. readonly capabilities: VRDisplayCapabilities;
  155714. /**
  155715. * z-depth defining the far plane of the eye view frustum
  155716. * enables mapping of values in the render target depth
  155717. * attachment to scene coordinates. Initially set to 10000.0.
  155718. */
  155719. depthFar: number;
  155720. /**
  155721. * z-depth defining the near plane of the eye view frustum
  155722. * enables mapping of values in the render target depth
  155723. * attachment to scene coordinates. Initially set to 0.01.
  155724. */
  155725. depthNear: number;
  155726. /**
  155727. * An identifier for this distinct VRDisplay. Used as an
  155728. * association point in the Gamepad API.
  155729. */
  155730. readonly displayId: number;
  155731. /**
  155732. * A display name, a user-readable name identifying it.
  155733. */
  155734. readonly displayName: string;
  155735. readonly isConnected: boolean;
  155736. readonly isPresenting: boolean;
  155737. /**
  155738. * If this VRDisplay supports room-scale experiences, the optional
  155739. * stage attribute contains details on the room-scale parameters.
  155740. */
  155741. readonly stageParameters: VRStageParameters | null;
  155742. /**
  155743. * Passing the value returned by `requestAnimationFrame` to
  155744. * `cancelAnimationFrame` will unregister the callback.
  155745. * @param handle Define the hanle of the request to cancel
  155746. */
  155747. cancelAnimationFrame(handle: number): void;
  155748. /**
  155749. * Stops presenting to the VRDisplay.
  155750. * @returns a promise to know when it stopped
  155751. */
  155752. exitPresent(): Promise<void>;
  155753. /**
  155754. * Return the current VREyeParameters for the given eye.
  155755. * @param whichEye Define the eye we want the parameter for
  155756. * @returns the eye parameters
  155757. */
  155758. getEyeParameters(whichEye: string): VREyeParameters;
  155759. /**
  155760. * Populates the passed VRFrameData with the information required to render
  155761. * the current frame.
  155762. * @param frameData Define the data structure to populate
  155763. * @returns true if ok otherwise false
  155764. */
  155765. getFrameData(frameData: VRFrameData): boolean;
  155766. /**
  155767. * Get the layers currently being presented.
  155768. * @returns the list of VR layers
  155769. */
  155770. getLayers(): VRLayer[];
  155771. /**
  155772. * Return a VRPose containing the future predicted pose of the VRDisplay
  155773. * when the current frame will be presented. The value returned will not
  155774. * change until JavaScript has returned control to the browser.
  155775. *
  155776. * The VRPose will contain the position, orientation, velocity,
  155777. * and acceleration of each of these properties.
  155778. * @returns the pose object
  155779. */
  155780. getPose(): VRPose;
  155781. /**
  155782. * Return the current instantaneous pose of the VRDisplay, with no
  155783. * prediction applied.
  155784. * @returns the current instantaneous pose
  155785. */
  155786. getImmediatePose(): VRPose;
  155787. /**
  155788. * The callback passed to `requestAnimationFrame` will be called
  155789. * any time a new frame should be rendered. When the VRDisplay is
  155790. * presenting the callback will be called at the native refresh
  155791. * rate of the HMD. When not presenting this function acts
  155792. * identically to how window.requestAnimationFrame acts. Content should
  155793. * make no assumptions of frame rate or vsync behavior as the HMD runs
  155794. * asynchronously from other displays and at differing refresh rates.
  155795. * @param callback Define the eaction to run next frame
  155796. * @returns the request handle it
  155797. */
  155798. requestAnimationFrame(callback: FrameRequestCallback): number;
  155799. /**
  155800. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  155801. * Repeat calls while already presenting will update the VRLayers being displayed.
  155802. * @param layers Define the list of layer to present
  155803. * @returns a promise to know when the request has been fulfilled
  155804. */
  155805. requestPresent(layers: VRLayer[]): Promise<void>;
  155806. /**
  155807. * Reset the pose for this display, treating its current position and
  155808. * orientation as the "origin/zero" values. VRPose.position,
  155809. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  155810. * updated when calling resetPose(). This should be called in only
  155811. * sitting-space experiences.
  155812. */
  155813. resetPose(): void;
  155814. /**
  155815. * The VRLayer provided to the VRDisplay will be captured and presented
  155816. * in the HMD. Calling this function has the same effect on the source
  155817. * canvas as any other operation that uses its source image, and canvases
  155818. * created without preserveDrawingBuffer set to true will be cleared.
  155819. * @param pose Define the pose to submit
  155820. */
  155821. submitFrame(pose?: VRPose): void;
  155822. }
  155823. declare var VRDisplay: {
  155824. prototype: VRDisplay;
  155825. new(): VRDisplay;
  155826. };
  155827. interface VRLayer {
  155828. leftBounds?: number[] | Float32Array | null;
  155829. rightBounds?: number[] | Float32Array | null;
  155830. source?: HTMLCanvasElement | null;
  155831. }
  155832. interface VRDisplayCapabilities {
  155833. readonly canPresent: boolean;
  155834. readonly hasExternalDisplay: boolean;
  155835. readonly hasOrientation: boolean;
  155836. readonly hasPosition: boolean;
  155837. readonly maxLayers: number;
  155838. }
  155839. interface VREyeParameters {
  155840. /** @deprecated */
  155841. readonly fieldOfView: VRFieldOfView;
  155842. readonly offset: Float32Array;
  155843. readonly renderHeight: number;
  155844. readonly renderWidth: number;
  155845. }
  155846. interface VRFieldOfView {
  155847. readonly downDegrees: number;
  155848. readonly leftDegrees: number;
  155849. readonly rightDegrees: number;
  155850. readonly upDegrees: number;
  155851. }
  155852. interface VRFrameData {
  155853. readonly leftProjectionMatrix: Float32Array;
  155854. readonly leftViewMatrix: Float32Array;
  155855. readonly pose: VRPose;
  155856. readonly rightProjectionMatrix: Float32Array;
  155857. readonly rightViewMatrix: Float32Array;
  155858. readonly timestamp: number;
  155859. }
  155860. interface VRPose {
  155861. readonly angularAcceleration: Float32Array | null;
  155862. readonly angularVelocity: Float32Array | null;
  155863. readonly linearAcceleration: Float32Array | null;
  155864. readonly linearVelocity: Float32Array | null;
  155865. readonly orientation: Float32Array | null;
  155866. readonly position: Float32Array | null;
  155867. readonly timestamp: number;
  155868. }
  155869. interface VRStageParameters {
  155870. sittingToStandingTransform?: Float32Array;
  155871. sizeX?: number;
  155872. sizeY?: number;
  155873. }
  155874. interface Navigator {
  155875. getVRDisplays(): Promise<VRDisplay[]>;
  155876. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  155877. }
  155878. interface Window {
  155879. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  155880. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  155881. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  155882. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  155883. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  155884. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  155885. }
  155886. interface Gamepad {
  155887. readonly displayId: number;
  155888. }
  155889. type XRSessionMode = "inline" | "immersive-vr" | "immersive-ar";
  155890. type XRReferenceSpaceType = "viewer" | "local" | "local-floor" | "bounded-floor" | "unbounded";
  155891. type XREnvironmentBlendMode = "opaque" | "additive" | "alpha-blend";
  155892. type XRVisibilityState = "visible" | "visible-blurred" | "hidden";
  155893. type XRHandedness = "none" | "left" | "right";
  155894. type XRTargetRayMode = "gaze" | "tracked-pointer" | "screen";
  155895. type XREye = "none" | "left" | "right";
  155896. type XREventType = "devicechange" | "visibilitychange" | "end" | "inputsourceschange" | "select" | "selectstart" | "selectend" | "squeeze" | "squeezestart" | "squeezeend" | "reset";
  155897. interface XRSpace extends EventTarget {}
  155898. interface XRRenderState {
  155899. depthNear?: number;
  155900. depthFar?: number;
  155901. inlineVerticalFieldOfView?: number;
  155902. baseLayer?: XRWebGLLayer;
  155903. }
  155904. interface XRInputSource {
  155905. handedness: XRHandedness;
  155906. targetRayMode: XRTargetRayMode;
  155907. targetRaySpace: XRSpace;
  155908. gripSpace: XRSpace | undefined;
  155909. gamepad: Gamepad | undefined;
  155910. profiles: Array<string>;
  155911. hand: XRHand | undefined;
  155912. }
  155913. interface XRSessionInit {
  155914. optionalFeatures?: string[];
  155915. requiredFeatures?: string[];
  155916. }
  155917. interface XRSession {
  155918. addEventListener: Function;
  155919. removeEventListener: Function;
  155920. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  155921. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  155922. requestAnimationFrame: Function;
  155923. end(): Promise<void>;
  155924. renderState: XRRenderState;
  155925. inputSources: Array<XRInputSource>;
  155926. // hit test
  155927. requestHitTestSource(options: XRHitTestOptionsInit): Promise<XRHitTestSource>;
  155928. requestHitTestSourceForTransientInput(options: XRTransientInputHitTestOptionsInit): Promise<XRTransientInputHitTestSource>;
  155929. // legacy AR hit test
  155930. requestHitTest(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  155931. // legacy plane detection
  155932. updateWorldTrackingState(options: { planeDetectionState?: { enabled: boolean } }): void;
  155933. }
  155934. interface XRReferenceSpace extends XRSpace {
  155935. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  155936. onreset: any;
  155937. }
  155938. type XRPlaneSet = Set<XRPlane>;
  155939. type XRAnchorSet = Set<XRAnchor>;
  155940. interface XRFrame {
  155941. session: XRSession;
  155942. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  155943. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  155944. // AR
  155945. getHitTestResults(hitTestSource: XRHitTestSource): Array<XRHitTestResult>;
  155946. getHitTestResultsForTransientInput(hitTestSource: XRTransientInputHitTestSource): Array<XRTransientInputHitTestResult>;
  155947. // Anchors
  155948. trackedAnchors?: XRAnchorSet;
  155949. createAnchor(pose: XRRigidTransform, space: XRSpace): Promise<XRAnchor>;
  155950. // Planes
  155951. worldInformation: {
  155952. detectedPlanes?: XRPlaneSet;
  155953. };
  155954. // Hand tracking
  155955. getJointPose(joint: XRJointSpace, baseSpace: XRSpace): XRJointPose;
  155956. }
  155957. interface XRViewerPose extends XRPose {
  155958. views: Array<XRView>;
  155959. }
  155960. interface XRPose {
  155961. transform: XRRigidTransform;
  155962. emulatedPosition: boolean;
  155963. }
  155964. interface XRWebGLLayerOptions {
  155965. antialias?: boolean;
  155966. depth?: boolean;
  155967. stencil?: boolean;
  155968. alpha?: boolean;
  155969. multiview?: boolean;
  155970. framebufferScaleFactor?: number;
  155971. }
  155972. declare var XRWebGLLayer: {
  155973. prototype: XRWebGLLayer;
  155974. new (session: XRSession, context: WebGLRenderingContext | undefined, options?: XRWebGLLayerOptions): XRWebGLLayer;
  155975. };
  155976. interface XRWebGLLayer {
  155977. framebuffer: WebGLFramebuffer;
  155978. framebufferWidth: number;
  155979. framebufferHeight: number;
  155980. getViewport: Function;
  155981. }
  155982. declare class XRRigidTransform {
  155983. constructor(matrix: Float32Array | DOMPointInit, direction?: DOMPointInit);
  155984. position: DOMPointReadOnly;
  155985. orientation: DOMPointReadOnly;
  155986. matrix: Float32Array;
  155987. inverse: XRRigidTransform;
  155988. }
  155989. interface XRView {
  155990. eye: XREye;
  155991. projectionMatrix: Float32Array;
  155992. transform: XRRigidTransform;
  155993. }
  155994. interface XRInputSourceChangeEvent {
  155995. session: XRSession;
  155996. removed: Array<XRInputSource>;
  155997. added: Array<XRInputSource>;
  155998. }
  155999. interface XRInputSourceEvent extends Event {
  156000. readonly frame: XRFrame;
  156001. readonly inputSource: XRInputSource;
  156002. }
  156003. // Experimental(er) features
  156004. declare class XRRay {
  156005. constructor(transformOrOrigin: XRRigidTransform | DOMPointInit, direction?: DOMPointInit);
  156006. origin: DOMPointReadOnly;
  156007. direction: DOMPointReadOnly;
  156008. matrix: Float32Array;
  156009. }
  156010. declare enum XRHitTestTrackableType {
  156011. "point",
  156012. "plane",
  156013. "mesh",
  156014. }
  156015. interface XRHitResult {
  156016. hitMatrix: Float32Array;
  156017. }
  156018. interface XRTransientInputHitTestResult {
  156019. readonly inputSource: XRInputSource;
  156020. readonly results: Array<XRHitTestResult>;
  156021. }
  156022. interface XRHitTestResult {
  156023. getPose(baseSpace: XRSpace): XRPose | undefined;
  156024. // When anchor system is enabled
  156025. createAnchor?(pose: XRRigidTransform): Promise<XRAnchor>;
  156026. }
  156027. interface XRHitTestSource {
  156028. cancel(): void;
  156029. }
  156030. interface XRTransientInputHitTestSource {
  156031. cancel(): void;
  156032. }
  156033. interface XRHitTestOptionsInit {
  156034. space: XRSpace;
  156035. entityTypes?: Array<XRHitTestTrackableType>;
  156036. offsetRay?: XRRay;
  156037. }
  156038. interface XRTransientInputHitTestOptionsInit {
  156039. profile: string;
  156040. entityTypes?: Array<XRHitTestTrackableType>;
  156041. offsetRay?: XRRay;
  156042. }
  156043. interface XRAnchor {
  156044. anchorSpace: XRSpace;
  156045. delete(): void;
  156046. }
  156047. interface XRPlane {
  156048. orientation: "Horizontal" | "Vertical";
  156049. planeSpace: XRSpace;
  156050. polygon: Array<DOMPointReadOnly>;
  156051. lastChangedTime: number;
  156052. }
  156053. interface XRJointSpace extends XRSpace {}
  156054. interface XRJointPose extends XRPose {
  156055. radius: number | undefined;
  156056. }
  156057. interface XRHand /*extends Iterablele<XRJointSpace>*/ {
  156058. readonly length: number;
  156059. [index: number]: XRJointSpace;
  156060. // Specs have the function 'joint(idx: number)', but chrome doesn't support it yet.
  156061. readonly WRIST: number;
  156062. readonly THUMB_METACARPAL: number;
  156063. readonly THUMB_PHALANX_PROXIMAL: number;
  156064. readonly THUMB_PHALANX_DISTAL: number;
  156065. readonly THUMB_PHALANX_TIP: number;
  156066. readonly INDEX_METACARPAL: number;
  156067. readonly INDEX_PHALANX_PROXIMAL: number;
  156068. readonly INDEX_PHALANX_INTERMEDIATE: number;
  156069. readonly INDEX_PHALANX_DISTAL: number;
  156070. readonly INDEX_PHALANX_TIP: number;
  156071. readonly MIDDLE_METACARPAL: number;
  156072. readonly MIDDLE_PHALANX_PROXIMAL: number;
  156073. readonly MIDDLE_PHALANX_INTERMEDIATE: number;
  156074. readonly MIDDLE_PHALANX_DISTAL: number;
  156075. readonly MIDDLE_PHALANX_TIP: number;
  156076. readonly RING_METACARPAL: number;
  156077. readonly RING_PHALANX_PROXIMAL: number;
  156078. readonly RING_PHALANX_INTERMEDIATE: number;
  156079. readonly RING_PHALANX_DISTAL: number;
  156080. readonly RING_PHALANX_TIP: number;
  156081. readonly LITTLE_METACARPAL: number;
  156082. readonly LITTLE_PHALANX_PROXIMAL: number;
  156083. readonly LITTLE_PHALANX_INTERMEDIATE: number;
  156084. readonly LITTLE_PHALANX_DISTAL: number;
  156085. readonly LITTLE_PHALANX_TIP: number;
  156086. }
  156087. // This file contains native only extensions for WebXR These APIs are not supported in the browser yet.
  156088. // They are intended for use with either Babylon Native https://github.com/BabylonJS/BabylonNative or
  156089. // Babylon React Native: https://github.com/BabylonJS/BabylonReactNative
  156090. interface XRSession {
  156091. trySetFeaturePointCloudEnabled(enabled: boolean): boolean;
  156092. }
  156093. interface XRFrame {
  156094. featurePointCloud? : Array<number>;
  156095. }